mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
ALF-3102 & FORM-36: Allow the starting point to be defined for the association control also required to implement ALF-4070: F20 Selectable resources are limited to the current site (if appropriate)
The association control now accepts a 'startLocation' parameter, this can be set to any of the following: {companyhome} {userhome} {siteshome} {doclib} {self} {parent} A NodeRef An XPath The NodeRef and XPath options can also be used for the category form control to start the category picker in a particular category. The XPath option is already used by the replication job UI and an example of {doclib} is in the FDK. Example config would be as follows: <form> .... <appearance> <field id="fdk:images"> <control> <control-param name="startLocation">{doclib}</control-param> </control> </field> <field id="fdk:reviews"> <control> <control-param name="startLocation">/app:company_home/app:dictionary/app:transfers/app:transfer_groups/cm:default</control-param> </control> </field> </appearance> </form> git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@21992 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -51,7 +51,6 @@ import org.alfresco.repo.thumbnail.ThumbnailDefinition;
|
||||
import org.alfresco.repo.thumbnail.ThumbnailRegistry;
|
||||
import org.alfresco.repo.thumbnail.script.ScriptThumbnail;
|
||||
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
|
||||
import org.alfresco.repo.transaction.TransactionUtil;
|
||||
import org.alfresco.repo.version.VersionModel;
|
||||
import org.alfresco.repo.workflow.jscript.JscriptWorkflowInstance;
|
||||
import org.alfresco.scripts.ScriptException;
|
||||
@@ -70,6 +69,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.cmr.repository.Path;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.repository.TemplateImageResolver;
|
||||
import org.alfresco.service.cmr.search.QueryParameterDefinition;
|
||||
@@ -136,6 +136,8 @@ public class ScriptNode implements Serializable, Scopeable, NamespacePrefixResol
|
||||
private String name;
|
||||
private QName type;
|
||||
protected String id;
|
||||
protected String siteName;
|
||||
protected boolean siteNameResolved = false;
|
||||
|
||||
/** The aspects applied to this node */
|
||||
protected Set<QName> aspects = null;
|
||||
@@ -2670,31 +2672,79 @@ public class ScriptNode implements Serializable, Scopeable, NamespacePrefixResol
|
||||
// ------------------------------------------------------------------------------
|
||||
// Workflow methods
|
||||
|
||||
/**
|
||||
* Get active workflow instances this node belongs to
|
||||
*
|
||||
* @return the active workflow instances this node belongs to
|
||||
*/
|
||||
public Scriptable getActiveWorkflows()
|
||||
{
|
||||
if (this.activeWorkflows == null)
|
||||
{
|
||||
WorkflowService workflowService = this.services.getWorkflowService();
|
||||
|
||||
List<WorkflowInstance> workflowInstances = workflowService.getWorkflowsForContent(this.nodeRef, true);
|
||||
Object[] jsWorkflowInstances = new Object[workflowInstances.size()];
|
||||
int index = 0;
|
||||
for (WorkflowInstance workflowInstance : workflowInstances)
|
||||
{
|
||||
jsWorkflowInstances[index++] = new JscriptWorkflowInstance(workflowInstance, this.services, this.scope);
|
||||
}
|
||||
this.activeWorkflows = Context.getCurrentContext().newArray(this.scope, jsWorkflowInstances);
|
||||
}
|
||||
|
||||
return this.activeWorkflows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get active workflow instances this node belongs to
|
||||
*
|
||||
* @return the active workflow instances this node belongs to
|
||||
*/
|
||||
public Scriptable getActiveWorkflows()
|
||||
{
|
||||
if (this.activeWorkflows == null)
|
||||
{
|
||||
WorkflowService workflowService = this.services.getWorkflowService();
|
||||
|
||||
List<WorkflowInstance> workflowInstances = workflowService.getWorkflowsForContent(this.nodeRef, true);
|
||||
Object[] jsWorkflowInstances = new Object[workflowInstances.size()];
|
||||
int index = 0;
|
||||
for (WorkflowInstance workflowInstance : workflowInstances)
|
||||
{
|
||||
jsWorkflowInstances[index++] = new JscriptWorkflowInstance(workflowInstance, this.services, this.scope);
|
||||
}
|
||||
this.activeWorkflows = Context.getCurrentContext().newArray(this.scope, jsWorkflowInstances);
|
||||
}
|
||||
|
||||
return this.activeWorkflows;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Site methods
|
||||
|
||||
/**
|
||||
* Returns the short name of the site this node is located within. If the
|
||||
* node is not located within a site null is returned.
|
||||
*
|
||||
* @return The short name of the site this node is located within, null
|
||||
* if the node is not located within a site.
|
||||
*/
|
||||
public String getSiteShortName()
|
||||
{
|
||||
if (!this.siteNameResolved)
|
||||
{
|
||||
this.siteNameResolved = true;
|
||||
|
||||
Path path = this.services.getNodeService().getPath(getNodeRef());
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Determing if node is within a site using path: " + path);
|
||||
|
||||
for (int i = 0; i < path.size(); i++)
|
||||
{
|
||||
if ("st:sites".equals(path.get(i).getPrefixedString(this.services.getNamespaceService())))
|
||||
{
|
||||
// we now know the node is in a site, find the next element in the array (if there is one)
|
||||
if ((i+1) < path.size())
|
||||
{
|
||||
// get the site name
|
||||
Path.Element siteName = path.get(i+1);
|
||||
|
||||
// remove the "cm:" prefix and add to result object
|
||||
this.siteName = siteName.getPrefixedString(this.services.getNamespaceService()).substring(3);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug(this.siteName != null ?
|
||||
"Node is in the site named \"" + this.siteName + "\"" : "Node is not in a site");
|
||||
}
|
||||
|
||||
return this.siteName;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Helper methods
|
||||
|
||||
@@ -2863,6 +2913,8 @@ public class ScriptNode implements Serializable, Scopeable, NamespacePrefixResol
|
||||
this.parent = null;
|
||||
this.primaryParentAssoc = null;
|
||||
this.activeWorkflows = null;
|
||||
this.siteName = null;
|
||||
this.siteNameResolved = false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -37,6 +37,7 @@ import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.service.cmr.repository.ContentService;
|
||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
import org.alfresco.service.cmr.repository.FileTypeImageSize;
|
||||
import org.alfresco.service.cmr.repository.Path;
|
||||
import org.alfresco.service.cmr.repository.TemplateImageResolver;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.springframework.extensions.surf.util.URLEncoder;
|
||||
@@ -70,6 +71,8 @@ public abstract class BaseContentNode implements TemplateContent
|
||||
private Boolean isContainer = null;
|
||||
private Boolean isLinkToDocument = null;
|
||||
private Boolean isLinkToContainer = null;
|
||||
private String siteName;
|
||||
private boolean siteNameResolved = false;
|
||||
|
||||
/**
|
||||
* @return true if this Node is a container (i.e. a folder)
|
||||
@@ -493,6 +496,45 @@ public abstract class BaseContentNode implements TemplateContent
|
||||
return (o instanceof TemplateNodeRef);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Site methods
|
||||
|
||||
/**
|
||||
* Returns the short name of the site this node is located within. If the
|
||||
* node is not located within a site null is returned.
|
||||
*
|
||||
* @return The short name of the site this node is located within, null
|
||||
* if the node is not located within a site.
|
||||
*/
|
||||
public String getSiteShortName()
|
||||
{
|
||||
if (!this.siteNameResolved)
|
||||
{
|
||||
this.siteNameResolved = true;
|
||||
|
||||
Path path = this.services.getNodeService().getPath(getNodeRef());
|
||||
|
||||
for (int i = 0; i < path.size(); i++)
|
||||
{
|
||||
if ("st:sites".equals(path.get(i).getPrefixedString(this.services.getNamespaceService())))
|
||||
{
|
||||
// we now know the node is in a site, find the next element in the array (if there is one)
|
||||
if ((i+1) < path.size())
|
||||
{
|
||||
// get the site name
|
||||
Path.Element siteName = path.get(i+1);
|
||||
|
||||
// remove the "cm:" prefix and add to result object
|
||||
this.siteName = siteName.getPrefixedString(this.services.getNamespaceService()).substring(3);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this.siteName;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Inner classes
|
||||
|
Reference in New Issue
Block a user