mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
12943: Port of support for ADB-47 from V2.1-A to 3.1 12948: Port of tests from CHK-2235 for ADB-20 from V2.1-A to 3.1 12965: Activated index tracker Quartz job by default 12974: Port for lazy creation of home folders with configuration from V2.1-A to V3.1: original CHK-2619, CHK-2716 12976: Merged V2.1A to V3.1 8562: (record-only) Fix to lazily create home folders - DO NOT MERGE 8694: (record-only) Added configuration for lazy or eager creation of home folders 12978: Merged V3.0 to V3.1 12920: Merged V2.2 to V3.0 12456: Wire up AVM locking service by interface to allow for potential over-ride 12457: Make AVM ChildKey case insensitive 12470: Merged V2.2.1-NBC-FIXES to V2.2 12156: Optimizations to WCMWorkflowEvaluator and WCMWorkflowDeletedEvaluator 12605: Hide annoying "Virtualisation Server not started" warnings (by making them debug) 12707: AVM console - "snap" also allows tag and description to be specified 12979: Build/test fix ___________________________________________________________________ Modified: svn:mergeinfo Merged /alfresco/BRANCHES/DEV/V2.2.1-NBC-FIXES:r12156 Merged /alfresco/BRANCHES/V2.1-A:r8562,8694 Merged /alfresco/BRANCHES/V3.0:r12920 Merged /alfresco/BRANCHES/V2.2:r12456-12457,12470,12605,12707 Merged /alfresco/BRANCHES/V3.1:r12943,12948,12965,12974,12976,12978-12979 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@13544 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
408 lines
11 KiB
Java
408 lines
11 KiB
Java
/*
|
|
* Copyright (C) 2005-2009 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.wcm;
|
|
|
|
import java.util.Collection;
|
|
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.web.scripts.FileTypeImageUtils;
|
|
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
|
|
import org.alfresco.service.cmr.avm.LayeringDescriptor;
|
|
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
|
import org.alfresco.service.cmr.repository.Path;
|
|
import org.alfresco.service.cmr.workflow.WorkflowTask;
|
|
import org.alfresco.service.namespace.QName;
|
|
import org.alfresco.wcm.asset.AssetInfo;
|
|
import org.alfresco.wcm.asset.AssetInfoImpl;
|
|
import org.alfresco.web.bean.BrowseBean;
|
|
import org.alfresco.web.bean.repository.Node;
|
|
import org.alfresco.web.bean.repository.NodePropertyResolver;
|
|
|
|
/**
|
|
* 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 extends Node implements Map<String, Object>
|
|
{
|
|
private static final long serialVersionUID = 2200295347489543757L;
|
|
|
|
public final static NodePropertyResolver RESOLVER_PREVIEW_URL =
|
|
new NodePropertyResolver()
|
|
{
|
|
private static final long serialVersionUID = -8437274476137672895L;
|
|
|
|
public Object get(final Node node)
|
|
{
|
|
if (! (node instanceof AVMNode))
|
|
{
|
|
return null;
|
|
}
|
|
final String storeId = AVMUtil.getStoreName(node.getPath());
|
|
final String assetPath = AVMUtil.getStoreRelativePath(node.getPath());
|
|
return AVMUtil.getPreviewURI(storeId, assetPath);
|
|
}
|
|
};
|
|
|
|
public final static NodePropertyResolver RESOLVER_SANDBOX_RELATIVE_PATH =
|
|
new NodePropertyResolver()
|
|
{
|
|
private static final long serialVersionUID = -2367701285830581225L;
|
|
|
|
public Object get(final Node node)
|
|
{
|
|
if (! (node instanceof AVMNode))
|
|
{
|
|
return null;
|
|
}
|
|
String s = node.getPath();
|
|
s = AVMUtil.getSandboxRelativePath(s);
|
|
final Path result = new Path();
|
|
final String[] parts = s.split("/");
|
|
for (int i = 1; i < parts.length; i++)
|
|
{
|
|
if (parts[i].length() != 0)
|
|
{
|
|
final String s2 = parts[i];
|
|
result.append(new Path.Element()
|
|
{
|
|
public String getElementString() { return s2; }
|
|
});
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
};
|
|
|
|
public final static NodePropertyResolver RESOLVER_FILE_TYPE_16 =
|
|
new NodePropertyResolver()
|
|
{
|
|
private static final long serialVersionUID = 4300079423348609858L;
|
|
|
|
public Object get(final Node node)
|
|
{
|
|
if (! (node instanceof AVMNode))
|
|
{
|
|
return null;
|
|
}
|
|
if (((AVMNode)node).isDirectory())
|
|
{
|
|
return "/images/icons/" + BrowseBean.SPACE_SMALL_DEFAULT + ".gif";
|
|
}
|
|
else
|
|
{
|
|
return FileTypeImageUtils.getFileTypeImage(node.getName(), true);
|
|
}
|
|
}
|
|
};
|
|
|
|
public final static NodePropertyResolver RESOLVER_DISPLAY_PATH =
|
|
new NodePropertyResolver()
|
|
{
|
|
private static final long serialVersionUID = 368552730555134975L;
|
|
|
|
public Object get(final Node node)
|
|
{
|
|
if (! (node instanceof AVMNode))
|
|
{
|
|
return null;
|
|
}
|
|
|
|
// the display path is the parent path to the node
|
|
String parentPath = AVMNodeConverter.SplitBase(node.getPath())[0];
|
|
return AVMUtil.getSandboxRelativePath(parentPath);
|
|
}
|
|
};
|
|
|
|
public final static NodePropertyResolver RESOLVER_PARENT_PATH =
|
|
new NodePropertyResolver()
|
|
{
|
|
private static final long serialVersionUID = -798036430912409497L;
|
|
|
|
public Object get(final Node node)
|
|
{
|
|
if (! (node instanceof AVMNode))
|
|
{
|
|
return null;
|
|
}
|
|
|
|
return AVMNodeConverter.SplitBase(node.getPath())[0];
|
|
}
|
|
};
|
|
|
|
private final AVMNodeDescriptor avmRef;
|
|
private LayeringDescriptor layeringDesc;
|
|
private final int version;
|
|
private final boolean deleted;
|
|
private Boolean workflowInFlight;
|
|
|
|
public AVMNode(final AssetInfo asset)
|
|
{
|
|
super(AVMNodeConverter.ToNodeRef(-1, asset.getAvmPath()));
|
|
|
|
// TODO - refactor !!
|
|
this.avmRef = ((AssetInfoImpl)asset).getAVMNodeDescriptor();
|
|
|
|
this.version = -1; // TODO: always -1 for now...
|
|
this.id = asset.getAvmPath();
|
|
this.deleted = asset.isDeleted();
|
|
}
|
|
|
|
/**
|
|
* Constructor
|
|
*
|
|
* @param avmRef The AVMNodeDescriptor that describes this node
|
|
*/
|
|
public AVMNode(final AVMNodeDescriptor avmRef)
|
|
{
|
|
super(AVMNodeConverter.ToNodeRef(-1, avmRef.getPath()));
|
|
this.avmRef = avmRef;
|
|
this.version = -1; // TODO: always -1 for now...
|
|
this.id = avmRef.getPath();
|
|
this.deleted = avmRef.isDeleted();
|
|
}
|
|
|
|
@Override
|
|
public String getPath()
|
|
{
|
|
return this.avmRef.getPath();
|
|
}
|
|
|
|
public final AVMNodeDescriptor getDescriptor()
|
|
{
|
|
return avmRef;
|
|
}
|
|
|
|
public int getVersion()
|
|
{
|
|
return this.version;
|
|
}
|
|
|
|
@Override
|
|
public String getName()
|
|
{
|
|
return this.avmRef.getName();
|
|
}
|
|
|
|
@Override
|
|
public QName getType()
|
|
{
|
|
if (this.type == null)
|
|
{
|
|
if (this.deleted == false)
|
|
{
|
|
this.type = getServiceRegistry().getNodeService().getType(this.nodeRef);
|
|
}
|
|
else
|
|
{
|
|
this.type = avmRef.isDeletedDirectory() ? WCMModel.TYPE_AVM_FOLDER : WCMModel.TYPE_AVM_CONTENT;
|
|
}
|
|
}
|
|
|
|
return type;
|
|
}
|
|
|
|
public final boolean isDirectory()
|
|
{
|
|
return this.avmRef.isDirectory() || this.avmRef.isDeletedDirectory();
|
|
}
|
|
|
|
public final boolean isFile()
|
|
{
|
|
return this.avmRef.isFile() || this.avmRef.isDeletedFile();
|
|
}
|
|
|
|
public final boolean isDeleted()
|
|
{
|
|
return this.avmRef.isDeleted();
|
|
}
|
|
|
|
public final boolean isModified()
|
|
{
|
|
if (this.layeringDesc == null)
|
|
{
|
|
this.layeringDesc = getServiceRegistry().getAVMService().getLayeringInfo(this.version, this.id);
|
|
}
|
|
return !this.layeringDesc.isBackground();
|
|
}
|
|
|
|
public final boolean isWorkflowInFlight(List<WorkflowTask> tasks)
|
|
{
|
|
if (this.workflowInFlight == null)
|
|
{
|
|
if (!this.isModified())
|
|
{
|
|
this.workflowInFlight = false;
|
|
}
|
|
else
|
|
{
|
|
this.workflowInFlight = AVMWorkflowUtil.getAssociatedTasksForNode(this.avmRef, tasks).size() != 0;
|
|
}
|
|
}
|
|
return this.workflowInFlight;
|
|
}
|
|
|
|
/**
|
|
* @return All the properties known about this node.
|
|
*/
|
|
public Map<String, Object> getProperties()
|
|
{
|
|
if (!this.propsRetrieved)
|
|
{
|
|
if (!this.deleted)
|
|
{
|
|
Map<QName, PropertyValue> props = getServiceRegistry().getAVMService().getNodeProperties(this.version, this.id);
|
|
for (QName qname: props.keySet())
|
|
{
|
|
PropertyValue propValue = props.get(qname);
|
|
this.properties.put(qname.toString(), propValue.getValue(DataTypeDefinition.ANY));
|
|
}
|
|
}
|
|
|
|
this.properties.put("id", this.id);
|
|
this.properties.put("nodeRef", this.nodeRef);
|
|
this.properties.put("size", this.avmRef.getLength());
|
|
this.properties.put("name", this.avmRef.getName());
|
|
this.properties.put("created", this.avmRef.getCreateDate());
|
|
this.properties.put("modified", this.avmRef.getModDate());
|
|
this.properties.put("creator", this.avmRef.getCreator());
|
|
this.properties.put("modifier", this.avmRef.getLastModifier());
|
|
this.properties.put("deleted", this.deleted);
|
|
|
|
this.propsRetrieved = true;
|
|
}
|
|
|
|
return this.properties;
|
|
}
|
|
|
|
|
|
// ------------------------------------------------------------------------------------
|
|
// Map implementation - allows the Node bean to be accessed using JSF expression syntax
|
|
|
|
/**
|
|
* @see java.util.Map#clear()
|
|
*/
|
|
public void clear()
|
|
{
|
|
getProperties().clear();
|
|
}
|
|
|
|
/**
|
|
* @see java.util.Map#containsKey(java.lang.Object)
|
|
*/
|
|
public boolean containsKey(Object key)
|
|
{
|
|
return getProperties().containsKey(key);
|
|
}
|
|
|
|
/**
|
|
* @see java.util.Map#containsValue(java.lang.Object)
|
|
*/
|
|
public boolean containsValue(Object value)
|
|
{
|
|
return getProperties().containsKey(value);
|
|
}
|
|
|
|
/**
|
|
* @see java.util.Map#entrySet()
|
|
*/
|
|
public Set entrySet()
|
|
{
|
|
return getProperties().entrySet();
|
|
}
|
|
|
|
/**
|
|
* @see java.util.Map#get(java.lang.Object)
|
|
*/
|
|
public Object get(Object key)
|
|
{
|
|
return getProperties().get(key);
|
|
}
|
|
|
|
/**
|
|
* @see java.util.Map#isEmpty()
|
|
*/
|
|
public boolean isEmpty()
|
|
{
|
|
return getProperties().isEmpty();
|
|
}
|
|
|
|
/**
|
|
* @see java.util.Map#keySet()
|
|
*/
|
|
public Set keySet()
|
|
{
|
|
return getProperties().keySet();
|
|
}
|
|
|
|
/**
|
|
* @see java.util.Map#put(java.lang.Object, java.lang.Object)
|
|
*/
|
|
public Object put(String key, Object value)
|
|
{
|
|
return getProperties().put(key, value);
|
|
}
|
|
|
|
/**
|
|
* @see java.util.Map#putAll(java.util.Map)
|
|
*/
|
|
public void putAll(Map t)
|
|
{
|
|
getProperties().putAll(t);
|
|
}
|
|
|
|
/**
|
|
* @see java.util.Map#remove(java.lang.Object)
|
|
*/
|
|
public Object remove(Object key)
|
|
{
|
|
return getProperties().remove(key);
|
|
}
|
|
|
|
/**
|
|
* @see java.util.Map#size()
|
|
*/
|
|
public int size()
|
|
{
|
|
return getProperties().size();
|
|
}
|
|
|
|
/**
|
|
* @see java.util.Map#values()
|
|
*/
|
|
public Collection values()
|
|
{
|
|
return getProperties().values();
|
|
}
|
|
}
|