Files
alfresco-community-repo/source/java/org/alfresco/web/bean/wcm/EditFolderPropertiesDialog.java
Kevin Roast 1ee6e16326 . Refactored client AVM Node class to extend existing Node class - allows the use of existing PermissionEvaluators etc. for a node action
. Permission evaluators added to AVM browse screen top-level actions and file/folder actions
. Permission evaluators added to Edit Details action in File/Folder Details screens
. Each user sandbox is now only visible to the assigned user and all Content Managers
. Import Website Content action hidden unless user has appropriate Write permissions to the main staging area (Content Managers only)
. Added Titled aspect to shtml content created through the XML Templating Service.
. Remove Create Content action from sandbox screen - makes no sense here until we can create via workflow or destination folder
. Fix nasty bug in Create Form Wizard where no default extension would be specified
  - this led to the XForms generating files such as "myfile.xml" and "myfile." - the generated HTML did not have a file extension...

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@4048 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
2006-10-06 12:53:22 +00:00

174 lines
5.9 KiB
Java

/*
* Copyright (C) 2005 Alfresco, Inc.
*
* Licensed under the Mozilla Public License version 1.1
* with a permitted attribution clause. You may obtain a
* copy of the License at
*
* http://www.alfresco.org/legal/license.txt
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the
* License.
*/
package org.alfresco.web.bean.wcm;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.faces.context.FacesContext;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.spaces.EditSpaceDialog;
import org.alfresco.web.ui.common.component.UIListItem;
/**
* Backing bean for the Edit Folder Properties dialog.
*
* @author Kevin Roast
*/
public class EditFolderPropertiesDialog extends EditSpaceDialog
{
protected AVMBrowseBean avmBrowseBean;
protected AVMService avmService;
// ------------------------------------------------------------------------------
// Bean property getters and setters
/**
* @param avmBrowseBean The AVMBrowseBean to set.
*/
public void setAvmBrowseBean(AVMBrowseBean avmBrowseBean)
{
this.avmBrowseBean = avmBrowseBean;
}
/**
* @param avmService The AVMService to set.
*/
public void setAvmService(AVMService avmService)
{
this.avmService = avmService;
}
// ------------------------------------------------------------------------------
// Dialog implementation
/**
* @see org.alfresco.web.bean.spaces.EditSpaceDialog#initEditableNode()
*/
@Override
protected Node initEditableNode()
{
return new Node(this.avmBrowseBean.getAvmActionNode().getNodeRef());
}
@Override
protected String finishImpl(FacesContext context, String outcome) throws Exception
{
// update the existing node in the repository
NodeRef nodeRef = this.editableNode.getNodeRef();
Map<String, Object> editedProps = this.editableNode.getProperties();
// handle the name property separately, it is a special case for AVM nodes
String name = (String)editedProps.get(ContentModel.PROP_NAME);
if (name != null)
{
editedProps.remove(ContentModel.PROP_NAME);
}
// 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())
{
String propName = iterProps.next();
QName qname = QName.createQName(propName);
// make sure the property is represented correctly
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) &&
(propValue.toString().length() == 0))
{
PropertyDefinition propDef = this.dictionaryService.getProperty(qname);
if (propDef != null)
{
if (propDef.getDataType().getName().equals(DataTypeDefinition.DOUBLE) ||
propDef.getDataType().getName().equals(DataTypeDefinition.FLOAT) ||
propDef.getDataType().getName().equals(DataTypeDefinition.INT) ||
propDef.getDataType().getName().equals(DataTypeDefinition.LONG))
{
propValue = null;
}
}
}
repoProps.put(qname, propValue);
}
// send the properties back to the repository
this.nodeService.setProperties(nodeRef, repoProps);
// perform the rename last as for an AVM it changes the NodeRef
if (name != null)
{
this.fileFolderService.rename(nodeRef, name);
editedProps.put(ContentModel.PROP_NAME.toString(), name);
}
return outcome;
}
@Override
protected String doPostCommitProcessing(FacesContext context, String outcome)
{
// a rename may have occured - we need to reset the NodeRef of the modified AVM Node
// as an AVM NodeRef contains the name as part of ref - which can therefore change!
String name = this.editableNode.getName();
String oldPath = AVMNodeConverter.ToAVMVersionPath(this.editableNode.getNodeRef()).getSecond();
String newPath = oldPath.substring(0, oldPath.lastIndexOf('/') + 1) + name;
this.avmBrowseBean.setAvmActionNode(new AVMNode(this.avmService.lookup(-1, newPath)));
return outcome;
}
public List<UIListItem> getIcons()
{
List<UIListItem> icons = new ArrayList<UIListItem>(1);
UIListItem item = new UIListItem();
item.setValue(DEFAULT_SPACE_ICON_NAME);
item.getAttributes().put("image", "/images/icons/" + DEFAULT_SPACE_ICON_NAME + ".gif");
icons.add(item);
return icons;
}
}