AnsweredAssumed Answered

null value for custom property aspects in alfresco 4.2e

Question asked by arunr307 on Dec 31, 2014
I am trying to insert document with custom property in java using Alfresco 4.2e. Now values are inserting without any error, but value for custom property is not set, it is showing null.
This my code:

Map<String, String> props = new HashMap<String, String>();
    props.put(PropertyIds.NAME, newDocName);
    props.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document,P:kb:referencable");
    props.put("kb:documentRef", "123");
    props.put("kb:documentID", "1234");
    String content = "sample=================";
    byte[] buf = null;
    try {
        buf = content.getBytes("UTF-8");
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }
    ByteArrayInputStream input = new ByteArrayInputStream(buf);
    ContentStream contentStream = session.getObjectFactory()
            .createContentStream(newDocName, buf.length,
                    "text/plain; charset=UTF-8", input);
    target.createDocument(props, contentStream, VersioningState.MAJOR);



Serach query:

    String query = "SELECT * FROM kb:referencable ";
    ItemIterable<QueryResult> queryResult = session.query(query, false);
    for (QueryResult item : queryResult) {
         System.out.println("item="+item.getProperties());

    }



Here is the search output:

item=[Property [id=kb:documentRef, display Name=KB Reference, local name=documentRef, query name=kb:documentRef, values=[]][extensions=null], Property [id=cmis:objectTypeId, display Name=Object Type Id, local name=objectTypeId, query name=cmis:objectTypeId, values=[cmis:document]][extensions=null], Property [id=cmis:lastModifiedBy, display Name=Last Modified By, local name=lastModifiedBy, query name=cmis:lastModifiedBy, values=[admin]][extensions=null], Property [id=cmis:name, display Name=Name, local name=name, query name=cmis:name, values=[chemistryTest1.txt]][extensions=null], Property [id=cmis:createdBy, display Name=Created by, local name=createdBy, query name=cmis:createdBy, values=[admin]][extensions=null], Property [id=kb:documentID, display Name=kb:documentID, local name=documentID, query name=kb:documentID, values=[]][extensions=null], Property [id=cmis:objectId, display Name=Object Id, local name=objectId, query name=cmis:objectId, values=[149666ab-5745-4365-b63e-c26cb6f4f6cc;1.0]][extensions=null], Property [id=cmis:creationDate, display Name=Creation Date, local name=creationDate, query name=cmis:creationDate, values=[java.util.GregorianCalendar[time=?,areFieldsSet=false,areAllFieldsSet=false,lenient=true,zone=sun.util.calendar.ZoneInfo[id="GMT+05:30",offset=19800000,dstSavings=0,useDaylight=false,transitions=0,lastRule=null],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=?,YEAR=2015,MONTH=0,WEEK_OF_YEAR=?,WEEK_OF_MONTH=?,DAY_OF_MONTH=1,DAY_OF_YEAR=?,DAY_OF_WEEK=?,DAY_OF_WEEK_IN_MONTH=?,AM_PM=?,HOUR=?,HOUR_OF_DAY=9,MINUTE=32,SECOND=59,MILLISECOND=725,ZONE_OFFSET=?,DST_OFFSET=?]]][extensions=null], Property [id=cmis:changeToken, display Name=Change token, local name=changeToken, query name=cmis:changeToken, values=[]][extensions=null], Property [id=cmis:secondaryObjectTypeIds, display Name=Secondary Object Type Ids, local name=secondaryObjectTypeIds, query name=cmis:secondaryObjectTypeIds, values=[P:kb:referencable, P:cm:titled, P:cm:author, P:sys:localized]][extensions=null], Property [id=cmis:baseTypeId, display Name=Base Type Id, local name=baseTypeId, query name=cmis:baseTypeId, values=[cmis:document]][extensions=null], Property [id=alfcmis:nodeRef, display Name=Alfresco Node Ref, local name=nodeRef, query name=alfcmis:nodeRef, values=[workspace://SpacesStore/149666ab-5745-4365-b63e-c26cb6f4f6cc]][extensions=null], Property [id=cmis:description, display Name=Description, local name=description, query name=cmis:description, values=[]][extensions=null], Property [id=cmis:lastModificationDate, display Name=Last Modified Date, local name=lastModificationDate, query name=cmis:lastModificationDate, values=[java.util.GregorianCalendar[time=?,areFieldsSet=false,areAllFieldsSet=false,lenient=true,zone=sun.util.calendar.ZoneInfo[id="GMT+05:30",offset=19800000,dstSavings=0,useDaylight=false,transitions=0,lastRule=null],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=?,YEAR=2015,MONTH=0,WEEK_OF_YEAR=?,WEEK_OF_MONTH=?,DAY_OF_MONTH=1,DAY_OF_YEAR=?,DAY_OF_WEEK=?,DAY_OF_WEEK_IN_MONTH=?,AM_PM=?,HOUR=?,HOUR_OF_DAY=9,MINUTE=32,SECOND=59,MILLISECOND=725,ZONE_OFFSET=?,DST_OFFSET=?]]][extensions=null]]



Outcomes