cancel
Showing results for 
Search instead for 
Did you mean: 

Error on POST document

flosk8
Champ in-the-making
Champ in-the-making
Hey,

I want to POST the following to Alfresco over CMIS and get this:

1101014 TypeError: Cannot read property "nativeValue" from null (file:C:/Alfresco/t
mcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfresc
/cmis/children.post.atom.js#93)


<?xml version="1.0" encoding="utf-8"?>
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:cmisra="http://docs.oasis-open.org/ns/cmis/restatom/200908/" xmlns:cmis="http://docs.oasis-open.org/ns/cmis/core/200908">
<title>sample-a.doc</title>
<summary>Sample</summary>
<content type="text/html">
SGFsbG8gRmxv
</content>
<cmisra:object>
<cmis:properties>
<cmis:propertyId propertyDefinitionId="cmis:objectTypeId"><cmis:value>D:cmiscustom:document</cmis:value></cmis:propertyId>
</cmis:properties>
</cmisra:object>
</entry>

I tested also  <cmis:value>cmis:document as</cmis:value> with no effect.

Can you help me? anyone did this before?
4 REPLIES 4

perucci
Champ in-the-making
Champ in-the-making
Error is due to an improper access to nativevalue property of a null object.

Since in script children.post.atom.js check is correct
    var objectId = (objectIdProp !== null) ? objectIdProp.nativeValue : null;

error comes out while using modify.lib.js i modified in some rows enforcing null check

row 12
    var typeId = ((object !== null) && (object.objectTypeId !== null)) ? object.objectTypeId.nativeValue : null;
and again in the same file

//
// Create Alfresco Association from Atom Entry
//
// @param source  source node
// @param entry  atom entry
// @return  created association (or null, in case of error)
//
function createAssociation(source, entry)
{
    var object = entry.getExtension(atom.names.cmisra_object);
    var typeId = ((object !== null) && (object.objectTypeId != null)) ? object.objectTypeId.nativeValue : null;

    // locate relationship type definition
    // TODO: check this against spec - default to Relationship, if not specified
    var type = cmis.queryType(typeId === null ? RELATIONSHIP_TYPE_ID.id : typeId);
    if (type === null)
    {
        status.setCode(400, "CMIS object type " + typeId + " not understood");
        return null;
    }
    if (type.typeId.baseTypeId != RELATIONSHIP_TYPE_ID)
    {
        status.setCode(400, "CMIS object type " + typeId + " is not a relationship type");
        return null;
    }
    if (!type.creatable)
    {
        status.setCode(400, "Relationship type " + typeId + " is not creatable");
        return null;
    }

    // locate target
    var targetId = ((object !== null) && (object.targetId !== null)) ? object.targetId.nativeValue : null;

That solved for me creating new node.

iblanco
Confirmed Champ
Confirmed Champ
That works around the problem, but it forces to create always regular cmis:content, it avoids the creation of custom type content.
AFAIK objectTypeId is a mandatory element for a CMIS content creation POST, so it should exist and be set. But checking it with the debugger it seems like it is not set at all. So the real problem starts before this.

I think that the responsible of setting those values is the Abdera CMIS Extension. Might it be a bug there ?

I posted and issue for this.

iblanco
Confirmed Champ
Confirmed Champ
ARGHGHGHGHGHG!!! After getting mad for over 2 days I managed to make it work.

All the problem was related to a #@1"·ng namespace that I was writing wrong. I copied the XML from Jeff Potts CMIS tutorial and it has an errata in page 25 when referring to the CMIS namespace, a ending / is missing.

jayjayecl
Confirmed Champ
Confirmed Champ
ARGHGHGHGHGHG!!! After getting mad for over 2 days I managed to make it work.

All the problem was related to a #@1"·ng namespace that I was writing wrong. I copied the XML from Jeff Potts CMIS tutorial and it has an errata in page 25 when referring to the CMIS namespace, a ending / is missing.


Thank you very much, you saved me a couple of days hardworking.
Nice sharing this Smiley Happy