. Implemented 'rename' for AVM files/folders

- this has highlighted some interesting future issues with AVM NodeRef objects - as unlike the usual noderefs, they can change due to a rename or move!
. Fixed issue with navigating back to details and browse screens after a delete file/folder operation

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@4004 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2006-10-03 11:49:37 +00:00
parent 1c6e3a68f0
commit 2d261f31f7
13 changed files with 615 additions and 427 deletions

View File

@@ -69,16 +69,17 @@ public class EditContentPropertiesDialog extends BaseDialogBean
NodeRef nodeRef = this.editableNode.getNodeRef();
Map<String, Object> editedProps = this.editableNode.getProperties();
// get the name and move the node as necessary
String name = (String) editedProps.get(ContentModel.PROP_NAME);
// we deal with 'name' as a rename/move operation later
String name = (String)editedProps.get(ContentModel.PROP_NAME);
if (name != null)
{
fileFolderService.rename(nodeRef, name);
editedProps.remove(ContentModel.PROP_NAME);
}
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
Map<QName, Serializable> repoProps = this.nodeService.getProperties(nodeRef);
repoProps.remove(ContentModel.PROP_NAME);
// but first extract and deal with the special mimetype property for ContentData
String mimetype = (String)editedProps.get(TEMP_PROP_MIMETYPE);
@@ -180,7 +181,14 @@ public class EditContentPropertiesDialog extends BaseDialogBean
this.nodeService.removeChild(assoc.getParentRef(), assoc.getChildRef());
}
}
// get the name and move the node as necessary
if (name != null)
{
this.fileFolderService.rename(nodeRef, name);
this.editableNode.getProperties().put(ContentModel.PROP_NAME.toString(), name);
}
return outcome;
}

View File

@@ -72,15 +72,16 @@ public class EditSpaceDialog extends CreateSpaceDialog
NodeRef nodeRef = this.editableNode.getNodeRef();
Map<String, Object> editedProps = this.editableNode.getProperties();
// handle the name property separately, perform a rename in case it changed
// we deal with 'name' as a rename/move operation later
String name = (String)editedProps.get(ContentModel.PROP_NAME);
if (name != null)
{
this.fileFolderService.rename(nodeRef, name);
editedProps.remove(ContentModel.PROP_NAME);
}
// get the current set of properties from the repository
Map<QName, Serializable> repoProps = this.nodeService.getProperties(nodeRef);
repoProps.remove(ContentModel.PROP_NAME);
// add the "uifacets" aspect if required, properties will get set below
if (this.nodeService.hasAspect(nodeRef, ContentModel.ASPECT_UIFACETS) == false)
@@ -162,6 +163,13 @@ public class EditSpaceDialog extends CreateSpaceDialog
this.nodeService.removeChild(assoc.getParentRef(), assoc.getChildRef());
}
}
// get the name and move the node as necessary
if (name != null)
{
this.fileFolderService.rename(nodeRef, name);
this.editableNode.getProperties().put(ContentModel.PROP_NAME.toString(), name);
}
return outcome;
}

View File

@@ -0,0 +1,34 @@
/*
* 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 javax.faces.context.FacesContext;
import org.alfresco.web.app.AlfrescoNavigationHandler;
/**
* @author Kevin Roast
*/
public class DeleteFileBrowseDialog extends DeleteFileDialog
{
@Override
protected String doPostCommitProcessing(FacesContext context, String outcome)
{
return AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME +
AlfrescoNavigationHandler.OUTCOME_SEPARATOR + "browseSandbox";
}
}

View File

@@ -8,7 +8,6 @@ import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.web.app.AlfrescoNavigationHandler;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.dialog.BaseDialogBean;
import org.alfresco.web.bean.repository.Node;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -72,9 +71,6 @@ public class DeleteFileDialog extends BaseDialogBean
@Override
protected String doPostCommitProcessing(FacesContext context, String outcome)
{
// clear action context
this.avmBrowseBean.setAvmNode(null);
return AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME;
}

View File

@@ -0,0 +1,34 @@
/*
* 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 javax.faces.context.FacesContext;
import org.alfresco.web.app.AlfrescoNavigationHandler;
/**
* @author Kevin Roast
*/
public class DeleteFolderBrowseDialog extends DeleteFolderDialog
{
@Override
protected String doPostCommitProcessing(FacesContext context, String outcome)
{
return AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME +
AlfrescoNavigationHandler.OUTCOME_SEPARATOR + "browseSandbox";
}
}

View File

@@ -8,7 +8,6 @@ import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.web.app.AlfrescoNavigationHandler;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.dialog.BaseDialogBean;
import org.alfresco.web.bean.repository.Node;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -72,9 +71,6 @@ public class DeleteFolderDialog extends BaseDialogBean
@Override
protected String doPostCommitProcessing(FacesContext context, String outcome)
{
// clear action context
this.avmBrowseBean.setAvmNode(null);
return AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME;
}

View File

@@ -20,6 +20,8 @@ import java.text.MessageFormat;
import javax.faces.context.FacesContext;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.model.FileExistsException;
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
import org.alfresco.web.app.Application;
@@ -35,6 +37,7 @@ import org.alfresco.web.bean.repository.Repository;
public class EditFilePropertiesDialog extends EditContentPropertiesDialog
{
protected AVMBrowseBean avmBrowseBean;
protected AVMService avmService;
// ------------------------------------------------------------------------------
@@ -48,6 +51,14 @@ public class EditFilePropertiesDialog extends EditContentPropertiesDialog
this.avmBrowseBean = avmBrowseBean;
}
/**
* @param avmService The AVMService to set.
*/
public void setAvmService(AVMService avmService)
{
this.avmService = avmService;
}
// ------------------------------------------------------------------------------
// Dialog implementation
@@ -64,6 +75,13 @@ public class EditFilePropertiesDialog extends EditContentPropertiesDialog
@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.setAvmNode(new AVMNode(this.avmService.lookup(-1, newPath)));
return outcome;
}

View File

@@ -23,6 +23,8 @@ import java.util.List;
import javax.faces.context.FacesContext;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.spaces.EditSpaceDialog;
import org.alfresco.web.ui.common.component.UIListItem;
@@ -35,6 +37,7 @@ import org.alfresco.web.ui.common.component.UIListItem;
public class EditFolderPropertiesDialog extends EditSpaceDialog
{
protected AVMBrowseBean avmBrowseBean;
protected AVMService avmService;
// ------------------------------------------------------------------------------
@@ -48,6 +51,14 @@ public class EditFolderPropertiesDialog extends EditSpaceDialog
this.avmBrowseBean = avmBrowseBean;
}
/**
* @param avmService The AVMService to set.
*/
public void setAvmService(AVMService avmService)
{
this.avmService = avmService;
}
// ------------------------------------------------------------------------------
// Dialog implementation
@@ -64,6 +75,13 @@ public class EditFolderPropertiesDialog extends EditSpaceDialog
@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.setAvmNode(new AVMNode(this.avmService.lookup(-1, newPath)));
return outcome;
}