. Merge horrors fixed

. Code compile issue fixed

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4669 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2006-12-20 10:03:44 +00:00
parent e6f28374a5
commit ec80a72900
11 changed files with 1932 additions and 1926 deletions

View File

@@ -333,10 +333,10 @@ public class MailActionExecuter extends ActionExecuterAbstractBase
Map<String, Object> model = new HashMap<String, Object>(8, 1.0f); Map<String, Object> model = new HashMap<String, Object>(8, 1.0f);
NodeRef person = personService.getPerson(authService.getCurrentUserName()); NodeRef person = personService.getPerson(authService.getCurrentUserName());
model.put("person", new TemplateNode(person, serviceRegistry)); model.put("person", new TemplateNode(person, serviceRegistry, null));
model.put("document", new TemplateNode(ref, serviceRegistry)); model.put("document", new TemplateNode(ref, serviceRegistry, null));
NodeRef parent = serviceRegistry.getNodeService().getPrimaryParent(ref).getParentRef(); NodeRef parent = serviceRegistry.getNodeService().getPrimaryParent(ref).getParentRef();
model.put("space", new TemplateNode(parent, serviceRegistry)); model.put("space", new TemplateNode(parent, serviceRegistry, null));
// current date/time is useful to have and isn't supplied by FreeMarker by default // current date/time is useful to have and isn't supplied by FreeMarker by default
model.put("date", new Date()); model.put("date", new Date());

View File

@@ -68,7 +68,7 @@ public final class AVM extends BaseScriptImplementation implements Scopeable
AVMNodeDescriptor nodeDesc = this.services.getAVMService().lookup(-1, rootPath); AVMNodeDescriptor nodeDesc = this.services.getAVMService().lookup(-1, rootPath);
if (nodeDesc != null) if (nodeDesc != null)
{ {
rootNode = new AVMNode(AVMNodeConverter.ToNodeRef(-1, rootPath), this.services, null, this.scope); rootNode = new AVMNode(AVMNodeConverter.ToNodeRef(-1, rootPath), this.services, this.scope);
} }
} }
return rootNode; return rootNode;
@@ -89,7 +89,7 @@ public final class AVM extends BaseScriptImplementation implements Scopeable
AVMNodeDescriptor nodeDesc = this.services.getAVMService().lookup(-1, path); AVMNodeDescriptor nodeDesc = this.services.getAVMService().lookup(-1, path);
if (nodeDesc != null) if (nodeDesc != null)
{ {
node = new AVMNode(AVMNodeConverter.ToNodeRef(-1, path), this.services, null, this.scope); node = new AVMNode(AVMNodeConverter.ToNodeRef(-1, path), this.services, this.scope);
} }
} }
return node; return node;

View File

@@ -39,9 +39,9 @@ public class AVMNode extends Node
* @param services * @param services
* @param resolver * @param resolver
*/ */
public AVMNode(NodeRef nodeRef, ServiceRegistry services, TemplateImageResolver resolver) public AVMNode(NodeRef nodeRef, ServiceRegistry services)
{ {
super(nodeRef, services, resolver); super(nodeRef, services);
this.path = AVMNodeConverter.ToAVMVersionPath(nodeRef).getSecond(); this.path = AVMNodeConverter.ToAVMVersionPath(nodeRef).getSecond();
} }
@@ -53,9 +53,9 @@ public class AVMNode extends Node
* @param resolver * @param resolver
* @param scope * @param scope
*/ */
public AVMNode(NodeRef nodeRef, ServiceRegistry services, TemplateImageResolver resolver, Scriptable scope) public AVMNode(NodeRef nodeRef, ServiceRegistry services, Scriptable scope)
{ {
super(nodeRef, services, resolver, scope); super(nodeRef, services, scope);
this.path = AVMNodeConverter.ToAVMVersionPath(nodeRef).getSecond(); this.path = AVMNodeConverter.ToAVMVersionPath(nodeRef).getSecond();
} }
@@ -63,9 +63,9 @@ public class AVMNode extends Node
* Factory method * Factory method
*/ */
@Override @Override
public Node newInstance(NodeRef nodeRef, ServiceRegistry services, TemplateImageResolver resolver, Scriptable scope) public Node newInstance(NodeRef nodeRef, ServiceRegistry services, Scriptable scope)
{ {
return new AVMNode(nodeRef, services, resolver, scope); return new AVMNode(nodeRef, services, scope);
} }
// TODO: changing the 'name' property (either directly using .name or with .properties.name) // TODO: changing the 'name' property (either directly using .name or with .properties.name)
@@ -121,7 +121,7 @@ public class AVMNode extends Node
this.services.getAVMService().copy(-1, getPath(), destination, getName()); this.services.getAVMService().copy(-1, getPath(), destination, getName());
copy = newInstance( copy = newInstance(
AVMNodeConverter.ToNodeRef(-1, destination + '/' + getName()), AVMNodeConverter.ToNodeRef(-1, destination + '/' + getName()),
this.services, null, this.scope); this.services, this.scope);
} }
return copy; return copy;

View File

@@ -25,6 +25,7 @@ import org.alfresco.model.ContentModel;
import org.alfresco.service.ServiceRegistry; import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.TemplateImageResolver;
import org.alfresco.service.cmr.repository.TemplateNode; import org.alfresco.service.cmr.repository.TemplateNode;
import org.alfresco.service.cmr.search.CategoryService; import org.alfresco.service.cmr.search.CategoryService;
import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.QName;
@@ -34,8 +35,6 @@ import org.alfresco.service.namespace.QName;
*/ */
public class CategoryTemplateNode extends TemplateNode public class CategoryTemplateNode extends TemplateNode
{ {
private static final long serialVersionUID = -2595282439089450151L;
/** /**
* Constructor * Constructor
* *
@@ -43,9 +42,9 @@ public class CategoryTemplateNode extends TemplateNode
* @param services * @param services
* @param resolver * @param resolver
*/ */
public CategoryTemplateNode(NodeRef nodeRef, ServiceRegistry services) public CategoryTemplateNode(NodeRef nodeRef, ServiceRegistry services, TemplateImageResolver resolver)
{ {
super(nodeRef, services); super(nodeRef, services, resolver);
} }
@Override @Override
@@ -164,7 +163,7 @@ public class CategoryTemplateNode extends TemplateNode
for (ChildAssociationRef ref : childRefs) for (ChildAssociationRef ref : childRefs)
{ {
// create our Node representation from the NodeRef // create our Node representation from the NodeRef
TemplateNode child = new TemplateNode(ref.getChildRef(), this.services); TemplateNode child = new TemplateNode(ref.getChildRef(), this.services, this.imageResolver);
answer.add(child); answer.add(child);
} }
return answer; return answer;
@@ -176,7 +175,7 @@ public class CategoryTemplateNode extends TemplateNode
for (ChildAssociationRef ref : childRefs) for (ChildAssociationRef ref : childRefs)
{ {
// create our Node representation from the NodeRef // create our Node representation from the NodeRef
CategoryTemplateNode child = new CategoryTemplateNode(ref.getChildRef(), this.services); CategoryTemplateNode child = new CategoryTemplateNode(ref.getChildRef(), this.services, this.imageResolver);
answer.add(child); answer.add(child);
} }
return answer; return answer;
@@ -185,16 +184,17 @@ public class CategoryTemplateNode extends TemplateNode
private List<TemplateNode> buildMixedNodeList(Collection<ChildAssociationRef> cars) private List<TemplateNode> buildMixedNodeList(Collection<ChildAssociationRef> cars)
{ {
List<TemplateNode> nodes = new ArrayList<TemplateNode>(cars.size()); List<TemplateNode> nodes = new ArrayList<TemplateNode>(cars.size());
int i = 0;
for (ChildAssociationRef car : cars) for (ChildAssociationRef car : cars)
{ {
QName type = services.getNodeService().getType(car.getChildRef()); QName type = services.getNodeService().getType(car.getChildRef());
if (services.getDictionaryService().isSubClass(type, ContentModel.TYPE_CATEGORY)) if (services.getDictionaryService().isSubClass(type, ContentModel.TYPE_CATEGORY))
{ {
nodes.add(new CategoryTemplateNode(car.getChildRef(), this.services)); nodes.add(new CategoryTemplateNode(car.getChildRef(), this.services, this.imageResolver));
} }
else else
{ {
nodes.add(new TemplateNode(car.getChildRef(), this.services)); nodes.add(new TemplateNode(car.getChildRef(), this.services, this.imageResolver));
} }
} }
return nodes; return nodes;

File diff suppressed because it is too large Load Diff

View File

@@ -77,7 +77,7 @@ public abstract class BasePathResultsMap extends BaseTemplateMap
if (nodes.size() != 0) if (nodes.size() != 0)
{ {
result = new ArrayList<TemplateNode>(1); result = new ArrayList<TemplateNode>(1);
result.add(new TemplateNode(nodes.get(0), this.services)); result.add(new TemplateNode(nodes.get(0), this.services, this.parent.getImageResolver()));
} }
} }
// or all the results // or all the results
@@ -86,7 +86,7 @@ public abstract class BasePathResultsMap extends BaseTemplateMap
result = new ArrayList<TemplateNode>(nodes.size()); result = new ArrayList<TemplateNode>(nodes.size());
for (NodeRef ref : nodes) for (NodeRef ref : nodes)
{ {
result.add(new TemplateNode(ref, this.services)); result.add(new TemplateNode(ref, this.services, this.parent.getImageResolver()));
} }
} }
} }

View File

@@ -75,7 +75,7 @@ public abstract class BaseSearchResultsMap extends BaseTemplateMap
NodeRef nodeRef = row.getNodeRef(); NodeRef nodeRef = row.getNodeRef();
if (!nodeRefs.contains(nodeRef)) if (!nodeRefs.contains(nodeRef))
{ {
nodes.add(new TemplateNode(nodeRef, services)); nodes.add(new TemplateNode(nodeRef, services, this.parent.getImageResolver()));
nodeRefs.add(nodeRef); nodeRefs.add(nodeRef);
} }
} }

View File

@@ -102,7 +102,7 @@ public final class Classification
ArrayList<CategoryTemplateNode> categoryNodes = new ArrayList<CategoryTemplateNode>(cars.size()); ArrayList<CategoryTemplateNode> categoryNodes = new ArrayList<CategoryTemplateNode>(cars.size());
for (ChildAssociationRef car : cars) for (ChildAssociationRef car : cars)
{ {
categoryNodes.add(new CategoryTemplateNode(car.getChildRef(), this.services)); categoryNodes.add(new CategoryTemplateNode(car.getChildRef(), this.services, this.imageResolver));
} }
return categoryNodes; return categoryNodes;
} }

View File

@@ -309,18 +309,18 @@ public class FreeMarkerProcessor implements TemplateProcessor
Map<String, Object> model = new HashMap<String, Object>(16, 1.0f); Map<String, Object> model = new HashMap<String, Object>(16, 1.0f);
// supply the Company Home space as "companyhome" // supply the Company Home space as "companyhome"
model.put("companyhome", new TemplateNode(companyHome, services)); model.put("companyhome", new TemplateNode(companyHome, services, imageResolver));
// supply the users Home Space as "userhome" // supply the users Home Space as "userhome"
model.put("userhome", new TemplateNode(userHome, services)); model.put("userhome", new TemplateNode(userHome, services, imageResolver));
// supply the current user Node as "person" // supply the current user Node as "person"
model.put("person", new TemplateNode(person, services)); model.put("person", new TemplateNode(person, services, imageResolver));
// add the template itself as "template" if it comes from content on a node // add the template itself as "template" if it comes from content on a node
if (template != null) if (template != null)
{ {
model.put("template", new TemplateNode(template, services)); model.put("template", new TemplateNode(template, services, imageResolver));
} }
// current date/time is useful to have and isn't supplied by FreeMarker by default // current date/time is useful to have and isn't supplied by FreeMarker by default

View File

@@ -116,7 +116,7 @@ public class TemplateServiceImplTest extends TestCase
// create test model // create test model
Map model = new HashMap(7, 1.0f); Map model = new HashMap(7, 1.0f);
model.put("root", new TemplateNode(root, serviceRegistry)); model.put("root", new TemplateNode(root, serviceRegistry, null));
// execute on test template // execute on test template
String output = templateService.processTemplate("freemarker", TEMPLATE_1, model); String output = templateService.processTemplate("freemarker", TEMPLATE_1, model);

View File

@@ -93,6 +93,7 @@ public class TemplateNode implements Serializable
private String displayPath = null; private String displayPath = null;
private String mimetype = null; private String mimetype = null;
private Long size = null; private Long size = null;
protected TemplateImageResolver imageResolver = null;
private TemplateNode parent = null; private TemplateNode parent = null;
private ChildAssociationRef primaryParentAssoc = null; private ChildAssociationRef primaryParentAssoc = null;
private Boolean isCategory = null; private Boolean isCategory = null;
@@ -108,7 +109,7 @@ public class TemplateNode implements Serializable
* @param services The ServiceRegistry the TemplateNode can use to access services * @param services The ServiceRegistry the TemplateNode can use to access services
* @param resolver Image resolver to use to retrieve icons * @param resolver Image resolver to use to retrieve icons
*/ */
public TemplateNode(NodeRef nodeRef, ServiceRegistry services) public TemplateNode(NodeRef nodeRef, ServiceRegistry services, TemplateImageResolver resolver)
{ {
if (nodeRef == null) if (nodeRef == null)
{ {
@@ -123,6 +124,7 @@ public class TemplateNode implements Serializable
this.nodeRef = nodeRef; this.nodeRef = nodeRef;
this.id = nodeRef.getId(); this.id = nodeRef.getId();
this.services = services; this.services = services;
this.imageResolver = resolver;
this.properties = new QNameMap<String, Object>(this.services.getNamespaceService()); this.properties = new QNameMap<String, Object>(this.services.getNamespaceService());
} }
@@ -131,14 +133,6 @@ public class TemplateNode implements Serializable
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
// Node API // Node API
/**
* Gets the image resolver
*/
public TemplateImageResolver getImageResolver()
{
return imageResolver;
}
/** /**
* @return The GUID for the node * @return The GUID for the node
*/ */
@@ -208,7 +202,7 @@ public class TemplateNode implements Serializable
for (ChildAssociationRef ref : childRefs) for (ChildAssociationRef ref : childRefs)
{ {
// create our Node representation from the NodeRef // create our Node representation from the NodeRef
TemplateNode child = new TemplateNode(ref.getChildRef(), this.services); TemplateNode child = new TemplateNode(ref.getChildRef(), this.services, this.imageResolver);
this.children.add(child); this.children.add(child);
} }
} }
@@ -235,7 +229,7 @@ public class TemplateNode implements Serializable
nodes = new ArrayList<TemplateNode>(4); nodes = new ArrayList<TemplateNode>(4);
this.assocs.put(ref.getTypeQName().toString(), nodes); this.assocs.put(ref.getTypeQName().toString(), nodes);
} }
nodes.add( new TemplateNode(ref.getTargetRef(), this.services) ); nodes.add( new TemplateNode(ref.getTargetRef(), this.services, this.imageResolver) );
} }
} }
@@ -258,7 +252,7 @@ public class TemplateNode implements Serializable
{ {
// NodeRef object properties are converted to new TemplateNode objects // NodeRef object properties are converted to new TemplateNode objects
// so they can be used as objects within a template // so they can be used as objects within a template
propValue = new TemplateNode(((NodeRef)propValue), this.services); propValue = new TemplateNode(((NodeRef)propValue), this.services, this.imageResolver);
} }
else if (propValue instanceof ContentData) else if (propValue instanceof ContentData)
{ {
@@ -392,7 +386,7 @@ public class TemplateNode implements Serializable
// handle root node (no parent!) // handle root node (no parent!)
if (parentRef != null) if (parentRef != null)
{ {
parent = new TemplateNode(parentRef, this.services); parent = new TemplateNode(parentRef, this.services, this.imageResolver);
} }
} }
@@ -549,7 +543,21 @@ public class TemplateNode implements Serializable
*/ */
public String getIcon16() public String getIcon16()
{ {
return "/images/filetypes/_default.gif"; if (this.imageResolver != null)
{
if (getIsDocument())
{
return this.imageResolver.resolveImagePathForName(getName(), true);
}
else
{
return "/images/icons/space_small.gif";
}
}
else
{
return "/images/filetypes/_default.gif";
}
} }
/** /**
@@ -557,7 +565,29 @@ public class TemplateNode implements Serializable
*/ */
public String getIcon32() public String getIcon32()
{ {
return "/images/filetypes32/_default.gif"; if (this.imageResolver != null)
{
if (getIsDocument())
{
return this.imageResolver.resolveImagePathForName(getName(), false);
}
else
{
String icon = (String)getProperties().get("app:icon");
if (icon != null)
{
return "/images/icons/" + icon + ".gif";
}
else
{
return "/images/icons/space-icon-default.gif";
}
}
}
else
{
return "/images/filetypes32/_default.gif";
}
} }
@@ -661,6 +691,14 @@ public class TemplateNode implements Serializable
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
// Misc helpers // Misc helpers
/**
* @return the image resolver instance used by this node
*/
public TemplateImageResolver getImageResolver()
{
return this.imageResolver;
}
/** /**
* Override Object.toString() to provide useful debug output * Override Object.toString() to provide useful debug output
*/ */