Use ApacheClientHttpInvoker instead of DefaultHttpInvoker - cmis

Is there any setting in Apache Chemistry to force Apache HTTP Client for connections instead of default Java HTTP functionality?
In package org.apache.chemistry.opencmis.client.bindings.spi.http there is ApacheClientHttpInvoker class that does what I need but I dont know how to use it without source code modification?
I'm asking this because Lotus Notes 9 has bug in its JVM and java.net.HttpURLConnection always throws NullPointerException...
Thank you for assistance.

Set the session parameter HTTP_INVOKER_CLASS to "org.apache.chemistry.opencmis.client.bindings.spi.http.ApacheClientHttpInvoker" and make sure that you have the Apache HTTP Client jars (tested with 4.2.5) in your classpath.
For more session parameters see:
http://chemistry.apache.org/java/0.10.0/maven/apidocs/org/apache/chemistry/opencmis/commons/SessionParameter.html

Related

opening an agent via SSJS in XPages including parameters

I want to open an agent via an URL and provide some additional parameters (re-writing an old Domino app, I want to maintain some document handling that resides now in web enabled agents)
I am trying:
...
var unid:String=mybean.myObject().getUnid();
importPackage(java.net);
importPackage(java.io);
var agent:URL = new URL("myagent?OpenAgent&unid=" + unid);
var agentConnection:URLConnection = agent.openConnection();
...
this causes an error. if I look in the log the address I am directing to has become: "dir/db.nsf/myagent?OpenAgent&unid=7FC612D6736836ECC125822800622FF1"
any easy way to get this old agent running?
You might want to revisit your approach. Instead of using http(s) to access your agent, you could call it directly with agent.run. It would require some adjustment on the agent side (still can be used dual use) and saves you the TLS headache. Follow this blog entry for inspiration: https://wissel.net/blog/2012/04/reuse-web-agents-that-use-print-bean-edition.html
Does your server or database use only https? I think that requires different code and there are issues with Java 1.6 and TLS versions.

ActiveMQ send ObjectMessage

I'm using ActiveMQ to implement a messaging system in my current project. I need to send and receive Java objects instead of simple text or binary messages. The Java object (my message object) implements the Serializable interface as required.
Recent versions of ActiveMQ added some security and I need to set a property with the allowed packages as described here, but I haven't managed to make it work. I'm not sure where that property needs to be added.
Error message:
This class is not allowed to be serialized. Add package with 'org.apache.activemq.SERIALIZABLE_PACKAGES' system property
You need to either pass trusted packages in environment variable while running jar or you can do this programmatically by adding following line of code:
System.setProperty("org.apache.activemq.SERIALIZABLE_PACKAGES","*");
I hope this will help
In your ActiveMQ config,add connectionFactory.setTrustedPackages(Arrays.asList("java.lang","your packagename"));

Apigee Java Call Out Response

In a standalone java code, using Apache HTTPClient libs, implementing the NTLM Authentication with SharePoint Server and accessing its Web Service and receiving the huge XML content as response. Now this final output is in String format. Created the Java Call Out Policy and uploaded all the jars.
I need some help here,
How to pass the java's final output response to Apigee's response.
My requirement is: If I hit the Apigee API Proxy then I need to receive the Java's output(String) as Apigee's response.
Which policy is more appropriate to handle this response.
Appreciate your help! Thanks in Advance.
You can use the javacallout policy to author custom java code. Here is a related post in SO: Working With JAVA Callout in apigee?
You can try
message.setContent(string) to create the content, and
messageContext.setResponseMessage(Message)
in java code to directly write to output.

Access a local IBM Notes application with default system browser

I am developping web applications using the Xpages framework from the IBM Lotus Notes technology.
My users don't use the embedded Notes Client browser, but use a regular modern browser (Firefox, Chrome) to browse Notes applications.
Everything is ok when the user has an internet connexion, he can access the application on the online server through his favorite browser.
However some of my applications need to be used Offline, in local. When a user works in local, he opens the IBM Notes Client, go to his workspace and click to open an application locally. Then, the Notes Client runs a http server on a random port and open the application with the embedded Notes Client browser.
What I want to achieve is to be able to open the application on a regular browser (Firefox, Chrome), by just using the default system browser and not the embedded Notes Client browser.
Here is what I tried without success :
With window.location.href I get the port where the local http server runs and the path to the page that is opened in the embedded Notes Client browser. I get this kind of result :
127.0.0.1:54428/xsp/Gfn/CoffeShop.nsf/xp_home.xsp?OpenXPage&&xspRunningContext=Notes
So I just keep the interesting part :
127.0.0.1:54428/xsp/Gfn/CoffeShop.nsf/xp_home.xsp
Now I need to pass the session id has a parameter of this http request so the browser will have the right to access the application. I get the session ID with the following :
facesContext.getExternalContext().getRequest().getSession().getId()
From this I get an ID and I build my complete http request :
127.0.0.1:54428/xsp/Gfn/CoffeShop.nsf/xp_home.xsp?SessionID=ID-fae7aca8f062023972fe35e5909b0106f44ba2ae
But when I try this into a regular browser, instead of getting the page I get an error 500. If I look at the log of the server, I see the following error message :
Exception Thrown
javax.servlet.ServletException: The request is not coming from a trusted Rich Client part
But I am sure my ID is correct. I tried to investigate this on the internet but no success for now, I would be happy if someone has an idea about what do I miss? Or maybe another way to open a local application in the default system browser?
Thank you!
In short, you can't. This is disabled by security restrictions.
But maybe you should think again about a XPiNC application: With 9.0.1, the underlying XULRunner component was upgraded and supports now HTML5 and a lot of the "newer" features.
It matches Firefox 10.0.6, here are the HTML5 test results:
https://html5test.com/s/555ae51ca555ac7b.html
The only reasonable action you have at you disposal is to install Domino designer on the clients. Then you get the nhttp task that serves to a standard browser (you might get away analysing what nhttp needs and only install that part).
The caveat there: the local nhttp does not support authentication. So you need to hack around it (e.g. copy data back and forth between the local NSF and the properly secured one).
Alternative you could try the approach I took with vert.x (should work with any Java container, but then you won't have any XPages, just raw Domino data.
Danielle pushed that forward with the Crossworlds Project - which might be what you need.
Stephan says it as it is: the way you are considering is just going to cause you huge headaches.
If offline capacity is a must, have you thought about creating a pure Notes-Client application? That would certainly be far easier.

How to set user agent in: new XmlSlurper().parse(URL)

I am launching requests to a web service using Groovy/XmlSlurper:
new XmlSlurper().parse("http://en.wikipedia.org/w/api.php?action=...")
I would like to set the user agent to let the website know what project the requests are from.
How to set the user agent?
XMLSlurper's constructors do not have anything like this.
The setProperty method sounds interesting but Google does not lead to anything related to UA.
I would rather avoid changing the code to abandon XmlSlurper in favor of another library.
Looks like Groovy uses the JVM's default SAX parser to connect to the input stream and perform the initial parsing. I saw this answer on SO that might help - all you need to do is set this before your call to the slurper to make it happen:
System.setProperty("http.agent", "my-agent-name");
P.S. This is just a guess - hope it helps.
I see p.3, btw there is also Groovy Http Builder, it uses JsonSlurper for JSON results, but it's much more flexible for making http requests - http://groovy.codehaus.org/HTTP+Builder

Resources