cancel
Showing results for 
Search instead for 
Did you mean: 

Document Type

albertogarcía
Champ in-the-making
Champ in-the-making
Hi,

Due to problems with versions I had to downgrade my Alfresco version to 3.1.2

I was using a newer version of the product to update custom type documents with this code

        PostMethod mPost = new PostMethod(urlString);
   Part[] parts = {
           new FilePart("filedata", filename, fileobj, filetype, null),
           new StringPart("filename", filename ),
           new StringPart("contenttype", "{bol.model}boletin" ),
           //modify this according to where you wanna put your content
      new StringPart("siteid", siteid),
      new StringPart("containerid", containeridbol)
      new StringPart("uploaddirectory", uploaddirectory)
      };
   mPost.setRequestEntity(new MultipartRequestEntity(parts, mPost.getParams()));
   int statusCode1 = client.executeMethod(mPost);

I have defined the model, and I can upload documents of the model manually, but when I execute the post method, ALfresco creates a document of defautl type like this:

Name: 40.pdf
Ref: workspace://SpacesStore/4ceab9c1-d0b6-45a3-8781-45bbe3a000a7
Type: {http://www.alfresco.org/model/content/1.0}content
DBID: 1.015.861

And should create a document like this instead

Name: aaaa.pdf
Ref: workspace://SpacesStore/6d33b3a6-8f4d-40fd-b0cf-1d800a4452e5
Type: {bol.model}boletin
DBID: 1.015.855

How can I do that with Alfresco 3.1.2? I can't find the property needed to upload a document of my type bol:boletin. I have added to the code some lines, but the only thing I can change is the contenttype

new StringPart("Type", "{bol.model}boletin" ),
new StringPart("type", "{bol.model}boletin" ),
new StringPart("contenttype", "{bol.model}boletin" )

CHANGE: {http://www.alfresco.org/model/content/1.0}contentType = {bol.model}boletin

Thanks in advance,
Alberto
15 REPLIES 15

mrogers
Star Contributor
Star Contributor
You also need to change the script node or add a new root scoped object that does the equivalent of the missing method.    In general we would not expect code developed on 4.2 to work on 3.1.    Maybe the other way around, but as you can see there are many differences.


The 3.1 version method is supposed to do it, but is not working.

I found a workaround:

      var newFile = destNode.createFile(filename);
      newFile.specializeType(contentType);
      newFile.properties.contentType = contentType;
      newFile.properties.content.write(content);

I checked the lib and found the method. Thanks for everything

kaynezhang
World-Class Innovator
World-Class Innovator
Another question ,version 4.2 should be better than 3.1 ,what reason cause you to downgrade your Alfresco to 3.1.2?

I started thinking the client would update SQL and Windows Server version, but the previsions changed, so I'm installing Alfresco previously to the version update.

anujcb
Confirmed Champ
Confirmed Champ
what format is "{bol.model}boletin"   on the call new StringPart("contenttype", "{bol.model}boletin" ),?  I have a custom type rs:receiptsDoc which is a subtype of cm:doc, how do I set the content type?

is it like this

new StringPart("contenttype", "rs:receiptsDoc " ),

kaynezhang
World-Class Innovator
World-Class Innovator
Yes ,just like

new StringPart("contenttype", "rs:receiptsDoc")