<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic [5.6-RC3] Custom operation java code - some properties don't get set in Nuxeo Forum</title>
    <link>https://connect.hyland.com/t5/nuxeo-forum/5-6-rc3-custom-operation-java-code-some-properties-don-t-get-set/m-p/320043#M7044</link>
    <description>&lt;P&gt;Hello all,&lt;/P&gt;
&lt;P&gt;I have a custom operation java code that creates an object (a CaseLink) and sets some data on it.&lt;/P&gt;
&lt;P&gt;Set properties works for all properties but one (at least, what I'm seeing) which stays null.
There no custom properties involved.
The property I cannot set is case_link / caseItemId.&lt;/P&gt;
&lt;P&gt;I've checked with the debugger: all the properties are set on the memory object, including the one that I find null in the DB afterword.&lt;/P&gt;
&lt;P&gt;There is no error message in the logs.&lt;/P&gt;
&lt;P&gt;How can I debug this?
Do you see any reason for the set on a particular property not to work?&lt;/P&gt;
&lt;P&gt;Thanks.&lt;/P&gt;
&lt;P&gt;Here is the code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;@Operation(	id = CreateCaseLinkOperation_withLastCaseItem.ID, 
		category = CaseConstants.CASE_MANAGEMENT_OPERATION_CATEGORY, 
		label = "Case Link creation", 
		description = "Create a CaseLink to be used latter in the chain," +
					  " takes on input a CaseItem, retrieves 		")
public class CreateCaseLinkOperation_withLastCaseItem {

public final static String ID = "MyPrefix.Case.Management.CreateCaseLink";

@Context
OperationContext context;

private CaseManagementDocumentTypeService correspDocumentTypeService;

@OperationMethod
public DocumentModelList createCaseLink(DocumentModelList docs) {
    CoreSession session = context.getCoreSession();
    List&amp;lt;CaseLink&amp;gt; links = new ArrayList&amp;lt;CaseLink&amp;gt;();
    try {
        for (DocumentModel doc : docs) {
        	
            DocumentModel linkDoc = session.createDocumentModel(getCaseManagementDocumentTypeService().getCaseLinkType());
            
        	// retrieve current user name mailboxId
        	String currentUserMailboxId = "";
        	{
            	Principal prin = session.getPrincipal();	            	
            	try {
            		MailboxManagementService mbMngtService = Framework.getService(MailboxManagementService.class);
        			currentUserMailboxId = mbMngtService.getUserPersonalMailboxId(prin.getName());
            	} catch (Exception e) {
        			e.printStackTrace();
        		}
        	}
        	
            // set case ID
            linkDoc.setPropertyValue( CaseLinkConstants.CASE_DOCUMENT_ID_FIELD, doc.getId() ); 
            
            // set case item ID (if any): taking the last case item in the case
            Case kase = doc.getAdapter(Case.class);
            List&amp;lt;CaseItem&amp;gt; list_ci = kase.getCaseItems(session);
            if ( list_ci.size() &amp;gt; 0 ) {
                String caseItemId = list_ci.get(list_ci.size() - 1).getDocument().getId();
                linkDoc.setPropertyValue( "cslk:caseItemId", caseItemId );                	
            }
            
            // set sender mailboxId
            linkDoc.setPropertyValue("cslk:sender", currentUserMailboxId );
                            
            // retrieve Case's responsible
        	String responsible;
        	{
        		// @TEMP
        		responsible = currentUserMailboxId;
        	} // retrieve Case's responsible            	
            Map&amp;lt;String, List&amp;lt;String&amp;gt;&amp;gt; recipients = new HashMap&amp;lt;String, List&amp;lt;String&amp;gt;&amp;gt;();
            recipients.put(CaseLinkType.FOR_ACTION.name(), Arrays.asList(new String[] { responsible }));

            CaseLink cl = linkDoc.getAdapter(CaseLink.class);
            cl.addInitialInternalParticipants(recipients);
            links.add(cl);
        }
        context.put(CaseConstants.OPERATION_CASE_LINKS_KEY, links);
    } catch (ClientException e) {
        throw new RuntimeException(e);
    }
    return docs;
}
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;up&lt;/P&gt;</description>
    <pubDate>Tue, 28 Aug 2012 13:53:49 GMT</pubDate>
    <dc:creator>promanov_</dc:creator>
    <dc:date>2012-08-28T13:53:49Z</dc:date>
    <item>
      <title>[5.6-RC3] Custom operation java code - some properties don't get set</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/5-6-rc3-custom-operation-java-code-some-properties-don-t-get-set/m-p/320043#M7044</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;
&lt;P&gt;I have a custom operation java code that creates an object (a CaseLink) and sets some data on it.&lt;/P&gt;
&lt;P&gt;Set properties works for all properties but one (at least, what I'm seeing) which stays null.
There no custom properties involved.
The property I cannot set is case_link / caseItemId.&lt;/P&gt;
&lt;P&gt;I've checked with the debugger: all the properties are set on the memory object, including the one that I find null in the DB afterword.&lt;/P&gt;
&lt;P&gt;There is no error message in the logs.&lt;/P&gt;
&lt;P&gt;How can I debug this?
Do you see any reason for the set on a particular property not to work?&lt;/P&gt;
&lt;P&gt;Thanks.&lt;/P&gt;
&lt;P&gt;Here is the code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;@Operation(	id = CreateCaseLinkOperation_withLastCaseItem.ID, 
		category = CaseConstants.CASE_MANAGEMENT_OPERATION_CATEGORY, 
		label = "Case Link creation", 
		description = "Create a CaseLink to be used latter in the chain," +
					  " takes on input a CaseItem, retrieves 		")
public class CreateCaseLinkOperation_withLastCaseItem {

public final static String ID = "MyPrefix.Case.Management.CreateCaseLink";

@Context
OperationContext context;

private CaseManagementDocumentTypeService correspDocumentTypeService;

@OperationMethod
public DocumentModelList createCaseLink(DocumentModelList docs) {
    CoreSession session = context.getCoreSession();
    List&amp;lt;CaseLink&amp;gt; links = new ArrayList&amp;lt;CaseLink&amp;gt;();
    try {
        for (DocumentModel doc : docs) {
        	
            DocumentModel linkDoc = session.createDocumentModel(getCaseManagementDocumentTypeService().getCaseLinkType());
            
        	// retrieve current user name mailboxId
        	String currentUserMailboxId = "";
        	{
            	Principal prin = session.getPrincipal();	            	
            	try {
            		MailboxManagementService mbMngtService = Framework.getService(MailboxManagementService.class);
        			currentUserMailboxId = mbMngtService.getUserPersonalMailboxId(prin.getName());
            	} catch (Exception e) {
        			e.printStackTrace();
        		}
        	}
        	
            // set case ID
            linkDoc.setPropertyValue( CaseLinkConstants.CASE_DOCUMENT_ID_FIELD, doc.getId() ); 
            
            // set case item ID (if any): taking the last case item in the case
            Case kase = doc.getAdapter(Case.class);
            List&amp;lt;CaseItem&amp;gt; list_ci = kase.getCaseItems(session);
            if ( list_ci.size() &amp;gt; 0 ) {
                String caseItemId = list_ci.get(list_ci.size() - 1).getDocument().getId();
                linkDoc.setPropertyValue( "cslk:caseItemId", caseItemId );                	
            }
            
            // set sender mailboxId
            linkDoc.setPropertyValue("cslk:sender", currentUserMailboxId );
                            
            // retrieve Case's responsible
        	String responsible;
        	{
        		// @TEMP
        		responsible = currentUserMailboxId;
        	} // retrieve Case's responsible            	
            Map&amp;lt;String, List&amp;lt;String&amp;gt;&amp;gt; recipients = new HashMap&amp;lt;String, List&amp;lt;String&amp;gt;&amp;gt;();
            recipients.put(CaseLinkType.FOR_ACTION.name(), Arrays.asList(new String[] { responsible }));

            CaseLink cl = linkDoc.getAdapter(CaseLink.class);
            cl.addInitialInternalParticipants(recipients);
            links.add(cl);
        }
        context.put(CaseConstants.OPERATION_CASE_LINKS_KEY, links);
    } catch (ClientException e) {
        throw new RuntimeException(e);
    }
    return docs;
}
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;up&lt;/P&gt;</description>
      <pubDate>Tue, 28 Aug 2012 13:53:49 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/5-6-rc3-custom-operation-java-code-some-properties-don-t-get-set/m-p/320043#M7044</guid>
      <dc:creator>promanov_</dc:creator>
      <dc:date>2012-08-28T13:53:49Z</dc:date>
    </item>
    <item>
      <title>Re: [5.6-RC3] Custom operation java code - some properties don't get set</title>
      <link>https://connect.hyland.com/t5/nuxeo-forum/5-6-rc3-custom-operation-java-code-some-properties-don-t-get-set/m-p/320044#M7045</link>
      <description>&lt;P&gt;Hard to say without seeing your java code to understand what you do through it. Can you copy into your question your java code ?&lt;/P&gt;</description>
      <pubDate>Thu, 30 Aug 2012 14:22:49 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/nuxeo-forum/5-6-rc3-custom-operation-java-code-some-properties-don-t-get-set/m-p/320044#M7045</guid>
      <dc:creator>Benjamin_Jalon1</dc:creator>
      <dc:date>2012-08-30T14:22:49Z</dc:date>
    </item>
  </channel>
</rss>

