Read a property value of a thing from java extension - java

I'm trying to read a property value of a thing in java extension, I'm always getting the Exception "Not authorized for PropertyRead on ss in PSIM_AlarmManagementServices_Thing"
my code is
Thing AlarmManagementServices_Thing = (Thing) EntityUtilities.findEntityDirect("PSIM_AlarmManagementServices_Thing",
ThingworxRelationshipTypes.Thing);
String ss = AlarmManagementServices_Thing.GetStringPropertyValue("ss");
enter image description here

now I know why I had this error, when I'm accessing the thing's property from inside a sub-thread, I have this error, but if I access it from the main thread of the Resource it goes without errors. Same things I had before when I was trying to call AddDataTableEntry's service of a dataTable from inside a sub-thread, I didn't have an error but the row wasn't added.

Related

I keep getting a permission error when trying to update a site's template in liferay 7.3

I've encountered an issue when trying to update a site's(group) template. The template is assigned and works correctly but a couple errors are thrown when doing so. They all read the same thing:
2023-01-18 10:42:24.934 ERROR [http-nio-8080-exec-48][FragmentRendererControllerImpl:120] Unable to render content of fragment entry 0:com.liferay.fragment.exception.FragmentEntryContentException: com.liferay.portal.kernel.portlet.PortletContainerException: java.lang.IllegalArgumentException: Someone may be trying to circumvent the permission checker: {company>
2023-01-18 10:42:24.936 ERROR [http-nio-8080-exec-48][FragmentRendererControllerImpl:120] Unable to render content of fragment entry 0:com.liferay.fragment.exception.FragmentEntryContentException: java.lang.NullPointerException
this is not an error i understand. As i'm not checking for permission, someone without permission simply wouldn't see the button and couldn't press it. I have code for that in my view.jsp, but even when i remove it the error still persist.
This is the code i have for updating a group:
// I first update a custom field showing if the site is active or not
group.getExpandoBridge().setAttribute("Status", "Actief" );
LayoutSetLocalServiceUtil.updateLayoutSetPrototypeLinkEnabled(groupId, true, true, privateTemp);
Like I said I tried removing any permission checking code but this had no effect. The method i'm using is from the LayoutSetLocalServiceUtil class. Given that it's a local this method shouldn't check for permission either. I'm also logged in as admin when I try to run my code so I should have the permission to do this anyway.
I also tried to hide the error using:
SessionMessages.add(portletRequest, PortalUtil.getPortletId(portletRequest) + SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_ERROR_MESSAGE);
But this didn't actually hide it for some reason and it doesn't solve the issue either. Did anyone encounter this before? And why do i keep getting a permission error without checking any permission?
I had similar permissions issues during the execution of custom code that updated ExpandoBridge attributes. Try the following update:
boolean isSecure = false; // Forces the use of ExpandoBridgeLocalService w/o permissions checking
// I first update a custom field showing if the site is active or not
group.getExpandoBridge().setAttribute("Status", "Actief", isSecure);
LayoutSetLocalServiceUtil.updateLayoutSetPrototypeLinkEnabled(groupId, true, true, privateTemp);
Reference:
https://docs.liferay.com/dxp/portal/7.4-latest/javadocs/portal-kernel/com/liferay/expando/kernel/model/ExpandoBridge.html#setAttribute-java.lang.String-java.io.Serializable-boolean-

Getting error Field UCLASS is not a member of BAPIUCLASS while updating through JCO

I am trying to update UCLASS field value using "BAPI_USER_CHANGE" through JCO, but getting below error:
com.sap.conn.jco.JCoRuntimeException: Field UCLASS is not a member of BAPIUCLASS
Here is my code to set the value:
JCoStructure license = params.getStructure("UCLASS");
license.setValue("UCLASS", changes.get(0).getCurrent());
JCoStructure licenseX = params.getStructure("UCLASSX");
licenseX.setValue("UCLASS", 'X');
Can you please tell me this comes under which Structure? tried also with "LOGONDATA" and "ADDRESS".
Logon with a SAP GUI and use transaction SE37 to display the parameters and structures of the RFM BAPI_USER_CHANGE.
The ABAP workbench offers forward navigation. So if you would like to see how this UCLASS structure looks like, go to the Import tab of the RFM BAPI_USER_CHANGE and double-click on the Associated Type BAPIUCLASS.
You are correctly getting the error message because there is no field with name UCLASS in the RFM parameter UCLASS (which is a JCoStructure).
Instead of this, license.setValue("LIC_TYPE", "XY"); would be valid here, for example.
If you want to set another structure as a whole, you would have to use
params.setValue("UCLASS", myJCoStructure);.

Message Manager displays messages only as field decorators and not in header

I am using the Eclipse MessageManager to provide error messages in case of invalid input. For example:
mmng.addMessage("textLength", "blah", null, IMessageProvider.ERROR, field);
I do this twice. Once inside an instance of ModifyListener and once just right after the creation of the Text field in order to validate input on load.
The MessageManager displays an error in the header of the page as well as next to the text field (decorator) when calling the addMessage method inside the modifyEvent method of an child instance of ModifyListener. However, when adding the message right after the creation of the text field, only a decorator will be displayed (no errors in the header saying that "n errors detected").
I am wondering why this happens. I tested this with the Eclipse ProductEditor and there's actually a similar behavior. The errors won't appear in the header if you open a .product file that has on the first page an error (only the decorator will appear). However, when switching to other pages and then switching back to this particular page, the error in the header will appear. Unfortunately, this is not the case on my side. I would be satisfied if I could implement the same behavior, even though the best case would be to automatically display errors on both locations, in the header and next to the field as a decorator.
I also tried to solve this issue by calling the update() method of the MessageManager instance, but unfortunately, that did not solve the mystery.
By the way, I am using Eclipse Luna 2.
I debugged the MessageManager class and noticed the following condition inside the update method:
if (form.getHead().getBounds().height == 0 || mergedList.isEmpty() || mergedList == null) {
form.setMessage(null, IMessageProvider.NONE);
return;
}
Besides that a NPE will be thrown when mergedList is null, this condition seems really strange to me. However, setting the height of head solved my problem:
form.getForm().getHead().setBounds(0, 0, 0, 1);

Variable not reachable without exception

I have a very weird problem, the classic of works on localhost and not in server.
I've tried to find a bigger problem and discovered that this code :
<div class="pageHeader"><h1>Products2 #{products.debug} </h1></div>
When :
#ManagedBean(name="products")
#SessionScoped
public class ProductsBean {
private String debug = "Debug : ";
public ProductsBean() {
debug = "Debug : ";
}
public String getDebug() {
return debug;
}
public void setDebug(String debug) {
this.debug = debug;
}
And the debug string has getters/setters,
Works perfectly in localhost but not on remote. In the remote server it doesn't echo the string at all, and no exception gets thrown and I have no idea how to start looking for the problem. The thing is that this problem gets repeated in other ways, for instance this page has a dataTable which appears empty, though it's not in localhost. when I tried file uploading in an whole different page I got exception of Target Unreachable, identifier resolved to null, which is not the problem in this case, but it seems to be related somehow I guess
Any help? I'm running on Oracle Linux Server with Oracle GlassFish
The problem is here.
Target Unreachable, identifier 'loadSimCards' resolved to null
I believe #loadSimCards resolved to null during processing.
The object is not getting created/prepopulated in your bean.
Check the code and verify if it is indeed getting populated.
You can post your Java code if you are still facing issues.
Also check beans.xml file and declaration in faces-config.xml
Reference - JEE CDI tip: Target Unreachable, identifier resolved to null
The first step in my mind would be to do a Right Click -> View Source in the browser and let us know what it shows. In the view source if the string "#{products.debug} is not getting printed, it means that the server is indeed evaluating the EL Expression, but at the time of rendering it is coming as an empty string.
Can you please provide the actual getters/setters.
Can you put loggers/SOPs in them and let us know whether they are being called and in what sequence.
Replace the pure EL Expression with a data-binding control like h:inputText and see what happens.
< h:inputText value="#{products.debug}" />
Probably unrelated, but do you have a < base /> tag declared in your page in the head section? Base tag href provides the location from which child resources are loaded. I have seen some abnormal behavior in the past while shifting servers, when the main page is loaded from from the remote while the child resources are loaded from the localhost itself on your developer box, because one forgets to change the base tag reference.

can't find file... using eclipse and file/filereader/bufferedreader

http://pastebin.com/m5fa7685e
It seems to fail when getting f3.. Output is:
not ready
File is null
Exception in thread "main" java.lang.NullPointerException
at BuabFile.parseBUAB(BuabFile.java:93)
at AddressBook.createBrowseForm(AddressBook.java:232)
at AddressBook.(AddressBook.java:51)
at Main.main(Main.java:4)"
But not before then - no file not found errors or anything...
My guess would be that the parseBUAB() method receives a "null" argument. Which means that it could be that it is the AddressBook class is responsible for the error.
It looks like you forgot to assign a value to BuabFile.file static field. You may want to add this to the end of your readFile() method:
BuabFile.file = f3;
I am guessing your AddressBook.createBrowseForm method looks something like this:
String filename = ...;
BuabFile buab = new BuabFile(filename);
buab.readFile();
ArrayList<String> buabLines = buab.returnFile(); // Returns null because readFile() never assigned a value to BuabFile.file
ArrayList<Buab> buabList = buab.parseBUAB(buabLines);
From all I can see, you just call parseBUAB(..) with a null value. I can't see the call to that method so you have to check the rest of your code.
For your 'not ready' output, which is created because your BufferedReader f3 is 'not ready', the API says
True if the next read() is guaranteed not to block for input, false otherwise.
Maybe you just call it too fast and the file is not loaded yet. Play with Thread.sleep() before calling ready() on the stream. Maybe a some-milliseconds blocking is just normal for File I/O.
And third - if f3 is the BufferedReader you want to keep, you have to assign it to the member file in the readFile() method. But now that's all I found ;)
I'm confused further but have found an answer sort of - I'm using windows 7 and have tried it on a windows xp computer and the code compiles fine and reads in the file (other errors you lot have noted are to be changed anyway through development - this was just one stick in the way...).
I'm wondering if there is some Windows 7 error with eclipse and opening/reading files...

Categories

Resources