Submitted by senthil A Kumar on Apr 23, 2012 5:49:59 AM

Re: 4.3.1 Lotus Web Content Management API Sample - Error

I am trying the below

query all content created with a template x

then update a text field y in each content with a vaule

save the content

the above runs in loop and i get the below error.

Exception IWKMU1062X: Message: IWKPY1016X: Unauthorised access on {e4a978804b2ea1eeb99efb3880c87bc9, com.aptrix.pluto.content.Content} by {{AUCPWPSAdmin, cn=aucpwpsadmin,ou=users,ou=portal,ou=applications,dc=ebiz,dc=ecorp,dc=anz,dc=com, c4bc1b6c53364a4aad3976a0d4d0c253, en, Type: User}, 2, {false, {userAccess={}}, {editorAccess={}}, {managerAccess={}}, [all_auth_portal_users%all_auth_portal_users_group_id, anonymous_user%anonymous_user_id, all_users%all_users_group_id, cn=aucpwpsadministrators,ou=groups,ou=portal,ou=applications,dc=ebiz,dc=ecorp,dc=anz,dc=com%e7efa8b5825793459c351ed692154619, cn=aucpwpsadmin,ou=users,ou=portal,ou=applications,dc=ebiz,dc=ecorp,dc=anz,dc=com%c4bc1b6c53364a4aad3976a0d4d0c253]}}, Cause: com.aptrix.pluto.security.AuthorisationException: IWKPY1016X: Unauthorised access on {e4a978804b2ea1eeb99efb3880c87bc9, com.aptrix.pluto.content.Content} by {{AUCPWPSAdmin, cn=aucpwpsadmin,ou=users,ou=portal,ou=applications,dc=ebiz,dc=ecorp,dc=anz,dc=com, c4bc1b6c53364a4aad3976a0d4d0c253, en, Type: User}, 2, {false, {userAccess={}}, {editorAccess={}}, {managerAccess={}}, [all_auth_portal_users%all_auth_portal_users_group_id, anonymous_user%anonymous_user_id, all_users%all_users_group_id, cn=aucpwpsadministrators,ou=groups,ou=portal,ou=applications,dc=ebiz,dc=ecorp,dc=anz,dc=com%e7efa8b5825793459c351ed692154619, cn=aucpwpsadmin,ou=users,ou=portal,ou=applications,dc=ebiz,dc=ecorp,dc=anz,dc=com%c4bc1b6c53364a4aad3976a0d4d0c253]}}

Submitted by Amanda J Wachendorf on Mar 13, 2012 11:21:02 AM

Re: 4.3.1 Lotus Web Content Management API Sample

Hello, I too am experiencing both the issues listed in the other two comments. Could you please provide a solution?

Submitted by Neil Andy on Jun 22, 2010 8:31:28 AM

4.3.1 Lotus Web Content Management API Sample

Hello,

I have used the similar code as above but have the below issues:

1)The comments that are added recently disappear upon server restart.

2)Some users get the below error upon submitting the comment but the comment actually shows when they navigate away and come beck to the page.So doesnot stop them from their work

error in the code: com.ibm.workplace.wcm.api.exceptions.DocumentSaveException: IWKMU1062X: Message: An External Lock could not be applied to {185fb68042e2b958b253fe1a4fe2fada, com.aptrix.pluto.content.Content}., Cause: com.ibm.workplace.wcm.services.repository.LockNodeFailedException: An External Lock could not be applied to {185fb68042e2b958b253fe1a4fe2fada, com.aptrix.pluto.content.Content}.

<%@ page import="com.ibm.workplace.wcm.api.*,com.ibm.workplace.wcm.api.exceptions.*,javax.portlet.*"%>

<%@ page import="com.ibm.wps.services.ServiceManager,java.util.*,java.security.Principal,java.text.SimpleDateFormat"%><%!

String COMMENTFIELDNAME = "Comment";

String SEPARATOR = "~";

String INTSEPARATOR = ";";

String format = "dd/MM/yy";

int commentsNo = 0;

%><%

try {

// Construct and inital Context

javax.naming.InitialContext ctx = new javax.naming.InitialContext();

// Retrieve WebContentService using JNDI name

WebContentService webContentService = (WebContentService) ctx.lookup("portal:service/wcm/WebContentService");

//Get the WCM Repository

Repository rep = webContentService.getRepository();

//Get an authenticated WCM Workspace

Workspace wsa = rep.getWorkspace();

//Set the current library

wsa.setCurrentDocumentLibrary(wsa.getDocumentLibrary("StannahIntranet"));

//Get the rendering context

RenderingContext renderingContext = (RenderingContext)request.getAttribute(Workspace.WCM_RENDERINGCONTEXT_KEY);

if(renderingContext == null) {

Object portletRequest = request.getAttribute("javax.portlet.request");

if(portletRequest != null && portletRequest instanceof PortletRequest) {

// JSR286 rendering

renderingContext = (RenderingContext) ((PortletRequest)portletRequest).getAttribute(Workspace.WCM_RENDERINGCONTEXT_KEY);

}

}

wsa.useUserAccess(true);

//Get the current content object

Content current = renderingContext.getContent();

//The comments component

String encodedComments = "";

if(current!=null&¤t.hasComponent(COMMENTFIELDNAME)){

try{

TextComponent commentscomponent = (TextComponent) current.getComponent(COMMENTFIELDNAME);

encodedComments = commentscomponent.getText();

//

if(request.getMethod().equalsIgnoreCase("POST")){

String comment = request.getParameter(COMMENTFIELDNAME);

if(comment!=null){

Principal user = request.getUserPrincipal();

//

Date today = new Date();

SimpleDateFormat formatter = new SimpleDateFormat(format);

String datenewformat = formatter.format(today);

//

comment.replace('~', ' ');

StringBuffer commentValue = new StringBuffer();

commentValue.append(encodedComments);

if(commentValue.length()>0){

commentValue.append(SEPARATOR);

}

commentValue.append(wsa.getUserProfile().getUsername()).append(INTSEPARATOR).append(datenewformat).append(INTSEPARATOR).append(comment);

encodedComments = commentValue.toString();

commentscomponent.setText(encodedComments);

current.setComponent(COMMENTFIELDNAME, commentscomponent);

//Save the content

wsa.save(current);

}

}

}catch(ComponentNotFoundException e){}

}

webContentService.getRepository().endWorkspace();

// Print out any comments.

if(encodedComments!=null){

String[] comments = encodedComments.split(SEPARATOR);

commentsNo = "".equals(encodedComments) ? 0 : comments.length;

%>

Comments: (<%=commentsNo %>)
<%

for(int i=0;i

{

String encodedComment = comments[i];

if(!"".equals(encodedComment)){

try{

int sepOne = encodedComment.indexOf(INTSEPARATOR);

int sepTwo = encodedComment.indexOf(INTSEPARATOR,(sepOne+1));

String userName = encodedComment.substring(0,sepOne);

String commentDate = encodedComment.substring(sepOne+1,sepTwo);

String commentText = encodedComment.substring(sepTwo+1);

%>

<%= userName %> - <%= commentDate %>

<%= commentText %>

<%

}catch(StringIndexOutOfBoundsException e){

%>

ERROR: <%= encodedComment %>

<%

}

}

}

}

}

catch (Exception t)

{

out.println("error in the code: " + t.toString());

}

%>

Submitted by Divya P Ballal on Nov 26, 2009 11:22:52 PM

4.3.1 Lotus Web Content Management API Sample

Hi,

Above code was very usefull however i had problem,on submit of comment, code checks for post method and apend the comment in the text component, when same page is refreshed request object still hold the previous comment and apend the same comment once again. please suggest how to avoid adding duplicate comment on browser refresh.

thanks,

Divya