mirror of
				https://github.com/Alfresco/alfresco-community-repo.git
				synced 2025-10-29 15:21:53 +00:00 
			
		
		
		
	34397: ALF-13064: Updated document lib WebScript to protect against access errors dealing with permissions of locked documents
   34406: ALF-13069: Fix flash upload file selection page title corruption
   34434: ALF-13066: Fix for intermittent failure (testConcurrentLinkToDeletedNode)
   34439: Merged BRANCHES/V4.0 to BRANCHES/DEV/V4.0-BUG-FIX
      34438: Fix to issue where new Hazelcast based Share clustering was broken by a recent SpringSurf change to ServletRequestContextFactory bean config in libs rev 1028 or higher.
   34443: ALF-11433: IE8 specific fix to ensure that document-picker panel is hidden before documents selected event is fired and for TinyMCE to set focus on editor so that content is added correctly
   34457: Merged V3.4-BUG-FIX to V4.0-BUG-FIX
      34354: ALF-12995 - IMAP: File is modified when received as a message in IMAP account
      34444: ALF-12169: Guest/guest/gUest username is now normalized to corresponding person's user ID during authentication, solving problems with synchronization with Active Directory's Guest account
      34454: Java 1.6.0_31 for 3.4.9 and 4.0.2
   34458: Merged V3.4-BUG-FIX to V4.0-BUG-FIX (RECORD ONLY)
      34392: ALF-13146: Merged V4.0-BUG-FIX to V3.4-BUG-FIX
         33813: ALF-12736: Stack specific: 'Getting updates failed' notification appears when non-admin user creats DWS
            - From Pavel: "Some users from ldap don't have lastName. That is why NPE occurs."
   34459: Merged V4.0 to V4.0-BUG-FIX
      34391: Merged DEV to V4.0 (with corrections)
         34390: ALF-13013 : It's impossible to change Activities Feed properties on Websphere
            Now the Schedule subtree in JMX is set to the correct MBeanServer.
      34407: Merged HEAD-2011_12_06 to V4.0 (4.0.1)
         Updated copyrights 
         32813: ALF-4098: WCM: Assets in in-flight worflow are allowed to be edited.
         Ability of editing assets submitted to 'in-flight' workflow has been removed:
         - .AVMSyncService. service interface was expanded with new method .List<AVMDifference> compare(int srcVersion, String srcPath, int dstVersion, String dstPath, NameMatcher excluder, boolean expandDirs). to introduce ability of collecting all created/modified items in created/modified folder;
         - all .AVMSyncService. implementations were expanded in accordance with changes in interface;
         - new tests for newly created items, items in modified folder and for deleted items in modified folder were added
      34414: ALF-11607: Bootstrap fails against database 'DB2/LINUXX8664'
      - Patched hibernate jar to recognize DB2 64 bit Linux
      34416: ALF-12992: Updated weblogic DD for SOLR
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@34460 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
		
	
		
			
				
	
	
		
			199 lines
		
	
	
		
			8.2 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
			
		
		
	
	
			199 lines
		
	
	
		
			8.2 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
| /*
 | |
|  * Copyright (C) 2005-2012 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.wcm.util;
 | |
| 
 | |
| import java.util.ArrayList;
 | |
| import java.util.HashMap;
 | |
| import java.util.LinkedList;
 | |
| import java.util.List;
 | |
| 
 | |
| import org.alfresco.model.WCMWorkflowModel;
 | |
| import org.alfresco.repo.avm.AVMNodeConverter;
 | |
| import org.alfresco.repo.domain.PropertyValue;
 | |
| import org.alfresco.repo.workflow.WorkflowModel;
 | |
| import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
 | |
| import org.alfresco.service.cmr.avm.AVMNotFoundException;
 | |
| import org.alfresco.service.cmr.avm.AVMService;
 | |
| import org.alfresco.service.cmr.avm.LayeringDescriptor;
 | |
| import org.alfresco.service.cmr.avmsync.AVMDifference;
 | |
| import org.alfresco.service.cmr.avmsync.AVMSyncService;
 | |
| import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
 | |
| import org.alfresco.service.cmr.repository.NodeRef;
 | |
| import org.alfresco.service.cmr.workflow.WorkflowService;
 | |
| import org.alfresco.service.cmr.workflow.WorkflowTask;
 | |
| import org.alfresco.service.cmr.workflow.WorkflowTaskQuery;
 | |
| import org.alfresco.service.namespace.QName;
 | |
| import org.alfresco.wcm.sandbox.SandboxInfo;
 | |
| import org.apache.commons.logging.Log;
 | |
| import org.apache.commons.logging.LogFactory;
 | |
| 
 | |
| /**
 | |
|  * WCM Specific workflow related helper methods.
 | |
|  * 
 | |
|  * @author Ariel Backenroth
 | |
|  * @author Kevin Roast
 | |
|  * @author janv
 | |
|  */
 | |
| public class WCMWorkflowUtil
 | |
| {
 | |
|     private static final Log logger = LogFactory.getLog(WCMWorkflowUtil.class);
 | |
|     
 | |
|     public static NodeRef createWorkflowPackage(WorkflowService workflowService, AVMService avmService, SandboxInfo sandboxInfo)
 | |
|     {
 | |
|         // create package paths (layered to user sandbox area as target)
 | |
|         final String workflowMainStoreName = sandboxInfo.getMainStoreName();
 | |
|         final String packagesPath = WCMUtil.buildStoreRootPath(workflowMainStoreName);
 | |
|         
 | |
|         // convert package to workflow package
 | |
|         final AVMNodeDescriptor packageDesc = avmService.lookup(-1, packagesPath);
 | |
|         final NodeRef packageNodeRef = workflowService.createPackage(AVMNodeConverter.ToNodeRef(-1, packageDesc.getPath()));
 | |
|         
 | |
|         avmService.setNodeProperty(packagesPath, WorkflowModel.PROP_IS_SYSTEM_PACKAGE, new PropertyValue(DataTypeDefinition.BOOLEAN, true));
 | |
|         
 | |
|         // NOTE: WCM-1019: As permissions are now implemented for AVM nodes we no longer need to set permisssions here
 | |
|         //                 as they will be inherited from the store the workflow store is layered over.
 | |
|         
 | |
|         //final ServiceRegistry services = Repository.getServiceRegistry(FacesContext.getCurrentInstance());
 | |
|         //final PermissionService permissionService = services.getPermissionService();
 | |
|         //permissionService.setPermission(packageNodeRef, PermissionService.ALL_AUTHORITIES, PermissionService.ALL_PERMISSIONS, true);
 | |
|         
 | |
|         return packageNodeRef;
 | |
|     }
 | |
|     
 | |
|     public static List<WorkflowTask> getAssociatedTasksForSandbox(WorkflowService workflowService, final String storeName)
 | |
|     {
 | |
|         long start = System.currentTimeMillis();
 | |
|         
 | |
|         String fromPath = WCMUtil.buildStoreRootPath(storeName);
 | |
|         WorkflowTaskQuery query = new WorkflowTaskQuery();
 | |
|         
 | |
|         HashMap<QName, Object> props = new HashMap<QName, Object>(1, 1.0f);
 | |
|         
 | |
|         props.put(WCMWorkflowModel.PROP_FROM_PATH, fromPath);
 | |
|         query.setProcessCustomProps(props);
 | |
|         query.setActive(true);
 | |
|         
 | |
|         List<WorkflowTask> tasks = workflowService.queryTasks(query);
 | |
|         
 | |
|         if (logger.isTraceEnabled())
 | |
|         {
 | |
|             logger.trace("getAssociatedTasksForSandbox: "+storeName+" (found "+tasks.size()+" tasks originating user sandbox "+fromPath+") in "+(System.currentTimeMillis()-start)+" msecs");
 | |
|         }
 | |
|       
 | |
|        return tasks;
 | |
|     }
 | |
|     
 | |
|     /**
 | |
|      * @deprecated since 3.2
 | |
|      */
 | |
|     public static List<WorkflowTask> getAssociatedTasksForNode(AVMService avmService, AVMNodeDescriptor node, List<WorkflowTask> tasks)
 | |
|     {
 | |
|         List<WorkflowTask> result = new LinkedList<WorkflowTask>();
 | |
|       
 | |
|         for (WorkflowTask task : tasks)
 | |
|         {
 | |
|             final NodeRef ref = task.path.instance.workflowPackage;
 | |
|             final String path = WCMUtil.getCorrespondingPath(node.getPath(), ref.getStoreRef().getIdentifier());
 | |
|             
 | |
|             if (logger.isDebugEnabled())
 | |
|             {
 | |
|                 logger.debug("checking store " + ref.getStoreRef().getIdentifier() +
 | |
|                              " for " + node.getPath() + " (" + path + ")");
 | |
|             }
 | |
|             
 | |
|             try
 | |
|             {
 | |
|                 final LayeringDescriptor ld = avmService.getLayeringInfo(-1, path);
 | |
|                 if (!ld.isBackground())
 | |
|                 {
 | |
|                     if (logger.isDebugEnabled())
 | |
|                     {
 | |
|                         logger.debug(path + " is in the foreground.  workflow active");
 | |
|                     }
 | |
|                     
 | |
|                     result.add(task);
 | |
|                 }
 | |
|             }
 | |
|             catch (final AVMNotFoundException avmnfe)
 | |
|             {
 | |
|                 if (logger.isDebugEnabled())
 | |
|                 {
 | |
|                     logger.debug(path + " not found");
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
|       
 | |
|         return result;
 | |
|     }
 | |
|     
 | |
|     /**
 | |
|      * @deprecated since 3.2
 | |
|      */
 | |
|     public static List<WorkflowTask> getAssociatedTasksForNode(WorkflowService workflowService, AVMService avmService, AVMNodeDescriptor node)
 | |
|     {
 | |
|         final List<WorkflowTask> tasks = getAssociatedTasksForSandbox(workflowService, WCMUtil.getSandboxStoreId(node.getPath()));
 | |
|         return getAssociatedTasksForNode(avmService, node, tasks);
 | |
|     }
 | |
|     
 | |
|     public static List<String> getAssociatedPathsForSandbox(AVMSyncService avmSyncService, WorkflowService workflowService, String sandboxName)
 | |
|     {
 | |
|         long start = System.currentTimeMillis();
 | |
|         
 | |
|         List<WorkflowTask> tasks = getAssociatedTasksForSandbox(workflowService, sandboxName);
 | |
|         List<String> storeRelativePaths = getAssociatedPathsForSandboxTasks(avmSyncService, sandboxName, tasks);
 | |
|         
 | |
|         if (logger.isDebugEnabled())
 | |
|         {
 | |
|             logger.debug("getAssociatedPathsForSandbox: "+sandboxName+" (tasks="+tasks.size()+", paths="+storeRelativePaths.size()+") in "+(System.currentTimeMillis()-start)+" msecs");
 | |
|         }
 | |
|         
 | |
|         return storeRelativePaths;
 | |
|     }
 | |
|     
 | |
|     private static List<String> getAssociatedPathsForSandboxTasks(AVMSyncService avmSyncService, String sandboxName, List<WorkflowTask> tasks)
 | |
|     {
 | |
|         long start = System.currentTimeMillis();
 | |
|         
 | |
|         String stagingSandboxName = WCMUtil.buildStagingStoreName(WCMUtil.getWebProjectStoreId(sandboxName));
 | |
|         List<String> storeRelativePaths = new ArrayList<String>(tasks.size());
 | |
|         
 | |
|         for (WorkflowTask task : tasks)
 | |
|         {
 | |
|             final NodeRef ref = task.path.instance.workflowPackage;
 | |
|             
 | |
|             String wfPath = AVMNodeConverter.ToAVMVersionPath(ref).getSecond();
 | |
|             String stagingSandboxPath = WCMUtil.getCorrespondingPath(wfPath, stagingSandboxName);
 | |
|             
 | |
|             List<AVMDifference> diffs = avmSyncService.compare(-1, wfPath, -1, stagingSandboxPath, null, true);
 | |
|             
 | |
|             for (AVMDifference diff : diffs)
 | |
|             {
 | |
|                 storeRelativePaths.add(WCMUtil.getStoreRelativePath(diff.getSourcePath()));
 | |
|             }
 | |
|         }
 | |
|         
 | |
|         if (logger.isTraceEnabled())
 | |
|         {
 | |
|             logger.trace("getAssociatedPathsForSandboxTasks: "+sandboxName+" (tasks="+tasks.size()+", paths="+storeRelativePaths.size()+") in "+(System.currentTimeMillis()-start)+" msecs");
 | |
|         }
 | |
|         
 | |
|         return storeRelativePaths;
 | |
|     }
 | |
| }
 |