mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Document Library: some refactoring & clean-up of evaluator code. Adds support for Repository custom response injection; the vti server details have now moved to this model instead of a separate webscript call. Added browser evaluator via userAgent regexp test and access to doclib webscript metadata response in evaluators.
Closes: ALF-9173 - SE.S07 Share - Single configuration files for actions ALF-9176 - SE.S15 Share - Refactor doclist data webscript to use web-tier ActionGroups and Evaluators ALF-9181 - SE.S63 Share - Refactor doclist client javascript to work with updated data response Fixes: ALF-9917 - wrong URLs are generated for some actions ALF-9931 - Add simple workflow rule crashes the Document Library git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@29845 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -33,5 +33,6 @@
|
||||
<import resource="classpath*:alfresco/slideshare-publishing-context.xml" />
|
||||
<import resource="classpath*:alfresco/flickr-publishing-context.xml" />
|
||||
<import resource="classpath*:alfresco/facebook-publishing-context.xml" />
|
||||
<import resource="classpath*:alfresco/slingshot-context.xml" />
|
||||
<import resource="classpath*:alfresco/domain/*-context.xml" />
|
||||
</beans>
|
||||
|
48
config/alfresco/slingshot-context.xml
Normal file
48
config/alfresco/slingshot-context.xml
Normal file
@@ -0,0 +1,48 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
|
||||
|
||||
<beans>
|
||||
|
||||
<bean id="doclibCustomVtiProperties" parent="common-placeholder-configurer">
|
||||
<property name="locations">
|
||||
<list>
|
||||
<value>classpath*:alfresco/module/org.alfresco.module.vti/context/vti.properties</value>
|
||||
<!-- Override -->
|
||||
<value>classpath*:alfresco/extension/custom-vti.properties</value>
|
||||
</list>
|
||||
</property>
|
||||
<property name="nullValue" value="null" />
|
||||
<property name="properties">
|
||||
<props>
|
||||
<prop key="vti.server.external.port">0</prop>
|
||||
<prop key="vti.server.external.host">null</prop>
|
||||
</props>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="doclibCustomVtiServer" class="org.alfresco.repo.jscript.app.CustomResponseVtiServer">
|
||||
<property name="port">
|
||||
<value>${vti.server.external.port}</value>
|
||||
</property>
|
||||
<property name="host">
|
||||
<value>${vti.server.external.host}</value>
|
||||
</property>
|
||||
<property name="sysAdminParams">
|
||||
<ref bean="sysAdminParams" />
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="slingshotDocLibCustomResponse" parent="baseJavaScriptExtension" class="org.alfresco.repo.jscript.SlingshotDocLibCustomResponse">
|
||||
<property name="extensionName">
|
||||
<value>slingshotDocLib</value>
|
||||
</property>
|
||||
<property name="customResponses">
|
||||
<map>
|
||||
<entry key="vtiServer">
|
||||
<ref bean="doclibCustomVtiServer"/>
|
||||
</entry>
|
||||
</map>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
</beans>
|
@@ -19,7 +19,7 @@
|
||||
package org.alfresco.repo.jscript;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.jscript.app.JSONPropertyDecorator;
|
||||
import org.alfresco.repo.jscript.app.PropertyDecorator;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
@@ -237,7 +237,7 @@ public final class ApplicationScriptUtils extends BaseScopableProcessorExtension
|
||||
// Has a decorator has been registered for this property?
|
||||
if (this.decoratedProperties.containsKey(shortQName))
|
||||
{
|
||||
json.put(key, ((JSONPropertyDecorator) this.decoratedProperties.get(shortQName)).decorate(nodeRef, shortQName, value));
|
||||
json.put(key, ((PropertyDecorator) this.decoratedProperties.get(shortQName)).decorate(nodeRef, shortQName, value));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import org.alfresco.repo.jscript.app.CustomResponse;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Populates DocLib webscript response with custom metadata output
|
||||
*
|
||||
* @author: mikeh
|
||||
*/
|
||||
public final class SlingshotDocLibCustomResponse extends BaseScopableProcessorExtension
|
||||
{
|
||||
private Map<String, Object> customResponses;
|
||||
|
||||
/**
|
||||
* Set the custom response beans
|
||||
*
|
||||
* @param customResponses
|
||||
*/
|
||||
public void setCustomResponses(Map<String, Object> customResponses)
|
||||
{
|
||||
this.customResponses = customResponses;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a JSON string to be added to the DocLib webscript response.
|
||||
*
|
||||
* @return The JSON string
|
||||
*/
|
||||
public String getJSON()
|
||||
{
|
||||
return this.getJSONObj().toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a JSON object to be added to the DocLib webscript response.
|
||||
*
|
||||
* @return The JSON object
|
||||
*/
|
||||
protected Object getJSONObj()
|
||||
{
|
||||
JSONObject json = new JSONObject();
|
||||
|
||||
|
||||
for (Map.Entry<String, Object> entry : this.customResponses.entrySet())
|
||||
{
|
||||
try
|
||||
{
|
||||
Serializable response = ((CustomResponse) entry.getValue()).populate();
|
||||
json.put(entry.getKey(), response == null ? JSONObject.NULL: response);
|
||||
}
|
||||
catch (JSONException error)
|
||||
{
|
||||
error.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return json;
|
||||
}
|
||||
}
|
@@ -37,7 +37,7 @@ import java.util.Map;
|
||||
*
|
||||
* @author Mike Hatfield
|
||||
*/
|
||||
public class CategoryPropertyDecorator implements JSONPropertyDecorator
|
||||
public class CategoryPropertyDecorator implements PropertyDecorator
|
||||
{
|
||||
private static Log logger = LogFactory.getLog(CategoryPropertyDecorator.class);
|
||||
|
||||
|
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* 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 java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Interface for custom properties used by SlingshotDocLibCustomResponse
|
||||
*
|
||||
* @author: mikeh
|
||||
*/
|
||||
public interface CustomResponse
|
||||
{
|
||||
/**
|
||||
* Populates the DocLib webscript response with custom metadata
|
||||
*/
|
||||
Serializable populate();
|
||||
}
|
@@ -26,7 +26,7 @@ import java.io.Serializable;
|
||||
*
|
||||
* @author Mike Hatfield
|
||||
*/
|
||||
public interface JSONPropertyDecorator
|
||||
public interface PropertyDecorator
|
||||
{
|
||||
Serializable decorate(NodeRef nodeRef, String propertyName, Serializable value);
|
||||
}
|
@@ -36,7 +36,7 @@ import java.util.Map;
|
||||
*
|
||||
* @author Mike Hatfield
|
||||
*/
|
||||
public class TagPropertyDecorator implements JSONPropertyDecorator
|
||||
public class TagPropertyDecorator implements PropertyDecorator
|
||||
{
|
||||
private static Log logger = LogFactory.getLog(TagPropertyDecorator.class);
|
||||
|
||||
|
@@ -34,7 +34,7 @@ import java.util.Map;
|
||||
*
|
||||
* @author Mike Hatfield
|
||||
*/
|
||||
public class UsernamePropertyDecorator implements JSONPropertyDecorator
|
||||
public class UsernamePropertyDecorator implements PropertyDecorator
|
||||
{
|
||||
private ServiceRegistry services;
|
||||
private NodeService nodeService = null;
|
||||
|
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
* 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.repo.admin.SysAdminParams;
|
||||
import org.alfresco.repo.jscript.ScriptUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.ibatis.migration.commands.StatusCommand;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Return current state of VTI (SharePoint) Server module
|
||||
*
|
||||
* @author: mikeh
|
||||
*/
|
||||
public class VtiServerCustomResponse implements CustomResponse
|
||||
{
|
||||
private static Log logger = LogFactory.getLog(VtiServerCustomResponse.class);
|
||||
|
||||
private static final String VTI_MODULE = "org.alfresco.module.vti";
|
||||
|
||||
private int vtiServerPort = 0;
|
||||
private String vtiServerHost;
|
||||
private SysAdminParams sysAdminParams;
|
||||
private ScriptUtils scriptUtils;
|
||||
|
||||
/*
|
||||
* Set ScriptUtils
|
||||
*
|
||||
* @param scriptUtils
|
||||
*/
|
||||
public void setScriptUtils(ScriptUtils scriptUtils) throws BeansException
|
||||
{
|
||||
this.scriptUtils = scriptUtils;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for vtiServer Port
|
||||
*
|
||||
* @param vtiServerPort
|
||||
*/
|
||||
public void setPort(int vtiServerPort)
|
||||
{
|
||||
this.vtiServerPort = vtiServerPort;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for vtiServer Host
|
||||
*
|
||||
* @param vtiServerHost
|
||||
*/
|
||||
public void setHost(String vtiServerHost)
|
||||
{
|
||||
this.vtiServerHost = vtiServerHost;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for sysAdminParams
|
||||
*
|
||||
* @param sysAdminParams
|
||||
*/
|
||||
public void setSysAdminParams(SysAdminParams sysAdminParams)
|
||||
{
|
||||
this.sysAdminParams = sysAdminParams;
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates the DocLib webscript response with custom metadata
|
||||
*
|
||||
* @return JSONObject or null
|
||||
*/
|
||||
public Serializable populate()
|
||||
{
|
||||
try
|
||||
{
|
||||
// Check module is installed
|
||||
if (!this.scriptUtils.moduleInstalled(VTI_MODULE))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
Map<String, Serializable> jsonObj = new LinkedHashMap<String, Serializable>(4);
|
||||
if (this.vtiServerPort != 0)
|
||||
{
|
||||
jsonObj.put("port", this.vtiServerPort);
|
||||
}
|
||||
if (this.vtiServerHost != null)
|
||||
{
|
||||
jsonObj.put("host", this.sysAdminParams.subsituteHost(this.vtiServerHost));
|
||||
}
|
||||
return (Serializable)jsonObj;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.warn("Could not add custom Vti Server response to DocLib webscript");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user