How would I change the mime-type on a piece of existing content?I have tried several methods and none seem to work. The program executes with no problem, it just doesn't do anything to the content.Method 1: Using the ContentWriterTransactionService transactionService = serviceRegistry.getTransactionService();
RetryingTransactionCallback<Object> exampleWork = new RetryingTransactionCallback<Object>()
{
public Object execute() throws Exception
{
ContentWriter content = contentService.getWriter(nodeIWantToChange, ContentModel.PROP_CONTENT, true);
content.setMimetype(MimetypeMap.MIMETYPE_HTML);
return null;
}
};
transactionService.getRetryingTransactionHelper().doInTransaction(exampleWork);
Method 2: Using the ContentReaderTransactionService transactionService = serviceRegistry.getTransactionService();
RetryingTransactionCallback<Object> exampleWork = new RetryingTransactionCallback<Object>()
{
public Object execute() throws Exception
{
ContentReader content = contentService.getReader(nodeIWantToChange, ContentModel.PROP_CONTENT);
content.setMimetype(MimetypeMap.MIMETYPE_HTML);
return null;
}
};
transactionService.getRetryingTransactionHelper().doInTransaction(exampleWork);