From 0dc8a68d44561d06b060933356013fdf54cce5d4 Mon Sep 17 00:00:00 2001 From: Kevin Roast Date: Mon, 2 Oct 2006 10:14:45 +0000 Subject: [PATCH] . Edit Folder Properties dialog . Edit file/folder properties now shows name+title+description as expected . Addition of TITLED and UIFACETS aspects to files and folders during import/create git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3987 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- config/alfresco/messages/webclient.properties | 1 + config/alfresco/web-client-config-dialogs.xml | 6 +- .../content/EditContentPropertiesDialog.java | 3 + .../web/bean/spaces/EditSpaceDialog.java | 12 ++- .../web/bean/wcm/AddAvmContentDialog.java | 5 -- .../web/bean/wcm/CreateFolderDialog.java | 4 +- .../web/bean/wcm/CreateWebContentWizard.java | 12 +++ .../bean/wcm/EditFilePropertiesDialog.java | 2 + .../bean/wcm/EditFolderPropertiesDialog.java | 81 +++++++++++++++++++ .../web/bean/wcm/ImportWebsiteDialog.java | 36 +++++++-- source/web/WEB-INF/faces-config-beans.xml | 29 +++++++ source/web/jsp/wcm/edit-folder-properties.jsp | 29 +++++++ source/web/jsp/wcm/folder-details.jsp | 2 +- 13 files changed, 204 insertions(+), 18 deletions(-) create mode 100644 source/java/org/alfresco/web/bean/wcm/EditFolderPropertiesDialog.java create mode 100644 source/web/jsp/wcm/edit-folder-properties.jsp diff --git a/config/alfresco/messages/webclient.properties b/config/alfresco/messages/webclient.properties index 8d08fe73b7..8b19d39722 100644 --- a/config/alfresco/messages/webclient.properties +++ b/config/alfresco/messages/webclient.properties @@ -854,6 +854,7 @@ edit_file_properties=Edit File Properties edit_file_description=Edit the properties of the file then click OK. edit_folder_properties=Edit Folder Properties edit_folder_description=Edit the properties of the folder then click OK. +folder_props=Folder Properties # New User Wizard messages new_user_title=New User Wizard diff --git a/config/alfresco/web-client-config-dialogs.xml b/config/alfresco/web-client-config-dialogs.xml index 6295360e14..42e719d313 100644 --- a/config/alfresco/web-client-config-dialogs.xml +++ b/config/alfresco/web-client-config-dialogs.xml @@ -132,7 +132,11 @@ + title-id="edit_file_properties" description-id="edit_file_description" /> + + diff --git a/source/java/org/alfresco/web/bean/content/EditContentPropertiesDialog.java b/source/java/org/alfresco/web/bean/content/EditContentPropertiesDialog.java index da7980131c..1d9f54b31a 100644 --- a/source/java/org/alfresco/web/bean/content/EditContentPropertiesDialog.java +++ b/source/java/org/alfresco/web/bean/content/EditContentPropertiesDialog.java @@ -54,6 +54,9 @@ public class EditContentPropertiesDialog extends BaseDialogBean } } + /** + * Init the editable Node + */ protected Node initEditableNode() { return new Node(this.browseBean.getDocument().getNodeRef()); diff --git a/source/java/org/alfresco/web/bean/spaces/EditSpaceDialog.java b/source/java/org/alfresco/web/bean/spaces/EditSpaceDialog.java index d95da6cffb..f33bc8c37e 100644 --- a/source/java/org/alfresco/web/bean/spaces/EditSpaceDialog.java +++ b/source/java/org/alfresco/web/bean/spaces/EditSpaceDialog.java @@ -31,10 +31,18 @@ public class EditSpaceDialog extends CreateSpaceDialog super.init(parameters); // setup the space being edited - this.editableNode = new Node(this.browseBean.getActionSpace().getNodeRef()); + this.editableNode = initEditableNode(); this.spaceType = this.editableNode.getType().toString(); } + /** + * Init the editable Node + */ + protected Node initEditableNode() + { + return new Node(this.browseBean.getActionSpace().getNodeRef()); + } + @Override public String getFinishButtonLabel() { @@ -61,7 +69,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.browseBean.getActionSpace().getNodeRef(); + NodeRef nodeRef = this.editableNode.getNodeRef(); Map editedProps = this.editableNode.getProperties(); // handle the name property separately, perform a rename in case it changed diff --git a/source/java/org/alfresco/web/bean/wcm/AddAvmContentDialog.java b/source/java/org/alfresco/web/bean/wcm/AddAvmContentDialog.java index d51a0b4fa9..44149cb335 100644 --- a/source/java/org/alfresco/web/bean/wcm/AddAvmContentDialog.java +++ b/source/java/org/alfresco/web/bean/wcm/AddAvmContentDialog.java @@ -81,11 +81,6 @@ public class AddAvmContentDialog extends AddContentDialog if (logger.isDebugEnabled()) logger.debug("Created AVM file: " + path); - // set the author aspect - Map authorProps = new HashMap(1, 1.0f); - authorProps.put(ContentModel.PROP_AUTHOR, this.author); - this.nodeService.addAspect(fileNodeRef, ContentModel.ASPECT_AUTHOR, authorProps); - // apply the titled aspect - title and description Map titledProps = new HashMap(2, 1.0f); titledProps.put(ContentModel.PROP_TITLE, this.title); diff --git a/source/java/org/alfresco/web/bean/wcm/CreateFolderDialog.java b/source/java/org/alfresco/web/bean/wcm/CreateFolderDialog.java index 43b83ad751..884abf7322 100644 --- a/source/java/org/alfresco/web/bean/wcm/CreateFolderDialog.java +++ b/source/java/org/alfresco/web/bean/wcm/CreateFolderDialog.java @@ -125,10 +125,12 @@ public class CreateFolderDialog extends BaseDialogBean { String parent = this.avmBrowseBean.getCurrentPath(); this.avmService.createDirectory(parent, this.name); + String path = parent + '/' + this.name; + NodeRef nodeRef = AVMNodeConverter.ToNodeRef(-1, path); + this.nodeService.addAspect(nodeRef, ContentModel.ASPECT_UIFACETS, null); if (this.description != null && this.description.length() != 0) { - NodeRef nodeRef = AVMNodeConverter.ToNodeRef(-1, path); this.nodeService.setProperty(nodeRef, ContentModel.PROP_DESCRIPTION, this.description); } diff --git a/source/java/org/alfresco/web/bean/wcm/CreateWebContentWizard.java b/source/java/org/alfresco/web/bean/wcm/CreateWebContentWizard.java index a108915f04..c7dfbfd6f2 100644 --- a/source/java/org/alfresco/web/bean/wcm/CreateWebContentWizard.java +++ b/source/java/org/alfresco/web/bean/wcm/CreateWebContentWizard.java @@ -20,8 +20,10 @@ import java.io.BufferedInputStream; import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileInputStream; +import java.io.Serializable; import java.util.ArrayList; import java.util.Collection; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.ResourceBundle; @@ -33,9 +35,12 @@ import javax.faces.model.SelectItem; import org.alfresco.config.Config; import org.alfresco.config.ConfigElement; import org.alfresco.config.ConfigService; +import org.alfresco.model.ContentModel; import org.alfresco.repo.avm.AVMNodeConverter; import org.alfresco.repo.content.MimetypeMap; import org.alfresco.service.cmr.avm.AVMService; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.namespace.QName; import org.alfresco.web.app.Application; import org.alfresco.web.bean.content.BaseContentWizard; import org.alfresco.web.data.IDataContainer; @@ -81,6 +86,7 @@ public class CreateWebContentWizard extends BaseContentWizard this.avmBrowseBean = avmBrowseBean; } + // ------------------------------------------------------------------------------ // Wizard implementation @@ -140,6 +146,12 @@ public class CreateWebContentWizard extends BaseContentWizard // remember the created path this.createdPath = path + '/' + this.fileName; + + // add titled aspect for the read/edit properties screens + NodeRef fileRef = AVMNodeConverter.ToNodeRef(-1, this.createdPath); + Map titledProps = new HashMap(1, 1.0f); + titledProps.put(ContentModel.PROP_TITLE, this.fileName); + this.nodeService.addAspect(fileRef, ContentModel.ASPECT_TITLED, titledProps); } @Override diff --git a/source/java/org/alfresco/web/bean/wcm/EditFilePropertiesDialog.java b/source/java/org/alfresco/web/bean/wcm/EditFilePropertiesDialog.java index bf834f2614..206296ddcc 100644 --- a/source/java/org/alfresco/web/bean/wcm/EditFilePropertiesDialog.java +++ b/source/java/org/alfresco/web/bean/wcm/EditFilePropertiesDialog.java @@ -28,6 +28,8 @@ import org.alfresco.web.bean.repository.Node; import org.alfresco.web.bean.repository.Repository; /** + * Backing bean for the Edit File Properties dialog. + * * @author Kevin Roast */ public class EditFilePropertiesDialog extends EditContentPropertiesDialog diff --git a/source/java/org/alfresco/web/bean/wcm/EditFolderPropertiesDialog.java b/source/java/org/alfresco/web/bean/wcm/EditFolderPropertiesDialog.java new file mode 100644 index 0000000000..6c8fff270e --- /dev/null +++ b/source/java/org/alfresco/web/bean/wcm/EditFolderPropertiesDialog.java @@ -0,0 +1,81 @@ +/* + * 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.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +import javax.faces.context.FacesContext; + +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; + + + // ------------------------------------------------------------------------------ + // Bean property getters and setters + + /** + * @param avmBrowseBean The AVMBrowseBean to set. + */ + public void setAvmBrowseBean(AVMBrowseBean avmBrowseBean) + { + this.avmBrowseBean = avmBrowseBean; + } + + + // ------------------------------------------------------------------------------ + // Dialog implementation + + /** + * @see org.alfresco.web.bean.spaces.EditSpaceDialog#initEditableNode() + */ + @Override + protected Node initEditableNode() + { + return new Node(this.avmBrowseBean.getAvmNode().getNodeRef()); + } + + @Override + protected String doPostCommitProcessing(FacesContext context, String outcome) + { + return outcome; + } + + public List getIcons() + { + List icons = new ArrayList(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; + } +} diff --git a/source/java/org/alfresco/web/bean/wcm/ImportWebsiteDialog.java b/source/java/org/alfresco/web/bean/wcm/ImportWebsiteDialog.java index 4251ad3323..1ed7939f54 100644 --- a/source/java/org/alfresco/web/bean/wcm/ImportWebsiteDialog.java +++ b/source/java/org/alfresco/web/bean/wcm/ImportWebsiteDialog.java @@ -82,6 +82,7 @@ public class ImportWebsiteDialog protected ContentService contentService; protected NavigationBean navigationBean; protected AVMService avmService; + protected NodeService nodeService; /** @@ -115,6 +116,14 @@ public class ImportWebsiteDialog { this.avmService = avmService; } + + /** + * @param nodeService The NodeService to set. + */ + public void setNodeService(NodeService nodeService) + { + this.nodeService = nodeService; + } /** * @return Returns the name of the file @@ -396,17 +405,22 @@ public class ImportWebsiteDialog if (file.isFile()) { String avmPath = AVMNodeConverter.ToAVMVersionPath(root).getSecond(); - avmService.createFile(avmPath, file.getName(), new BufferedInputStream(new FileInputStream(file), BUFFER_SIZE)); + String fileName = file.getName(); + this.avmService.createFile( + avmPath, fileName,new BufferedInputStream(new FileInputStream(file), BUFFER_SIZE)); + + String filePath = avmPath + '/' + fileName; + NodeRef fileRef = AVMNodeConverter.ToNodeRef(-1, filePath); + + // add titled aspect for the read/edit properties screens + Map titledProps = new HashMap(1, 1.0f); + titledProps.put(ContentModel.PROP_TITLE, fileName); + this.nodeService.addAspect(fileRef, ContentModel.ASPECT_TITLED, titledProps); + // create content node based on the filename /*FileInfo contentFile = fileFolderService.create(root, fileName, ContentModel.TYPE_AVM_PLAIN_CONTENT); NodeRef content = contentFile.getNodeRef(); - // add titled aspect (for Web Client display) - //Map titledProps = new HashMap(); - //titledProps.put(ContentModel.PROP_TITLE, fileName); - //titledProps.put(ContentModel.PROP_DESCRIPTION, fileName); - //nodeService.addAspect(content, ContentModel.ASPECT_TITLED, titledProps); - InputStream contentStream = new BufferedInputStream(new FileInputStream(file), BUFFER_SIZE); ContentWriter writer = contentService.getWriter(content, ContentModel.PROP_CONTENT, true); @@ -418,10 +432,16 @@ public class ImportWebsiteDialog else { //FileInfo fileInfo = fileFolderService.create(root, file.getName(), ContentModel.TYPE_AVM_PLAIN_FOLDER); + String avmPath = AVMNodeConverter.ToAVMVersionPath(root).getSecond(); avmService.createDirectory(avmPath, file.getName()); - importDirectory(file.getPath(), AVMNodeConverter.ToNodeRef(-1, avmPath + '/' + file.getName()));//fileInfo.getNodeRef() + String folderPath = avmPath + '/' + file.getName(); + NodeRef folderRef = AVMNodeConverter.ToNodeRef(-1, folderPath); + importDirectory(file.getPath(), folderRef); + + // add the uifacets aspect for the read/edit properties screens + this.nodeService.addAspect(folderRef, ContentModel.ASPECT_UIFACETS, null); } } catch (FileNotFoundException e) diff --git a/source/web/WEB-INF/faces-config-beans.xml b/source/web/WEB-INF/faces-config-beans.xml index 39b0a9e9eb..c045103e0c 100644 --- a/source/web/WEB-INF/faces-config-beans.xml +++ b/source/web/WEB-INF/faces-config-beans.xml @@ -615,6 +615,10 @@ ImportWebsiteDialog org.alfresco.web.bean.wcm.ImportWebsiteDialog session + + nodeService + #{NodeService} + fileFolderService #{FileFolderService} @@ -879,6 +883,31 @@ + + + The bean that backs up the Edit AVM Folder Properties Dialog + + EditFolderPropertiesDialog + org.alfresco.web.bean.wcm.EditFolderPropertiesDialog + session + + nodeService + #{NodeService} + + + fileFolderService + #{FileFolderService} + + + dictionaryService + #{DictionaryService} + + + avmBrowseBean + #{AVMBrowseBean} + + + The bean that backs up the Set Content Properties Dialog diff --git a/source/web/jsp/wcm/edit-folder-properties.jsp b/source/web/jsp/wcm/edit-folder-properties.jsp new file mode 100644 index 0000000000..4211f4de14 --- /dev/null +++ b/source/web/jsp/wcm/edit-folder-properties.jsp @@ -0,0 +1,29 @@ +<%-- + 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. +--%> +<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> +<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> +<%@ taglib uri="/WEB-INF/alfresco.tld" prefix="a" %> +<%@ taglib uri="/WEB-INF/repo.tld" prefix="r" %> + + + + + + diff --git a/source/web/jsp/wcm/folder-details.jsp b/source/web/jsp/wcm/folder-details.jsp index ff2306fba3..3d656c7e1a 100644 --- a/source/web/jsp/wcm/folder-details.jsp +++ b/source/web/jsp/wcm/folder-details.jsp @@ -126,7 +126,7 @@ <%----%> - + <%----%>