cancel
Showing results for 
Search instead for 
Did you mean: 

Mimetype and ContentFormat

cburghardt
Champ in-the-making
Champ in-the-making
Hi,

I'm a little bit confused. I create new content with the webservice so I call ContentService.create() which takes a ContentFormat. This one is constructed with a mimetype and encoding. But how do I add a new mimetype (like rfc/822)? I found the tutorial to create a new content type but how is this linked to the mimetype? I want to create a new content with the mentioned mimetype (which is not available in alfresco yet) and I need to add some properties to the content (which is probably done with the content type). Can somebody please enlighten me how this is supposed to work?

Thanks a bunch!

Carsten
12 REPLIES 12

cburghardt
Champ in-the-making
Champ in-the-making
UpdateResult[] result = repositoryService.update(cml);
            contentService.write(result[0].getDestination(), bytes);

I can't find the error - it seems to be a bug in the webservice. Is there any working example for this?

rwetherall
Confirmed Champ
Confirmed Champ
Hi,

First appoligies for the delay in responce, I must have missed you previous post.

From the infor you've provided it looks like the problem is that the mime-type for the content you are writting is not set.

Unfortunatly at this point we have noticed a problem with the API.  create() allows a ContentFormat object to be passed which sets the mime type, write() does not.  I will add a JIRA task for this and try and fix this up ASAP.

In the mean time there may be a work around.  When creating the node you need to set a preliminary value on the content attribute, the code should look something like this ….



String mimeType = MimetypeMap.MIMETYPE_HTML;
NamedValue[] values = new NamedValue[]{new NamedValue(ContentModel.PROP_CONTENT.toString(), "contentUrl=|mimetype=" + mimeType + "|size=|encoding=UTF-8")};
CMLCreate create = new CMLCreate("id1", parentReference, <your content type, values); 

UpdateResult[] result = repositoryService.update(cml);
contentService.write(result[0].getDestination(), bytes);

I've performed a quick test and it seams to work so it should get you going in the short term. 

Hope this helps,
Roy

cburghardt
Champ in-the-making
Champ in-the-making
That seems to work so now I have to program a query via webservice so I can actually check if the properties have been set correctly as the webinterface does not display them
The NamedValue only accepts strings so I wonder how to set date attributes because I have defined one in my model. Any hints on that?

Update: there is something strange going on. I can retrieve my content including all properties (except the date ;-)), so that's fine.
But I have problems with the search:
- I can search for complete words in the properties, e.g. @{ns}subject: "Test1"
- searching with wildcards does not work, e.g. I find a document with the subject "Test1" but a search with "Test*" returns nothing
- searches for TEXT return no results, no matter what I search