Lotus API getAllReadEntries throughs not implemented error in Eclipse - lotus-notes

I am trying to get Read/Unread documents from Lotus notes, I can connect using this code:
package mypackage.Notes.GetRead;
import java.util.Vector;
import lotus.domino.Database;
import lotus.domino.NotesException;
import lotus.domino.NotesFactory;
import lotus.domino.Session;
import lotus.domino.View;
import lotus.domino.ViewEntryCollection;
public class GetRead {
public static void main(String[] args) {
// TODO Auto-generated method stub
try {
Session s = NotesFactory.createSession("192.168.32.156", "Administrator/MyOrg","password");
Database db = s.getDatabase("192.168.32.156", "\\mail\\administ.nsf");
//db.open();
View view = db.getView("($Inbox)");
ViewEntryCollection vec = view.getAllReadEntries();
System.out.println("View has " +
vec.getCount() + " read entries");
} catch (NotesException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
yet, I am getting:
NotesException: Not implemented
at lotus.domino.cso.Base.notImplemented(Unknown Source)
at lotus.domino.cso.View.getAllReadEntries(Unknown Source)
at sysgravity.Notes.GetRead.GetRead.main(GetRead.java:21)
I have made sure I am using the same notes.jar and NCSO.jar files as on the server, also tried to read Lotus Notes API giving error while accessing the NSF but not luck.
Is it realted to JDK version or eclipse version ?! what do I need to check ?!
EDIT WITH A SOLUTION:
Thanks Richard
for those who are struggling with this issue, here is the detailed solution:
As Richard have highlighted the getallreadentries is implemented in Notes.Jar and NOT NCSO.jar, and specifically it must be a local lotus call.
if you put a server address in the Notesfactory, Notes considers this a remote call and implement notes remote call not a local call through Notes.Jar and this is why you get troubles
the call must be local using:
NotesFactory.createSession((String)null, (String)null, password);
also you must use
- Java 32 bit for the JDK and JRE when running the jar.
- The computer that is running eclipse or your Jar must be running Lotus Admin + designer or has Notes client installed with the default notes.id properly configured (I found that having multiple notes IDs configured gives issues).
- Configure the PATH in your environment variables to point to Lotus Data File and Notes path.
then it will work.
Thanks, Mahmoud

Related

Tenant Not availalbe exception despite the use of the workaround

I have implented GetAllBusinessPartnerCommand and also customized the code in the BusinessPartnerServlet. When I try to call the application with the customized code, I always get this error.
Code GetAllBusinessPartnersCommand
package com.sap.cloud.s4hana.examples.commands;
import java.util.Collections;
import java.util.List;
import org.slf4j.Logger;
import com.sap.cloud.s4hana.examples.BusinessPartnerServlet;
import com.sap.cloud.sdk.cloudplatform.logging.CloudLoggerFactory;
import com.sap.cloud.sdk.frameworks.hystrix.HystrixUtil;
import com.sap.cloud.sdk.s4hana.connectivity.ErpCommand;
import com.sap.cloud.sdk.s4hana.datamodel.odata.helper.Order;
import com.sap.cloud.sdk.s4hana.datamodel.odata.namespaces.businesspartner.BusinessPartner;
import com.sap.cloud.sdk.s4hana.datamodel.odata.services.DefaultBusinessPartnerService;
public class GetAllBusinessPartnersCommand extends ErpCommand<List<BusinessPartner>>{
private static final Logger logger = CloudLoggerFactory.getLogger(BusinessPartnerServlet.class);
public static final String CATEGORY_PERSON ="1";
public GetAllBusinessPartnersCommand() {
super(HystrixUtil.getDefaultErpCommandSetter(
GetAllBusinessPartnersCommand.class,
HystrixUtil.getDefaultErpCommandProperties().withExecutionTimeoutInMilliseconds(10000)));
}
#Override
protected List<BusinessPartner> run() throws Exception {
// TODO Auto-generated method stub
return new DefaultBusinessPartnerService().getAllBusinessPartner()
.select(BusinessPartner.BUSINESS_PARTNER,
BusinessPartner.LAST_NAME,
BusinessPartner.FIRST_NAME,
BusinessPartner.IS_MALE,
BusinessPartner.IS_FEMALE,
BusinessPartner.CREATION_DATE)
.filter(BusinessPartner.BUSINESS_PARTNER_CATEGORY.eq(CATEGORY_PERSON))
.orderBy(BusinessPartner.LAST_NAME, Order.ASC)
.execute();
}
#Override
protected List<BusinessPartner> getFallback() {
logger.warn("Fallback called because of exception:",
getExecutionException());
return Collections.emptyList();
}
}
n the following you can see the commands and the offered workaround for the problem set ALLOW_MOCKED_AUTH_HEADER=true. Before testing I checked if all variables are set correctly and set ALLOW_MOCKED_AUTH_HEADER=true again because I set it too early before.
After this steps i build my project like i always do and get the error from above when im calling the service. I also read this post where someone have the same problem and used the mentioned workaround. But this doesnt work for me and i have no clue why. TenantNotAvailableException, when trying to call business partner from s4 CF SDK
error when call page
Starting mock-server
set variables and workaround plus check
Unfortunately SAP Cloud SDK 2.x is no longer supported. Please use our migration guide to move to the latest version 3.43.0 You can find my blog post on this topic too. If you face any issues, please create another StackOverflow question (with tag sap-cloud-sdk) or comment to the blog post. For more details, please find our documentation.

Reuse web agents that PRINT to the browser in XPages Lotus

When upgrading classic Domino applications to XPages one particular problem arises constantly: "what to do with the PRINT statements in existing agents that write back directly to the browser?" I have 200 agents in my nsf file which all uses Print statement in their code.
I have investigated found the link http://www.wissel.net/blog/d6plinks/SHWL-8SF7AH
but it is not possible for me to change agent code as it is also used from forms.
I have to re-use these agents from xpages on button click and also have to pass document.
Is there any way or alternative which can solve my problem.
help is required.
We have Agent.runWithDocumentContext(doc:NotesDocument) method which can run the agent from xpage and passing an in-memory document. I create an im-memory document
var doc = database.createDocument();
doc.replaceItemValue("StartDate",startDate.getDateOnly())
doc.replaceItemValue("EndDate",endDate.getDateOnly())
doc.replaceItemValue("ReportName",reportName)
var agent:NotesAgent = database.getAgent("("+reportName+")");
agent.runWithDocumentContext(doc);
This in-memory document i can pass to the agent. But the issue I am facing currently that my agents are used to print directly which is not possible through xpage i assume.
Is there any alternative way to pass in-memory document to agent and able to print directly to browser through xpages.
Help needed please help.
If you want to use XPages.. then USE XPages... Meaning migrate the agents to the XPages way of doing things. There can be a lot of coexhistance between XPages and Notes Client or I supposed even Classic Domino Web. But if you're set on keeping 200 Agents which are NOT really part of XPages Best practices, then it sounds to me like you shouldn't be using XPages at all.
EDIT:
This link:
http://www-10.lotus.com/ldd/ddwiki.nsf/dx/XPages_and_Calling_Agents_Using_an_In-Memory_Document
Talks about calling an Agent from XPages and being able to use the in memory document. Maybe that will help but if it's heavily used performance will not be great since an agent loads and unloads for each call. It's still a bad idea to do.
create a java class that calls your agent and read the output from your agents in an input stream and display the stream in computed field in Xpages.
here is a sample java class that will retrive the output from your agent
package com.thomas;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
public class getAgentData{
public String getData() throws IOException {
try {
URL url = new URL("http://localhost/mydatabase.nsf/myagent?openagent");
BufferedReader in = new BufferedReader(
new InputStreamReader(url.openStream()));
String content = new String();
String inputLine;
while ((inputLine = in.readLine()) != null) {
content+=inputLine;
}
in.close();
return content;
} catch (MalformedURLException e) {
e.printStackTrace();
}
return null;
}
}
If you add your java class as a bean in faces-config.xml you can call it using a computed field in your xpages like this
<xp:text escape="true" id="computedField1" value="#{javascript:getAgentData().getData()}"></xp:text>
You need to change your agent a little. Instead of Print "Something" you would use someobj.print "Something" - which should be a manageable task using search/replace. The detailed steps have been documented in this blog entry.
Now you state that you need to dual use the agent. Not that hard, once you move beyond copy and paste programming.
When you check the class - it looks for documentcontext. When you call the agent directly, the document context is not there. So you check if you have the document - if not it is classic and you add a print statement to the class, if it is there you save to the context.
The code is myObject.printResult = true to print - or you set it to true per default (but then you pollute your log :-) )
If you provide a context doc when calling the agent, then you would provide an item (e.g. DontPrint=1) from your XPages and check that one. If it is there, only save to the context, otherwise add the print statement.
Let us know how it goes.

Connect XPage with OpenOffice

I have a button on an XPage where I want to connect to a remote OpenOffice instance. OpenOffice is started and is listening for a socket connection.
The onclick event of the button runs following SSJS:
oo = new com.test.OpenOffice();
oo.init("host=127.0.0.1,port=8107");
oo.openFile("C:\\TEMP\\Test.odt");
The code raises an excepction jva.lang.IlleagalStateException: NotesContext not initialized for the thread
The exception is raised within the method initof the class OpenOffice.
The relevant parts of the class OpenOffice is the following code:
public class DHOpenOffice implements Serializable {
private static final long serialVersionUID = -7443191805456329135L;
private XComponentContext xRemoteContext;
private XMultiComponentFactory xMCF;
private XTextDocument oTextDocument;
public DHOpenOffice() {
xRemoteContext = null;
xMCF = null;
oTextDocument = null;
}
public void init(String hostAdr) throws java.lang.Exception {
xRemoteContext = null;
XComponentContext xLocalContext = Bootstrap.createInitialComponentContext(null);
XUnoUrlResolver xUrlResolver = UnoUrlResolver.create(xLocalContext);
String sConnect = "uno:socket," + hostAdr + ",tcpNoDelay=0;urp;StarOffice.ServiceManager";
Object context = xUrlResolver.resolve(sConnect);
xRemoteContext = UnoRuntime.queryInterface(XComponentContext.class, context);
xMCF = xRemoteContext.getServiceManager();
}
The code line Object context = xUrlResolver.resolve(sConnect); is the one that raises the exception.
Why is this happing? What is the reason for this exception and how can I resolve the situation?
N.B.: The class code runs smoothly in a standalone application. The error occurs only when the code is started by a SSJS code.
It looks like a threading issue. There are a number of things you can go and try:
Wrap the whole interaction into a custom class and use it from a managed bean instead of calling it from SSJS
Make sure not to hand over any Notes objects into the custom class, only your own
Check if the Open Document Toolkit would be sufficient to do the operations you are interested in, so you don't need to run OO
let us know how it goes
Update
Try to get outside the standard XPages cycle. One way is to deploy a custom plug-in servlet:
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
public class OpenOfficeServlet extends HttpServlet {
// Your code goes here
}
You need to get the plugin.xml right:
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension point="org.eclipse.equinox.http.registry.servlets">
<servlet alias="/ooproxy" class="com.yourcompany.OpenOfficeServlet" />
</extension>
</plugin>
Then you could e.g. post a JSON structure or a serializable Java object to the servlet with the data and process it there (async if necessary). You deploy such a plug-in using the updatesite.nsf
Thanks to the answer of #stwissel I was able to solve the problem (he pointed me to the right direction).
I could solve the problem with a simple OSGI plug-in. The servlet approach solved the problem, too, but for me the OSGI plug-in was easier to use.
So these are the steps to create the plug-in
start a new plugin project
copy the open office jar files into the project and include them into the build path
copy the custom class that uses the UNO API into the plug-in
create a feature project for the plugin
create an update site
deploy the plugin via an update site
The following site where also quite helpfull:
Creating an XPages Library
Wrap an existing JAR file into a plug-in

Lwuit class not found error.Please help me to solve it?

Im very new to "LWUIT" for "J2ME". I installed eclipse pulsar in my system.I also installed sony ericsson j2me sdk. The normal j2me is works fine.
When I use lwuit in my j2me project. Then it will not working.
I'm creating new project namely "lwuit2" in my eclipse pulsar.
Then I select my project from project or package explorer, then right clickt
Then I click libraries tab, then I click add external jar button,
then I choose the lwuit path where I store the lwuit.jar
then I click ok. It is success.
the following are my source code
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
import com.sun.lwuit.Display;
import com.sun.lwuit.Form;
public class TestMidlet1 extends MIDlet {
Form frm=null;
public TestMidlet1() {
// TODO Auto-generated constructor stub
}
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
// TODO Auto-generated method stub
}
protected void pauseApp() {
// TODO Auto-generated method stub
}
protected void startApp() throws MIDletStateChangeException {
// TODO Auto-generated method stub
Display.init(this);
frm=new Form("Testing lwuit");
frm.show();
}
}
When I type the above code the eclipse pulsar does not shows any compile time error. But when I run it, then it shows the error. I print screen the error window and attached it please refer the attachment below.
Pulsar does not export the lwuit.jar into your midlet's jar unless you instruct it to explicitly. On the "Order and Export" tab of the project's "Java Build Properties" select the lwuit.jar so that it is exported as part of your midlet.

Multiple Threads in Xpages

I have a problem and hoped somone could help me
I'm trying to start multiple threads from an XAgent (not rendered XPage)
public class ImportThread extends NotesThread {
Session currentSession;
public ImportThread(String maildb, String Server)
{
try{
currentSession =DominoAccess.getCurrentSession();
this.maildb = currentSession.getDatabase(Server, maildb);
}catch (Exception e) {
e.printStackTrace();
}
}
public void runNotes()
{
View v = maildb.getView("$Calendar");
}
in this version I could not access the View I only get "null" back
Ive tryed a version with Java Threads not realy better.
thean i've found something on Openntf
http://www.openntf.org/internal/home.nsf/project.xsp?action=openDocument&name=Threads%20and%20Jobs
but there I got an "AccessControl Exception"
I have no more ideas, I hope that someone has an idea how to create
an XAgent with multiple thread
As Egor wrote you need the change the Java policy file if you run the Java code from an NSF. You don't have to do this if you deploy your Java code as OSGi plugin. See the documentation of that OpenNTF project.
Afaik NotesObjects should not be shared between threads. So instead of using Database mailDB you should use String mailDBName and instantiate all NotesObjects inside their own thread. You also need to watch run time: if your XAgent waits for the treads to conclude, you should be fine, but if it is a 'fire-and-forget' approach you need to start it from something more persistent like a managed bean in the session scope.
Hope that helps

Resources