mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-06-30 18:15:39 +00:00
29484: Merged V3.4 to V3.4-BUG-FIX 29426: ALF-9588: Merged PATCHES/V3.4.2 to V3.4 29402: ALF-9637: Enable Share Advanced Search on properties containing a '-' in the prefix 29469: ALF-8341: Merged missing fragment from ALF-6598 29476: ALF-3061 Need to disable major/minor version radio buttons after [Upload File(s)] 29483: ALF-9407: Escape quote characters in parameterized strings 29488: Build Fix and correct fix for ALF-9632 "CMIS query fails if model name contains numbers" fix - Ensure CMIS query types are ISO9075 encoded - the user has to type them in encoded if encoding is required - the encoded look up name was in fact incorrect - not the lookup 29561: Merge DEV/BELARUS/V3.4-BUG-FIX-2011_07_13 V3.4-BUG-FIX 29422: ALF-7195 Add DisableAuditingInterceptor to NodeService and LockService. 29572: ALF-9601 - Simultaneous deployment of the same web project to two file system targets on the same engine can cause some missing files in one of the targets. 29578: Merged DEV/TEMPORARY to V3.4-BUG-FIX 29334: ALF-7390 : Alfresco ftp server never binds to a single ip address Added default configuration for bindTo property for FTP server. 29587: Merged V3.4 to V3.4-BUG-FIX 29495: Merged DEV/TEMPORARY to V3.4 29494: ALF-7701: Untranslated strings when Quickr module is installed: Task details page Global workflow messages were removed 29502: ALF-8929: Merged DEV/TEMPORARY to V3.4 29499: Rename dictionaryModelBootstrap beans for QuickR model and example model. 29504: ALF-5895: Profile CSS tweaks for other languages (Kev reviewed) 29519: Merged DEV/TEMPORARY to V3.4 (Reviewed by Kev) 29510: ALF-9419: Share - Filename changes in "Upload new version" (with italian language set) Upload WebScript was modified for support locale as a request parameter. 29518: ALF-9419: Share - Filename changes in "Upload new version" (with italian language set) ScriptUtils used for locale change. 29520: ALF-9717: Possible workaround to PolicyTest taking so long to run - Set sun.net.client.defaultConnectTimeout and sun.net.client.defaultReadTimeout System properties so that hanging request for a DTD times out quickly 29596: Merged DEV/TEMPORARY to V3.4-BUG-FIX 29595: ALF-5046: DeclarativeWebScriptRegistry causes blow-out when loading system without content 1. In org.alfresco.repo.web.scripts.RepoStore class added isContentPresent(NodeRef nodeRef) method. 2. In org.alfresco.repo.web.scripts.RepoStore#getScriptDocumentPaths added check isContentPresent(nodeRef). 3. In org.alfresco.repo.web.scripts.RepoStore#getDocumentPaths added check isContentPresent(nodeRef). 4. In org.alfresco.repo.web.scripts.RepoStore#getAllDocumentPaths added check isContentPresent(nodeRef). 29634: ALF-371 Alfresco Explorer: A change of a user's home folder now creates a new folder if it does not exist. If a home folder is shared, other users no longer find their home folder moving. However the content of the home folder must be manually moved. 29637: ALF-9847 High level audit does not include initial node properties or changed path if node moved 29685: Merged PATCHES/V3.4.1 to V3.4-BUG-FIX 29682: ALF-9777: Merged V3.4-BUG-FIX to PATCHES/V3.4.1 28188: Fix for ALF-731 - in a cluster environment (high availibility), when a node goes down, the users are asked to login 29684: ALF-9777: Correction 29686: ALF-2372 Revert action does not restore changes to document metadata Now uses VersionService.revert(...) 29697: ALF-9886: Missing space in apostrophe-laden Italian translation - The world is safe once more 29698: Merged V3.4 to V3.4-BUG-FIX 29672: Merged PATCHES/V3.4.1 to V3.4 29441: ALF-9876 / ALF-9579: Share external authentication fixes 1. Share SSO filter makes touch requests in the name of the external user ID (remoteUser) for unauthenticated users 2. Include WebScriptSSOAuthenticationFilter in external-filter-context.xml to allow cookie-based manual login failover (A Spring Surf patch is required to support this) 3. On the repository tier, web client authentication will send a 401 response for an invalid remote user (with redirect to login page in HTML markup) so that Share SSO authenticator detects this as an authentication failure and redirects to the login page, thus allowing manual login failover. 29454: ALF-9876 / ALF-9579: Share external authentication fixes 4. Spring Surf / Spring webscripts jars (from Kevin Roast) 29563: ALF-8607 / ALF-9596: Guarantee read consistency in AbstractNodeDAOImpl.getNodeRefStatus - Partly achieved by making EntityLookupCache.removeByKey() unconditionally cache removes 29673: ALF-9530: Reverse merged V3.4-BUG-FIX revisions 29124 and 29109 - Postgres service will continue to run as SYSTEM user on Windows. See bug for more details. 29674: ALF-7993: Reversed changes to bitrock files made during removal of 32 bit linux support from the build, as requested by Bitrock (V3.4-BUG-FIX revision 26582) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@29700 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
298 lines
8.2 KiB
Java
298 lines
8.2 KiB
Java
/*
|
|
* 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.jscript;
|
|
|
|
import java.util.Date;
|
|
import java.util.Locale;
|
|
import java.util.Map;
|
|
|
|
import org.alfresco.service.ServiceRegistry;
|
|
import org.alfresco.service.cmr.module.ModuleDetails;
|
|
import org.alfresco.service.cmr.module.ModuleService;
|
|
import org.alfresco.service.cmr.repository.NodeRef;
|
|
import org.alfresco.service.namespace.NamespaceService;
|
|
import org.alfresco.service.namespace.QName;
|
|
import org.alfresco.util.ScriptPagingDetails;
|
|
import org.springframework.extensions.surf.util.I18NUtil;
|
|
import org.springframework.extensions.surf.util.ISO8601DateFormat;
|
|
|
|
/**
|
|
* Place for general and miscellaneous utility functions not already found in generic JavaScript.
|
|
*
|
|
* @author Kevin Roast
|
|
*/
|
|
public final class ScriptUtils extends BaseScopableProcessorExtension
|
|
{
|
|
private final static String NAMESPACE_BEGIN = "" + QName.NAMESPACE_BEGIN;
|
|
|
|
/** Services */
|
|
private ServiceRegistry services;
|
|
|
|
/**
|
|
* Sets the service registry
|
|
*
|
|
* @param services the service registry
|
|
*/
|
|
public void setServiceRegistry(ServiceRegistry services)
|
|
{
|
|
this.services = services;
|
|
}
|
|
|
|
/**
|
|
* Function to pad a string with zero '0' characters to the required length
|
|
*
|
|
* @param s String to pad with leading zero '0' characters
|
|
* @param len Length to pad to
|
|
*
|
|
* @return padded string or the original if already at >=len characters
|
|
*/
|
|
public String pad(String s, int len)
|
|
{
|
|
String result = s;
|
|
for (int i=0; i<(len - s.length()); i++)
|
|
{
|
|
result = "0" + result;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Gets a JS node object from a string noderef
|
|
*
|
|
* @param nodeRefString string reference to a node
|
|
* @return a JS node object
|
|
*/
|
|
public ScriptNode getNodeFromString(String nodeRefString)
|
|
{
|
|
NodeRef nodeRef = new NodeRef(nodeRefString);
|
|
return (ScriptNode)new ValueConverter().convertValueForScript(this.services, getScope(), null, nodeRef);
|
|
}
|
|
|
|
/**
|
|
* Gets a boolean value from a string
|
|
*
|
|
* @see Boolean#parseBoolean(String)
|
|
*
|
|
* @param booleanString boolean string
|
|
* @return boolean the boolean value
|
|
*/
|
|
public boolean toBoolean(String booleanString)
|
|
{
|
|
return Boolean.parseBoolean(booleanString);
|
|
}
|
|
|
|
/**
|
|
* Function to check if a module is installed
|
|
*
|
|
* @param moduleName module name (e.g. "org.alfresco.module.foo")
|
|
* @return boolean true if the module is currently installed
|
|
*/
|
|
public boolean moduleInstalled(String moduleName)
|
|
{
|
|
ModuleService moduleService = (ModuleService)this.services.getService(QName.createQName(NamespaceService.ALFRESCO_URI, "ModuleService"));
|
|
if (moduleService != null)
|
|
{
|
|
ModuleDetails moduleDetail = (ModuleDetails)moduleService.getModule(moduleName);
|
|
return (moduleDetail != null);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* Format timeInMillis to ISO 8601 formatted string
|
|
*
|
|
* @param timeInMillis
|
|
* @return
|
|
*/
|
|
public String toISO8601(long timeInMillis)
|
|
{
|
|
return ISO8601DateFormat.format(new Date(timeInMillis));
|
|
}
|
|
|
|
/**
|
|
* Format date to ISO 8601 formatted string
|
|
*
|
|
* @param date
|
|
* @return
|
|
*/
|
|
public String toISO8601(Date date)
|
|
{
|
|
return ISO8601DateFormat.format(date);
|
|
}
|
|
|
|
/**
|
|
* Parse date from ISO formatted string
|
|
*
|
|
* @param isoDateString
|
|
* @return
|
|
*/
|
|
public Date fromISO8601(String isoDateString)
|
|
{
|
|
return ISO8601DateFormat.parse(isoDateString);
|
|
}
|
|
|
|
/**
|
|
* Given a long-form QName string, this method uses the namespace service to create a
|
|
* short-form QName string.
|
|
*
|
|
* @param s Fully qualified QName string
|
|
* @return the short form of the QName string, e.g. "cm:content"
|
|
*/
|
|
public String shortQName(String s)
|
|
{
|
|
return createQName(s).toPrefixString(services.getNamespaceService());
|
|
}
|
|
|
|
/**
|
|
* Given a short-form QName string, this method returns the fully qualified QName string.
|
|
*
|
|
* @param s Short form QName string, e.g. "cm:content"
|
|
* @return Fully qualified QName string
|
|
*/
|
|
public String longQName(String s)
|
|
{
|
|
return createQName(s).toString();
|
|
}
|
|
|
|
/**
|
|
* Builds a paging object, from the supplied
|
|
* Max Items and Skip Count
|
|
*/
|
|
public ScriptPagingDetails createPaging(int maxItems, int skipCount)
|
|
{
|
|
return new ScriptPagingDetails(maxItems, skipCount);
|
|
}
|
|
|
|
/**
|
|
* Builds a paging object, from the supplied
|
|
* Max Items, Skip Count and Query Execution ID
|
|
*/
|
|
public ScriptPagingDetails createPaging(int maxItems, int skipCount, String queryExecutionId)
|
|
{
|
|
return new ScriptPagingDetails(maxItems, skipCount, queryExecutionId);
|
|
}
|
|
|
|
/**
|
|
* Builds a paging object, from the supplied Args object.
|
|
* Requires that the parameters have their standard names,
|
|
* i.e. "maxItems" and "skipCount"
|
|
*/
|
|
public ScriptPagingDetails createPaging(Map<String, String> args)
|
|
{
|
|
int maxItems = -1;
|
|
int skipCount = -1;
|
|
String queryId = null;
|
|
|
|
if(args.containsKey("maxItems"))
|
|
{
|
|
try
|
|
{
|
|
maxItems = Integer.parseInt(args.get("maxItems"));
|
|
}
|
|
catch(NumberFormatException e)
|
|
{}
|
|
}
|
|
if(args.containsKey("skipCount"))
|
|
{
|
|
try
|
|
{
|
|
skipCount = Integer.parseInt(args.get("skipCount"));
|
|
}
|
|
catch(NumberFormatException e)
|
|
{}
|
|
}
|
|
|
|
if(args.containsKey("queryId"))
|
|
{
|
|
queryId = args.get("queryId");
|
|
}
|
|
else if(args.containsKey("queryExecutionId"))
|
|
{
|
|
queryId = args.get("queryExecutionId");
|
|
}
|
|
|
|
return new ScriptPagingDetails(maxItems, skipCount, queryId);
|
|
}
|
|
|
|
/**
|
|
* Helper to create a QName from either a fully qualified or short-name QName string
|
|
*
|
|
* @param s Fully qualified or short-name QName string
|
|
*
|
|
* @return QName
|
|
*/
|
|
private QName createQName(String s)
|
|
{
|
|
QName qname;
|
|
if (s.indexOf(NAMESPACE_BEGIN) != -1)
|
|
{
|
|
qname = QName.createQName(s);
|
|
}
|
|
else
|
|
{
|
|
qname = QName.createQName(s, this.services.getNamespaceService());
|
|
}
|
|
return qname;
|
|
}
|
|
|
|
/**
|
|
* Get a localized message string, parameterized using standard MessageFormatter.
|
|
*
|
|
* @param messageKey message key
|
|
* @param params format parameters
|
|
* @return the localized string, null if not found
|
|
*/
|
|
public String toLocalizedString(String messageId, Object... params)
|
|
{
|
|
return I18NUtil.getMessage(messageId, params);
|
|
}
|
|
|
|
/**
|
|
* Disable rule execution for this thread
|
|
*/
|
|
public void disableRules()
|
|
{
|
|
services.getRuleService().disableRules();
|
|
}
|
|
|
|
/**
|
|
* Enable rule execution for this thread
|
|
*/
|
|
public void enableRules()
|
|
{
|
|
services.getRuleService().enableRules();
|
|
}
|
|
|
|
/**
|
|
* Sets current Locale from string
|
|
*/
|
|
public void setLocale(String language)
|
|
{
|
|
I18NUtil.setLocale(new Locale(language));
|
|
}
|
|
|
|
/**
|
|
* Returns current thread's locale
|
|
*/
|
|
public String getLocale()
|
|
{
|
|
return I18NUtil.getLocale().toString();
|
|
}
|
|
}
|