Hey Remy,
The reason the File create failed is because further up in my code an
Exception was being thrown and that caused a nat.rollback() to occur. Hence
the bug. When the rollback() is call the corresponding records are removed
from the JDBCDescriptorStore but the File is not removed from the
FileContentStore. Shouldn't the call to nat.rollback() also remove any
related content from the FileContentStore?
Thanks in advance,
Matt
----- Original Message -----
From: "Matthew Stone" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, August 02, 2001 11:54 AM
Subject: NodeRevisionContent creating files (Sorry for the HTML text
posting)
> 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;
> }
>