mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
ACE-2030: Remove more patches introduced for upgrade to V3.1
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@87776 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,143 +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 org.alfresco.repo.admin.patch.AbstractPatch;
|
||||
import org.alfresco.repo.domain.node.NodeDAO;
|
||||
import org.alfresco.repo.domain.patch.PatchDAO;
|
||||
import org.alfresco.repo.domain.qname.QNameDAO;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||
import org.alfresco.util.Pair;
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
|
||||
/**
|
||||
* Patch usr:user and cm:person objects so that the user name properties are in the index in untokenized form. If not
|
||||
* authentication may fail in mixed language use.
|
||||
*
|
||||
* @author andyh
|
||||
*/
|
||||
public class CalendarModelUriPatch extends AbstractPatch
|
||||
{
|
||||
private static final String MSG_SUCCESS = "patch.calendarModelNamespacePatch.result";
|
||||
|
||||
private static final String URI_BEFORE = "com.infoaxon.alfresco.calendar";
|
||||
|
||||
private static final String URI_AFTER = "http://www.alfresco.org/model/calendar";
|
||||
|
||||
private QNameDAO qnameDAO;
|
||||
|
||||
private PatchDAO patchDAO;
|
||||
|
||||
private NodeDAO nodeDAO;
|
||||
|
||||
private RetryingTransactionHelper retryingTransactionHelper;
|
||||
|
||||
private static long BATCH_SIZE = 100000L;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param qnameDAO the qnameDAO to set
|
||||
*/
|
||||
public void setQnameDAO(QNameDAO qnameDAO)
|
||||
{
|
||||
this.qnameDAO = qnameDAO;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param patchDAO the patchDAO to set
|
||||
*/
|
||||
public void setPatchDAO(PatchDAO patchDAO)
|
||||
{
|
||||
this.patchDAO = patchDAO;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param nodeDAO the nodeDAO to set
|
||||
*/
|
||||
public void setNodeDAO(NodeDAO nodeDAO)
|
||||
{
|
||||
this.nodeDAO = nodeDAO;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param retryingTransactionHelper the retryingTransactionHelper to set
|
||||
*/
|
||||
public void setRetryingTransactionHelper(RetryingTransactionHelper retryingTransactionHelper)
|
||||
{
|
||||
this.retryingTransactionHelper = retryingTransactionHelper;
|
||||
}
|
||||
|
||||
protected void checkProperties()
|
||||
{
|
||||
super.checkProperties();
|
||||
checkPropertyNotNull(patchDAO, "patchDAO");
|
||||
checkPropertyNotNull(qnameDAO, "qnameDAO");
|
||||
checkPropertyNotNull(nodeDAO, "nodeDAO");
|
||||
checkPropertyNotNull(retryingTransactionHelper, "retryingTransactionHelper");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String applyInternal() throws Exception
|
||||
{
|
||||
Long maxNodeId = patchDAO.getMaxAdmNodeID();
|
||||
long count = 0L;
|
||||
|
||||
// Make sure the old name spaces exists before we update it ...
|
||||
Pair<Long, String> before = qnameDAO.getOrCreateNamespace(URI_BEFORE);
|
||||
for (Long i = 0L; i < maxNodeId; i+=BATCH_SIZE)
|
||||
{
|
||||
Work work = new Work(before.getFirst(), i);
|
||||
count += retryingTransactionHelper.doInTransaction(work, false, true);
|
||||
}
|
||||
|
||||
// modify namespace for all calendar entries
|
||||
qnameDAO.updateNamespace(URI_BEFORE, URI_AFTER);
|
||||
|
||||
return I18NUtil.getMessage(MSG_SUCCESS, count);
|
||||
}
|
||||
|
||||
private class Work implements RetryingTransactionHelper.RetryingTransactionCallback<Integer>
|
||||
{
|
||||
long nsId;
|
||||
|
||||
long lower;
|
||||
|
||||
Work(long nsId, long lower)
|
||||
{
|
||||
this.nsId = nsId;
|
||||
this.lower = lower;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback#execute()
|
||||
*/
|
||||
@Override
|
||||
public Integer execute() throws Throwable
|
||||
{
|
||||
List<Long> nodeIds = patchDAO.getNodesByTypeUriId(nsId, lower, lower + BATCH_SIZE);
|
||||
nodeDAO.touchNodes(nodeDAO.getCurrentTransactionId(true), nodeIds);
|
||||
return nodeIds.size();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,212 +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.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
import org.alfresco.repo.admin.patch.AbstractPatch;
|
||||
import org.alfresco.repo.invitation.InvitationServiceImpl;
|
||||
import org.alfresco.service.cmr.workflow.WorkflowDefinition;
|
||||
|
||||
import org.alfresco.repo.invitation.WorkflowModelNominatedInvitation;
|
||||
import org.alfresco.repo.invitation.site.AcceptInviteAction;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||
import org.alfresco.service.cmr.invitation.Invitation;
|
||||
import org.alfresco.service.cmr.invitation.InvitationService;
|
||||
import org.alfresco.service.cmr.invitation.Invitation.ResourceType;
|
||||
import org.alfresco.service.cmr.workflow.WorkflowException;
|
||||
import org.alfresco.service.cmr.workflow.WorkflowInstance;
|
||||
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.cmr.workflow.WorkflowTaskState;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* Invitation service changes from Labs3D 3.1.0E
|
||||
*
|
||||
* wf:invite becomes wf:invitation-nominated
|
||||
*
|
||||
* Create new invitations
|
||||
* Cancel wf:invite workflows.
|
||||
*
|
||||
* @author mrogers
|
||||
*/
|
||||
public class InvitationMigrationPatch extends AbstractPatch
|
||||
{
|
||||
private WorkflowService workflowService;
|
||||
private InvitationService invitationService;
|
||||
private static final String MSG_SUCCESS = "patch.invitationMigration.result";
|
||||
private static final String MSG_NO_INVITES = "patch.invitationMigration.no_invites";
|
||||
|
||||
private static final Log logger = LogFactory.getLog(InvitationMigrationPatch.class);
|
||||
|
||||
/**
|
||||
* Old invite model from V3.0 E / Labs 3 D
|
||||
*/
|
||||
private static class OldInviteModel
|
||||
{
|
||||
// process name
|
||||
public static final QName WF_PROCESS_INVITE = QName.createQName(NamespaceService.WORKFLOW_MODEL_1_0_URI, "invite");
|
||||
|
||||
// workflow definition name
|
||||
public static final String WORKFLOW_DEFINITION_NAME = "jbpm$wf:invite";
|
||||
|
||||
// tasks
|
||||
public static final QName WF_INVITE_TASK_INVITE_TO_SITE = QName.createQName(NamespaceService.WORKFLOW_MODEL_1_0_URI, "inviteToSiteTask");
|
||||
public static final QName WF_INVITE_TASK_INVITE_PENDING = QName.createQName(NamespaceService.WORKFLOW_MODEL_1_0_URI, "invitePendingTask");
|
||||
public static final QName WF_TASK_ACCEPT_INVITE = QName.createQName(NamespaceService.WORKFLOW_MODEL_1_0_URI, "acceptInviteTask");
|
||||
public static final QName WF_TASK_REJECT_INVITE = QName.createQName(NamespaceService.WORKFLOW_MODEL_1_0_URI, "rejectInviteTask");
|
||||
|
||||
// transition names
|
||||
public static final String WF_TRANSITION_SEND_INVITE = "sendInvite";
|
||||
public static final String WF_TRANSITION_ACCEPT = "accept";
|
||||
public static final String WF_TRANSITION_REJECT = "reject";
|
||||
public static final String WF_TRANSITION_CANCEL = "cancel";
|
||||
public static final String WF_TRANSITION_ACCEPT_INVITE_END = "end";
|
||||
public static final String WF_TRANSITION_REJECT_INVITE_END = "end";
|
||||
|
||||
// workflow properties
|
||||
public static final QName WF_PROP_SERVER_PATH = QName.createQName(NamespaceService.WORKFLOW_MODEL_1_0_URI, "serverPath");
|
||||
public static final QName WF_PROP_ACCEPT_URL = QName.createQName(NamespaceService.WORKFLOW_MODEL_1_0_URI, "acceptUrl");
|
||||
public static final QName WF_PROP_REJECT_URL = QName.createQName(NamespaceService.WORKFLOW_MODEL_1_0_URI, "rejectUrl");
|
||||
public static final QName WF_PROP_INVITE_TICKET = QName.createQName(NamespaceService.WORKFLOW_MODEL_1_0_URI, "inviteTicket");
|
||||
public static final QName WF_PROP_INVITER_USER_NAME = QName.createQName(NamespaceService.WORKFLOW_MODEL_1_0_URI, "inviterUserName");
|
||||
public static final QName WF_PROP_INVITEE_USER_NAME = QName.createQName(NamespaceService.WORKFLOW_MODEL_1_0_URI, "inviteeUserName");
|
||||
public static final QName WF_PROP_INVITEE_FIRSTNAME = QName.createQName(NamespaceService.WORKFLOW_MODEL_1_0_URI, "inviteeFirstName");
|
||||
public static final QName WF_PROP_INVITEE_LASTNAME = QName.createQName(NamespaceService.WORKFLOW_MODEL_1_0_URI, "inviteeLastName");
|
||||
public static final QName WF_PROP_SITE_SHORT_NAME = QName.createQName(NamespaceService.WORKFLOW_MODEL_1_0_URI, "siteShortName");
|
||||
public static final QName WF_PROP_INVITEE_SITE_ROLE = QName.createQName(NamespaceService.WORKFLOW_MODEL_1_0_URI, "inviteeSiteRole");
|
||||
public static final QName WF_PROP_SENT_INVITE_DATE = QName.createQName(NamespaceService.WORKFLOW_MODEL_1_0_URI, "sentInviteDate");
|
||||
public static final QName WF_PROP_INVITEE_GEN_PASSWORD = QName.createQName(NamespaceService.WORKFLOW_MODEL_1_0_URI, "inviteeGenPassword");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String applyInternal() throws Exception
|
||||
{
|
||||
|
||||
WorkflowDefinition def = workflowService.getDefinitionByName(OldInviteModel.WORKFLOW_DEFINITION_NAME);
|
||||
|
||||
if(def != null)
|
||||
{
|
||||
|
||||
// Get the process properties.
|
||||
List<WorkflowInstance> currentInstances = workflowService.getActiveWorkflows(def.getId());
|
||||
|
||||
int count = 0;
|
||||
|
||||
for(WorkflowInstance oldInstance : currentInstances)
|
||||
{
|
||||
String oldWorkflowId = oldInstance.id;
|
||||
|
||||
convertOldInvite(oldWorkflowId);
|
||||
|
||||
// Cancel the old workflow instance
|
||||
workflowService.cancelWorkflow(oldWorkflowId);
|
||||
|
||||
count++;
|
||||
}
|
||||
|
||||
// build the result message
|
||||
String msg = I18NUtil.getMessage(MSG_SUCCESS, count);
|
||||
return msg;
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.debug("no invites to cancel");
|
||||
String msg = I18NUtil.getMessage(MSG_NO_INVITES);
|
||||
return msg;
|
||||
}
|
||||
}
|
||||
|
||||
public void setWorkflowService(WorkflowService workflowService)
|
||||
{
|
||||
this.workflowService = workflowService;
|
||||
}
|
||||
|
||||
public WorkflowService getWorkflowService()
|
||||
{
|
||||
return workflowService;
|
||||
}
|
||||
|
||||
public void setInvitationService(InvitationService invitationService) {
|
||||
this.invitationService = invitationService;
|
||||
}
|
||||
|
||||
public InvitationService getInvitationService() {
|
||||
return invitationService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts old invite to new service
|
||||
* @param oldWorkflowId
|
||||
*/
|
||||
private void convertOldInvite(String oldWorkflowId)
|
||||
{
|
||||
|
||||
WorkflowTaskQuery query = new WorkflowTaskQuery();
|
||||
query.setProcessId(oldWorkflowId);
|
||||
query.setProcessName(OldInviteModel.WF_PROCESS_INVITE);
|
||||
query.setTaskName(OldInviteModel.WF_INVITE_TASK_INVITE_TO_SITE);
|
||||
|
||||
// query for invite workflow task associate
|
||||
List<WorkflowTask> inviteStartTasks = workflowService.queryTasks(query);
|
||||
|
||||
// should also be 0 or 1
|
||||
if (inviteStartTasks.size() < 1)
|
||||
{
|
||||
// task not found - can't do anything
|
||||
}
|
||||
else
|
||||
{
|
||||
WorkflowTask oldTask = inviteStartTasks.get(0);
|
||||
|
||||
Map<QName, Serializable> workflowProps = oldTask.properties;
|
||||
final String inviteeUserName = (String)workflowProps.get(OldInviteModel.WF_PROP_INVITEE_USER_NAME);
|
||||
final String inviterUserName = (String)workflowProps.get(OldInviteModel.WF_PROP_INVITER_USER_NAME);
|
||||
final String resourceName = (String)workflowProps.get(OldInviteModel.WF_PROP_SITE_SHORT_NAME);
|
||||
final String roleName = (String)workflowProps.get(OldInviteModel.WF_PROP_INVITEE_SITE_ROLE);
|
||||
final String serverPath = (String)workflowProps.get(OldInviteModel.WF_PROP_SERVER_PATH);
|
||||
final String acceptUrl = (String)workflowProps.get(OldInviteModel.WF_PROP_ACCEPT_URL);
|
||||
final String rejectUrl = (String)workflowProps.get(OldInviteModel.WF_PROP_REJECT_URL);
|
||||
|
||||
// add Invitee to Site with the site role that the inviter "started" the invite process with
|
||||
AuthenticationUtil.runAs(new RunAsWork<Object>()
|
||||
{
|
||||
public Object doWork() throws Exception
|
||||
{
|
||||
// Create a new invitation.
|
||||
invitationService.inviteNominated(inviteeUserName, Invitation.ResourceType.WEB_SITE, resourceName, roleName, serverPath, acceptUrl, rejectUrl);
|
||||
return null;
|
||||
}
|
||||
|
||||
}, inviterUserName);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,84 +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.Properties;
|
||||
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
import org.alfresco.repo.admin.patch.AbstractPatch;
|
||||
import org.alfresco.repo.tenant.TenantService;
|
||||
import org.alfresco.repo.workflow.WorkflowDeployer;
|
||||
|
||||
/**
|
||||
* MT Share - update existing tenants (if any)
|
||||
*/
|
||||
public class MultiTShareExistingTenantsPatch extends AbstractPatch
|
||||
{
|
||||
private static final String MSG_RESULT = "patch.mtShareExistingTenants.result";
|
||||
private static final String MSG_RESULT_NA = "patch.mtShareExistingTenants.result.not_applicable";
|
||||
|
||||
private WorkflowDeployer workflowPatchDeployer;
|
||||
private List<Properties> workflowDefinitions;
|
||||
private TenantService tenantService;
|
||||
|
||||
public void setWorkflowDeployer(WorkflowDeployer workflowPatchDeployer)
|
||||
{
|
||||
this.workflowPatchDeployer = workflowPatchDeployer;
|
||||
}
|
||||
|
||||
public void setWorkflowDefinitions(List<Properties> workflowDefinitions)
|
||||
{
|
||||
this.workflowDefinitions = workflowDefinitions;
|
||||
}
|
||||
|
||||
public void setTenantService(TenantService tenantService)
|
||||
{
|
||||
this.tenantService = tenantService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.admin.patch.AbstractPatch#checkProperties()
|
||||
*/
|
||||
@Override
|
||||
protected void checkProperties()
|
||||
{
|
||||
super.checkProperties();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.admin.patch.AbstractPatch#applyInternal()
|
||||
*/
|
||||
@Override
|
||||
protected String applyInternal() throws Exception
|
||||
{
|
||||
if (!tenantService.isEnabled())
|
||||
{
|
||||
return I18NUtil.getMessage(MSG_RESULT_NA);
|
||||
}
|
||||
|
||||
if (! tenantService.getCurrentUserDomain().equals(TenantService.DEFAULT_DOMAIN))
|
||||
{
|
||||
workflowPatchDeployer.setWorkflowDefinitions(workflowDefinitions);
|
||||
workflowPatchDeployer.init();
|
||||
}
|
||||
|
||||
return I18NUtil.getMessage(MSG_RESULT);
|
||||
}
|
||||
}
|
@@ -1,111 +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 org.springframework.extensions.surf.util.I18NUtil;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.admin.patch.AbstractPatch;
|
||||
import org.alfresco.repo.importer.ImporterBootstrap;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
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.cmr.security.PermissionService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.namespace.RegexQNamePattern;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* Grant <b>Read</b> permission to <b>Guest</b> in <b>SpacesStore</b> root node.
|
||||
* Fix for bug ETWOONE-163.
|
||||
* <p>
|
||||
* [KR] Now correctly applies modified permissions to immediate child nodes of the
|
||||
* root node:
|
||||
* <p>
|
||||
* sys:system - Changed inherit=false, Added GROUP_EVERYONE=READ (to disallow guest)
|
||||
* cm:categoryRoot - Removed guest=READ (as already inherits)
|
||||
*
|
||||
* @author Arseny Kovalchuk
|
||||
* @author kevinr
|
||||
*/
|
||||
public class SpacesStoreGuestPermissionPatch extends AbstractPatch
|
||||
{
|
||||
private static Log logger = LogFactory.getLog(SpacesStoreGuestPermissionPatch.class);
|
||||
|
||||
private static final String MSG_RESULT = "patch.spacesStoreGuestPermission.result";
|
||||
|
||||
private PermissionService permissionService;
|
||||
private ImporterBootstrap importerBootstrap;
|
||||
|
||||
|
||||
public void setPermissionService(PermissionService permissionService)
|
||||
{
|
||||
this.permissionService = permissionService;
|
||||
}
|
||||
|
||||
public void setImporterBootstrap(ImporterBootstrap importerBootstrap)
|
||||
{
|
||||
this.importerBootstrap = importerBootstrap;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected String applyInternal() throws Exception
|
||||
{
|
||||
StoreRef store = importerBootstrap.getStoreRef();
|
||||
if (store == null)
|
||||
{
|
||||
throw new PatchException("Bootstrap store has not been set");
|
||||
}
|
||||
|
||||
NodeRef rootRef = nodeService.getRootNode(store);
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Store Ref:" + store + " NodeRef: " + rootRef);
|
||||
}
|
||||
permissionService.setPermission(
|
||||
rootRef, AuthenticationUtil.getGuestUserName(), PermissionService.READ, true);
|
||||
|
||||
String sysQName = importerBootstrap.getConfiguration().getProperty("system.system_container.childname");
|
||||
String catQName = "cm:categoryRoot";
|
||||
List<ChildAssociationRef> refs = nodeService.getChildAssocs(
|
||||
rootRef, ContentModel.ASSOC_CHILDREN, RegexQNamePattern.MATCH_ALL);
|
||||
for (ChildAssociationRef ref : refs)
|
||||
{
|
||||
if (ref.getQName().equals(QName.createQName(sysQName, namespaceService)))
|
||||
{
|
||||
// found sys:system node
|
||||
permissionService.setInheritParentPermissions(ref.getChildRef(), false);
|
||||
permissionService.setPermission(
|
||||
ref.getChildRef(), PermissionService.ALL_AUTHORITIES, PermissionService.READ, true);
|
||||
}
|
||||
else if (ref.getQName().equals(QName.createQName(catQName, namespaceService)))
|
||||
{
|
||||
// found cm:categoryRoot node
|
||||
permissionService.clearPermission(ref.getChildRef(), AuthenticationUtil.getGuestUserName());
|
||||
}
|
||||
}
|
||||
|
||||
return I18NUtil.getMessage(MSG_RESULT);
|
||||
}
|
||||
}
|
@@ -1,107 +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.Set;
|
||||
|
||||
import org.springframework.extensions.surf.util.I18NUtil;
|
||||
import org.alfresco.repo.admin.patch.AbstractPatch;
|
||||
import org.alfresco.repo.site.SiteModel;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.security.AccessPermission;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.service.cmr.site.SiteInfo;
|
||||
import org.alfresco.service.cmr.site.SiteService;
|
||||
import org.alfresco.service.cmr.site.SiteVisibility;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Patch that changes the web site visibility from a boolean
|
||||
* (isPublic) to an enum (PUBLIC, PRIVATE, MODERATED).
|
||||
*
|
||||
* @author mrogers
|
||||
*/
|
||||
public class WebSiteAddModeratedPatch extends AbstractPatch
|
||||
{
|
||||
private PermissionService permissionService;
|
||||
private SiteService siteService;
|
||||
|
||||
private static final String MSG_SUCCESS = "patch.webSiteAddModerated.result";
|
||||
|
||||
@Override
|
||||
protected String applyInternal() throws Exception
|
||||
{
|
||||
// for all web sites
|
||||
String nameFilter = null;
|
||||
String sitePresetFilter = null;
|
||||
List<SiteInfo> sites = getSiteService().listSites(nameFilter, sitePresetFilter);
|
||||
|
||||
for(SiteInfo site : sites)
|
||||
{
|
||||
SiteVisibility visibility = SiteVisibility.PRIVATE;
|
||||
NodeRef siteNodeRef = site.getNodeRef();
|
||||
|
||||
// Get the visibility value stored in the repo
|
||||
String visibilityValue = (String)this.nodeService.getProperty(siteNodeRef, SiteModel.PROP_SITE_VISIBILITY);
|
||||
// To maintain backwards compatibility calculate the visibility from the permissions
|
||||
// if there is no value specified on the site node
|
||||
if (visibilityValue == null)
|
||||
{
|
||||
// Examine each permission to see if this is a public site or not
|
||||
Set<AccessPermission> permissions = this.permissionService.getAllSetPermissions(siteNodeRef);
|
||||
for (AccessPermission permission : permissions)
|
||||
{
|
||||
if (permission.getAuthority().equals(PermissionService.ALL_AUTHORITIES) == true &&
|
||||
permission.getPermission().equals(SiteModel.SITE_CONSUMER) == true)
|
||||
{
|
||||
visibility = SiteVisibility.PUBLIC;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Store the visibility value on the node ref for next time
|
||||
this.nodeService.setProperty(siteNodeRef, SiteModel.PROP_SITE_VISIBILITY, visibility.toString());
|
||||
}
|
||||
}
|
||||
|
||||
String msg = I18NUtil.getMessage(MSG_SUCCESS);
|
||||
return msg;
|
||||
|
||||
}
|
||||
|
||||
public void setPermissionService(PermissionService permissionService) {
|
||||
this.permissionService = permissionService;
|
||||
}
|
||||
|
||||
public PermissionService getPermissionService() {
|
||||
return permissionService;
|
||||
}
|
||||
|
||||
public void setSiteService(SiteService siteService) {
|
||||
this.siteService = siteService;
|
||||
}
|
||||
|
||||
public SiteService getSiteService() {
|
||||
return siteService;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user