Hey Remy,
 
Help!  I'm attempting to create a file using the ContentHelper.  Below is my code.  Note that the file "IS" created in the File Store but the RevisionDescriptor properties are not stored in the database.  Also you'll probably recognize a lot of this code because I grabbed it from the PutMethod.executeRequest() method.  What am I doing wrong?  There are no Exceptions being thrown so I would expect this code to work.
 
On a side note, I have to use the following code to a get java.io.Reader to work with NodeRevisionContent because there's code missing in NodeRevisionContent.streamContent() to handle the Reader object.
 
    nrc.setContent(in);
    byte[] result = nrc.getContentBytes();
    nrc.setContent( result );
 
Thanks,
Matt
 
------------------
 
public SubjectNode createFile( SlideToken token, String locationUri,
                                String fileName, java.io.Reader in, String contentType )
    throws AccessDeniedException, ObjectNotFoundException, ServiceAccessException,
            LinkedObjectNotFoundException, ObjectLockedException, ObjectAlreadyExistsException,
            RevisionAlreadyExistException
{
 SubjectNode sn = new SubjectNode();
    m_nat.getStructureHelper().create( token, sn, objUri + "/" + objName );
 
    NodeRevisionContent nrc = new NodeRevisionContent();
    nrc.setContent(in);
    byte[] result = nrc.getContentBytes();
    nrc.setContent( result );
 
    NodeRevisionDescriptor rev = new NodeRevisionDescriptor((long)result.length);
    NodeProperty property = null;
            // Creation date
    // Resource type
    property = new NodeProperty("resourcetype", "", true);
    rev.setProperty(property);
    // Source
    property = new NodeProperty("source", "", true);
    rev.setProperty(property);
    // Get content language
    property = new NodeProperty("getcontentlanguage", "en", true);
    rev.setProperty(property);
    // Get content length
    property = new NodeProperty("getcontentlength", new Long((long)result.length), true);
    rev.setProperty(property);
    // Get content type
    if (contentType == null) {
        contentType = "text/plain";
    }
    property = new NodeProperty("getcontenttype", contentType, true);
    rev.setProperty(property);
    // Last modification date
    rev.setLastModified(new java.util.Date());
    // Etag generation
    String etag = sn.getUri().hashCode() + "_"
        + (new NodeRevisionNumber()).hashCode() + "_"
        + String.valueOf(result.length);
    property = new NodeProperty("getetag", etag, true);
    rev.setProperty(property);
 
    m_nat.getContentHelper().create(token, sn.getUri(), rev, nrc);
    return sn;
}

Reply via email to