Fix AWC-999: Content encoding is displayed and is settable in the UI.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6120 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2007-06-27 13:32:42 +00:00
parent a45351ff3d
commit f6c4af6d9b
7 changed files with 63 additions and 3 deletions

View File

@@ -1044,6 +1044,13 @@ public class BrowseBean implements IContextListener
}
};
public NodePropertyResolver resolverEncoding = new NodePropertyResolver() {
public Object get(Node node) {
ContentData content = (ContentData)node.getProperties().get(ContentModel.PROP_CONTENT);
return (content != null ? content.getEncoding() : null);
}
};
public NodePropertyResolver resolverSize = new NodePropertyResolver() {
public Object get(Node node) {
ContentData content = (ContentData)node.getProperties().get(ContentModel.PROP_CONTENT);
@@ -1397,6 +1404,7 @@ public class BrowseBean implements IContextListener
}
node.addPropertyResolver("fileType32", this.resolverFileType32);
node.addPropertyResolver("mimetype", this.resolverMimetype);
node.addPropertyResolver("encoding", this.resolverEncoding);
node.addPropertyResolver("size", this.resolverSize);
node.addPropertyResolver("lang", this.resolverLang);

View File

@@ -70,6 +70,7 @@ import org.alfresco.web.ui.common.Utils;
public class DocumentPropertiesBean
{
private static final String TEMP_PROP_MIMETYPE = "mimetype";
private static final String TEMP_PROP_ENCODING = "encoding";
protected NodeService nodeService;
protected FileFolderService fileFolderService;
@@ -105,6 +106,7 @@ public class DocumentPropertiesBean
if (content != null)
{
this.editableNode.getProperties().put(TEMP_PROP_MIMETYPE, content.getMimetype());
this.editableNode.getProperties().put(TEMP_PROP_ENCODING, content.getEncoding());
}
this.hasOtherProperties = null;
@@ -140,7 +142,7 @@ public class DocumentPropertiesBean
// we need to put all the properties from the editable bag back into
// the format expected by the repository
// but first extract and deal with the special mimetype property for ContentData
// Deal with the special mimetype property for ContentData
String mimetype = (String)props.get(TEMP_PROP_MIMETYPE);
if (mimetype != null)
{
@@ -154,6 +156,20 @@ public class DocumentPropertiesBean
}
}
// Deal with the special encoding property for ContentData
String encoding = (String) props.get(TEMP_PROP_ENCODING);
if (encoding != null)
{
// remove temporary prop from list so it isn't saved with the others
props.remove(TEMP_PROP_ENCODING);
ContentData contentData = (ContentData)props.get(ContentModel.PROP_CONTENT);
if (contentData != null)
{
contentData = ContentData.setEncoding(contentData, encoding);
props.put(ContentModel.PROP_CONTENT.toString(), contentData);
}
}
// extra and deal with the Author prop if the aspect has not been applied yet
String author = (String)props.get(ContentModel.PROP_AUTHOR);
if (author != null && author.length() != 0)

View File

@@ -54,6 +54,7 @@ import org.alfresco.web.bean.repository.Repository;
public class EditContentPropertiesDialog extends BaseDialogBean
{
protected static final String TEMP_PROP_MIMETYPE = "mimetype";
protected static final String TEMP_PROP_ENCODING = "encoding";
protected Node editableNode;
@@ -75,6 +76,7 @@ public class EditContentPropertiesDialog extends BaseDialogBean
if (content != null)
{
this.editableNode.getProperties().put(TEMP_PROP_MIMETYPE, content.getMimetype());
this.editableNode.getProperties().put(TEMP_PROP_ENCODING, content.getEncoding());
}
}
@@ -104,8 +106,8 @@ public class EditContentPropertiesDialog extends BaseDialogBean
// the format expected by the repository
Map<QName, Serializable> repoProps = this.nodeService.getProperties(nodeRef);
// but first extract and deal with the special mimetype property for ContentData
String mimetype = (String)editedProps.get(TEMP_PROP_MIMETYPE);
// Extract and deal with the special mimetype property for ContentData
String mimetype = (String) editedProps.get(TEMP_PROP_MIMETYPE);
if (mimetype != null)
{
// remove temporary prop from list so it isn't saved with the others
@@ -117,6 +119,19 @@ public class EditContentPropertiesDialog extends BaseDialogBean
editedProps.put(ContentModel.PROP_CONTENT.toString(), contentData);
}
}
// Extract and deal with the special encoding property for ContentData
String encoding = (String) editedProps.get(TEMP_PROP_ENCODING);
if (encoding != null)
{
// remove temporary prop from list so it isn't saved with the others
editedProps.remove(TEMP_PROP_ENCODING);
ContentData contentData = (ContentData) editedProps.get(ContentModel.PROP_CONTENT);
if (contentData != null)
{
contentData = ContentData.setEncoding(contentData, encoding);
editedProps.put(ContentModel.PROP_CONTENT.toString(), contentData);
}
}
// add the "author" aspect if required, properties will get set below
if (this.nodeService.hasAspect(nodeRef, ContentModel.ASPECT_AUTHOR) == false)

View File

@@ -42,6 +42,7 @@ import org.alfresco.web.bean.repository.Node;
public class ViewContentPropertiesDialog extends BaseDialogBean
{
protected static final String TEMP_PROP_MIMETYPE = "mimetype";
protected static final String TEMP_PROP_ENCODING = "encoding";
protected Node viewingNode;
@@ -63,6 +64,7 @@ public class ViewContentPropertiesDialog extends BaseDialogBean
if (content != null)
{
this.viewingNode.getProperties().put(TEMP_PROP_MIMETYPE, content.getMimetype());
this.viewingNode.getProperties().put(TEMP_PROP_ENCODING, content.getEncoding());
}
// add the specially handled 'size' property