mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
. Refactored client AVM Node class to extend existing Node class - allows the use of existing PermissionEvaluators etc. for a node action
. Permission evaluators added to AVM browse screen top-level actions and file/folder actions . Permission evaluators added to Edit Details action in File/Folder Details screens . Each user sandbox is now only visible to the assigned user and all Content Managers . Import Website Content action hidden unless user has appropriate Write permissions to the main staging area (Content Managers only) . Added Titled aspect to shtml content created through the XML Templating Service. . Remove Create Content action from sandbox screen - makes no sense here until we can create via workflow or destination folder . Fix nasty bug in Create Form Wizard where no default extension would be specified - this led to the XForms generating files such as "myfile.xml" and "myfile." - the generated HTML did not have a file extension... git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@4048 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -66,6 +66,11 @@ public class CreateXmlContentTypeWizard extends BaseWizardBean
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private static final String FILE_TEMPLATEOUTPUT = "template-output-method";
|
||||
|
||||
private static final String FILE_SCHEMA = "schema";
|
||||
|
||||
|
||||
/**
|
||||
* Simple wrapper class to represent a template output method
|
||||
*/
|
||||
@@ -204,8 +209,6 @@ public class CreateXmlContentTypeWizard extends BaseWizardBean
|
||||
this.schemaRootTagName = null;
|
||||
this.templateName = null;
|
||||
this.templateOutputMethods = new ArrayList<TemplateOutputMethodData>();
|
||||
clearUpload("schema");
|
||||
clearUpload("template-output-method");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -275,7 +278,7 @@ public class CreateXmlContentTypeWizard extends BaseWizardBean
|
||||
*/
|
||||
public String removeUploadedSchemaFile()
|
||||
{
|
||||
clearUpload("schema");
|
||||
clearUpload(FILE_SCHEMA);
|
||||
|
||||
// refresh the current page
|
||||
return null;
|
||||
@@ -286,7 +289,7 @@ public class CreateXmlContentTypeWizard extends BaseWizardBean
|
||||
*/
|
||||
public String removeUploadedTemplateOutputMethodFile()
|
||||
{
|
||||
clearUpload("template-output-method");
|
||||
clearUpload(FILE_TEMPLATEOUTPUT);
|
||||
|
||||
// refresh the current page
|
||||
return null;
|
||||
@@ -369,7 +372,7 @@ public class CreateXmlContentTypeWizard extends BaseWizardBean
|
||||
*/
|
||||
public File getSchemaFile()
|
||||
{
|
||||
return this.getFile("schema");
|
||||
return this.getFile(FILE_SCHEMA);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -379,7 +382,7 @@ public class CreateXmlContentTypeWizard extends BaseWizardBean
|
||||
{
|
||||
// try and retrieve the file and filename from the file upload bean
|
||||
// representing the file we previously uploaded.
|
||||
return this.getFileName("schema");
|
||||
return this.getFileName(FILE_SCHEMA);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -387,7 +390,7 @@ public class CreateXmlContentTypeWizard extends BaseWizardBean
|
||||
*/
|
||||
public String getTemplateOutputMethodFileName()
|
||||
{
|
||||
return this.getFileName("template-output-method");
|
||||
return this.getFileName(FILE_TEMPLATEOUTPUT);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -395,7 +398,7 @@ public class CreateXmlContentTypeWizard extends BaseWizardBean
|
||||
*/
|
||||
public File getTemplateOutputMethodFile()
|
||||
{
|
||||
return this.getFile("template-output-method");
|
||||
return this.getFile(FILE_TEMPLATEOUTPUT);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -490,12 +493,12 @@ public class CreateXmlContentTypeWizard extends BaseWizardBean
|
||||
{
|
||||
// remove the file upload bean from the session
|
||||
FacesContext ctx = FacesContext.getCurrentInstance();
|
||||
FileUploadBean fileBean = (FileUploadBean)
|
||||
ctx.getExternalContext().getSessionMap().
|
||||
get(FileUploadBean.getKey(id));
|
||||
FileUploadBean fileBean =
|
||||
(FileUploadBean)ctx.getExternalContext().getSessionMap().get(FileUploadBean.getKey(id));
|
||||
if (fileBean != null)
|
||||
{
|
||||
fileBean.setFile(null);
|
||||
fileBean.setFileName(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -89,7 +89,7 @@ public class Node implements Serializable
|
||||
/**
|
||||
* @return All the properties known about this node.
|
||||
*/
|
||||
public final Map<String, Object> getProperties()
|
||||
public Map<String, Object> getProperties()
|
||||
{
|
||||
if (this.propsRetrieved == false)
|
||||
{
|
||||
@@ -289,7 +289,7 @@ public class Node implements Serializable
|
||||
/**
|
||||
* @return The display name for the node
|
||||
*/
|
||||
public final String getName()
|
||||
public String getName()
|
||||
{
|
||||
if (this.name == null)
|
||||
{
|
||||
@@ -339,20 +339,20 @@ public class Node implements Serializable
|
||||
public boolean hasPermission(String permission)
|
||||
{
|
||||
Boolean valid = null;
|
||||
if (permissions != null)
|
||||
if (this.permissions != null)
|
||||
{
|
||||
valid = permissions.get(permission);
|
||||
valid = this.permissions.get(permission);
|
||||
}
|
||||
else
|
||||
{
|
||||
permissions = new HashMap<String, Boolean>(5, 1.0f);
|
||||
this.permissions = new HashMap<String, Boolean>(8, 1.0f);
|
||||
}
|
||||
|
||||
if (valid == null)
|
||||
{
|
||||
PermissionService service = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getPermissionService();
|
||||
valid = Boolean.valueOf(service.hasPermission(this.nodeRef, permission) == AccessStatus.ALLOWED);
|
||||
permissions.put(permission, valid);
|
||||
this.permissions.put(permission, valid);
|
||||
}
|
||||
|
||||
return valid.booleanValue();
|
||||
@@ -369,7 +369,7 @@ public class Node implements Serializable
|
||||
/**
|
||||
* @return The path for the node
|
||||
*/
|
||||
public final String getPath()
|
||||
public String getPath()
|
||||
{
|
||||
if (this.path == null)
|
||||
{
|
||||
|
@@ -90,6 +90,7 @@ public class AVMBrowseBean implements IContextListener
|
||||
private String username;
|
||||
private String sandboxTitle = null;
|
||||
private String currentPath = null;
|
||||
private AVMNode currentPathNode = null;
|
||||
|
||||
/* component references */
|
||||
private UIRichList foldersRichList;
|
||||
@@ -100,7 +101,7 @@ public class AVMBrowseBean implements IContextListener
|
||||
private List<Map> files = null;
|
||||
private List<Map> folders = null;
|
||||
|
||||
/** Current AVM Node context*/
|
||||
/** Current AVM Node action context */
|
||||
private AVMNode avmNode = null;
|
||||
|
||||
private String wcmDomain;
|
||||
@@ -415,25 +416,25 @@ public class AVMBrowseBean implements IContextListener
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the current AVM node context.
|
||||
* @return Returns the current AVM node action context.
|
||||
*/
|
||||
public AVMNode getAvmNode()
|
||||
public AVMNode getAvmActionNode()
|
||||
{
|
||||
return this.avmNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param avmNode The AVM node context to set.
|
||||
* @param avmNode The AVM node action context to set.
|
||||
*/
|
||||
public void setAvmNode(AVMNode avmNode)
|
||||
public void setAvmActionNode(AVMNode avmNode)
|
||||
{
|
||||
this.avmNode = avmNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param avmRef The AVMNodeDescriptor context to set.
|
||||
* @param avmRef The AVMNodeDescriptor action context to set.
|
||||
*/
|
||||
public void setAVMNodeDescriptor(AVMNodeDescriptor avmRef)
|
||||
public void setAVMActionNodeDescriptor(AVMNodeDescriptor avmRef)
|
||||
{
|
||||
AVMNode avmNode = new AVMNode(avmRef);
|
||||
this.avmNode = avmNode;
|
||||
@@ -457,11 +458,29 @@ public class AVMBrowseBean implements IContextListener
|
||||
public void setCurrentPath(String path)
|
||||
{
|
||||
this.currentPath = path;
|
||||
if (path == null)
|
||||
{
|
||||
// clear dependant objects (recreated when the path is reinitialised)
|
||||
this.currentPathNode = null;
|
||||
}
|
||||
|
||||
// update UI state ready for screen refresh
|
||||
UIContextService.getInstance(FacesContext.getCurrentInstance()).notifyBeans();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the AVMNode that represents the current browsing path
|
||||
*/
|
||||
public AVMNode getCurrentPathNode()
|
||||
{
|
||||
if (this.currentPathNode == null)
|
||||
{
|
||||
AVMNodeDescriptor node = this.avmService.lookup(-1, getCurrentPath(), true);
|
||||
this.currentPathNode = new AVMNode(node);
|
||||
}
|
||||
return this.currentPathNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Breadcrumb location list
|
||||
*/
|
||||
@@ -638,11 +657,11 @@ public class AVMBrowseBean implements IContextListener
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Setup content action for path: " + path);
|
||||
AVMNodeDescriptor node = avmService.lookup(-1, path, true);
|
||||
setAVMNodeDescriptor(node);
|
||||
setAVMActionNodeDescriptor(node);
|
||||
}
|
||||
else
|
||||
{
|
||||
setAvmNode(null);
|
||||
setAvmActionNode(null);
|
||||
}
|
||||
|
||||
// update UI state ready for return after dialog close
|
||||
@@ -667,14 +686,14 @@ public class AVMBrowseBean implements IContextListener
|
||||
tx.begin();
|
||||
|
||||
Action action = this.actionService.createAction(ACTION_AVM_SUBMIT);
|
||||
this.actionService.executeAction(action, getAvmNode().getNodeRef());
|
||||
this.actionService.executeAction(action, getAvmActionNode().getNodeRef());
|
||||
|
||||
// commit the transaction
|
||||
tx.commit();
|
||||
|
||||
// if we get here, all was well - output friendly status message to the user
|
||||
String msg = MessageFormat.format(Application.getMessage(
|
||||
context, MSG_SUBMIT_SUCCESS), getAvmNode().getName());
|
||||
context, MSG_SUBMIT_SUCCESS), getAvmActionNode().getName());
|
||||
FacesMessage facesMsg = new FacesMessage(FacesMessage.SEVERITY_INFO, msg, msg);
|
||||
String formId = Utils.getParentForm(context, event.getComponent()).getClientId(context);
|
||||
context.addMessage(formId + ':' + COMPONENT_SANDBOXESPANEL, facesMsg);
|
||||
|
@@ -116,7 +116,7 @@ public class AVMEditBean
|
||||
*/
|
||||
public AVMNode getAvmNode()
|
||||
{
|
||||
return this.avmBrowseBean.getAvmNode();
|
||||
return this.avmBrowseBean.getAvmActionNode();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -20,25 +20,23 @@ import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.repo.avm.AVMNodeConverter;
|
||||
import org.alfresco.repo.domain.PropertyValue;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.namespace.QNameMap;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
|
||||
/**
|
||||
* Node class representing an AVM specific Node.
|
||||
*
|
||||
* Handles AVM related notions such as Path and Version. Provides the usual properties and
|
||||
* property resolving functions, and appropriate method overrides for the AVM world.
|
||||
*
|
||||
* @author Kevin Roast
|
||||
*/
|
||||
public class AVMNode implements Map<String, Object>
|
||||
public class AVMNode extends Node implements Map<String, Object>
|
||||
{
|
||||
private QNameMap<String, Object> properties = null;
|
||||
private ServiceRegistry services = null;
|
||||
private AVMNodeDescriptor avmRef;
|
||||
private String path;
|
||||
private int version;
|
||||
@@ -47,46 +45,51 @@ public class AVMNode implements Map<String, Object>
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param avmRef The AVMNodeDescriptor that describes this node
|
||||
*/
|
||||
public AVMNode(AVMNodeDescriptor avmRef)
|
||||
{
|
||||
super(AVMNodeConverter.ToNodeRef(-1, avmRef.getPath()));
|
||||
this.avmRef = avmRef;
|
||||
this.version = -1; // TODO: always -1 for now...
|
||||
this.path = avmRef.getPath();
|
||||
this.id = this.path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param avmRef The AVMNodeDescriptor that describes this node
|
||||
* @param deleted True if the node represents a ghosted deleted node
|
||||
*/
|
||||
public AVMNode(AVMNodeDescriptor avmRef, boolean deleted)
|
||||
{
|
||||
this(avmRef);
|
||||
this.deleted = deleted;
|
||||
}
|
||||
|
||||
public String getPath()
|
||||
public final String getPath()
|
||||
{
|
||||
return this.path;
|
||||
}
|
||||
|
||||
public int getVersion()
|
||||
public final int getVersion()
|
||||
{
|
||||
return this.version;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
public final String getName()
|
||||
{
|
||||
return this.avmRef.getName();
|
||||
}
|
||||
|
||||
public NodeRef getNodeRef()
|
||||
{
|
||||
return AVMNodeConverter.ToNodeRef(this.version, this.path);
|
||||
}
|
||||
|
||||
public boolean isDirectory()
|
||||
public final boolean isDirectory()
|
||||
{
|
||||
return this.avmRef.isDirectory();
|
||||
}
|
||||
|
||||
public boolean isFile()
|
||||
public final boolean isFile()
|
||||
{
|
||||
return this.avmRef.isFile();
|
||||
}
|
||||
@@ -96,10 +99,8 @@ public class AVMNode implements Map<String, Object>
|
||||
*/
|
||||
public final Map<String, Object> getProperties()
|
||||
{
|
||||
if (this.properties == null)
|
||||
if (this.propsRetrieved == false)
|
||||
{
|
||||
this.properties = new QNameMap<String, Object>(getServiceRegistry().getNamespaceService());
|
||||
|
||||
if (this.deleted == false)
|
||||
{
|
||||
Map<QName, PropertyValue> props = getServiceRegistry().getAVMService().getNodeProperties(this.version, this.path);
|
||||
@@ -117,31 +118,13 @@ public class AVMNode implements Map<String, Object>
|
||||
this.properties.put("created", this.avmRef.getCreateDate());
|
||||
this.properties.put("modified", this.avmRef.getModDate());
|
||||
this.properties.put("creator", this.avmRef.getCreator());
|
||||
|
||||
this.propsRetrieved = true;
|
||||
}
|
||||
|
||||
return this.properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the given property name is held by this node
|
||||
*
|
||||
* @param propertyName Property to test existence of
|
||||
* @return true if property exists, false otherwise
|
||||
*/
|
||||
public final boolean hasProperty(String propertyName)
|
||||
{
|
||||
return getProperties().containsKey(propertyName);
|
||||
}
|
||||
|
||||
private ServiceRegistry getServiceRegistry()
|
||||
{
|
||||
if (this.services == null)
|
||||
{
|
||||
this.services = Repository.getServiceRegistry(FacesContext.getCurrentInstance());
|
||||
}
|
||||
return this.services;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------------
|
||||
// Map implementation - allows the Node bean to be accessed using JSF expression syntax
|
||||
|
@@ -131,7 +131,7 @@ public class CreateWebsiteWizard extends BaseWizardBean
|
||||
{
|
||||
foundCurrentUser = true;
|
||||
}
|
||||
if (ROLE_CONTENT_MANAGER.equals(userRole))
|
||||
if (ROLE_CONTENT_MANAGER.equals(userRole.getRole()))
|
||||
{
|
||||
managers.add(authority);
|
||||
}
|
||||
|
@@ -49,7 +49,7 @@ public class DeleteFileDialog extends BaseDialogBean
|
||||
throws Exception
|
||||
{
|
||||
// get the content to delete
|
||||
AVMNode node = this.avmBrowseBean.getAvmNode();
|
||||
AVMNode node = this.avmBrowseBean.getAvmActionNode();
|
||||
if (node != null)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
@@ -101,6 +101,6 @@ public class DeleteFileDialog extends BaseDialogBean
|
||||
"delete_avm_file_confirm");
|
||||
|
||||
return MessageFormat.format(fileConfirmMsg,
|
||||
new Object[] {this.avmBrowseBean.getAvmNode().getName()});
|
||||
new Object[] {this.avmBrowseBean.getAvmActionNode().getName()});
|
||||
}
|
||||
}
|
||||
|
@@ -49,7 +49,7 @@ public class DeleteFolderDialog extends BaseDialogBean
|
||||
throws Exception
|
||||
{
|
||||
// get the content to delete
|
||||
AVMNode node = this.avmBrowseBean.getAvmNode();
|
||||
AVMNode node = this.avmBrowseBean.getAvmActionNode();
|
||||
if (node != null)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
@@ -101,6 +101,6 @@ public class DeleteFolderDialog extends BaseDialogBean
|
||||
"delete_avm_folder_confirm");
|
||||
|
||||
return MessageFormat.format(fileConfirmMsg,
|
||||
new Object[] {this.avmBrowseBean.getAvmNode().getName()});
|
||||
new Object[] {this.avmBrowseBean.getAvmActionNode().getName()});
|
||||
}
|
||||
}
|
||||
|
@@ -78,7 +78,7 @@ public class EditFilePropertiesDialog extends EditContentPropertiesDialog
|
||||
@Override
|
||||
protected Node initEditableNode()
|
||||
{
|
||||
return new Node(this.avmBrowseBean.getAvmNode().getNodeRef());
|
||||
return new Node(this.avmBrowseBean.getAvmActionNode().getNodeRef());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -170,7 +170,7 @@ public class EditFilePropertiesDialog extends EditContentPropertiesDialog
|
||||
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)));
|
||||
this.avmBrowseBean.setAvmActionNode(new AVMNode(this.avmService.lookup(-1, newPath)));
|
||||
|
||||
return outcome;
|
||||
}
|
||||
@@ -194,7 +194,7 @@ public class EditFilePropertiesDialog extends EditContentPropertiesDialog
|
||||
{
|
||||
return MessageFormat.format(Application.getMessage(
|
||||
FacesContext.getCurrentInstance(), Repository.ERROR_NODEREF),
|
||||
new Object[] {this.avmBrowseBean.getAvmNode().getPath()});
|
||||
new Object[] {this.avmBrowseBean.getAvmActionNode().getPath()});
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -77,7 +77,7 @@ public class EditFolderPropertiesDialog extends EditSpaceDialog
|
||||
@Override
|
||||
protected Node initEditableNode()
|
||||
{
|
||||
return new Node(this.avmBrowseBean.getAvmNode().getNodeRef());
|
||||
return new Node(this.avmBrowseBean.getAvmActionNode().getNodeRef());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -154,7 +154,7 @@ public class EditFolderPropertiesDialog extends EditSpaceDialog
|
||||
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)));
|
||||
this.avmBrowseBean.setAvmActionNode(new AVMNode(this.avmService.lookup(-1, newPath)));
|
||||
|
||||
return outcome;
|
||||
}
|
||||
|
@@ -35,7 +35,7 @@ public class FileDetailsBean extends AVMDetailsBean
|
||||
@Override
|
||||
public AVMNode getAvmNode()
|
||||
{
|
||||
return this.avmBrowseBean.getAvmNode();
|
||||
return this.avmBrowseBean.getAvmActionNode();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -35,7 +35,7 @@ public class FolderDetailsBean extends AVMDetailsBean
|
||||
@Override
|
||||
public AVMNode getAvmNode()
|
||||
{
|
||||
return this.avmBrowseBean.getAvmNode();
|
||||
return this.avmBrowseBean.getAvmActionNode();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -18,6 +18,7 @@ package org.alfresco.web.templating;
|
||||
|
||||
import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -30,6 +31,7 @@ import org.alfresco.service.cmr.repository.ContentService;
|
||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.web.bean.wcm.AVMConstants;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
@@ -83,6 +85,9 @@ public class OutputUtil
|
||||
nodeService.setProperty(outputNodeRef,
|
||||
TemplatingService.TT_QNAME,
|
||||
tt.getName());
|
||||
Map<QName, Serializable> titledProps = new HashMap<QName, Serializable>(1, 1.0f);
|
||||
titledProps.put(ContentModel.PROP_TITLE, fileName);
|
||||
nodeService.addAspect(outputNodeRef, ContentModel.ASPECT_TITLED, titledProps);
|
||||
|
||||
LOGGER.debug("generated " + generatedFileName + " using " + tom);
|
||||
|
||||
|
@@ -42,6 +42,8 @@ import org.alfresco.service.cmr.avmsync.AVMSyncService;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.security.AccessStatus;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.service.namespace.RegexQNamePattern;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.app.servlet.DownloadContentServlet;
|
||||
@@ -184,6 +186,7 @@ public class UIUserSandboxes extends SelfRenderingComponent
|
||||
ResourceBundle bundle = Application.getBundle(context);
|
||||
AVMService avmService = getAVMService(context);
|
||||
NodeService nodeService = getNodeService(context);
|
||||
PermissionService permissionService = getPermissionService(context);
|
||||
UserTransaction tx = null;
|
||||
try
|
||||
{
|
||||
@@ -191,13 +194,14 @@ public class UIUserSandboxes extends SelfRenderingComponent
|
||||
tx.begin();
|
||||
|
||||
NodeRef websiteRef = getValue();
|
||||
if (value == null)
|
||||
if (websiteRef == null)
|
||||
{
|
||||
throw new IllegalArgumentException("Website NodeRef must be specified.");
|
||||
}
|
||||
String storeRoot = (String)nodeService.getProperty(websiteRef, ContentModel.PROP_AVMSTORE);
|
||||
|
||||
// get the list of users who have a sandbox in the website
|
||||
String currentUser = Application.getCurrentUser(context).getUserName();
|
||||
int index = 0;
|
||||
List<ChildAssociationRef> userInfoRefs = nodeService.getChildAssocs(
|
||||
websiteRef, ContentModel.ASSOC_WEBUSER, RegexQNamePattern.MATCH_ALL);
|
||||
@@ -213,83 +217,92 @@ public class UIUserSandboxes extends SelfRenderingComponent
|
||||
// check it exists before we render the view
|
||||
if (avmService.getAVMStore(mainStore) != null)
|
||||
{
|
||||
// check the permissions on this store for the current user
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Building sandbox view for user store: " + mainStore);
|
||||
|
||||
// for each user sandbox, generate an outer panel table
|
||||
PanelGenerator.generatePanelStart(out,
|
||||
context.getExternalContext().getRequestContextPath(),
|
||||
"white",
|
||||
"white");
|
||||
|
||||
// components for the current username, preview, browse and modified items inner list
|
||||
out.write("<table cellspacing=2 cellpadding=2 border=0 width=100%><tr><td>");
|
||||
// show the icon for the sandbox as a clickable browse link image
|
||||
// this is currently identical to the sandbox_browse action as below
|
||||
Utils.encodeRecursive(context, aquireAction(
|
||||
context, mainStore, username, "sandbox_icon", WebResources.IMAGE_USERSANDBOX_32,
|
||||
"#{AVMBrowseBean.setupSandboxAction}", "browseSandbox", null));
|
||||
out.write("</td><td width=100%>");
|
||||
out.write("<b>");
|
||||
out.write(bundle.getString(MSG_USERNAME));
|
||||
out.write(":</b> ");
|
||||
out.write(username);
|
||||
out.write(" (");
|
||||
out.write(bundle.getString(userrole));
|
||||
out.write(")</td><td><nobr>");
|
||||
|
||||
// direct actions for a sandbox
|
||||
String sandboxUrl = AVMConstants.buildAVMStoreUrl(mainStore);
|
||||
Utils.encodeRecursive(context, aquireAction(
|
||||
context, mainStore, username, "sandbox_preview", "/images/icons/preview_website.gif",
|
||||
null, null, sandboxUrl));
|
||||
out.write(" ");
|
||||
|
||||
Utils.encodeRecursive(context, aquireAction(
|
||||
context, mainStore, username, "sandbox_create", "/images/icons/new_content.gif",
|
||||
"#{AVMBrowseBean.setupSandboxAction}", "wizard:createWebContent", null));
|
||||
out.write(" ");
|
||||
|
||||
Utils.encodeRecursive(context, aquireAction(
|
||||
context, mainStore, username, "sandbox_submitall", "/images/icons/submit.gif",
|
||||
"#{AVMBrowseBean.submitAll}", null, null));
|
||||
out.write(" ");
|
||||
|
||||
Utils.encodeRecursive(context, aquireAction(
|
||||
context, mainStore, username, "sandbox_browse", "/images/icons/space_small.gif",
|
||||
"#{AVMBrowseBean.setupSandboxAction}", "browseSandbox", null));
|
||||
out.write("</nobr></td></tr>");
|
||||
|
||||
// modified items panel
|
||||
out.write("<tr><td></td><td colspan=2>");
|
||||
String panelImage = WebResources.IMAGE_COLLAPSED;
|
||||
if (this.expandedPanels.contains(username))
|
||||
logger.debug("Checking user permissions for store: " + mainStore);
|
||||
if (permissionService.hasPermission(
|
||||
AVMNodeConverter.ToNodeRef(-1, AVMConstants.buildAVMStoreRootPath(mainStore)),
|
||||
PermissionService.READ) == AccessStatus.ALLOWED)
|
||||
{
|
||||
panelImage = WebResources.IMAGE_EXPANDED;
|
||||
}
|
||||
out.write(Utils.buildImageTag(context, panelImage, 11, 11, "",
|
||||
Utils.generateFormSubmit(context, this, getClientId(context), username)));
|
||||
out.write(" <b>");
|
||||
out.write(bundle.getString(MSG_MODIFIED_ITEMS));
|
||||
out.write("</b>");
|
||||
if (this.expandedPanels.contains(username))
|
||||
{
|
||||
out.write("<div style='padding:2px'></div>");
|
||||
|
||||
// list the modified docs for this sandbox user
|
||||
renderUserFiles(context, out, username, storeRoot);
|
||||
}
|
||||
out.write("</td></tr></table>");
|
||||
|
||||
// end the outer panel for this sandbox
|
||||
PanelGenerator.generatePanelEnd(out,
|
||||
context.getExternalContext().getRequestContextPath(),
|
||||
"white");
|
||||
|
||||
// spacer row
|
||||
if (index++ < userInfoRefs.size() - 1)
|
||||
{
|
||||
out.write("<div style='padding:4px'></div>");
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Building sandbox view for user store: " + mainStore);
|
||||
|
||||
// for each user sandbox, generate an outer panel table
|
||||
PanelGenerator.generatePanelStart(out,
|
||||
context.getExternalContext().getRequestContextPath(),
|
||||
"white",
|
||||
"white");
|
||||
|
||||
// components for the current username, preview, browse and modified items inner list
|
||||
out.write("<table cellspacing=2 cellpadding=2 border=0 width=100%><tr><td>");
|
||||
// show the icon for the sandbox as a clickable browse link image
|
||||
// this is currently identical to the sandbox_browse action as below
|
||||
Utils.encodeRecursive(context, aquireAction(
|
||||
context, mainStore, username, "sandbox_icon", WebResources.IMAGE_USERSANDBOX_32,
|
||||
"#{AVMBrowseBean.setupSandboxAction}", "browseSandbox", null));
|
||||
out.write("</td><td width=100%>");
|
||||
out.write("<b>");
|
||||
out.write(bundle.getString(MSG_USERNAME));
|
||||
out.write(":</b> ");
|
||||
out.write(username);
|
||||
out.write(" (");
|
||||
out.write(bundle.getString(userrole));
|
||||
out.write(")</td><td><nobr>");
|
||||
|
||||
// direct actions for a sandbox
|
||||
String sandboxUrl = AVMConstants.buildAVMStoreUrl(mainStore);
|
||||
Utils.encodeRecursive(context, aquireAction(
|
||||
context, mainStore, username, "sandbox_preview", "/images/icons/preview_website.gif",
|
||||
null, null, sandboxUrl));
|
||||
out.write(" ");
|
||||
|
||||
// TODO: add this action back once we can create in a specific sub-folder
|
||||
/*Utils.encodeRecursive(context, aquireAction(
|
||||
context, mainStore, username, "sandbox_create", "/images/icons/new_content.gif",
|
||||
"#{AVMBrowseBean.setupSandboxAction}", "wizard:createWebContent", null));
|
||||
out.write(" ");*/
|
||||
|
||||
Utils.encodeRecursive(context, aquireAction(
|
||||
context, mainStore, username, "sandbox_submitall", "/images/icons/submit.gif",
|
||||
"#{AVMBrowseBean.submitAll}", null, null));
|
||||
out.write(" ");
|
||||
|
||||
Utils.encodeRecursive(context, aquireAction(
|
||||
context, mainStore, username, "sandbox_browse", "/images/icons/space_small.gif",
|
||||
"#{AVMBrowseBean.setupSandboxAction}", "browseSandbox", null));
|
||||
out.write("</nobr></td></tr>");
|
||||
|
||||
// modified items panel
|
||||
out.write("<tr><td></td><td colspan=2>");
|
||||
String panelImage = WebResources.IMAGE_COLLAPSED;
|
||||
if (this.expandedPanels.contains(username))
|
||||
{
|
||||
panelImage = WebResources.IMAGE_EXPANDED;
|
||||
}
|
||||
out.write(Utils.buildImageTag(context, panelImage, 11, 11, "",
|
||||
Utils.generateFormSubmit(context, this, getClientId(context), username)));
|
||||
out.write(" <b>");
|
||||
out.write(bundle.getString(MSG_MODIFIED_ITEMS));
|
||||
out.write("</b>");
|
||||
if (this.expandedPanels.contains(username))
|
||||
{
|
||||
out.write("<div style='padding:2px'></div>");
|
||||
|
||||
// list the modified docs for this sandbox user
|
||||
renderUserFiles(context, out, username, storeRoot);
|
||||
}
|
||||
out.write("</td></tr></table>");
|
||||
|
||||
// end the outer panel for this sandbox
|
||||
PanelGenerator.generatePanelEnd(out,
|
||||
context.getExternalContext().getRequestContextPath(),
|
||||
"white");
|
||||
|
||||
// spacer row
|
||||
if (index++ < userInfoRefs.size() - 1)
|
||||
{
|
||||
out.write("<div style='padding:4px'></div>");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -664,6 +677,11 @@ public class UIUserSandboxes extends SelfRenderingComponent
|
||||
return (AVMSyncService)FacesContextUtils.getRequiredWebApplicationContext(fc).getBean("AVMSyncService");
|
||||
}
|
||||
|
||||
private PermissionService getPermissionService(FacesContext fc)
|
||||
{
|
||||
return Repository.getServiceRegistry(fc).getPermissionService();
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Strongly typed component property accessors
|
||||
|
Reference in New Issue
Block a user