mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Another merge. I was bored.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@2923 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -2,7 +2,6 @@ package org.alfresco.web.bean.content;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -60,66 +59,54 @@ public class EditContentPropertiesDialog extends BaseDialogBean
|
||||
throws Exception
|
||||
{
|
||||
NodeRef nodeRef = this.browseBean.getDocument().getNodeRef();
|
||||
Map<String, Object> props = this.editableNode.getProperties();
|
||||
Map<String, Object> editedProps = this.editableNode.getProperties();
|
||||
|
||||
// get the name and move the node as necessary
|
||||
String name = (String) props.get(ContentModel.PROP_NAME);
|
||||
String name = (String) editedProps.get(ContentModel.PROP_NAME);
|
||||
if (name != null)
|
||||
{
|
||||
fileFolderService.rename(nodeRef, name);
|
||||
}
|
||||
|
||||
Map<QName, Serializable> properties = this.nodeService.getProperties(nodeRef);
|
||||
Map<QName, Serializable> repoProps = this.nodeService.getProperties(nodeRef);
|
||||
// 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
|
||||
String mimetype = (String)props.get(TEMP_PROP_MIMETYPE);
|
||||
String mimetype = (String)editedProps.get(TEMP_PROP_MIMETYPE);
|
||||
if (mimetype != null)
|
||||
{
|
||||
// remove temporary prop from list so it isn't saved with the others
|
||||
props.remove(TEMP_PROP_MIMETYPE);
|
||||
ContentData contentData = (ContentData)props.get(ContentModel.PROP_CONTENT);
|
||||
editedProps.remove(TEMP_PROP_MIMETYPE);
|
||||
ContentData contentData = (ContentData)editedProps.get(ContentModel.PROP_CONTENT);
|
||||
if (contentData != null)
|
||||
{
|
||||
contentData = ContentData.setMimetype(contentData, mimetype);
|
||||
props.put(ContentModel.PROP_CONTENT.toString(), contentData);
|
||||
editedProps.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)
|
||||
// add the "author" aspect if required, properties will get set below
|
||||
if (this.nodeService.hasAspect(nodeRef, ContentModel.ASPECT_AUTHOR) == false)
|
||||
{
|
||||
// add aspect if required
|
||||
if (this.nodeService.hasAspect(nodeRef, ContentModel.ASPECT_AUTHOR) == false)
|
||||
{
|
||||
Map<QName, Serializable> authorProps = new HashMap<QName, Serializable>(1, 1.0f);
|
||||
authorProps.put(ContentModel.PROP_AUTHOR, author);
|
||||
this.nodeService.addAspect(nodeRef, ContentModel.ASPECT_AUTHOR, authorProps);
|
||||
}
|
||||
// else it will get updated in the later setProperties() call
|
||||
this.nodeService.addAspect(nodeRef, ContentModel.ASPECT_AUTHOR, null);
|
||||
}
|
||||
|
||||
// deal with adding the "titled" aspect if required
|
||||
String title = (String)props.get(ContentModel.PROP_TITLE);
|
||||
String description = (String)props.get(ContentModel.PROP_DESCRIPTION);
|
||||
if (title != null || description != null)
|
||||
// add the "titled" aspect if required, properties will get set below
|
||||
if (this.nodeService.hasAspect(nodeRef, ContentModel.ASPECT_TITLED) == false)
|
||||
{
|
||||
// add the aspect to be sure it's present
|
||||
nodeService.addAspect(nodeRef, ContentModel.ASPECT_TITLED, null);
|
||||
// props will get added later in setProperties()
|
||||
}
|
||||
|
||||
// add the remaining properties
|
||||
Iterator<String> iterProps = props.keySet().iterator();
|
||||
Iterator<String> iterProps = editedProps.keySet().iterator();
|
||||
while (iterProps.hasNext())
|
||||
{
|
||||
String propName = iterProps.next();
|
||||
QName qname = QName.createQName(propName);
|
||||
|
||||
// make sure the property is represented correctly
|
||||
Serializable propValue = (Serializable)props.get(propName);
|
||||
Serializable propValue = (Serializable)editedProps.get(propName);
|
||||
|
||||
// check for empty strings when using number types, set to null in this case
|
||||
if ((propValue != null) && (propValue instanceof String) &&
|
||||
@@ -138,11 +125,11 @@ public class EditContentPropertiesDialog extends BaseDialogBean
|
||||
}
|
||||
}
|
||||
|
||||
properties.put(qname, propValue);
|
||||
repoProps.put(qname, propValue);
|
||||
}
|
||||
|
||||
// send the properties back to the repository
|
||||
this.nodeService.setProperties(this.browseBean.getDocument().getNodeRef(), properties);
|
||||
this.nodeService.setProperties(nodeRef, repoProps);
|
||||
|
||||
// we also need to persist any association changes that may have been made
|
||||
|
||||
|
@@ -28,8 +28,7 @@ public class LabelGenerator extends BaseComponentGenerator
|
||||
// add the component to the property sheet item
|
||||
item.getChildren().add(component);
|
||||
|
||||
// TODO: Turn the label red if the field is required
|
||||
// setup the 'for' attribute to associate with it the control
|
||||
// TODO: setup the 'for' attribute to associate with it the control
|
||||
|
||||
return component;
|
||||
}
|
||||
|
@@ -31,7 +31,8 @@ public class EditSpaceDialog extends CreateSpaceDialog
|
||||
super.init(parameters);
|
||||
|
||||
// setup the space being edited
|
||||
this.editableNode = this.browseBean.getActionSpace();
|
||||
this.editableNode = new Node(this.browseBean.getActionSpace().getNodeRef());
|
||||
this.spaceType = this.editableNode.getType().toString();
|
||||
this.spaceType = this.editableNode.getType().toString();
|
||||
}
|
||||
|
||||
@@ -55,7 +56,7 @@ public class EditSpaceDialog extends CreateSpaceDialog
|
||||
protected String finishImpl(FacesContext context, String outcome) throws Exception
|
||||
{
|
||||
// update the existing node in the repository
|
||||
NodeRef nodeRef = this.editableNode.getNodeRef();
|
||||
NodeRef nodeRef = this.browseBean.getActionSpace().getNodeRef();
|
||||
Map<String, Object> editedProps = this.editableNode.getProperties();
|
||||
|
||||
// handle the name property separately, perform a rename in case it changed
|
||||
@@ -68,6 +69,12 @@ public class EditSpaceDialog extends CreateSpaceDialog
|
||||
// get the current set of properties from the repository
|
||||
Map<QName, Serializable> repoProps = this.nodeService.getProperties(nodeRef);
|
||||
|
||||
// add the "uifacets" aspect if required, properties will get set below
|
||||
if (this.nodeService.hasAspect(nodeRef, ContentModel.ASPECT_UIFACETS) == false)
|
||||
{
|
||||
this.nodeService.addAspect(nodeRef, ContentModel.ASPECT_UIFACETS, null);
|
||||
}
|
||||
|
||||
// overwrite the current properties with the edited ones
|
||||
Iterator<String> iterProps = editedProps.keySet().iterator();
|
||||
while (iterProps.hasNext())
|
||||
@@ -149,7 +156,7 @@ public class EditSpaceDialog extends CreateSpaceDialog
|
||||
@Override
|
||||
protected String doPostCommitProcessing(FacesContext context, String outcome)
|
||||
{
|
||||
this.editableNode.reset();
|
||||
this.browseBean.getActionSpace().reset();
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
Reference in New Issue
Block a user