mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged HEAD-BUG-FIX (5.0/Cloud) to HEAD (5.0/Cloud)
78392: Merged EOL (5.0/Cloud) to HEAD-BUG-FIX (5.0/Cloud) 75693: ACE-2149 Remove AVM/WCM - first round, based on the following Sparta commits 08f1ff556cf3e8eb370e433b69b634026c848af1: SlimRepo: comment-out AVM schema bootstrap and wcm-services-context - plus associated bootstrap/startup fallout - note: disabling/removing WCM/AVM will be a work-in-progress due to tight code coupling :-( cdb78eeae53522cc2d78feb94be49d11648fa582; SlimRepo: comment-out AVM schema bootstrap and wcm-services-context - follow-on to fix "regenerate_renditions" fallout error (in Alfresco Explorer web client) 33337ad4239df91b9a8dc7a00be43e55ffef5bef: SlimRepo: remove WCM/AVM - round 1 (wip) - removal of some of the AVM code and tests (including core impl such as AVMServiceImpl, AVMRepository, AVMSyncServiceImpl, underlying DAOs etc) - fix Spring config (major impact) and any obvious compile-time fallout - ensured repo starts and ran (some of the) repo unit tests - also check basic Explorer access 47e50847bbbbdda5fd64a27c212dfbdd625cbfdb: Jenkins build/test repo - minor: disable/remove repo tests - disabled unused tests, removed remaining AVM* tests git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@82537 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -21,7 +21,6 @@ package org.alfresco.repo.admin.patch.impl;
|
||||
import java.sql.Savepoint;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
@@ -29,8 +28,6 @@ import org.alfresco.repo.admin.patch.AbstractPatch;
|
||||
import org.alfresco.repo.admin.patch.PatchExecuter;
|
||||
import org.alfresco.repo.admin.registry.RegistryKey;
|
||||
import org.alfresco.repo.admin.registry.RegistryService;
|
||||
import org.alfresco.repo.avm.AVMDAOs;
|
||||
import org.alfresco.repo.avm.PlainFileNode;
|
||||
import org.alfresco.repo.batch.BatchProcessor;
|
||||
import org.alfresco.repo.batch.BatchProcessor.BatchProcessWorkerAdaptor;
|
||||
import org.alfresco.repo.content.ContentStore;
|
||||
@@ -39,14 +36,13 @@ import org.alfresco.repo.domain.contentdata.ContentDataDAO;
|
||||
import org.alfresco.repo.domain.control.ControlDAO;
|
||||
import org.alfresco.repo.domain.patch.PatchDAO;
|
||||
import org.alfresco.repo.lock.JobLockService;
|
||||
import org.alfresco.repo.lock.JobLockService.JobLockRefreshCallback;
|
||||
import org.alfresco.repo.lock.LockAcquisitionException;
|
||||
import org.alfresco.repo.lock.JobLockService.JobLockRefreshCallback;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
|
||||
import org.alfresco.repo.transaction.AlfrescoTransactionSupport.TxnReadState;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.ContentData;
|
||||
import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
@@ -316,8 +312,13 @@ public class ContentUrlConverterPatch extends AbstractPatch
|
||||
|
||||
logger.info(I18NUtil.getMessage("patch.convertContentUrls.adm.start"));
|
||||
boolean admCompleted = applyADMLooping(running);
|
||||
|
||||
/* Sparta: remove WCM/AVM
|
||||
logger.info(I18NUtil.getMessage("patch.convertContentUrls.avm.start"));
|
||||
boolean avmCompleted = applyAVMLooping(running);
|
||||
*/
|
||||
boolean avmCompleted = true;
|
||||
|
||||
logger.info(I18NUtil.getMessage("patch.convertContentUrls.store.start", contentStore));
|
||||
boolean urlLiftingCompleted = applyUrlLifting(running);
|
||||
|
||||
@@ -468,6 +469,7 @@ public class ContentUrlConverterPatch extends AbstractPatch
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
private boolean applyAVMLooping(final AtomicBoolean running)
|
||||
{
|
||||
RetryingTransactionCallback<Boolean> callback = new RetryingTransactionCallback<Boolean>()
|
||||
@@ -488,10 +490,12 @@ public class ContentUrlConverterPatch extends AbstractPatch
|
||||
}
|
||||
return done;
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Do the AVM conversion work
|
||||
*/
|
||||
/*
|
||||
private boolean applyAVM() throws Exception
|
||||
{
|
||||
Long maxId = (Long) registryService.getProperty(KEY_AVM_MAX_ID);
|
||||
@@ -563,6 +567,7 @@ public class ContentUrlConverterPatch extends AbstractPatch
|
||||
// More to do
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
|
||||
private boolean applyUrlLifting(final AtomicBoolean running) throws Exception
|
||||
{
|
||||
|
@@ -1,426 +0,0 @@
|
||||
/*
|
||||
* 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.admin.patch.impl;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.alfresco.model.WCMAppModel;
|
||||
import org.alfresco.repo.admin.patch.AbstractPatch;
|
||||
import org.alfresco.repo.avm.AVMNodeConverter;
|
||||
import org.alfresco.repo.domain.PropertyValue;
|
||||
import org.alfresco.repo.search.AVMSnapShotTriggeredIndexingMethodInterceptor;
|
||||
import org.alfresco.repo.search.AVMSnapShotTriggeredIndexingMethodInterceptorImpl.StoreType;
|
||||
import org.alfresco.service.cmr.avm.AVMService;
|
||||
import org.alfresco.service.cmr.avm.AVMStoreDescriptor;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.security.AccessPermission;
|
||||
import org.alfresco.service.cmr.security.AuthorityService;
|
||||
import org.alfresco.service.cmr.security.AuthorityType;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.namespace.RegexQNamePattern;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
|
||||
/**
|
||||
* Remove ACLs on all but staging area stores On staging area stores, set ACls according to the users and roles as set
|
||||
* on the web site Note: runs as the system user
|
||||
*
|
||||
* @author andyh
|
||||
*/
|
||||
public class MoveWCMToGroupBasedPermissionsPatch extends AbstractPatch
|
||||
{
|
||||
public static final String[] PERMISSIONS = new String[]
|
||||
{
|
||||
PermissionService.WCM_CONTENT_MANAGER, PermissionService.WCM_CONTENT_PUBLISHER,
|
||||
PermissionService.WCM_CONTENT_CONTRIBUTOR, PermissionService.WCM_CONTENT_REVIEWER
|
||||
};
|
||||
|
||||
protected static final String WCM_STORE_SEPARATOR = "--";
|
||||
|
||||
private static final String MSG_SUCCESS = "patch.moveWCMToGroupBasedPermissionsPatch.result";
|
||||
|
||||
AVMSnapShotTriggeredIndexingMethodInterceptor avmSnapShotTriggeredIndexingMethodInterceptor;
|
||||
|
||||
AVMService avmService;
|
||||
|
||||
PermissionService permissionService;
|
||||
|
||||
AuthorityService authorityService;
|
||||
|
||||
String replaceAllWith = PermissionService.WCM_CONTENT_MANAGER;
|
||||
|
||||
public void setAvmService(AVMService avmService)
|
||||
{
|
||||
this.avmService = avmService;
|
||||
}
|
||||
|
||||
public void setAvmSnapShotTriggeredIndexingMethodInterceptor(
|
||||
AVMSnapShotTriggeredIndexingMethodInterceptor avmSnapShotTriggeredIndexingMethodInterceptor)
|
||||
{
|
||||
this.avmSnapShotTriggeredIndexingMethodInterceptor = avmSnapShotTriggeredIndexingMethodInterceptor;
|
||||
}
|
||||
|
||||
public void setPermissionService(PermissionService permissionService)
|
||||
{
|
||||
this.permissionService = permissionService;
|
||||
}
|
||||
|
||||
public void setAuthorityService(AuthorityService authorityService)
|
||||
{
|
||||
this.authorityService = authorityService;
|
||||
}
|
||||
|
||||
public void setReplaceAllWith(String replaceAllWith)
|
||||
{
|
||||
this.replaceAllWith = replaceAllWith;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String applyInternal() throws Exception
|
||||
{
|
||||
List<AVMStoreDescriptor> stores = this.avmService.getStores();
|
||||
for (AVMStoreDescriptor store : stores)
|
||||
{
|
||||
|
||||
Map<QName, PropertyValue> storeProperties = this.avmService.getStoreProperties(store.getName());
|
||||
|
||||
switch (StoreType.getStoreType(store.getName(), store, storeProperties))
|
||||
{
|
||||
/* Set permissions in staging */
|
||||
case STAGING:
|
||||
fixAllPermissions(store);
|
||||
setStagingAreaPermissions(store);
|
||||
setStagingAreaMasks(store);
|
||||
// TODO: mark read only
|
||||
break;
|
||||
/* Clear permissions */
|
||||
case AUTHOR:
|
||||
case AUTHOR_PREVIEW:
|
||||
case AUTHOR_WORKFLOW:
|
||||
case AUTHOR_WORKFLOW_PREVIEW:
|
||||
fixAllStagingPermissions(store);
|
||||
setSandBoxMasks(store);
|
||||
break;
|
||||
case STAGING_PREVIEW:
|
||||
fixAllStagingPermissions(store);
|
||||
setStagingAreaMasks(store);
|
||||
// TODO: mark read only
|
||||
break;
|
||||
case WORKFLOW:
|
||||
case WORKFLOW_PREVIEW:
|
||||
break;
|
||||
/* non WCM stores - nothing to do */
|
||||
case UNKNOWN:
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
// build the result message
|
||||
String msg = I18NUtil.getMessage(MoveWCMToGroupBasedPermissionsPatch.MSG_SUCCESS);
|
||||
// done
|
||||
return msg;
|
||||
}
|
||||
|
||||
private boolean isPermissionSet(NodeRef nodeRef, String authority, String permission)
|
||||
{
|
||||
Set<AccessPermission> set = this.permissionService.getAllSetPermissions(nodeRef);
|
||||
for (AccessPermission ap : set)
|
||||
{
|
||||
if (ap.getAuthority().equals(authority) && ap.isSetDirectly() && ap.getPermission().equals(permission))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isMaskSet(StoreRef storeRef, String authority, String permission)
|
||||
{
|
||||
Set<AccessPermission> set = this.permissionService.getAllSetPermissions(storeRef);
|
||||
for (AccessPermission ap : set)
|
||||
{
|
||||
if (ap.getAuthority().equals(authority) && ap.isSetDirectly() && ap.getPermission().equals(permission))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void makeGroupsIfRequired(String stagingStoreName, NodeRef dirRef)
|
||||
{
|
||||
for (String permission : MoveWCMToGroupBasedPermissionsPatch.PERMISSIONS)
|
||||
{
|
||||
String shortName = stagingStoreName + "-" + permission;
|
||||
String group = this.authorityService.getName(AuthorityType.GROUP, shortName);
|
||||
if (!this.authorityService.authorityExists(group))
|
||||
{
|
||||
String newGroup = this.authorityService.createAuthority(AuthorityType.GROUP, shortName);
|
||||
this.permissionService.setPermission(dirRef, newGroup, permission, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void addToGroupIfRequired(String stagingStoreName, String user, String permission)
|
||||
{
|
||||
String shortName = stagingStoreName + "-" + permission;
|
||||
String group = this.authorityService.getName(AuthorityType.GROUP, shortName);
|
||||
Set<String> members = this.authorityService.getContainedAuthorities(AuthorityType.USER, group, true);
|
||||
if (!members.contains(user))
|
||||
{
|
||||
this.authorityService.addAuthority(group, user);
|
||||
}
|
||||
}
|
||||
|
||||
private void fixAllPermissions(AVMStoreDescriptor store)
|
||||
{
|
||||
fixAllPermissionsImpl(store.getName());
|
||||
}
|
||||
|
||||
private void fixAllStagingPermissions(AVMStoreDescriptor store)
|
||||
{
|
||||
|
||||
String stagingAreaName = extractStagingAreaName(store.getName());
|
||||
fixAllPermissionsImpl(stagingAreaName);
|
||||
}
|
||||
|
||||
private void fixAllPermissionsImpl(String stagingStoreName)
|
||||
{
|
||||
QName propQName = QName.createQName(null, ".web_project.noderef");
|
||||
|
||||
PropertyValue pValue = this.avmService.getStoreProperty(stagingStoreName, propQName);
|
||||
|
||||
if (pValue != null)
|
||||
{
|
||||
NodeRef webProjectNodeRef = (NodeRef) pValue.getValue(DataTypeDefinition.NODE_REF);
|
||||
|
||||
// Apply sepcific user permissions as set on the web project
|
||||
List<ChildAssociationRef> userInfoRefs = this.nodeService.getChildAssocs(webProjectNodeRef,
|
||||
WCMAppModel.ASSOC_WEBUSER, RegexQNamePattern.MATCH_ALL);
|
||||
for (ChildAssociationRef ref : userInfoRefs)
|
||||
{
|
||||
NodeRef userInfoRef = ref.getChildRef();
|
||||
//String username = (String) this.nodeService.getProperty(userInfoRef, WCMAppModel.PROP_WEBUSERNAME); // not used
|
||||
String userrole = (String) this.nodeService.getProperty(userInfoRef, WCMAppModel.PROP_WEBUSERROLE);
|
||||
|
||||
if (userrole.equals(PermissionService.ALL_PERMISSIONS))
|
||||
{
|
||||
this.nodeService.setProperty(userInfoRef, WCMAppModel.PROP_WEBUSERROLE, this.replaceAllWith);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void setStagingAreaPermissions(AVMStoreDescriptor store) throws Exception
|
||||
{
|
||||
QName propQName = QName.createQName(null, ".web_project.noderef");
|
||||
|
||||
NodeRef dirRef = AVMNodeConverter.ToNodeRef(-1, store.getName() + ":/www");
|
||||
|
||||
makeGroupsIfRequired(store.getName(), dirRef);
|
||||
|
||||
if (!isPermissionSet(dirRef, PermissionService.ALL_AUTHORITIES, PermissionService.READ))
|
||||
{
|
||||
this.permissionService.setPermission(dirRef, PermissionService.ALL_AUTHORITIES, PermissionService.READ,
|
||||
true);
|
||||
}
|
||||
|
||||
// Add group permissions
|
||||
for (String permission : MoveWCMToGroupBasedPermissionsPatch.PERMISSIONS)
|
||||
{
|
||||
String cms = this.authorityService.getName(AuthorityType.GROUP, store.getName() + "-" + permission);
|
||||
this.permissionService.setPermission(dirRef, cms, permission, true);
|
||||
}
|
||||
|
||||
PropertyValue pValue = this.avmService.getStoreProperty(store.getName(), propQName);
|
||||
|
||||
if (pValue != null)
|
||||
{
|
||||
NodeRef webProjectNodeRef = (NodeRef) pValue.getValue(DataTypeDefinition.NODE_REF);
|
||||
|
||||
// Apply sepcific user permissions as set on the web project
|
||||
List<ChildAssociationRef> userInfoRefs = this.nodeService.getChildAssocs(webProjectNodeRef,
|
||||
WCMAppModel.ASSOC_WEBUSER, RegexQNamePattern.MATCH_ALL);
|
||||
for (ChildAssociationRef ref : userInfoRefs)
|
||||
{
|
||||
NodeRef userInfoRef = ref.getChildRef();
|
||||
String username = (String) this.nodeService.getProperty(userInfoRef, WCMAppModel.PROP_WEBUSERNAME);
|
||||
String userrole = (String) this.nodeService.getProperty(userInfoRef, WCMAppModel.PROP_WEBUSERROLE);
|
||||
|
||||
// remove existing
|
||||
|
||||
if (isPermissionSet(dirRef, username, userrole))
|
||||
{
|
||||
this.permissionService.deletePermission(dirRef, username, userrole);
|
||||
}
|
||||
|
||||
addToGroupIfRequired(store.getName(), username, userrole);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void setStagingAreaMasks(AVMStoreDescriptor store)
|
||||
{
|
||||
// groups must exist
|
||||
NodeRef dirRef = AVMNodeConverter.ToNodeRef(-1, store.getName() + ":/www");
|
||||
|
||||
if (!isMaskSet(dirRef.getStoreRef(), PermissionService.ALL_AUTHORITIES, PermissionService.READ))
|
||||
{
|
||||
this.permissionService.setPermission(dirRef.getStoreRef(), PermissionService.ALL_AUTHORITIES,
|
||||
PermissionService.READ, true);
|
||||
}
|
||||
|
||||
String cms = this.authorityService.getName(AuthorityType.GROUP, store.getName() + "-"
|
||||
+ PermissionService.WCM_CONTENT_MANAGER);
|
||||
if (!isMaskSet(dirRef.getStoreRef(), cms, PermissionService.CHANGE_PERMISSIONS))
|
||||
{
|
||||
this.permissionService.setPermission(dirRef.getStoreRef(), cms, PermissionService.CHANGE_PERMISSIONS, true);
|
||||
}
|
||||
|
||||
if (!isMaskSet(dirRef.getStoreRef(), cms, PermissionService.READ_PERMISSIONS))
|
||||
{
|
||||
this.permissionService.setPermission(dirRef.getStoreRef(), cms, PermissionService.READ_PERMISSIONS, true);
|
||||
}
|
||||
|
||||
QName propQName = QName.createQName(null, ".web_project.noderef");
|
||||
|
||||
PropertyValue pValue = this.avmService.getStoreProperty(store.getName(), propQName);
|
||||
|
||||
if (pValue != null)
|
||||
{
|
||||
NodeRef webProjectNodeRef = (NodeRef) pValue.getValue(DataTypeDefinition.NODE_REF);
|
||||
|
||||
// Apply sepcific user permissions as set on the web project
|
||||
List<ChildAssociationRef> userInfoRefs = this.nodeService.getChildAssocs(webProjectNodeRef,
|
||||
WCMAppModel.ASSOC_WEBUSER, RegexQNamePattern.MATCH_ALL);
|
||||
for (ChildAssociationRef ref : userInfoRefs)
|
||||
{
|
||||
NodeRef userInfoRef = ref.getChildRef();
|
||||
String username = (String) this.nodeService.getProperty(userInfoRef, WCMAppModel.PROP_WEBUSERNAME);
|
||||
String userrole = (String) this.nodeService.getProperty(userInfoRef, WCMAppModel.PROP_WEBUSERROLE);
|
||||
|
||||
if (userrole.equals(PermissionService.WCM_CONTENT_MANAGER))
|
||||
{
|
||||
// remove existing
|
||||
|
||||
if (isMaskSet(dirRef.getStoreRef(), username, PermissionService.CHANGE_PERMISSIONS))
|
||||
{
|
||||
this.permissionService.deletePermission(dirRef.getStoreRef(), username,
|
||||
PermissionService.CHANGE_PERMISSIONS);
|
||||
}
|
||||
|
||||
if (isMaskSet(dirRef.getStoreRef(), username, PermissionService.READ_PERMISSIONS))
|
||||
{
|
||||
this.permissionService.deletePermission(dirRef.getStoreRef(), username,
|
||||
PermissionService.READ_PERMISSIONS);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void setSandBoxMasks(AVMStoreDescriptor sandBoxStore)
|
||||
{
|
||||
// get the settings from the staging store ...
|
||||
|
||||
String owner = extractOwner(sandBoxStore.getName());
|
||||
String stagingAreaName = extractStagingAreaName(sandBoxStore.getName());
|
||||
|
||||
QName propQName = QName.createQName(null, ".web_project.noderef");
|
||||
|
||||
NodeRef dirRef = AVMNodeConverter.ToNodeRef(-1, sandBoxStore.getName() + ":/www");
|
||||
|
||||
//Map<QName, PropertyValue> woof = this.avmService.getStoreProperties(stagingAreaName); // not used
|
||||
PropertyValue pValue = this.avmService.getStoreProperty(stagingAreaName, propQName);
|
||||
|
||||
if (!isMaskSet(dirRef.getStoreRef(), PermissionService.ALL_AUTHORITIES, PermissionService.READ))
|
||||
{
|
||||
this.permissionService.setPermission(dirRef.getStoreRef(), PermissionService.ALL_AUTHORITIES,
|
||||
PermissionService.READ, true);
|
||||
}
|
||||
|
||||
String cms = this.authorityService.getName(AuthorityType.GROUP, stagingAreaName + "-"
|
||||
+ PermissionService.WCM_CONTENT_MANAGER);
|
||||
if (!isMaskSet(dirRef.getStoreRef(), cms, PermissionService.WCM_CONTENT_MANAGER))
|
||||
{
|
||||
this.permissionService
|
||||
.setPermission(dirRef.getStoreRef(), cms, PermissionService.WCM_CONTENT_MANAGER, true);
|
||||
}
|
||||
|
||||
if (pValue != null)
|
||||
{
|
||||
NodeRef webProjectNodeRef = (NodeRef) pValue.getValue(DataTypeDefinition.NODE_REF);
|
||||
|
||||
// Apply sepcific user permissions as set on the web project
|
||||
List<ChildAssociationRef> userInfoRefs = this.nodeService.getChildAssocs(webProjectNodeRef,
|
||||
WCMAppModel.ASSOC_WEBUSER, RegexQNamePattern.MATCH_ALL);
|
||||
for (ChildAssociationRef ref : userInfoRefs)
|
||||
{
|
||||
NodeRef userInfoRef = ref.getChildRef();
|
||||
String username = (String) this.nodeService.getProperty(userInfoRef, WCMAppModel.PROP_WEBUSERNAME);
|
||||
String userrole = (String) this.nodeService.getProperty(userInfoRef, WCMAppModel.PROP_WEBUSERROLE);
|
||||
|
||||
if (username.equals(owner))
|
||||
{
|
||||
this.permissionService.setPermission(dirRef.getStoreRef(), username,
|
||||
PermissionService.ALL_PERMISSIONS, true);
|
||||
}
|
||||
else if (userrole.equals("ContentManager"))
|
||||
{
|
||||
if (isMaskSet(dirRef.getStoreRef(), username, userrole))
|
||||
{
|
||||
this.permissionService.deletePermission(dirRef.getStoreRef(), username, userrole);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String extractOwner(String name)
|
||||
{
|
||||
int start = name.indexOf(WCM_STORE_SEPARATOR);
|
||||
if (start == -1)
|
||||
{
|
||||
throw new UnsupportedOperationException(name);
|
||||
}
|
||||
int end = name.indexOf(WCM_STORE_SEPARATOR, start + 1);
|
||||
if (end == -1)
|
||||
{
|
||||
return name.substring(start + 2);
|
||||
}
|
||||
return name.substring(start + 2, end);
|
||||
}
|
||||
|
||||
protected String extractStagingAreaName(String name)
|
||||
{
|
||||
int index = name.indexOf(WCM_STORE_SEPARATOR);
|
||||
if (index == -1)
|
||||
{
|
||||
throw new UnsupportedOperationException(name);
|
||||
}
|
||||
return name.substring(0, index);
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@@ -1,364 +0,0 @@
|
||||
/*
|
||||
* 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.admin.patch.impl;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.alfresco.model.ApplicationModel;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.admin.patch.AbstractPatch;
|
||||
import org.alfresco.repo.importer.ImporterBootstrap;
|
||||
import org.alfresco.repo.rule.RuleModel;
|
||||
import org.alfresco.service.cmr.admin.PatchException;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.springframework.context.MessageSource;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
|
||||
/**
|
||||
* Ensures that the <b>Web Projects</b> and <b>Web Forms</b>folders are present.
|
||||
* <p>
|
||||
* This uses the bootstrap importer to get the paths to look for. If not present,
|
||||
* the required structures are created.
|
||||
* <p>
|
||||
*
|
||||
* @author Kevin Roast
|
||||
*/
|
||||
public class WCMFoldersPatch extends AbstractPatch
|
||||
{
|
||||
private static final String MSG_WEBPROJECTS_EXISTS = "patch.wcmFolders.webprojects.result.exists";
|
||||
private static final String MSG_WEBPROJECTS_CREATED = "patch.wcmFolders.webprojects.result.created";
|
||||
private static final String MSG_WEBFORMS_EXISTS = "patch.wcmFolders.webforms.result.exists";
|
||||
private static final String MSG_WEBFORMS_CREATED = "patch.wcmFolders.webforms.result.created";
|
||||
|
||||
private static final String PROPERTY_COMPANY_HOME_CHILDNAME = "spaces.company_home.childname";
|
||||
private static final String PROPERTY_DICTIONARY_CHILDNAME = "spaces.dictionary.childname";
|
||||
public static final String PROPERTY_WEBPROJECTS_FOLDER_CHILDNAME = "spaces.wcm.childname";
|
||||
private static final String MSG_WEBPROJECTS_FOLDER_NAME = "spaces.wcm.name";
|
||||
private static final String MSG_WEBPROJECTS_FOLDER_DESCRIPTION = "spaces.wcm.description";
|
||||
public static final String PROPERTY_WEBFORMS_FOLDER_CHILDNAME = "spaces.wcm_content_forms.childname";
|
||||
private static final String MSG_WEBFORMS_FOLDER_NAME = "spaces.wcm_content_forms.name";
|
||||
private static final String MSG_WEBFORMS_FOLDER_DESCRIPTION = "spaces.wcm_content_forms.description";
|
||||
|
||||
private static final String PROPERTY_ICON = "space-icon-default";
|
||||
|
||||
private ImporterBootstrap importerBootstrap;
|
||||
private MessageSource messageSource;
|
||||
|
||||
protected NodeRef companyHomeNodeRef;
|
||||
protected NodeRef dictionaryNodeRef;
|
||||
protected Properties configuration;
|
||||
protected NodeRef wcmProjectsFolderNodeRef;
|
||||
protected NodeRef wcmFormsFolderNodeRef;
|
||||
|
||||
public void setImporterBootstrap(ImporterBootstrap importerBootstrap)
|
||||
{
|
||||
this.importerBootstrap = importerBootstrap;
|
||||
}
|
||||
|
||||
public void setMessageSource(MessageSource messageSource)
|
||||
{
|
||||
this.messageSource = messageSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that required common properties have been set
|
||||
*/
|
||||
protected void checkCommonProperties() throws Exception
|
||||
{
|
||||
if (importerBootstrap == null)
|
||||
{
|
||||
throw new PatchException("'importerBootstrap' property has not been set");
|
||||
}
|
||||
else if (namespaceService == null)
|
||||
{
|
||||
throw new PatchException("'namespaceService' property has not been set");
|
||||
}
|
||||
else if (searchService == null)
|
||||
{
|
||||
throw new PatchException("'searchService' property has not been set");
|
||||
}
|
||||
else if (nodeService == null)
|
||||
{
|
||||
throw new PatchException("'nodeService' property has not been set");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts pertinent references and properties that are common to execution
|
||||
* of this and derived patches.
|
||||
*/
|
||||
protected void setUp() throws Exception
|
||||
{
|
||||
// get the node store that we must work against
|
||||
StoreRef storeRef = importerBootstrap.getStoreRef();
|
||||
if (storeRef == null)
|
||||
{
|
||||
throw new PatchException("Bootstrap store has not been set");
|
||||
}
|
||||
NodeRef storeRootNodeRef = nodeService.getRootNode(storeRef);
|
||||
|
||||
this.configuration = importerBootstrap.getConfiguration();
|
||||
// get the association names that form the path
|
||||
String companyHomeChildName = configuration.getProperty(PROPERTY_COMPANY_HOME_CHILDNAME);
|
||||
if (companyHomeChildName == null || companyHomeChildName.length() == 0)
|
||||
{
|
||||
throw new PatchException("Bootstrap property '" + PROPERTY_COMPANY_HOME_CHILDNAME + "' is not present");
|
||||
}
|
||||
String dictionaryChildName = configuration.getProperty(PROPERTY_DICTIONARY_CHILDNAME);
|
||||
if (dictionaryChildName == null || dictionaryChildName.length() == 0)
|
||||
{
|
||||
throw new PatchException("Bootstrap property '" + PROPERTY_DICTIONARY_CHILDNAME + "' is not present");
|
||||
}
|
||||
String wcmProjectsChildName = configuration.getProperty(PROPERTY_WEBPROJECTS_FOLDER_CHILDNAME);
|
||||
if (wcmProjectsChildName == null || wcmProjectsChildName.length() == 0)
|
||||
{
|
||||
throw new PatchException("Bootstrap property '" + PROPERTY_WEBPROJECTS_FOLDER_CHILDNAME + "' is not present");
|
||||
}
|
||||
String wcmFormsChildName = configuration.getProperty(PROPERTY_WEBFORMS_FOLDER_CHILDNAME);
|
||||
if (wcmFormsChildName == null || wcmFormsChildName.length() == 0)
|
||||
{
|
||||
throw new PatchException("Bootstrap property '" + PROPERTY_WEBFORMS_FOLDER_CHILDNAME + "' is not present");
|
||||
}
|
||||
|
||||
// build the search string to get the company home node
|
||||
StringBuilder sb = new StringBuilder(256);
|
||||
sb.append("/").append(companyHomeChildName);
|
||||
String xpath = sb.toString();
|
||||
// get the company home
|
||||
List<NodeRef> nodeRefs = searchService.selectNodes(storeRootNodeRef, xpath, null, namespaceService, false);
|
||||
if (nodeRefs.size() == 0)
|
||||
{
|
||||
throw new PatchException("XPath didn't return any results: \n" +
|
||||
" root: " + storeRootNodeRef + "\n" +
|
||||
" xpath: " + xpath);
|
||||
}
|
||||
else if (nodeRefs.size() > 1)
|
||||
{
|
||||
throw new PatchException("XPath returned too many results: \n" +
|
||||
" root: " + storeRootNodeRef + "\n" +
|
||||
" xpath: " + xpath + "\n" +
|
||||
" results: " + nodeRefs);
|
||||
}
|
||||
this.companyHomeNodeRef = nodeRefs.get(0);
|
||||
|
||||
// build the search string to get the dictionary node
|
||||
sb.append("/").append(dictionaryChildName);
|
||||
xpath = sb.toString();
|
||||
// get the dictionary node
|
||||
nodeRefs = searchService.selectNodes(storeRootNodeRef, xpath, null, namespaceService, false);
|
||||
if (nodeRefs.size() == 0)
|
||||
{
|
||||
throw new PatchException("XPath didn't return any results: \n" +
|
||||
" root: " + storeRootNodeRef + "\n" +
|
||||
" xpath: " + xpath);
|
||||
}
|
||||
else if (nodeRefs.size() > 1)
|
||||
{
|
||||
throw new PatchException("XPath returned too many results: \n" +
|
||||
" root: " + storeRootNodeRef + "\n" +
|
||||
" xpath: " + xpath + "\n" +
|
||||
" results: " + nodeRefs);
|
||||
}
|
||||
this.dictionaryNodeRef = nodeRefs.get(0);
|
||||
|
||||
// Check for the existence of the 'Web Projects' folder
|
||||
xpath = wcmProjectsChildName;
|
||||
nodeRefs = searchService.selectNodes(companyHomeNodeRef, xpath, null, namespaceService, false);
|
||||
if (nodeRefs.size() > 1)
|
||||
{
|
||||
throw new PatchException("XPath returned too many results: \n" +
|
||||
" company home node: " + companyHomeNodeRef + "\n" +
|
||||
" xpath: " + xpath + "\n" +
|
||||
" results: " + nodeRefs);
|
||||
}
|
||||
else if (nodeRefs.size() == 0)
|
||||
{
|
||||
// the node does not exist
|
||||
this.wcmProjectsFolderNodeRef = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
// we have the 'Web Projects' folder noderef
|
||||
this.wcmProjectsFolderNodeRef = nodeRefs.get(0);
|
||||
}
|
||||
|
||||
// Check for the existence of the 'Web Forms' folder
|
||||
xpath = wcmFormsChildName;
|
||||
nodeRefs = searchService.selectNodes(dictionaryNodeRef, xpath, null, namespaceService, false);
|
||||
if (nodeRefs.size() > 1)
|
||||
{
|
||||
throw new PatchException("XPath returned too many results: \n" +
|
||||
" dictionary node: " + dictionaryNodeRef + "\n" +
|
||||
" xpath: " + xpath + "\n" +
|
||||
" results: " + nodeRefs);
|
||||
}
|
||||
else if (nodeRefs.size() == 0)
|
||||
{
|
||||
// the node does not exist
|
||||
this.wcmFormsFolderNodeRef = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
// we have the 'Web Forms' folder noderef
|
||||
this.wcmFormsFolderNodeRef = nodeRefs.get(0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String applyInternal() throws Exception
|
||||
{
|
||||
// properties must be set
|
||||
checkCommonProperties();
|
||||
if (messageSource == null)
|
||||
{
|
||||
throw new PatchException("'messageSource' property has not been set");
|
||||
}
|
||||
|
||||
// get useful values
|
||||
setUp();
|
||||
|
||||
String msg = null;
|
||||
if (wcmProjectsFolderNodeRef == null)
|
||||
{
|
||||
// create it
|
||||
createWebProjectsFolder();
|
||||
msg = I18NUtil.getMessage(MSG_WEBPROJECTS_CREATED, wcmProjectsFolderNodeRef);
|
||||
}
|
||||
else
|
||||
{
|
||||
// it already exists
|
||||
msg = I18NUtil.getMessage(MSG_WEBPROJECTS_EXISTS, wcmProjectsFolderNodeRef);
|
||||
}
|
||||
|
||||
if (wcmFormsFolderNodeRef == null)
|
||||
{
|
||||
// create it
|
||||
createWebFormsFolder();
|
||||
msg = msg + "\r\n" + I18NUtil.getMessage(MSG_WEBFORMS_CREATED, wcmProjectsFolderNodeRef);
|
||||
}
|
||||
else
|
||||
{
|
||||
// it already exists
|
||||
msg = msg + "\r\n" + I18NUtil.getMessage(MSG_WEBFORMS_EXISTS, wcmProjectsFolderNodeRef);
|
||||
}
|
||||
|
||||
// done
|
||||
return msg;
|
||||
}
|
||||
|
||||
private void createWebProjectsFolder()
|
||||
{
|
||||
// get required properties
|
||||
String wcmProjectsChildName = configuration.getProperty(PROPERTY_WEBPROJECTS_FOLDER_CHILDNAME);
|
||||
if (wcmProjectsChildName == null)
|
||||
{
|
||||
throw new PatchException("Bootstrap property '" + PROPERTY_WEBPROJECTS_FOLDER_CHILDNAME + "' is not present");
|
||||
}
|
||||
|
||||
String name = messageSource.getMessage(
|
||||
MSG_WEBPROJECTS_FOLDER_NAME,
|
||||
null,
|
||||
I18NUtil.getLocale());
|
||||
if (name == null || name.length() == 0)
|
||||
{
|
||||
throw new PatchException("Bootstrap property '" + MSG_WEBPROJECTS_FOLDER_NAME + "' is not present");
|
||||
}
|
||||
|
||||
String description = messageSource.getMessage(
|
||||
MSG_WEBPROJECTS_FOLDER_DESCRIPTION,
|
||||
null,
|
||||
I18NUtil.getLocale());
|
||||
if (description == null || description.length() == 0)
|
||||
{
|
||||
throw new PatchException("Bootstrap property '" + MSG_WEBPROJECTS_FOLDER_DESCRIPTION + "' is not present");
|
||||
}
|
||||
|
||||
Map<QName, Serializable> properties = new HashMap<QName, Serializable>(7);
|
||||
properties.put(ContentModel.PROP_NAME, name);
|
||||
properties.put(ContentModel.PROP_TITLE, name);
|
||||
properties.put(ContentModel.PROP_DESCRIPTION, description);
|
||||
properties.put(ApplicationModel.PROP_ICON, PROPERTY_ICON);
|
||||
// create the node
|
||||
ChildAssociationRef childAssocRef = nodeService.createNode(
|
||||
companyHomeNodeRef,
|
||||
ContentModel.ASSOC_CONTAINS,
|
||||
QName.resolveToQName(namespaceService, wcmProjectsChildName),
|
||||
ContentModel.TYPE_FOLDER,
|
||||
properties);
|
||||
wcmProjectsFolderNodeRef = childAssocRef.getChildRef();
|
||||
|
||||
// add the required aspects
|
||||
nodeService.addAspect(wcmProjectsFolderNodeRef, ApplicationModel.ASPECT_UIFACETS, null);
|
||||
|
||||
// ALF-906: ensure that DM rules are not inherited by web projects
|
||||
nodeService.addAspect(wcmProjectsFolderNodeRef, RuleModel.ASPECT_IGNORE_INHERITED_RULES, null);
|
||||
}
|
||||
|
||||
private void createWebFormsFolder()
|
||||
{
|
||||
// get required properties
|
||||
String wcmFormsChildName = configuration.getProperty(PROPERTY_WEBFORMS_FOLDER_CHILDNAME);
|
||||
if (wcmFormsChildName == null)
|
||||
{
|
||||
throw new PatchException("Bootstrap property '" + PROPERTY_WEBFORMS_FOLDER_CHILDNAME + "' is not present");
|
||||
}
|
||||
|
||||
String name = messageSource.getMessage(
|
||||
MSG_WEBFORMS_FOLDER_NAME,
|
||||
null,
|
||||
I18NUtil.getLocale());
|
||||
if (name == null || name.length() == 0)
|
||||
{
|
||||
throw new PatchException("Bootstrap property '" + MSG_WEBFORMS_FOLDER_NAME + "' is not present");
|
||||
}
|
||||
|
||||
String description = messageSource.getMessage(
|
||||
MSG_WEBFORMS_FOLDER_DESCRIPTION,
|
||||
null,
|
||||
I18NUtil.getLocale());
|
||||
if (description == null || description.length() == 0)
|
||||
{
|
||||
throw new PatchException("Bootstrap property '" + MSG_WEBFORMS_FOLDER_DESCRIPTION + "' is not present");
|
||||
}
|
||||
|
||||
Map<QName, Serializable> properties = new HashMap<QName, Serializable>(7);
|
||||
properties.put(ContentModel.PROP_NAME, name);
|
||||
properties.put(ContentModel.PROP_TITLE, name);
|
||||
properties.put(ContentModel.PROP_DESCRIPTION, description);
|
||||
properties.put(ApplicationModel.PROP_ICON, PROPERTY_ICON);
|
||||
// create the node
|
||||
ChildAssociationRef childAssocRef = nodeService.createNode(
|
||||
dictionaryNodeRef,
|
||||
ContentModel.ASSOC_CONTAINS,
|
||||
QName.resolveToQName(namespaceService, wcmFormsChildName),
|
||||
ContentModel.TYPE_FOLDER,
|
||||
properties);
|
||||
wcmFormsFolderNodeRef = childAssocRef.getChildRef();
|
||||
|
||||
// add the required aspects
|
||||
nodeService.addAspect(wcmFormsFolderNodeRef, ApplicationModel.ASPECT_UIFACETS, null);
|
||||
}
|
||||
}
|
@@ -1,158 +0,0 @@
|
||||
/*
|
||||
* 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.admin.patch.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.repo.admin.patch.AbstractPatch;
|
||||
import org.alfresco.repo.domain.patch.PatchDAO;
|
||||
import org.alfresco.repo.search.AVMSnapShotTriggeredIndexingMethodInterceptor;
|
||||
import org.alfresco.repo.search.impl.lucene.AVMLuceneIndexer;
|
||||
import org.alfresco.service.cmr.avm.AVMService;
|
||||
import org.alfresco.service.cmr.avm.AVMStoreDescriptor;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
|
||||
/**
|
||||
* Snap shot all stores after applying the staging are permissions patch
|
||||
*
|
||||
* @author andyh
|
||||
*/
|
||||
public class WCMPostPermissionSnapshotPatch extends AbstractPatch
|
||||
{
|
||||
private static final String MSG_SUCCESS = "patch.wcmPostPermissionSnapshotPatch.result";
|
||||
|
||||
private static final String AVM_SITE_STORE_NAME = "sitestore";
|
||||
|
||||
private AVMSnapShotTriggeredIndexingMethodInterceptor avmSnapShotTriggeredIndexingMethodInterceptor;
|
||||
|
||||
private AVMService avmService;
|
||||
|
||||
private PatchDAO patchDAO;
|
||||
|
||||
public void setAvmService(AVMService avmService)
|
||||
{
|
||||
this.avmService = avmService;
|
||||
}
|
||||
|
||||
public void setAvmSnapShotTriggeredIndexingMethodInterceptor(AVMSnapShotTriggeredIndexingMethodInterceptor avmSnapShotTriggeredIndexingMethodInterceptor)
|
||||
{
|
||||
this.avmSnapShotTriggeredIndexingMethodInterceptor = avmSnapShotTriggeredIndexingMethodInterceptor;
|
||||
}
|
||||
|
||||
public void setPatchDAO(PatchDAO patchDAO)
|
||||
{
|
||||
this.patchDAO = patchDAO;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String applyInternal() throws Exception
|
||||
{
|
||||
List<AVMStoreDescriptor> stores = avmService.getStores();
|
||||
|
||||
Thread progressThread = null;
|
||||
|
||||
Long toDo = patchDAO.getAVMNodesCountWhereNewInStore();
|
||||
|
||||
List<AVMLuceneIndexer> indexers = new ArrayList<AVMLuceneIndexer>(stores.size());
|
||||
for (AVMStoreDescriptor storeDesc : stores)
|
||||
{
|
||||
// post 4.0 we can safely skip "sitestore" no longer used by share
|
||||
if(storeDesc.getName().equals(AVM_SITE_STORE_NAME))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
AVMLuceneIndexer indexer = avmSnapShotTriggeredIndexingMethodInterceptor.getIndexer(storeDesc.getName());
|
||||
indexers.add(indexer);
|
||||
}
|
||||
|
||||
progressThread = new Thread(new ProgressWatcher(toDo, indexers), "WCMPactchProgressWatcher");
|
||||
progressThread.start();
|
||||
|
||||
for (AVMStoreDescriptor storeDesc : stores)
|
||||
{
|
||||
// post 4.0 we can safely skip "sitestore" no longer used by share
|
||||
if(storeDesc.getName().equals(AVM_SITE_STORE_NAME))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (avmService.getStoreRoot(-1, storeDesc.getName()).getLayerID() == -1)
|
||||
{
|
||||
avmService.createSnapshot(storeDesc.getName(), "PermissionPatch", "Snapshot after 2.2 permission patch");
|
||||
AVMLuceneIndexer indexer = avmSnapShotTriggeredIndexingMethodInterceptor.getIndexer(storeDesc.getName());
|
||||
indexer.flushPending();
|
||||
}
|
||||
}
|
||||
|
||||
progressThread.interrupt();
|
||||
progressThread.join();
|
||||
|
||||
// build the result message
|
||||
String msg = I18NUtil.getMessage(MSG_SUCCESS);
|
||||
// done
|
||||
return msg;
|
||||
}
|
||||
|
||||
private class ProgressWatcher implements Runnable
|
||||
{
|
||||
private boolean running = true;
|
||||
|
||||
Long toDo;
|
||||
|
||||
List<AVMLuceneIndexer> indexers;
|
||||
|
||||
ProgressWatcher(Long toDo, List<AVMLuceneIndexer> indexers)
|
||||
{
|
||||
this.toDo = toDo;
|
||||
this.indexers = indexers;
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
while (running)
|
||||
{
|
||||
try
|
||||
{
|
||||
Thread.sleep(60000);
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
running = false;
|
||||
}
|
||||
|
||||
if (running)
|
||||
{
|
||||
long done = 0;
|
||||
for(AVMLuceneIndexer indexer : indexers)
|
||||
{
|
||||
if(indexer != null)
|
||||
{
|
||||
done += indexer.getIndexedDocCount();
|
||||
}
|
||||
}
|
||||
|
||||
reportProgress(toDo, done);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user