avmNode = AVMNodeConverter.ToAVMVersionPath(value);
+ String avmPath = avmNode.getSecond();
+ label = avmPath.substring(avmPath.indexOf(AVMConstants.DIR_ROOT)+4);
+ }
+ else
+ {
+ label = Repository.getNameForNode(service, value);
+ }
showValueInHiddenField = true;
}
@@ -392,6 +420,12 @@ public abstract class AbstractItemSelector extends UIInput
if (value != null)
{
fieldValue = encodeFieldValues(theMode, value.getId());
+
+ // setup the avmStore if the value represents an avm path
+ if (value.getStoreRef().getProtocol().equals(StoreRef.PROTOCOL_AVM))
+ {
+ this.avmStore = value.getStoreRef().getIdentifier();
+ }
}
else
{
@@ -514,10 +548,9 @@ public abstract class AbstractItemSelector extends UIInput
buf.append("/>");
// get the name for the child and output as link
- NodeRef childNodeRef = new NodeRef(Repository.getStoreRef(), childId);
- String name = Repository.getNameForNode(service, childNodeRef);
+ String name = Repository.getNameForNode(service, childRef);
String prefixHtml = null;
- String icon = getItemIcon(context, childNodeRef);
+ String icon = getItemIcon(context, childRef);
if (icon != null)
{
prefixHtml = "" +
@@ -801,6 +834,7 @@ public abstract class AbstractItemSelector extends UIInput
/**
* Class representing the clicking of a breadcrumb element.
*/
+ @SuppressWarnings("serial")
public static class ItemSelectorEvent extends ActionEvent
{
public ItemSelectorEvent(UIComponent component, int mode, String id)
diff --git a/source/java/org/alfresco/web/ui/repo/component/UIWebProjectFolderSelector.java b/source/java/org/alfresco/web/ui/repo/component/UIWebProjectFolderSelector.java
new file mode 100644
index 0000000000..23847faab3
--- /dev/null
+++ b/source/java/org/alfresco/web/ui/repo/component/UIWebProjectFolderSelector.java
@@ -0,0 +1,221 @@
+/*
+ * Copyright (C) 2005-2007 Alfresco Software Limited.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program 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 General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ * As a special exception to the terms and conditions of version 2.0 of
+ * the GPL, you may redistribute this Program in connection with Free/Libre
+ * and Open Source Software ("FLOSS") applications as described in Alfresco's
+ * FLOSS exception. You should have recieved a copy of the text describing
+ * the FLOSS exception, and it is also available here:
+ * http://www.alfresco.com/legal/licensing"
+ */
+package org.alfresco.web.ui.repo.component;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import javax.faces.context.FacesContext;
+
+import org.alfresco.config.JNDIConstants;
+import org.alfresco.model.ApplicationModel;
+import org.alfresco.repo.avm.AVMNodeConverter;
+import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
+import org.alfresco.service.cmr.avm.AVMService;
+import org.alfresco.service.cmr.avm.AVMStoreDescriptor;
+import org.alfresco.service.cmr.repository.NodeRef;
+import org.alfresco.service.cmr.search.SearchService;
+import org.alfresco.service.cmr.security.AccessStatus;
+import org.alfresco.service.cmr.security.PermissionService;
+import org.alfresco.service.namespace.NamespaceService;
+import org.alfresco.web.app.Application;
+import org.alfresco.web.bean.repository.Repository;
+import org.alfresco.web.bean.wcm.AVMConstants;
+import org.alfresco.web.bean.wcm.WebProject;
+import org.alfresco.web.ui.repo.WebResources;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Selector component for folders within a Web Project.
+ *
+ * @author gavinc
+ */
+public class UIWebProjectFolderSelector extends AbstractItemSelector
+{
+ private static final Log logger = LogFactory.getLog(UIWebProjectFolderSelector.class);
+
+ // ------------------------------------------------------------------------------
+ // Component Impl
+
+ public String getFamily()
+ {
+ return "org.alfresco.faces.WebProjectFolderSelector";
+ }
+
+ public String getDefaultLabel()
+ {
+ return Application.getMessage(FacesContext.getCurrentInstance(), "select_web_project_folder");
+ }
+
+ public String getParentNodeId(FacesContext context)
+ {
+ String id = null;
+
+ if (this.navigationId != null && this.navigationId.startsWith("-1;"))
+ {
+ String rootPath = "-1;" + JNDIConstants.DIR_DEFAULT_WWW + ";" + JNDIConstants.DIR_DEFAULT_APPBASE +
+ ";" + AVMConstants.DIR_ROOT;
+
+ if (this.navigationId.equals(rootPath) == false)
+ {
+ // remove the last part of the path
+ String parentPath = this.navigationId.substring(0,
+ this.navigationId.lastIndexOf(';'));
+
+ if (logger.isDebugEnabled())
+ logger.debug("Parent of " + this.navigationId + " is: " + parentPath);
+
+ id = parentPath;
+ }
+ }
+
+ return id;
+ }
+
+ public Collection getChildrenForNode(FacesContext context)
+ {
+ if (logger.isDebugEnabled())
+ logger.debug("Getting children for: " + this.navigationId);
+
+ List folders = new ArrayList();
+
+ if (this.navigationId.startsWith("-1;"))
+ {
+ // if we are within the web project folder structure calculate the
+ // current path and get the children
+ if (logger.isDebugEnabled())
+ logger.debug("Getting children for path: " + this.navigationId +
+ " in store: " + this.avmStore);
+
+ // remove the -1; from the beginning of the path and change ; for /
+ String translatedPath = this.navigationId.substring(3);
+ String path = translatedPath.replace(';', '/');
+
+ String avmPath = this.avmStore + ":/" + path;
+ addChildrenForPath(context, avmPath, folders);
+ }
+ else
+ {
+ // get the root children for the sandbox of the current user
+ WebProject webProject = new WebProject(new NodeRef(Repository.getStoreRef(), this.navigationId));
+ this.avmStore = AVMConstants.buildUserMainStoreName(webProject.getStoreId(),
+ Application.getCurrentUser(context).getUserName());
+
+ if (logger.isDebugEnabled())
+ logger.debug("Getting children for store: " + this.avmStore);
+
+ String rootPath = AVMConstants.buildStoreWebappPath(this.avmStore, AVMConstants.DIR_ROOT);
+
+ if (logger.isDebugEnabled())
+ logger.debug("Root path for store: "+ rootPath);
+
+ addChildrenForPath(context, rootPath, folders);
+ }
+
+ return folders;
+ }
+
+ public Collection getRootChildren(FacesContext context)
+ {
+ // query for all nodes under the "Web Projects" foler in company home.
+ FacesContext fc = FacesContext.getCurrentInstance();
+ String xpath = Application.getRootPath(fc) + "/" + Application.getWebsitesFolderName(fc) + "/*";
+ NodeRef rootNodeRef = getNodeService(fc).getRootNode(Repository.getStoreRef());
+ NamespaceService resolver = Repository.getServiceRegistry(fc).getNamespaceService();
+ SearchService searchService = Repository.getServiceRegistry(fc).getSearchService();
+ List nodes = searchService.selectNodes(rootNodeRef, xpath, null, resolver, false);
+
+ // filter the web projects i.e. only show those available to the current user
+ AVMService avmService = Repository.getServiceRegistry(context).getAVMService();
+ PermissionService permissionService = Repository.getServiceRegistry(context).getPermissionService();
+ String currentUserName = Application.getCurrentUser(context).getUserName();
+ List webProjects = new ArrayList(nodes.size());
+ for (NodeRef node : nodes)
+ {
+ // see if the user has AddChildren permission on the Web Project node
+ if (permissionService.hasPermission(node, PermissionService.ADD_CHILDREN) == AccessStatus.ALLOWED)
+ {
+ // if they have AddChildren there is probably a sandbox but check to make
+ // sure as it could have been deleted
+ WebProject webProject = new WebProject(node);
+ String storeName = AVMConstants.buildUserMainStoreName(webProject.getStoreId(),
+ currentUserName);
+ AVMStoreDescriptor storeDesc = avmService.getStore(storeName);
+ if (storeDesc != null)
+ {
+ // if we found a store (sandbox) for the user add to the list
+ webProjects.add(node);
+ }
+ }
+ }
+
+ return webProjects;
+ }
+
+ public String getItemIcon(FacesContext context, NodeRef ref)
+ {
+ String icon = (String)getNodeService(context).getProperty(ref, ApplicationModel.PROP_ICON);
+ if (icon != null)
+ {
+ icon = "/images/icons/" + icon + "-16.gif";
+ }
+ else
+ {
+ icon = WebResources.IMAGE_SPACE;
+ }
+ return icon;
+ }
+
+ /**
+ * Adds any child folders of the given path to the given list of children
+ *
+ * @param context Faces context
+ * @param path The path to get children of
+ * @param children The list of child folders
+ */
+ protected void addChildrenForPath(FacesContext context, String path, List children)
+ {
+ if (logger.isDebugEnabled())
+ logger.debug("Retrieving children for path: " + path);
+
+ // get directory listing for the given path and convert to NodeRef's
+ AVMService avmService = Repository.getServiceRegistry(context).getAVMService();
+ Map nodes = avmService.getDirectoryListing(-1, path);
+ for (String name : nodes.keySet())
+ {
+ AVMNodeDescriptor avmRef = nodes.get(name);
+ NodeRef node = AVMNodeConverter.ToNodeRef(-1, avmRef.getPath());
+
+ // only add folders
+ if (avmRef.isDirectory())
+ {
+ children.add(node);
+ }
+ }
+ }
+}
diff --git a/source/java/org/alfresco/web/ui/repo/tag/WebProjectFolderSelectorTag.java b/source/java/org/alfresco/web/ui/repo/tag/WebProjectFolderSelectorTag.java
new file mode 100644
index 0000000000..6d92ab6579
--- /dev/null
+++ b/source/java/org/alfresco/web/ui/repo/tag/WebProjectFolderSelectorTag.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2005-2007 Alfresco Software Limited.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program 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 General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ * As a special exception to the terms and conditions of version 2.0 of
+ * the GPL, you may redistribute this Program in connection with Free/Libre
+ * and Open Source Software ("FLOSS") applications as described in Alfresco's
+ * FLOSS exception. You should have recieved a copy of the text describing
+ * the FLOSS exception, and it is also available here:
+ * http://www.alfresco.com/legal/licensing"
+ */
+
+package org.alfresco.web.ui.repo.tag;
+
+/**
+ * Tag class to allow the web project folder selector to be used on a JSP
+ *
+ * @author gavinc
+ */
+public class WebProjectFolderSelectorTag extends ItemSelectorTag
+{
+ /**
+ * @see javax.faces.webapp.UIComponentTag#getComponentType()
+ */
+ public String getComponentType()
+ {
+ return "org.alfresco.faces.WebProjectFolderSelector";
+ }
+}
diff --git a/source/web/WEB-INF/faces-config-repo.xml b/source/web/WEB-INF/faces-config-repo.xml
index ac93fe09ad..564defef2a 100644
--- a/source/web/WEB-INF/faces-config-repo.xml
+++ b/source/web/WEB-INF/faces-config-repo.xml
@@ -57,6 +57,11 @@
org.alfresco.faces.ContentSelector
org.alfresco.web.ui.repo.component.UIContentSelector
+
+
+
+ org.alfresco.faces.WebProjectFolderSelector
+ org.alfresco.web.ui.repo.component.UIWebProjectFolderSelector
diff --git a/source/web/WEB-INF/repo.tld b/source/web/WEB-INF/repo.tld
index 6796c54c5c..2a1cb9e68e 100644
--- a/source/web/WEB-INF/repo.tld
+++ b/source/web/WEB-INF/repo.tld
@@ -793,6 +793,84 @@
+
+ webProjectFolderSelector
+ org.alfresco.web.ui.repo.tag.WebProjectFolderSelectorTag
+ JSP
+
+
+ id
+ false
+ true
+
+
+
+ binding
+ false
+ true
+
+
+
+ rendered
+ false
+ true
+
+
+
+ style
+ false
+ true
+
+
+
+ styleClass
+ false
+ true
+
+
+
+ nodeStyle
+ false
+ true
+
+
+
+ nodeStyleClass
+ false
+ true
+
+
+
+ value
+ false
+ true
+
+
+
+ label
+ true
+ true
+
+
+
+ spacing
+ false
+ true
+
+
+
+ initialSelection
+ false
+ true
+
+
+
+ disabled
+ false
+ true
+
+
+
categorySelector
org.alfresco.web.ui.repo.tag.CategorySelectorTag
diff --git a/source/web/jsp/actions/copy-to-web-project.jsp b/source/web/jsp/actions/copy-to-web-project.jsp
new file mode 100644
index 0000000000..7d3b912940
--- /dev/null
+++ b/source/web/jsp/actions/copy-to-web-project.jsp
@@ -0,0 +1,172 @@
+<%--
+ * Copyright (C) 2005-2007 Alfresco Software Limited.
+
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program 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 General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ * As a special exception to the terms and conditions of version 2.0 of
+ * the GPL, you may redistribute this Program in connection with Free/Libre
+ * and Open Source Software ("FLOSS") applications as described in Alfresco's
+ * FLOSS exception. You should have recieved a copy of the text describing
+ * the FLOSS exception, and it is also available here:
+ * http://www.alfresco.com/legal/licensing"
+--%>
+<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<%@ taglib uri="/WEB-INF/alfresco.tld" prefix="a" %>
+<%@ taglib uri="/WEB-INF/repo.tld" prefix="r" %>
+
+<%@ page buffer="32kb" contentType="text/html;charset=UTF-8" %>
+<%@ page isELIgnored="false" %>
+<%@ page import="org.alfresco.web.ui.common.PanelGenerator" %>
+
+
+
+
+
+ <%-- load a bundle of properties with I18N strings --%>
+
+
+
+
+ <%-- Main outer table --%>
+
+
+ <%-- Title bar --%>
+
+
+ <%@ include file="../parts/titlebar.jsp" %>
+ |
+
+
+ <%-- Main area --%>
+
+ <%-- Shelf --%>
+
+ <%@ include file="../parts/shelf.jsp" %>
+ |
+
+ <%-- Work Area --%>
+
+
+ <%-- Breadcrumb --%>
+ <%@ include file="../parts/breadcrumb.jsp" %>
+
+ <%-- Status and Actions --%>
+
+ |
+
+
+ <%-- Status and Actions inner contents table --%>
+ <%-- Generally this consists of an icon, textual summary and actions for the current object --%>
+
+
+ |
+ |
+
+
+ <%-- separator row with gradient shadow --%>
+
+ %>/images/parts/statuspanel_7.gif) |
+ |
+ %>/images/parts/statuspanel_9.gif) |
+
+
+ <%-- Details --%>
+
+ |
+
+
+
+
+
+
+
+ <% PanelGenerator.generatePanelStart(out, request.getContextPath(), "white", "white"); %>
+
+
+ |
+
+ |
+
+ : |
+
+ <%--
+
+ --%>
+
+ |
+
+ |
+
+ <% PanelGenerator.generatePanelEnd(out, request.getContextPath(), "white"); %>
+ |
+
+
+ <% PanelGenerator.generatePanelStart(out, request.getContextPath(), "greyround", "#F5F5F5"); %>
+
+ <% PanelGenerator.generatePanelEnd(out, request.getContextPath(), "greyround"); %>
+ |
+
+
+ |
+ |
+
+
+ <%-- separator row with bottom panel graphics --%>
+
+ %>/images/parts/whitepanel_7.gif) |
+ |
+ %>/images/parts/whitepanel_9.gif) |
+
+
+
+ |
+
+
+
+
+
+
+
+
\ No newline at end of file
|