Initial version of a "copy to web project" action

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5387 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Gavin Cornwell
2007-03-15 10:49:26 +00:00
parent 83e8cf83b8
commit 0ceb9065ea
12 changed files with 751 additions and 9 deletions

View File

@@ -87,6 +87,7 @@ select_existing_space_prompt=Click here to select an existing Space
select_home_space_prompt=Click here to select the Home Space location select_home_space_prompt=Click here to select the Home Space location
select_category_prompt=Click here to select a Category select_category_prompt=Click here to select a Category
select_destination_prompt=Click here to select the destination select_destination_prompt=Click here to select the destination
select_web_project_folder=Click here to select a Web Project folder
add_new=Add New add_new=Add New
change=Change change=Change
set=Set set=Set
@@ -775,6 +776,7 @@ action_link_category=Link to category ''{0}''
action_transform=Copies content to ''{0}'' and transforms to ''{1}'' action_transform=Copies content to ''{0}'' and transforms to ''{1}''
action_transform_image=Copies image to ''{0}'' and transforms to ''{1}'' using option ''{2}'' action_transform_image=Copies image to ''{0}'' and transforms to ''{1}'' using option ''{2}''
action_copy=Copy to ''{0}'' action_copy=Copy to ''{0}''
action_copy_to_web_project_folder=Copy to ''{0}'' in ''{1}''
action_move=Move to ''{0}'' action_move=Move to ''{0}''
action_mail=Send email to ''{0}'' action_mail=Send email to ''{0}''
action_mail_template=Use Template action_mail_template=Use Template
@@ -1361,6 +1363,7 @@ title_action_remove_feature=Remove Feature Action
title_action_checkin=Check In Action title_action_checkin=Check In Action
title_action_checkout=Check Out Action title_action_checkout=Check Out Action
title_action_copy=Copy Action title_action_copy=Copy Action
title_action_copy_to_web_project=Copy To Web Project Action
title_action_move=Move Action title_action_move=Move Action
title_action_script=Script Action title_action_script=Script Action
title_action_import=Import Action title_action_import=Import Action

View File

@@ -329,6 +329,7 @@
<handler name="check-in" class="org.alfresco.web.bean.actions.handlers.CheckInHandler" /> <handler name="check-in" class="org.alfresco.web.bean.actions.handlers.CheckInHandler" />
<handler name="check-out" class="org.alfresco.web.bean.actions.handlers.CheckOutHandler" /> <handler name="check-out" class="org.alfresco.web.bean.actions.handlers.CheckOutHandler" />
<handler name="copy" class="org.alfresco.web.bean.actions.handlers.CopyHandler" /> <handler name="copy" class="org.alfresco.web.bean.actions.handlers.CopyHandler" />
<handler name="copy-to-web-project" class="org.alfresco.web.bean.actions.handlers.CopyToWebProjectHandler" />
<handler name="import" class="org.alfresco.web.bean.actions.handlers.ImportHandler" /> <handler name="import" class="org.alfresco.web.bean.actions.handlers.ImportHandler" />
<handler name="link-category" class="org.alfresco.web.bean.actions.handlers.LinkCategoryHandler" /> <handler name="link-category" class="org.alfresco.web.bean.actions.handlers.LinkCategoryHandler" />
<handler name="mail" class="org.alfresco.web.bean.actions.handlers.MailHandler" /> <handler name="mail" class="org.alfresco.web.bean.actions.handlers.MailHandler" />

View File

@@ -111,7 +111,12 @@ public class RunActionWizard extends BaseActionWizard
this.actions = new ArrayList<SelectItem>(); this.actions = new ArrayList<SelectItem>();
for (ActionDefinition ruleActionDef : ruleActions) for (ActionDefinition ruleActionDef : ruleActions)
{ {
this.actions.add(new SelectItem(ruleActionDef.getName(), ruleActionDef.getTitle())); String title = ruleActionDef.getTitle();
if (title == null || title.length() == 0)
{
title = ruleActionDef.getName();
}
this.actions.add(new SelectItem(ruleActionDef.getName(), title));
} }
// make sure the list is sorted by the label // make sure the list is sorted by the label

View File

@@ -0,0 +1,116 @@
/*
* 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.bean.actions.handlers;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.Map;
import javax.faces.context.FacesContext;
import org.alfresco.repo.action.executer.CopyToWebProjectActionExecuter;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.util.Pair;
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.bean.wizard.IWizardBean;
/**
* Action handler implementation for the "copy-to-web-project" action.
*
* @author gavinc
*/
public class CopyToWebProjectHandler extends BaseActionHandler
{
public String getJSPPath()
{
return getJSPPath(CopyToWebProjectActionExecuter.NAME);
}
public void prepareForSave(Map<String, Serializable> actionProps,
Map<String, Serializable> repoProps)
{
// get the destination selected by the user
NodeRef destNodeRef = (NodeRef)actionProps.get(PROP_DESTINATION);
// if the destination is a workspace node the use the root of the
// webapp for the web project
if (destNodeRef.getStoreRef().getProtocol().equals(StoreRef.PROTOCOL_WORKSPACE))
{
WebProject webProject = new WebProject(destNodeRef);
String storeName = AVMConstants.buildUserMainStoreName(webProject.getStoreId(),
Application.getCurrentUser(FacesContext.getCurrentInstance()).getUserName());
String rootPath = AVMConstants.buildStoreWebappPath(storeName, AVMConstants.DIR_ROOT);
destNodeRef = AVMNodeConverter.ToNodeRef(-1, rootPath);
}
// setup the destination parameter
repoProps.put(CopyToWebProjectActionExecuter.PARAM_DESTINATION_FOLDER, destNodeRef);
}
public void prepareForEdit(Map<String, Serializable> actionProps,
Map<String, Serializable> repoProps)
{
NodeRef destNodeRef = (NodeRef)repoProps.get(CopyToWebProjectActionExecuter.PARAM_DESTINATION_FOLDER);
actionProps.put(PROP_DESTINATION, destNodeRef);
}
public String generateSummary(FacesContext context, IWizardBean wizard,
Map<String, Serializable> actionProps)
{
NodeRef dest = (NodeRef)actionProps.get(PROP_DESTINATION);
String folder = "/";
String webProject = "?";
if (dest.getStoreRef().getProtocol().equals(StoreRef.PROTOCOL_AVM))
{
// get the destination path
Pair<Integer, String> avmNode = AVMNodeConverter.ToAVMVersionPath(dest);
String avmPath = avmNode.getSecond();
folder = avmPath.substring(avmPath.indexOf(AVMConstants.DIR_ROOT)+4);
// get the destination web project name
NodeRef webProjectNode = AVMConstants.getWebProjectNode(avmPath);
webProject = Repository.getNameForNode(
Repository.getServiceRegistry(context).getNodeService(), webProjectNode);
}
else if (dest.getStoreRef().getProtocol().equals(StoreRef.PROTOCOL_AVM))
{
// get the destination web project name
webProject = Repository.getNameForNode(
Repository.getServiceRegistry(context).getNodeService(), dest);
}
return MessageFormat.format(Application.getMessage(context, "action_copy_to_web_project_folder"),
new Object[] {folder, webProject});
}
}

View File

@@ -25,6 +25,7 @@
package org.alfresco.web.bean.wcm; package org.alfresco.web.bean.wcm;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Stack; import java.util.Stack;
import java.util.regex.Matcher; import java.util.regex.Matcher;
@@ -38,6 +39,11 @@ import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.repo.domain.PropertyValue; import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.service.cmr.avm.AVMNotFoundException; import org.alfresco.service.cmr.avm.AVMNotFoundException;
import org.alfresco.service.cmr.avm.AVMService; import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.search.ResultSet;
import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.QName;
import org.alfresco.service.ServiceRegistry; import org.alfresco.service.ServiceRegistry;
import org.alfresco.util.VirtServerUtils; import org.alfresco.util.VirtServerUtils;
@@ -224,8 +230,8 @@ public final class AVMConstants
} }
/** /**
* Returns the corresponding path in the preview store name if this is a path in * Returns the corresponding path in the main store name if this is a path in
* a main store. * a preview store.
* *
* @param avmPath an avm path within the main store. * @param avmPath an avm path within the main store.
* *
@@ -625,6 +631,51 @@ public final class AVMConstants
final Matcher m = SANDBOX_RELATIVE_PATH_PATTERN.matcher(absoluteAVMPath); final Matcher m = SANDBOX_RELATIVE_PATH_PATTERN.matcher(absoluteAVMPath);
return m.matches() && m.group(1).length() != 0 ? m.group(1) : null; return m.matches() && m.group(1).length() != 0 ? m.group(1) : null;
} }
/**
* Returns the NodeRef that represents the given avm path
*
* @param absoluteAVMPath The path from which to determine the Web Project
* @return The NodeRef representing the Web Project the path is from or null
* if it could not be determined
*/
public static NodeRef getWebProjectNode(final String absoluteAVMPath)
{
// get services
FacesContext fc = FacesContext.getCurrentInstance();
SearchService searchService = Repository.getServiceRegistry(fc).getSearchService();
// get the store name
String storeName = AVMConstants.getStoreName(absoluteAVMPath);
String storeId = AVMConstants.getStoreId(storeName);
// construct the query
String path = Application.getRootPath(fc) + "/" + Application.getWebsitesFolderName(fc) + "/*";
String query = "PATH:\"/" + path + "\" AND @wca\\:avmstore:\"" + storeId + "\"";
NodeRef webProjectNode = null;
ResultSet results = null;
try
{
// execute the query
results = searchService.query(Repository.getStoreRef(),
SearchService.LANGUAGE_LUCENE, query);
if (results.length() == 1)
{
webProjectNode = results.getNodeRef(0);
}
}
finally
{
if (results != null)
{
results.close();
}
}
return webProjectNode;
}
/** /**
* Creates all directories for a path if they do not already exist. * Creates all directories for a path if they do not already exist.

View File

@@ -108,6 +108,13 @@ public class ErrorsRenderer extends BaseRenderer
renderMessageAttrs(fm, out, errorClass, infoClass); renderMessageAttrs(fm, out, errorClass, infoClass);
out.write(">"); out.write(">");
out.write(Utils.encode(fm.getSummary())); out.write(Utils.encode(fm.getSummary()));
String detail = fm.getDetail();
if (detail != null && detail.length() > 0)
{
out.write("&nbsp(");
out.write(Utils.encode(detail));
out.write(")");
}
out.write("</li>\n"); out.write("</li>\n");
} }
@@ -129,6 +136,13 @@ public class ErrorsRenderer extends BaseRenderer
renderMessageAttrs(fm, out, errorClass, infoClass); renderMessageAttrs(fm, out, errorClass, infoClass);
out.write(">"); out.write(">");
out.write(Utils.encode(fm.getSummary())); out.write(Utils.encode(fm.getSummary()));
String detail = fm.getDetail();
if (detail != null && detail.length() > 0)
{
out.write("&nbsp(");
out.write(Utils.encode(detail));
out.write(")");
}
out.write("</div>\n"); out.write("</div>\n");
} }

View File

@@ -41,11 +41,15 @@ import javax.faces.event.ActionEvent;
import javax.faces.event.FacesEvent; import javax.faces.event.FacesEvent;
import javax.transaction.UserTransaction; import javax.transaction.UserTransaction;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService; import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.util.Pair;
import org.alfresco.web.app.Application; import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Repository; import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.bean.wcm.AVMConstants;
import org.alfresco.web.ui.common.Utils; import org.alfresco.web.ui.common.Utils;
import org.alfresco.web.ui.common.WebResources; import org.alfresco.web.ui.common.WebResources;
@@ -81,6 +85,9 @@ public abstract class AbstractItemSelector extends UIInput
/** currently browsing node id */ /** currently browsing node id */
protected String navigationId = null; protected String navigationId = null;
/** current AVM store being browsed */
protected String avmStore = null;
/** id of the initially selected item, if value is not set */ /** id of the initially selected item, if value is not set */
protected String initialSelectionId = null; protected String initialSelectionId = null;
@@ -157,6 +164,7 @@ public abstract class AbstractItemSelector extends UIInput
this.navigationId = (String)values[4]; this.navigationId = (String)values[4];
this.initialSelectionId = (String)values[5]; this.initialSelectionId = (String)values[5];
this.disabled = (Boolean)values[6]; this.disabled = (Boolean)values[6];
this.avmStore = (String)values[7];
} }
/** /**
@@ -164,7 +172,7 @@ public abstract class AbstractItemSelector extends UIInput
*/ */
public Object saveState(FacesContext context) public Object saveState(FacesContext context)
{ {
Object values[] = new Object[7]; Object values[] = new Object[8];
// standard component attributes are saved by the super class // standard component attributes are saved by the super class
values[0] = super.saveState(context); values[0] = super.saveState(context);
values[1] = this.label; values[1] = this.label;
@@ -173,6 +181,7 @@ public abstract class AbstractItemSelector extends UIInput
values[4] = this.navigationId; values[4] = this.navigationId;
values[5] = this.initialSelectionId; values[5] = this.initialSelectionId;
values[6] = this.disabled; values[6] = this.disabled;
values[7] = this.avmStore;
return (values); return (values);
} }
@@ -219,7 +228,17 @@ public abstract class AbstractItemSelector extends UIInput
String selection = (String)requestMap.get(getClientId(context) + OPTION); String selection = (String)requestMap.get(getClientId(context) + OPTION);
if (selection != null && selection.length() != 0) if (selection != null && selection.length() != 0)
{ {
((EditableValueHolder)this).setSubmittedValue(new NodeRef(Repository.getStoreRef(), selection)); if (selection.startsWith("-1;"))
{
String translatedPath = selection.substring(3);
String path = translatedPath.replace(';', '/');
String avmPath = this.avmStore + ":/" + path;
((EditableValueHolder)this).setSubmittedValue(AVMNodeConverter.ToNodeRef(-1, avmPath));
}
else
{
((EditableValueHolder)this).setSubmittedValue(new NodeRef(Repository.getStoreRef(), selection));
}
} }
} }
} }
@@ -358,7 +377,16 @@ public abstract class AbstractItemSelector extends UIInput
} }
else else
{ {
label = Repository.getNameForNode(service, value); if (value.getStoreRef().getProtocol().equals(StoreRef.PROTOCOL_AVM))
{
Pair<Integer, String> 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; showValueInHiddenField = true;
} }
@@ -392,6 +420,12 @@ public abstract class AbstractItemSelector extends UIInput
if (value != null) if (value != null)
{ {
fieldValue = encodeFieldValues(theMode, value.getId()); 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 else
{ {
@@ -514,10 +548,9 @@ public abstract class AbstractItemSelector extends UIInput
buf.append("/></td><td>"); buf.append("/></td><td>");
// get the name for the child and output as link // get the name for the child and output as link
NodeRef childNodeRef = new NodeRef(Repository.getStoreRef(), childId); String name = Repository.getNameForNode(service, childRef);
String name = Repository.getNameForNode(service, childNodeRef);
String prefixHtml = null; String prefixHtml = null;
String icon = getItemIcon(context, childNodeRef); String icon = getItemIcon(context, childRef);
if (icon != null) if (icon != null)
{ {
prefixHtml = "<span style='padding-right:4px'>" + prefixHtml = "<span style='padding-right:4px'>" +
@@ -801,6 +834,7 @@ public abstract class AbstractItemSelector extends UIInput
/** /**
* Class representing the clicking of a breadcrumb element. * Class representing the clicking of a breadcrumb element.
*/ */
@SuppressWarnings("serial")
public static class ItemSelectorEvent extends ActionEvent public static class ItemSelectorEvent extends ActionEvent
{ {
public ItemSelectorEvent(UIComponent component, int mode, String id) public ItemSelectorEvent(UIComponent component, int mode, String id)

View File

@@ -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<NodeRef> getChildrenForNode(FacesContext context)
{
if (logger.isDebugEnabled())
logger.debug("Getting children for: " + this.navigationId);
List<NodeRef> folders = new ArrayList<NodeRef>();
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<NodeRef> 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<NodeRef> 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<NodeRef> webProjects = new ArrayList<NodeRef>(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<NodeRef> 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<String, AVMNodeDescriptor> 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);
}
}
}
}

View File

@@ -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";
}
}

View File

@@ -57,6 +57,11 @@
<component> <component>
<component-type>org.alfresco.faces.ContentSelector</component-type> <component-type>org.alfresco.faces.ContentSelector</component-type>
<component-class>org.alfresco.web.ui.repo.component.UIContentSelector</component-class> <component-class>org.alfresco.web.ui.repo.component.UIContentSelector</component-class>
</component>
<component>
<component-type>org.alfresco.faces.WebProjectFolderSelector</component-type>
<component-class>org.alfresco.web.ui.repo.component.UIWebProjectFolderSelector</component-class>
</component> </component>
<component> <component>

View File

@@ -793,6 +793,84 @@
</attribute> </attribute>
</tag> </tag>
<tag>
<name>webProjectFolderSelector</name>
<tag-class>org.alfresco.web.ui.repo.tag.WebProjectFolderSelectorTag</tag-class>
<body-content>JSP</body-content>
<attribute>
<name>id</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>binding</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>rendered</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>style</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>styleClass</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>nodeStyle</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>nodeStyleClass</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>value</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>label</name>
<required>true</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>spacing</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>initialSelection</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>disabled</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>
<tag> <tag>
<name>categorySelector</name> <name>categorySelector</name>
<tag-class>org.alfresco.web.ui.repo.tag.CategorySelectorTag</tag-class> <tag-class>org.alfresco.web.ui.repo.tag.CategorySelectorTag</tag-class>

View File

@@ -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" %>
<r:page titleId="title_action_copy_to_web_project">
<f:view>
<%-- load a bundle of properties with I18N strings --%>
<f:loadBundle basename="alfresco.messages.webclient" var="msg"/>
<h:form acceptcharset="UTF-8" id="copy-to-web-project-action">
<%-- Main outer table --%>
<table cellspacing="0" cellpadding="2">
<%-- Title bar --%>
<tr>
<td colspan="2">
<%@ include file="../parts/titlebar.jsp" %>
</td>
</tr>
<%-- Main area --%>
<tr valign="top">
<%-- Shelf --%>
<td>
<%@ include file="../parts/shelf.jsp" %>
</td>
<%-- Work Area --%>
<td width="100%">
<table cellspacing="0" cellpadding="0" width="100%">
<%-- Breadcrumb --%>
<%@ include file="../parts/breadcrumb.jsp" %>
<%-- Status and Actions --%>
<tr>
<td style="background-image: url(<%=request.getContextPath()%>/images/parts/statuspanel_4.gif)" width="4"></td>
<td bgcolor="#dfe6ed">
<%-- Status and Actions inner contents table --%>
<%-- Generally this consists of an icon, textual summary and actions for the current object --%>
<table cellspacing="4" cellpadding="0" width="100%">
<tr>
<td width="32">
<h:graphicImage id="wizard-logo" url="/images/icons/new_rule_large.gif" />
</td>
<td>
<div class="mainTitle"><h:outputText value="#{WizardManager.title}" /></div>
<div class="mainSubText"><h:outputText value="#{WizardManager.description}" /></div>
</td>
</tr>
</table>
</td>
<td style="background-image: url(<%=request.getContextPath()%>/images/parts/statuspanel_6.gif)" width="4"></td>
</tr>
<%-- separator row with gradient shadow --%>
<tr>
<td><img src="<%=request.getContextPath()%>/images/parts/statuspanel_7.gif" width="4" height="9"></td>
<td style="background-image: url(<%=request.getContextPath()%>/images/parts/statuspanel_8.gif)"></td>
<td><img src="<%=request.getContextPath()%>/images/parts/statuspanel_9.gif" width="4" height="9"></td>
</tr>
<%-- Details --%>
<tr valign=top>
<td style="background-image: url(<%=request.getContextPath()%>/images/parts/whitepanel_4.gif)" width="4"></td>
<td>
<table cellspacing="0" cellpadding="3" border="0" width="100%">
<tr>
<td width="100%" valign="top">
<a:errors message="#{msg.error_wizard}" styleClass="errorMessage" />
<% PanelGenerator.generatePanelStart(out, request.getContextPath(), "white", "white"); %>
<table cellpadding="2" cellspacing="2" border="0" width="100%">
<tr>
<td colspan="2" class="mainSubTitle"><h:outputText value="#{msg.set_action_values}" /></td>
</tr>
<tr><td class="paddingRow"></td></tr>
<tr>
<td><h:outputText value="#{msg.destination}"/>:</td>
<td width="90%">
<%--
<r:spaceSelector id="space-selector" label="#{msg.select_destination_prompt}"
value="#{WizardManager.bean.actionProperties.destinationLocation}"
initialSelection="#{NavigationBean.currentNodeId}"
styleClass="selector"/>
--%>
<r:webProjectFolderSelector id="web-proj-folder-selector" styleClass="selector"
label="#{msg.select_web_project_folder}"
value="#{WizardManager.bean.actionProperties.destinationLocation}" />
</td>
</tr>
<tr><td class="paddingRow"></td></tr>
</table>
<% PanelGenerator.generatePanelEnd(out, request.getContextPath(), "white"); %>
</td>
<td valign="top">
<% PanelGenerator.generatePanelStart(out, request.getContextPath(), "greyround", "#F5F5F5"); %>
<table cellpadding="1" cellspacing="1" border="0">
<tr>
<td align="center">
<h:commandButton value="#{msg.ok}" action="#{WizardManager.bean.addAction}" styleClass="wizardButton"
disabled="#{WizardManager.bean.actionProperties.destinationLocation == null}" />
</td>
</tr>
<tr>
<td align="center">
<h:commandButton value="#{msg.cancel_button}" action="#{WizardManager.bean.cancelAddAction}"
styleClass="wizardButton" />
</td>
</tr>
</table>
<% PanelGenerator.generatePanelEnd(out, request.getContextPath(), "greyround"); %>
</td>
</tr>
</table>
</td>
<td style="background-image: url(<%=request.getContextPath()%>/images/parts/whitepanel_6.gif)" width="4"></td>
</tr>
<%-- separator row with bottom panel graphics --%>
<tr>
<td><img src="<%=request.getContextPath()%>/images/parts/whitepanel_7.gif" width="4" height="4"></td>
<td width="100%" align="center" style="background-image: url(<%=request.getContextPath()%>/images/parts/whitepanel_8.gif)"></td>
<td><img src="<%=request.getContextPath()%>/images/parts/whitepanel_9.gif" width="4" height="4"></td>
</tr>
</table>
</td>
</tr>
</table>
</h:form>
</f:view>
</r:page>