getStructureId returns the real ID minus 1? - liferay-6

this is the code I am using :
JournalArticle article = null;
article = JournalArticleLocalServiceUtil.getLatestArticle(classPk);
String structureId = article.getStructureId();
When I debugged I found that structureId is always the real structureId but minus 1 !!!
Why ?? I need to know if it's Liferay bug ...
thank you,
I am Liferay 6.2 ce ga2.

JournalArticle's field structureId is equivalent not to DDMStructure.structureId, but to DDMStructure.structureKey. I admit, that can be really confusing.
This is due to the DDMStructure's object generation mechanism. When you add new structure using Control Panel, the structureKey is generated automatically using counterLocalService (check this code). As it happens just before the structureId is generated, it is always smaller by one.

See following Jira tickets, where it is explained the structureId vs structureKey issue:
- https://issues.liferay.com/browse/LPS-50671
- https://issues.liferay.com/browse/LPS-31163

Related

Moodle - update_moduleinfo - invalid course module id

I'm currently building a new moodle plugin. I'm using add_moduleinfo and update_moduleinfo. To add a new attandance atictivity in a course and update it later on.
Sadly I'm facing the issue that update_moduleinfo always throws an "invalid course module id" error. I already checked the cm entry in my database to ensure im using the right module instance.
I dont really know what to do.
$cm = get_coursemodule_from_instance($moduleName, $activityID, $course->id);
$moduleinfo = update_moduleinfo($cm, $moduleinfo, $course); <-- Error
Thats how I try to update the entry.
I also found that post. Didn't help anything.
Moodle - Invalid course module ID
I found the issue myself:
$moduleinfo->introeditor['format'] = FORMAT_HTML;
$moduleinfo->introeditor['text'] = "INTRO TEXT";
$moduleinfo->coursemodule = $cm->id;
list($cm, $moduleinfo) = update_moduleinfo($cm, $moduleinfo, $course, null);
In order to use this function the above mentioned properties need to exist in order to perform a update.

How to replace deprecated SOBE Code in TYPO3 10.4

I inherited an old TYPO3 Extension using SOBE. As far as I unterstand it's deprecated, but it seems there is no documentation on how to replace it.
The Extension is using Backend Forms and the following line is throwing an error:
if (is_array($GLOBALS['SOBE']->editconf['tt_content']) && reset($GLOBALS['SOBE']->editconf['tt_content']) === 'new') {
The error is:
Cannot access protected property TYPO3\CMS\Backend\Controller\EditDocumentController::$editconf
The Var $GLOBALS['SOBE'] is still there, and there is also editconf, but it's not working.
How can I replace this code or rewrite it?
The SOBE object is part by part removed since years. As there are multiple ways for using it - see https://docs.typo3.org/c/typo3/cms-core/main/en-us/search.html?q=sobe&check_keywords=yes&area=default - you may need to take a closer look what is the exact part of replacing this code.
I would guess you can see more at https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/9.2/Deprecation-84195-ProtectedMethodsAndPropertiesInEditDocumentController.html?highlight=editconf.

MongoDB unique index allows duplication

I am new in mongoDb and I have a problem with mongock. Previously I had an index defined by annotation like below. In my unit test I have a case which tries to save same value on the same field and it throws exception as expected.
#Indexed(unique = true)
private String name;
I removed #Indexed annotation and I created index by mongock migration. But in this time I am able to insert a record with same value for this column without getting exception. So what is wrong here and why it is not working as it works above. I created my migration as :
collection.createIndex(
new Document(new ImmutableMap.Builder<String, Object>()
.put("name", 1)
.build()),
new IndexOptions().name("name_idx").unique(true),
);
Without providing information about the version you are using, it's hard to say.
However I believe your issue can be related to an old existing bug.
Please use the last version 4.0.8.alpha, which is alpha as features are still being added, but very stable(there is no official documentation yet, but you can see the sample project here) or the last official stable version: 3.3.2.
Please notice that in both case you should use MongockTemplate, instead of MongoTemplate.
I believe that will solve your issue. Otherwise, please provide version and stack trace.

OrientDB: is OCommandFunction usable in 3.0.0m1?

In version 2 OCommandFuction would be used more or less like this:
OCommandFunction command = new OCommandFunction(function);
ODocument doc = db.command(command).execute(args);
or
OResultSet<ODocument> rs = db.command(command).execute(args);
In 3.0 db.command is deprecated and the 3.0 idiomatic alternatives are documented in most use cases, except, to the best of my knowledge, for the one I described.
Any suggestions?
Thanks
The following should work fine:
db.execute("sql", "RETURN yourFunctin()", params);
3.0M1 is still an early beta, so if you find any problems please report them on the official issue tracker. Thanks!

NullPointerException in Jasper Reports?

When I export a report using jasper report (version 1.2.4), it throws NPE. And I cant find any solution to the problem online. Can anyone help me in this regard please?
If I remove one problematic column in my report and export it, it exports fine. Couldn't find whats the problem with that column as it contains large data.
Many Thanks in Advance !
Posting the exception below :
java.lang.NullPointerException|
at java.awt.font.TextLayout.getBaselineFromGraphic(Unknown Source)|
at java.awt.font.TextMeasurer.initAll(Unknown Source)|
at java.awt.font.TextMeasurer.<init>(Unknown Source)|
at java.awt.font.LineBreakMeasurer.<init>(Unknown Source)|
at java.awt.font.LineBreakMeasurer.<init>(Unknown Source)|
at net.sf.jasperreports.engine.fill.TextMeasurer.renderParagraph(TextMeasurer.java:259)|
at net.sf.jasperreports.engine.fill.TextMeasurer.measure(TextMeasurer.java:220)|
at net.sf.jasperreports.engine.fill.JRFillTextElement.chopTextElement(JRFillTextElement.java:528)|
at net.sf.jasperreports.engine.fill.JRFillTextField.prepare(JRFillTextField.java:501)|
at net.sf.jasperreports.engine.fill.JRFillElementContainer.prepareElements(JRFillElementContainer.java:345)|
at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:311)|
at net.sf.jasperreports.engine.fill.JRFillBand.fill(JRFillBand.java:275)|
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:1291)|
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:631)|
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportContent(JRVerticalFiller.java:248)|
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:132)|
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:750)|
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:666)|
at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:89)|
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:601)
You can get the exact same error using pure JRE code, like this:
#Test
public void testText()
{
String text = "\uFFFF\u0300";
JTextArea textArea = new JTextArea(text);
JOptionPane.showMessageDialog(null, textArea);
}
Because of this, I have been assuming it's a JRE bug and already submitted it to Oracle. The workaround is presumably to cull whatever character sequence is causing it, but I obviously don't know what you are feeding in.
This is likely either (1) a bug in the version of the JRE you're using, or (2) a threading bug. We've had the same top five lines in stack traces in a project I work on.