I have a custom user property implemented via the Extension Property on my directory. The property is visible in the graph explorer:
https://graph.microsoft.com/v1.0/users/6dc2cecc-a3dd-4c18-ba7a-38b70db82e95?$select=extension_8655692d0a034443a9b32af6caa95f56_favColour
returns
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#users(extension_8655692d0a034443a9b32af6caa95f56_favColour)/$entity",
"extension_8655692d0a034443a9b32af6caa95f56_favColour": "foooooo"
}
I can also see it in the raw response in the User object returned by com.microsoft.graph.models.extensions.User#getRawObject when using MS Graph Java SDK, but the User class doesn't seem to have any API for accessing this kind of properties. Best I can do is manipulating the raw response. Is there any better way of accessing extension properties without touching the raw response?
Extension properties can be accessed by ExtensionPropertyCollectionPage class
If you are using User Class, you can try with below code inside the User Class:
final User user = graphClient.me()
.buildRequest()
.select("extension_8655692d0a034443a9b32af6caa95f56_favColour")
.get();
The User entity really doesn't contain the extension property. Then I try to find answer from the c# SDK, as I tested by c# SDK, I can get the extension claim from the User.Result.AdditionalData, so I came back to Java SDK and I found the property additionalDataManager, then I test it and get the result.
User user = graphClient.users("198a7xxxxx19ce1c").buildRequest().get();
String res = user.additionalDataManager().get("extension_3d3xxxxe8707e_tiny_custom_prop").toString();
=================================Update=================================
It's ok for me to get it
UserCollectionPage users = graphClient.users()
.buildRequest().select("extension_3d35xxx7e_tiny_custom_prop")
.get();
String temp = users.getCurrentPage().get(1).additionalDataManager().get("extension_3d35xxx07e_tiny_custom_prop").toString();
And if you find it not working for you, maybe you can try to use beta version for calling the api.
<repositories>
<repository>
<id>sonatype-snapshot</id>
<name>Sonatype Snapshot</name>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
</repositories>
<dependency>
<groupId>com.microsoft.graph</groupId>
<artifactId>microsoft-graph-beta</artifactId>
<version>0.33.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-identity</artifactId>
<version>[1.3,)</version>
</dependency>
Related
I am analyzing the Fabcar Java Project in Hyperledger Fabric.
Below are the dependencies in project. snippet from pom.xml
<dependencies>
<dependency>
<groupId>org.hyperledger.fabric</groupId>
<artifactId>fabric-gateway-java</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>1.4.2</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.4.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>5.4.2</version>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.12.2</version>
<scope>test</scope>
</dependency>
I am able to run the Programs in it. like
EnrollAdmin.main(null);
RegisterUser.main(null);
ClientApp.main(null);
Then I wanted to write my own smart contract from scratch.so started research/analysis and stumbled upon
Video By Hyperledger Foundation
here in this video , presenter said every smart contract has to extend from Contract class.
Contract class contains methods like
beforeTransaction()
afterTransaction()
createContext()
etc
so I searched Contract class in my Java workspace and found different methods present in it.
such as
Transaction createTransaction(String name);
submitTransaction(String name, String... args)
evaluateTransaction(String name, String... args)
So my questions
has Contract class upgraded and I am watching old tutorials or I am referring to OLD APIs ?
Also I found that , there is a dependency fabric-chaincode-shim 2.2.4 API, which contains the methods which matches with Video tutorial.
package: org.hyperledger.fabric.contract
interface: ContractInterface
Do i have to import this dependency or my existing Contract interface(org.hyperledger.fabric.gateway.Contract) enough to write a new smart contract?
There are two coding aspects to writing an application for Fabric. One is the Smart Contract (also referred to as chaincode). The other is the client side application that will send in transaction requests that result in functions in the Smart Contract being executed.
Taking the SmartContract first, that will extend the Contract Interface, and then you'll write various transaction functions (for example createAsset).
To 'run' these transaction functions a client application needs to call submit or evaluate transaction. Only if a transaction function is submitted will changes be made to the ledger. Evaluate is therefore really just a query.
In summary there are two APIs that you need to use - one for the Contract and one for the Client Application.
createContext(), beforeTransaction() and afterTransaction() methods are part of the Hyperledger Fabric contractapi. These methods are available to use in chaincode. createTransaction​(), submitTransaction() and evaluateTransaction() are part of the application gateway. Application gateway package is used to interact with the Fabric network. You can invoke/query chaincode using application gateway. Samples for both are available in fabric-samples. For more information, refer official documentation.
I'm trying to implement OpenNTF Domino API as a replacement in our project but it fails with this message:
"OpenNTF Domino API: org.openntf.domino.utils.Factory is not initialized for this thread!"
Code snippet:
boolean init = Factory.isInitialized(); // false
Database db = Factory.getSession().getCurrentDatabase(); // This fails of course because no Session
I'm implementing the call in a JAVA DAO behind a EXTLib Servlet in XPages.
So it's not called by an XPage but as an REST API call.
The Domino API Demo DB is working so the server install seems to be OK.
Is there a setup, properties I'm missing to init it ?
Yes, there is specific setup require for non-XPages access, as done in OsgiWorlds on OpenNTF. Nathan has added a DAS extension specifically for REST access from Graph database. You basically need to initialise the session for the Factory before trying to access it, generally done in the Servlet when it initiates the HTTP connection. Please contact me on Twitter (Paulswithers) so the team can work with you. Also it's worth you having a look at the OsgiWorlds source code. Although that's for a Vaadin servlet and allows defining a development user to run as, in production mode it also uses the logged on user name and the configuration class and calls to it from the servlet are effectively what you need from the REST servlet.
Is there a way to expose a Java rest web service in Liferay but not in a portlet, that can receive JSON request and store the data in Journal Article?
Therefore when a user logs into Liferay they will be see web content
Yes there is : JSONWebServiceActionsManagerUtil.registerJSONWebServiceAction
For instance :
Class<?> serviceImplClass;
Method serviceMethod;
Object serviceImpl;
String path = jsonWebServiceMappingResolver.resolvePath(serviceImplClass, serviceMethod);
String method = jsonWebServiceMappingResolver.resolveHttpMethod(serviceMethod);
JSONWebServiceActionsManagerUtil.registerJSONWebServiceAction("/yourwspath", serviceImpl, serviceImplClass, serviceMethod, path, method);
You should then be able to see the new web service in http://SERVER/api/jsonws
Well yes, Liferay has a full API (even JSON-based, SOAP optional, no classic REST though) that you can use. A simple Stackoverflow answer is not the right place to give a full introduction on how to work with Liferay's API, but you might want to look up Servicebuilder (which is used to create Liferay's API) and then look at JournalArticleService and related services: The Web Content Management API is called "Journal" in Liferay (for historical reasons)
I am trying to work out how to use the Hooks and just can't seem to get the syntax correct.
I have built a site using PirahnaCMS that has a blog component and am extending it to call some social plugins and auto post to FB, Twitter etc.
I just can't seem to get the syntax correct though. My app is MVC and I have looked at this section
1.2 ASP.NET MVC
If you're using ASP.NET MVC hooks should be attached in you Global.asax.cs in the Application_Start method, or any other place where you keep you startup code. You attach you hooks with the followin syntax:
protected void Application_Start() {
Piranha.WebPages.Hooks.Menu.RenderItemLink = (ui, str, title, url) => {
str.Append(String.Format("<span>{1}</span>", url, title)) ;
} ;
}
The Hook I believe I want to use is Piranha.WebPages.Hooks.Manager.PostEditModelAfterSave but for the life of me I can't seem to work it out.
All of the hooks are just static delegates that you can attach methods to. In the above example an anonymous method has been assigned to the hook with the syntax:
delegate += (parameters) => { method body }
You could also assign a previously declared method.
delegate += MyMethod
Example skeletons for attaching hooks should be available in the Docs at the official site. If not you can find the hooks in the file:
~/WebPages/Hooks.cs
And all delegates in:
~/Delegates.cs
I hope these URL:s are correct as I'm typing from memory :)
Regards
I want to get parameter from a URL under portlet environment.
The URL i am using to open a portlet is http://localhost:10039/wps/myportal/myPortlet?recId=100
When the portlet opens the URL changes and looks like
*http://localhost:10039/wps/myportal/myPortlet/!ut/p/b1/dY7LcoIwAAC_hQ9wElQSckwJ8lLEgjxyYbDTBAQMgkXHr7ft9Nq97cweFnBQmEhfGUtMdJADfqnmRla3Rl2q7sc5Kt_I0d1RxCCOyAZ6EQl8a29CSA3gAy47dfpOU1aoB1NUMsrEerIUz7lu0vma1pY9hNTZRbXZx8jYP8-SBSv_OibxLD66fnwvknYom9xPMzkK9awT_3Ru6i8Wt5SLA7GDTXtPt5OdGYMkd2wnDorD6UHKm8SqrwpRCb6YD5oGMsB_ly2Humu8hdA0TB161D1iFLMlpKu_AP4DhSB0Vf8Jeu4Qb0G1F8FgaxU!/dl4/d5/L2dBISEvZ0FBIS9nQSEh/?recId=100*
The actuall thing is I want to get recID=100 parameter. The code i am using to get parameter is given below
PortletRequest portletRequest = (PortletRequest) webAppAccess.getHttpServletRequest().getAttribute( Constants.PORTLET_REQUEST);
HttpServletRequest httpRequest = PortletUtils.getInternalRequest(portletRequest).getHttpServletRequest();
httpRequest.getParameter("recId");
but it returns null
Can anyone help me how can i get the parameter under the given situation?
Note :
I am using WebSphere Portal Server 7.
Well, its not that easy.
You have to generate specific urls. WebSphere Portal Advanced Url Generation and How to create a link to a portlet and pass parameters.
I had this scenario before, and someone suggested me to use Portlet utilities, you can find this class in "com.ibm.ws.portletcontainer.portlet" pakcage, there are a lot of constructors(RenderRequest, ActionRequest, PortletRequest, ...), this is the method(PortletUtils.getHttpServletRequest(YOUR NEEDED OBJECT)) you can find your needs.