Merged HEAD-BUG-FIX (5.0/Cloud) to HEAD (5.0/Cloud)

78403: Merged EOL (5.0/Cloud) to HEAD-BUG-FIX (5.0/Cloud)
      75700: ACE-2149: EOL AVM / WCM
       - Remove most of the AVM and WCM beans, scripts, classes, patches, etc
       - The Explorer client is very broken for compilation
         - TODO: Remove all WCM-related functionality, which I thought would be best left to a UI dev
                 I've murdered many of the classes and beans but there's more to do
       - The repository compiles
         TODO: Get it running again
       - TODO: Check if we can wipe the 'deployment' project as well


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@82540 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Erik Winlof
2014-09-03 12:01:49 +00:00
parent eaff240152
commit 0baa0f74f4
284 changed files with 206 additions and 58844 deletions

View File

@@ -1,235 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.template;
import java.util.ArrayList;
import java.util.List;
import org.alfresco.config.JNDIConstants;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
import org.alfresco.service.cmr.avm.AVMStoreDescriptor;
import org.springframework.extensions.surf.util.ParameterCheck;
import org.alfresco.wcm.asset.AssetInfo;
import org.alfresco.wcm.sandbox.SandboxService;
import org.alfresco.wcm.util.WCMUtil;
/**
* AVM root object access for a template model.
*
* @author Kevin Roast
*/
public class AVM extends BaseTemplateProcessorExtension
{
private ServiceRegistry services;
/**
* Sets the service registry
*
* @param services the service registry
*/
public void setServiceRegistry(ServiceRegistry services)
{
this.services = services;
}
/**
* @return a list of all AVM stores in the system
*/
public List<AVMTemplateStore> getStores()
{
List<AVMStoreDescriptor> stores = this.services.getAVMService().getStores();
List<AVMTemplateStore> results = new ArrayList<AVMTemplateStore>(stores.size());
for (AVMStoreDescriptor store : stores)
{
results.add(new AVMTemplateStore(this.services, getTemplateImageResolver(), store));
}
return results;
}
/**
* Return an AVM store object for the specified store name
*
* @param store Store name to lookup
*
* @return the AVM store object for the specified store or null if not found
*/
public AVMTemplateStore lookupStore(String store)
{
ParameterCheck.mandatoryString("Store", store);
AVMTemplateStore avmStore = null;
AVMStoreDescriptor descriptor = this.services.getAVMService().getStore(store);
if (descriptor != null)
{
avmStore = new AVMTemplateStore(this.services, getTemplateImageResolver(), descriptor);
}
return avmStore;
}
/**
* Return the root node for a specified AVM store
*
* @param store Store name to find root node for
*
* @return the AVM store root node for the specified store or null if not found.
*/
public AVMTemplateNode lookupStoreRoot(String store)
{
ParameterCheck.mandatoryString("Store", store);
AVMTemplateNode root = null;
AVMTemplateStore avmStore = lookupStore(store);
if (avmStore != null)
{
root = avmStore.getLookupRoot();
}
return root;
}
/**
* Look a node by the absolute path. Path should include the store reference.
*
* @param path Absolute path to the node, including store reference.
*
* @return the node if found, null otherwise.
*/
public AVMTemplateNode lookupNode(String path)
{
ParameterCheck.mandatoryString("AVM Path", path);
AVMTemplateNode node = null;
AVMNodeDescriptor nodeDesc = this.services.getAVMService().lookup(-1, path);
if (nodeDesc != null)
{
node = new AVMTemplateNode(path, -1, this.services, getTemplateImageResolver());
}
return node;
}
/**
* Return the list of modified items for the specified user sandbox against staging store id
* for a specific webapp.
*
* @param storeId Root Store ID
* @param username Username to get modified items for
* @param webapp Webapp name to filter by
*
* @return List of AVMTemplateNode objects representing the modified items
*/
public List<AVMTemplateNode> getModifiedItems(String storeId, String username, String webapp)
{
ParameterCheck.mandatoryString("Store ID", storeId);
ParameterCheck.mandatoryString("Username", username);
ParameterCheck.mandatoryString("Webapp", webapp);
SandboxService sbService = this.services.getSandboxService();
String userStoreId = userSandboxStore(storeId, username);
// get modified items - not including deleted
List<AssetInfo> assets = sbService.listChangedWebApp(userStoreId, webapp, false);
List<AVMTemplateNode> items = new ArrayList<AVMTemplateNode>(assets.size());
for (AssetInfo asset : assets)
{
// convert each diff/node record into an AVM Node template wrapper
items.add(new AVMTemplateNode(asset.getAvmPath(), -1, this.services, getTemplateImageResolver()));
}
return items;
}
/**
* @param storeId Store ID to build staging store name for
*
* @return the Staging Store name for the given store ID
*/
public static String stagingStore(String storeId)
{
return WCMUtil.buildStagingStoreName(storeId);
}
/**
* @param storeId Store ID to build sandbox store name for
* @param username Username of the sandbox user
*
* @return the Sandbox Store name for the given store ID and username
*/
public static String userSandboxStore(String storeId, String username)
{
return WCMUtil.buildUserMainStoreName(storeId, username);
}
/**
* @param storeId Store ID to build preview URL for
*
* @return the preview URL to the staging store for the specified store ID
*/
public String websiteStagingUrl(String storeId)
{
return this.services.getPreviewURIService().getPreviewURI(storeId, null);
}
/**
* @param storeId Store ID to build preview URL for
* @param username Username to build sandbox preview URL for
*
* @return the preview URL to the user sandbox for the specified store ID and username
*/
public String websiteUserSandboxUrl(String storeId, String username)
{
ParameterCheck.mandatoryString("Store ID", storeId);
ParameterCheck.mandatoryString("Username", username);
return websiteStagingUrl(userSandboxStore(storeId, username));
}
/**
* @param store Store ID of the asset
* @param assetPath Store relative path to the asset
*
* @return the preview URL to the specified store asset
*/
public String assetUrl(String storeId, String assetPath)
{
return this.services.getPreviewURIService().getPreviewURI(storeId, assetPath);
}
/**
* @param avmPath Fully qualified AVM path of the asset
*
* @return the preview URL to the specified asset
*/
public String assetUrl(String avmPath)
{
ParameterCheck.mandatoryString("AVM Path", avmPath);
String[] s = avmPath.split(":");
if (s.length != 2)
{
throw new IllegalArgumentException("Expected exactly one ':' in " + avmPath);
}
return assetUrl(s[0], s[1]);
}
/**
* @return the path to the webapps folder in a standard web store.
*/
public static String getWebappsFolderPath()
{
return JNDIConstants.DIR_DEFAULT_WWW_APPBASE;
}
}

View File

@@ -1,601 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.template;
import java.io.Serializable;
import java.io.StringReader;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.alfresco.model.WCMModel;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.repo.domain.PropertyValue;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
import org.alfresco.service.cmr.avm.locking.AVMLockingService.LockState;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.ContentData;
import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.repository.TemplateImageResolver;
import org.alfresco.service.namespace.NamespacePrefixResolver;
import org.alfresco.service.namespace.NamespacePrefixResolverProvider;
import org.alfresco.service.namespace.QName;
import org.alfresco.service.namespace.QNameMap;
import org.alfresco.util.Pair;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.extensions.surf.util.URLEncoder;
import org.xml.sax.InputSource;
import freemarker.ext.dom.NodeModel;
/**
* AVM node class for use by a Template model.
* <p>
* The class exposes Node properties, children as dynamically populated maps and lists.
* <p>
* Various helper methods are provided to access common and useful node variables such
* as the content url and type information.
* <p>
* See {@link http://wiki.alfresco.com/wiki/Template_Guide}
*
* @author Kevin Roast
*/
@SuppressWarnings("serial")
public class AVMTemplateNode extends BasePermissionsNode implements NamespacePrefixResolverProvider
{
private static Log logger = LogFactory.getLog(AVMTemplateNode.class);
/** Cached values */
private NodeRef nodeRef;
private String name;
private QName type;
private String path;
private int version;
private boolean deleted;
private QNameMap<String, Serializable> properties;
private boolean propsRetrieved = false;
private AVMTemplateNode parent = null;
private AVMNodeDescriptor avmRef;
// ------------------------------------------------------------------------------
// Construction
/**
* Constructor
*
* @param nodeRef The NodeRef for the AVM node this wrapper represents
* @param services The ServiceRegistry the Node can use to access services
* @param resolver Image resolver to use to retrieve icons
*/
public AVMTemplateNode(NodeRef nodeRef, ServiceRegistry services, TemplateImageResolver resolver)
{
if (nodeRef == null)
{
throw new IllegalArgumentException("NodeRef must be supplied.");
}
if (services == null)
{
throw new IllegalArgumentException("The ServiceRegistry must be supplied.");
}
this.nodeRef = nodeRef;
Pair<Integer, String> pair = AVMNodeConverter.ToAVMVersionPath(nodeRef);
this.services = services;
this.imageResolver = resolver;
init(pair.getFirst(), pair.getSecond(), null);
}
/**
* Constructor
*
* @param path AVM path to the node
* @param version Version number for avm path
* @param services The ServiceRegistry the Node can use to access services
* @param resolver Image resolver to use to retrieve icons
*/
public AVMTemplateNode(String path, int version, ServiceRegistry services, TemplateImageResolver resolver)
{
if (path == null)
{
throw new IllegalArgumentException("Path must be supplied.");
}
if (services == null)
{
throw new IllegalArgumentException("The ServiceRegistry must be supplied.");
}
this.nodeRef = AVMNodeConverter.ToNodeRef(version, path);
this.services = services;
this.imageResolver = resolver;
init(version, path, null);
}
/**
* Constructor
*
* @param descriptor AVMNodeDescriptior
* @param services
* @param resolver
*/
public AVMTemplateNode(AVMNodeDescriptor descriptor, ServiceRegistry services, TemplateImageResolver resolver)
{
if (descriptor == null)
{
throw new IllegalArgumentException("AVMNodeDescriptor must be supplied.");
}
if (services == null)
{
throw new IllegalArgumentException("The ServiceRegistry must be supplied.");
}
this.version = -1;
this.path = descriptor.getPath();
this.nodeRef = AVMNodeConverter.ToNodeRef(this.version, this.path);
this.services = services;
this.imageResolver = resolver;
init(this.version, this.path, descriptor);
}
private void init(int version, String path, AVMNodeDescriptor descriptor)
{
this.version = version;
this.path = path;
this.properties = new QNameMap<String, Serializable>(this);
if (descriptor == null)
{
descriptor = this.services.getAVMService().lookup(version, path, true);
if (descriptor == null)
{
throw new IllegalArgumentException("Invalid node specified: " + nodeRef.toString());
}
}
this.avmRef = descriptor;
this.deleted = descriptor.isDeleted();
}
// ------------------------------------------------------------------------------
// AVM Node API
/**
* @return ID for the AVM path - the path.
*/
public String getId()
{
return this.path;
}
/**
* @return the path for this AVM node.
*/
public String getPath()
{
return this.path;
}
/**
* @return the version part of the AVM path.
*/
public int getVersion()
{
return this.version;
}
/**
* @return file/folder name of the AVM path.
*/
public String getName()
{
if (this.name == null)
{
this.name = AVMNodeConverter.SplitBase(this.path)[1];
}
return this.name;
}
/**
* @return AVM path to the parent node
*/
public String getParentPath()
{
return AVMNodeConverter.SplitBase(this.path)[0];
}
/**
* @see org.alfresco.repo.template.TemplateNodeRef#getNodeRef()
*/
public NodeRef getNodeRef()
{
return this.nodeRef;
}
/**
* @see org.alfresco.repo.template.TemplateNodeRef#getType()
*/
public QName getType()
{
if (this.type == null)
{
if (this.deleted == false)
{
this.type = this.services.getNodeService().getType(this.nodeRef);
}
else
{
this.type = this.avmRef.isDeletedDirectory() ? WCMModel.TYPE_AVM_FOLDER : WCMModel.TYPE_AVM_CONTENT;
}
}
return type;
}
/**
* @return true if the item is a deleted node, false otherwise
*/
public boolean getIsDeleted()
{
return this.avmRef.isDeleted();
}
/**
* @return true if the node is currently locked
*/
public boolean getIsLocked()
{
String currentUser = AuthenticationUtil.getFullyAuthenticatedUser();
LockState lockStatus = this.services.getAVMLockingService().getLockState(
getWebProject(), path.substring(path.indexOf("/")), currentUser);
return lockStatus != LockState.NO_LOCK;
}
/**
* @return true if this node is locked and the current user is the lock owner
*/
public boolean getIsLockOwner()
{
String currentUser = AuthenticationUtil.getFullyAuthenticatedUser();
LockState lockStatus = this.services.getAVMLockingService().getLockState(
getWebProject(), path.substring(path.indexOf("/")), currentUser);
return lockStatus == LockState.LOCK_OWNER;
}
/**
* @return true if this user can perform operations on the node when locked.
* This is true if the item is either unlocked, or locked and the current user is the lock owner,
* or locked and the current user has Content Manager role in the associated web project.
*/
public boolean getHasLockAccess()
{
return this.services.getAVMLockingService().hasAccess(
getWebProject(), path, this.services.getAuthenticationService().getCurrentUserName());
}
// ------------------------------------------------------------------------------
// TemplateProperties API
/**
* @return the immediate parent in the node path (null if root of store)
*/
public TemplateProperties getParent()
{
if (this.parent == null)
{
String parentPath = this.getParentPath();
if (parentPath != null)
{
this.parent = new AVMTemplateNode(parentPath, this.version, this.services, this.imageResolver);
}
}
return this.parent;
}
/**
* @return true if this Node is a container (i.e. a folder)
*/
@Override
public boolean getIsContainer()
{
return this.avmRef.isDirectory() || this.avmRef.isDeletedDirectory();
}
/**
* @return true if this Node is a document (i.e. a file)
*/
@Override
public boolean getIsDocument()
{
return this.avmRef.isFile() || this.avmRef.isDeletedFile();
}
/**
* @see org.alfresco.repo.template.TemplateProperties#getChildren()
*/
public List<TemplateProperties> getChildren()
{
if (this.children == null)
{
// use the NodeService so appropriate permission checks are performed
List<ChildAssociationRef> childRefs = this.services.getNodeService().getChildAssocs(this.nodeRef);
this.children = new ArrayList<TemplateProperties>(childRefs.size());
for (ChildAssociationRef ref : childRefs)
{
// create our Node representation from the NodeRef
AVMTemplateNode child = new AVMTemplateNode(ref.getChildRef(), this.services, this.imageResolver);
this.children.add(child);
}
}
return this.children;
}
/**
* @see org.alfresco.repo.template.TemplateProperties#getProperties()
*/
@SuppressWarnings("unchecked")
public Map<String, Serializable> getProperties()
{
if (!this.propsRetrieved)
{
if (!this.deleted)
{
Map<QName, PropertyValue> props = this.services.getAVMService().getNodeProperties(this.version, this.path);
for (QName qname: props.keySet())
{
PropertyDefinition propertyDefinition = services.getDictionaryService().getProperty(qname);
QName currentPropertyType = DataTypeDefinition.ANY;
if (null != propertyDefinition)
{
currentPropertyType = propertyDefinition.getDataType().getName();
}
Serializable propValue = props.get(qname).getValue(currentPropertyType);
if (propValue instanceof NodeRef)
{
// NodeRef object properties are converted to new TemplateNode objects
// so they can be used as objects within a template
NodeRef nodeRef = (NodeRef)propValue;
if (StoreRef.PROTOCOL_AVM.equals(nodeRef.getStoreRef().getProtocol()))
{
propValue = new AVMTemplateNode(nodeRef, this.services, this.imageResolver);
}
else
{
propValue = new TemplateNode(nodeRef, this.services, this.imageResolver);
}
}
else if (propValue instanceof ContentData)
{
// ContentData object properties are converted to TemplateContentData objects
// so the content and other properties of those objects can be accessed
propValue = new TemplateContentData((ContentData)propValue, qname);
}
this.properties.put(qname.toString(), propValue);
}
}
// AVM node properties not available in usual getProperties() call
this.properties.put("name", this.avmRef.getName());
this.properties.put("created", new Date(this.avmRef.getCreateDate()));
this.properties.put("modified", new Date(this.avmRef.getModDate()));
this.properties.put("creator", this.avmRef.getCreator());
this.properties.put("modifier", this.avmRef.getLastModifier());
this.propsRetrieved = true;
}
return this.properties;
}
/**
* @return The list of aspects applied to this node
*/
@Override
public Set<QName> getAspects()
{
if (this.aspects == null)
{
this.aspects = this.services.getAVMService().getAspects(this.version, this.path);
}
return this.aspects;
}
// ------------------------------------------------------------------------------
// Content API
/**
* @return the content String for this node from the default content property
* (@see ContentModel.PROP_CONTENT)
*/
public String getContent()
{
ContentReader reader = this.services.getAVMService().getContentReader(this.version, this.path);
return (reader != null && reader.exists()) ? reader.getContentString() : "";
}
/**
* @return For a content document, this method returns the URL to the content stream for
* the default content property (@see ContentModel.PROP_CONTENT)
* <p>
* For a container node, this method return the URL to browse to the folder in the web-client
*/
public String getUrl()
{
if (getIsDocument() == true)
{
return MessageFormat.format(CONTENT_GET_URL, new Object[] {
getNodeRef().getStoreRef().getProtocol(),
getNodeRef().getStoreRef().getIdentifier(),
getNodeRef().getId(),
URLEncoder.encode(getName()) } );
}
else
{
return MessageFormat.format(FOLDER_BROWSE_URL, new Object[] {
getNodeRef().getStoreRef().getProtocol(),
getNodeRef().getStoreRef().getIdentifier(),
getNodeRef().getId() } );
}
}
/**
* @return For a content document, this method returns the download URL to the content for
* the default content property (@see ContentModel.PROP_CONTENT)
* <p>
* For a container node, this method returns an empty string
*/
public String getDownloadUrl()
{
if (getIsDocument() == true)
{
return MessageFormat.format(CONTENT_DOWNLOAD_URL, new Object[] {
getNodeRef().getStoreRef().getProtocol(),
getNodeRef().getStoreRef().getIdentifier(),
getNodeRef().getId(),
URLEncoder.encode(getName()) } );
}
else
{
return "";
}
}
/**
* @return The mimetype encoding for content attached to the node from the default content property
* (@see ContentModel.PROP_CONTENT)
*/
public String getMimetype()
{
if (getIsContainer())
{
return null;
}
return this.services.getAVMService().getContentDataForRead(this.avmRef).getMimetype();
}
/**
* @return The display label of the mimetype encoding for content attached to the node from the default
* content property (@see ContentModel.PROP_CONTENT)
*/
public String getDisplayMimetype()
{
if (getIsContainer())
{
return null;
}
final String mimetype = this.services.getAVMService().getContentDataForRead(this.avmRef).getMimetype();
return services.getMimetypeService().getDisplaysByMimetype().get(mimetype);
}
/**
* @return The character encoding for content attached to the node from the default content property
* (@see ContentModel.PROP_CONTENT)
*/
public String getEncoding()
{
if (getIsContainer())
{
return null;
}
return this.services.getAVMService().getContentDataForRead(this.avmRef).getEncoding();
}
/**
* @return The size in bytes of the content attached to the node from the default content property
* (@see ContentModel.PROP_CONTENT)
*/
public long getSize()
{
if (getIsContainer())
{
return -1;
}
return this.services.getAVMService().getContentDataForRead(this.avmRef).getSize();
}
// ------------------------------------------------------------------------------
// Node Helper API
/**
* @return FreeMarker NodeModel for the XML content of this node, or null if no parsable XML found
*/
public NodeModel getXmlNodeModel()
{
try
{
return NodeModel.parse(new InputSource(new StringReader(getContent())));
}
catch (Throwable err)
{
if (logger.isDebugEnabled())
logger.debug(err.getMessage(), err);
return null;
}
}
/**
* @return Display path to this node - the path built of 'cm:name' attribute values.
*/
@Override
public String getDisplayPath()
{
return this.path;
}
public NamespacePrefixResolver getNamespacePrefixResolver()
{
return this.services.getNamespaceService();
}
// ------------------------------------------------------------------------------
// Private helpers
/**
* @return the WebProject identifier for the current path
*/
private String getWebProject()
{
String webProject = this.path.substring(0, this.path.indexOf(':'));
int index = webProject.indexOf("--");
if (index != -1)
{
webProject = webProject.substring(0, index);
}
return webProject;
}
}

View File

@@ -1,182 +0,0 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.template;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.repo.jscript.ScriptNode;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
import org.alfresco.service.cmr.avm.AVMStoreDescriptor;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.repository.TemplateImageResolver;
import org.alfresco.service.cmr.search.ResultSet;
import org.alfresco.service.cmr.search.ResultSetRow;
import org.alfresco.service.cmr.search.SearchService;
/**
* Representation of an AVM Store for the template model. Accessed via the AVM helper object
* and is responsible for returning AVMTemplateNode objects via various mechanisms.
*
* @author Kevin Roast
*/
public class AVMTemplateStore
{
private ServiceRegistry services;
private AVMStoreDescriptor descriptor;
private TemplateImageResolver resolver;
/**
* Constructor
*
* @param services
* @param resolver
* @param store Store descriptor this object represents
*/
public AVMTemplateStore(ServiceRegistry services, TemplateImageResolver resolver, AVMStoreDescriptor store)
{
this.descriptor = store;
this.services = services;
this.resolver = resolver;
}
/**
* @return Store name
*/
public String getName()
{
return this.descriptor.getName();
}
/**
* @return Store name
*/
public String getId()
{
return this.descriptor.getName();
}
/**
* @return User who created the store
*/
public String getCreator()
{
return this.descriptor.getCreator();
}
/**
* @return Creation date of the store
*/
public Date getCreatedDate()
{
return new Date(this.descriptor.getCreateDate());
}
/**
* @return the root node of all webapps in the store
*/
public AVMTemplateNode getLookupRoot()
{
AVMTemplateNode rootNode = null;
String rootPath = this.descriptor.getName() + ':' + AVM.getWebappsFolderPath();
AVMNodeDescriptor nodeDesc = this.services.getAVMService().lookup(-1, rootPath);
if (nodeDesc != null)
{
rootNode = new AVMTemplateNode(rootPath, -1, this.services, this.resolver);
}
return rootNode;
}
/**
* Lookup a node in the store, the path is assumed to be related to the webapps folder root.
* Therefore a valid path would be "/ROOT/WEB-INF/lib/web.xml".
*
* @param path Relative to the webapps folder root path for this store.
*
* @return node if found, null otherwise.
*/
public AVMTemplateNode lookupNode(String path)
{
AVMTemplateNode node = null;
if (path != null && path.length() != 0)
{
if (path.charAt(0) != '/')
{
path = '/' + path;
}
path = this.descriptor.getName() + ':' + AVM.getWebappsFolderPath() + path;
AVMNodeDescriptor nodeDesc = this.services.getAVMService().lookup(-1, path);
if (nodeDesc != null)
{
node = new AVMTemplateNode(path, -1, this.services, this.resolver);
}
}
return node;
}
/**
* Perform a lucene query against this store.
*
* @param query Lucene
*
* @return list of AVM node objects as results - empty list if no results found
*/
public List<AVMTemplateNode> luceneSearch(String query)
{
List<AVMTemplateNode> nodes = null;
// perform the search against the repo
ResultSet results = null;
try
{
results = this.services.getSearchService().query(
new StoreRef(StoreRef.PROTOCOL_AVM, this.descriptor.getName()),
SearchService.LANGUAGE_LUCENE,
query);
if (results.length() != 0)
{
nodes = new ArrayList<AVMTemplateNode>(results.length());
for (ResultSetRow row : results)
{
NodeRef nodeRef = row.getNodeRef();
nodes.add(new AVMTemplateNode(nodeRef, this.services, this.resolver));
}
}
}
catch (Throwable err)
{
throw new AlfrescoRuntimeException("Failed to execute search: " + query, err);
}
finally
{
if (results != null)
{
results.close();
}
}
return (nodes != null ? nodes : (List)Collections.emptyList());
}
}

View File

@@ -30,7 +30,6 @@ import org.alfresco.processor.ProcessorExtension;
import org.alfresco.repo.processor.BaseProcessor;
import org.alfresco.service.cmr.repository.AssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.repository.TemplateException;
import org.alfresco.service.cmr.repository.TemplateImageResolver;
import org.alfresco.service.cmr.repository.TemplateProcessor;
@@ -408,14 +407,7 @@ public class FreeMarkerProcessor extends BaseProcessor implements TemplateProces
if (value instanceof NodeRef)
{
NodeRef ref = (NodeRef)value;
if (StoreRef.PROTOCOL_AVM.equals(ref.getStoreRef().getProtocol()))
{
return new AVMTemplateNode((NodeRef)value, this.services, imageResolver);
}
else
{
return new TemplateNode((NodeRef)value, this.services, imageResolver);
}
return new TemplateNode((NodeRef)value, this.services, imageResolver);
}
else if (value instanceof AssociationRef)

View File

@@ -27,7 +27,6 @@ import java.util.Map;
import org.alfresco.model.ApplicationModel;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.repo.forms.processor.workflow.ExtendedFieldBuilder;
import org.alfresco.repo.workflow.WorkflowModel;
import org.alfresco.service.ServiceRegistry;
@@ -263,27 +262,17 @@ public class Workflow extends BaseTemplateProcessorExtension
for(NodeRef nodeRef : contents)
{
if (nodeRef.getStoreRef().getProtocol().equals(StoreRef.PROTOCOL_AVM))
{
Pair<Integer, String> vp = AVMNodeConverter.ToAVMVersionPath(nodeRef);
resources.add(new AVMTemplateNode(
vp.getSecond(), vp.getFirst(), this.services, this.resolver));
}
else
{
QName type = nodeService.getType(nodeRef);
QName type = nodeService.getType(nodeRef);
// make sure the type is defined in the data dictionary
if (ddService.getType(type) != null)
// make sure the type is defined in the data dictionary
if (ddService.getType(type) != null)
{
// look for content nodes or links to content
// NOTE: folders within workflow packages are ignored for now
if (ddService.isSubClass(type, ContentModel.TYPE_CONTENT) ||
ApplicationModel.TYPE_FILELINK.equals(type))
{
// look for content nodes or links to content
// NOTE: folders within workflow packages are ignored for now
if (ddService.isSubClass(type, ContentModel.TYPE_CONTENT) ||
ApplicationModel.TYPE_FILELINK.equals(type))
{
resources.add(new TemplateNode(nodeRef, this.services, this.resolver));
}
resources.add(new TemplateNode(nodeRef, this.services, this.resolver));
}
}
}