Files
alfresco-community-repo/source/java/org/alfresco/web/bean/wcm/EditFolderPropertiesDialog.java
Dave Ward 07227a5487 Merged V4.0-BUG-FIX to HEAD
35394: ALF-13394: Allow administrators to gain SiteManager role
   35407: ALF-12740: Updated XHR request processing for IE to ensure no caching (had previously thought IE9 was not affected but apparently it is)
   35408: Fix for ALF-13286 who_can_create_site mention and bad error message
   - explicitly declare public interface on SiteService
   35412: Merged DEV to V4.0-BUG-FIX
      35153: ALF-1834: Renaming folders breaks web form content
             Original solution by Ivan has been reimplemented as per Derek's requirements and against 4.0. 
             [DH: Did some minor legibility changes and fixed LF for AVMDiskDriver]
   35414: Incremented version.revision for 4.0.2
   35417: Merged BRANCHES/DEV/THOR0 to BRANCHES/DEV/V4.0-BUG-FIX: (THOR-6 / ALF-13755)
      29356: THOR-6: MT is configured (but not enabled) by default - will be auto-enabled when first tenant is created
      29455: THOR-6: build test/fix
      29471: THOR-6: build test/fix
   35423: Merged BRANCHES/DEV/THOR0 to BRANCHES/DEV/V4.0-BUG-FIX: (THOR-4 / ALF-13756)
      29500: THOR-4: Replace Tenant attributes with Tenant table (alf_tenant)
      29501: THOR-4: Replace Tenant attributes with Tenant table (alf_tenant)
      29503: THOR-4: Replace Tenant attributes with Tenant table (alf_tenant)
      TODO: ALF-13757 - patch to migrate Tenant attributes to Tenant table (for existing customers)
   35431: Merged V3.4-BUG-FIX to V4.0-BUG-FIX
      35367: ALF-13382: WorkflowService Returning Incorrect Values When Using Native jBPM API to set Local Task Variables
      - Fix by Alex Bykov
      35400: Fix for ALF-13557 - Share forms selectmany.ftl template does not work with Share search query parser; should do a logical OR or AND but does a concatenation
      35416: Incremented version.revision for 3.4.10
      35429: Merged V4.0-BUG-FIX to V3.4-BUG-FIX (partial)
         35328: ALF-13409: Avoid concurrency issues in unit test tear downs by deleting users before sites. User deletion deletes invitations synchronously. Site deletion deletes invitations concurrently to avoid UI timeouts. The potential to access invitations that are being concurrently deleted still exists, but always did!
      35430: ALF-13409: Avoid concurrency issues in unit test tear downs by deleting users before sites - another instance.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@35434 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
2012-04-19 15:43:03 +00:00

216 lines
7.7 KiB
Java

/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.web.bean.wcm;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.faces.context.FacesContext;
import org.alfresco.model.ApplicationModel;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.repo.avm.LayeredFolderType;
import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
import org.alfresco.web.app.servlet.FacesHelper;
import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.repository.Repository;
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
{
private static final long serialVersionUID = -6423913727249054187L;
protected AVMBrowseBean avmBrowseBean;
transient private 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;
}
protected AVMService getAvmService()
{
if (avmService == null)
{
avmService = (AVMService) FacesHelper.getManagedBean(FacesContext.getCurrentInstance(), "AVMLockingAwareService");
}
return 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.getNodeService().getProperties(nodeRef);
// add the "uifacets" aspect if required, properties will get set below
if (this.getNodeService().hasAspect(nodeRef, ApplicationModel.ASPECT_UIFACETS) == false)
{
this.getNodeService().addAspect(nodeRef, ApplicationModel.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.getDictionaryService().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);
}
// Translate to what AVMService wants to take.
DictionaryService dd = Repository.getServiceRegistry(context).getDictionaryService();
Map<QName, PropertyValue> avmProps = new HashMap<QName, PropertyValue>();
for (Map.Entry<QName, Serializable> entry : repoProps.entrySet())
{
PropertyDefinition propDef = dd.getProperty(entry.getKey());
if (propDef != null)
{
avmProps.put(entry.getKey(), new PropertyValue(propDef.getDataType().getName(), entry.getValue()));
}
}
// send the properties back to the repository
this.getAvmService().setNodeProperties(AVMNodeConverter.ToAVMVersionPath(nodeRef).getSecond(), avmProps);
// perform the rename last as for an AVM it changes the NodeRef
if (name != null)
{
// OnMoveNodePolicy behavior differs for Web-Client and external calls (FTP, CIFS)
// Flag is set for the current thread
Boolean wasIssuedByWebClient = LayeredFolderType.isIssuedByWebClient();
try
{
LayeredFolderType.setIssuedByWebClient(true);
this.getFileFolderService().rename(nodeRef, name);
editedProps.put(ContentModel.PROP_NAME.toString(), name);
}
finally
{
LayeredFolderType.setIssuedByWebClient(wasIssuedByWebClient);
}
}
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.getAvmService().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.setImage("/images/icons/" + DEFAULT_SPACE_ICON_NAME + ".gif");
icons.add(item);
return icons;
}
}