mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged DEV/SWIFT-MIKE to HEAD
28328: Merged DEV/SWIFT-UI to DEV/SWIFT-MIKE 28245: Work in Progress: DocLib data webscript and action config refactor. 28676: Work in Progress: Document Library list view renders with new data structures. Action evaluators mostly populated. Tweaks to appUtils.toJSON. Client-side "ScriptNode-lite". Evaluators now use json-simple lib. 28898: Work in progress. New doclib webscripts into new "v2" namespace. Action refactoring. Initial status indicator config. Site preset & container type returned & evaluator templates to support wcmqs and dod5015. 28952: Work in Progress: End of Sprint 3. Refactored web-tier data webscripts. Full parent node details returned with nodes (or in metadata for common parent scenario). Action fixes. 28971: Merged HEAD@28970 to DEV/SWIFT-MIKE 29018: Work in progress: Document details page. Evaluator tweaks. New value evaluator. Consolidated getActionUrls. 29037: Merged HEAD@29035 to DEV/SWIFT-MIKE (Bringing in publishing action to migrate to new framework) 29156: Work in progress: Folder details page refactor. "working mode" flag removed to allow removal of some repository browser-specific overrides. Client-side folder and document renderers coalesced. Category, link and working copy handling improved. 29168: Merged HEAD@29166 to DEV/SWIFT-MIKE (Share extensibility features merged across. Folder details page conflicts resolved by migrating to new extensibility model.) 29195: Minor fixes for action event handler and changes to Surf API 29197: Merged HEAD@29196 to DEV/SWIFT-MIKE to prepare for merge back to trunk Note: Awaiting imminent Spring Surf fix before Document Libraries are fully functional. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@29201 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2011 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.jscript.app;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Category property decorator class.
|
||||
*
|
||||
* @author Mike Hatfield
|
||||
*/
|
||||
public class CategoryPropertyDecorator implements JSONPropertyDecorator
|
||||
{
|
||||
private static Log logger = LogFactory.getLog(CategoryPropertyDecorator.class);
|
||||
|
||||
private ServiceRegistry services;
|
||||
private NodeService nodeService = null;
|
||||
private PermissionService permissionService = null;
|
||||
|
||||
public void setServiceRegistry(ServiceRegistry serviceRegistry)
|
||||
{
|
||||
this.services = serviceRegistry;
|
||||
this.nodeService = serviceRegistry.getNodeService();
|
||||
this.permissionService = serviceRegistry.getPermissionService();
|
||||
}
|
||||
|
||||
public Serializable decorate(NodeRef nodeRef, String propertyName, Serializable value)
|
||||
{
|
||||
Collection<NodeRef> collection = (Collection<NodeRef>)value;
|
||||
Object[] array = new Object[collection.size()];
|
||||
int index = 0;
|
||||
|
||||
for (NodeRef obj : collection)
|
||||
{
|
||||
try
|
||||
{
|
||||
Map<String, Serializable> jsonObj = new LinkedHashMap<String, Serializable>(4);
|
||||
jsonObj.put("name", this.nodeService.getProperty(obj, ContentModel.PROP_NAME));
|
||||
jsonObj.put("path", this.getPath(obj));
|
||||
jsonObj.put("nodeRef", obj.toString());
|
||||
array[index++] = jsonObj;
|
||||
}
|
||||
catch (InvalidNodeRefException e)
|
||||
{
|
||||
logger.warn("Category with nodeRef " + obj.toString() + " does not exist.");
|
||||
}
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Category path used for node membership queries
|
||||
*
|
||||
* @return Display path to this node
|
||||
*/
|
||||
public String getPath(NodeRef nodeRef)
|
||||
{
|
||||
String displayPath = this.nodeService.getPath(nodeRef).toDisplayPath(this.nodeService, this.permissionService);
|
||||
return displayPath.replaceFirst("/categories/General", "");
|
||||
}
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2011 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.jscript.app;
|
||||
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Interface for property decorators used by ApplicationScriptUtils.toJSON()
|
||||
*
|
||||
* @author Mike Hatfield
|
||||
*/
|
||||
public interface JSONPropertyDecorator
|
||||
{
|
||||
Serializable decorate(NodeRef nodeRef, String propertyName, Serializable value);
|
||||
}
|
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2011 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.jscript.app;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Tag property decorator class.
|
||||
*
|
||||
* @author Mike Hatfield
|
||||
*/
|
||||
public class TagPropertyDecorator implements JSONPropertyDecorator
|
||||
{
|
||||
private static Log logger = LogFactory.getLog(TagPropertyDecorator.class);
|
||||
|
||||
private ServiceRegistry services;
|
||||
private NodeService nodeService = null;
|
||||
|
||||
public void setServiceRegistry(ServiceRegistry serviceRegistry)
|
||||
{
|
||||
this.services = serviceRegistry;
|
||||
this.nodeService = serviceRegistry.getNodeService();
|
||||
}
|
||||
|
||||
public Serializable decorate(NodeRef nodeRef, String propertyName, Serializable value)
|
||||
{
|
||||
Collection<NodeRef> collection = (Collection<NodeRef>)value;
|
||||
Object[] array = new Object[collection.size()];
|
||||
int index = 0;
|
||||
|
||||
for (NodeRef obj : collection)
|
||||
{
|
||||
try
|
||||
{
|
||||
Map<String, Serializable> jsonObj = new LinkedHashMap<String, Serializable>(2);
|
||||
jsonObj.put("name", this.nodeService.getProperty(obj, ContentModel.PROP_NAME));
|
||||
jsonObj.put("nodeRef", obj.toString());
|
||||
array[index++] = jsonObj;
|
||||
}
|
||||
catch (InvalidNodeRefException e)
|
||||
{
|
||||
logger.warn("Tag with nodeRef " + obj.toString() + " does not exist.");
|
||||
}
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
}
|
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2011 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.jscript.app;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.security.PersonService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Username property decorator class.
|
||||
*
|
||||
* @author Mike Hatfield
|
||||
*/
|
||||
public class UsernamePropertyDecorator implements JSONPropertyDecorator
|
||||
{
|
||||
private ServiceRegistry services;
|
||||
private NodeService nodeService = null;
|
||||
private PersonService personService = null;
|
||||
|
||||
public void setServiceRegistry(ServiceRegistry serviceRegistry)
|
||||
{
|
||||
this.services = serviceRegistry;
|
||||
this.nodeService = serviceRegistry.getNodeService();
|
||||
this.personService = serviceRegistry.getPersonService();
|
||||
}
|
||||
|
||||
public Serializable decorate(NodeRef nodeRef, String propertyName, Serializable value)
|
||||
{
|
||||
String username = value.toString();
|
||||
String firstName = null;
|
||||
String lastName = null;
|
||||
Map<String, Serializable> map = new LinkedHashMap<String, Serializable>(1);
|
||||
map.put("userName", username);
|
||||
|
||||
if (this.personService.personExists(username))
|
||||
{
|
||||
NodeRef personRef = this.personService.getPerson(username);
|
||||
Map<QName, Serializable> properties = this.nodeService.getProperties(personRef);
|
||||
firstName = properties.get(ContentModel.PROP_FIRSTNAME).toString();
|
||||
lastName = properties.get(ContentModel.PROP_LASTNAME).toString();
|
||||
}
|
||||
else if (username.equals("System") || username.startsWith("System@"))
|
||||
{
|
||||
firstName = "System";
|
||||
lastName = "User";
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
map.put("firstName", firstName);
|
||||
map.put("lastName", lastName);
|
||||
map.put("displayName", (firstName + " " + lastName).replaceAll("^\\s+|\\s+$", ""));
|
||||
return (Serializable)map;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user