diff --git a/config/alfresco/messages/patch-service.properties b/config/alfresco/messages/patch-service.properties index 91e8a7a72e..9ae11d713b 100644 --- a/config/alfresco/messages/patch-service.properties +++ b/config/alfresco/messages/patch-service.properties @@ -214,26 +214,16 @@ patch.migrateVersionStore.description=Version Store migration (from lightWeightV patch.inviteEmailTemplate.description=Adds invite email template to invite space patch.calendarModelNamespacePatch.description=Update the Calendar model namespace URI and reindex all calendar objects. -patch.calendarModelNamespacePatch.result=Updated the Calendar model namespace URI to http://www.alfresco.org/model/calendar and reindexed {0} calendar objects. patch.spacesStoreGuestPermission.description=Sets READ permissions for GUEST on root node of the SpacesStore. -patch.spacesStoreGuestPermission.result=Granted READ permissions for GUEST on root node of the SpacesStore. patch.administratorGroup.description=Adds the 'ALFRESCO_ADMINISTRATORS' group. -patch.migrateVersionStoreUpdateCounter.description=Update internal version2Store counter (if needed). -patch.migrateVersionStoreUpdateCounter.result=Update internal version2Store counter (if needed): {0} - patch.invitationMigration.description=Migrate invitations from old invite service to invitation service -patch.invitationMigration.result=Migrated {0} invitations from old invite service to invitation service. -patch.invitationMigration.no_invites=No invitations require migrating old invite service to invitation service. patch.webSiteAddModerated.description=Changing Web Site visibility from a boolean to enum. -patch.webSiteAddModerated.result=Changed Web Site visibility. patch.mtShareExistingTenants.description=Update existing tenants for MT Share. -patch.mtShareExistingTenants.result=Update existing tenants for MT Share. -patch.mtShareExistingTenants.result.not_applicable=Patch applied, although no changes made since MT is not enabled. patch.redeployInvitationProcess.description=Re-deploy Invitation Process Definitions. diff --git a/config/alfresco/patch/patch-services-context.xml b/config/alfresco/patch/patch-services-context.xml index 4009435815..00d4435683 100644 --- a/config/alfresco/patch/patch-services-context.xml +++ b/config/alfresco/patch/patch-services-context.xml @@ -824,60 +824,36 @@ 4.2.x - - + patch.calendarNamespaceUri patch.calendarModelNamespacePatch.description 0 131 132 - - - - - - - - - - - - - - - - + + 4.2.x - - + patch.db-V2.1-AuditPathIndex patch.schemaUpgradeScript.description 0 132 133 + + 4.2.x + - - + patch.spacesStoreGuestPermission patch.spacesStoreGuestPermission.description 0 133 134 - - - - - - - - - - - + + 4.2.x - patch.db-V2.2-Person-3 patch.schemaUpgradeScript.description @@ -888,106 +864,44 @@ 4.2.x - - + patch.webSiteAddModerated patch.webSiteAddModerated.description 0 2006 2007 - - - - - - - - - - - - - + + 4.2.x - - + patch.invitationMigration patch.invitationMigration.description 0 2006 2007 - - - - - - - - - - + + 4.2.x - - + patch.mtShareExistingTenants patch.mtShareExistingTenants.description 0 2008 2009 - true - - - - - - - - - - - - - - - jbpm - alfresco/workflow/invitation-nominated_processdefinition.xml - text/xml - - - jbpm - alfresco/workflow/invitation-moderated_processdefinition.xml - text/xml - - + + 4.2.x - - + patch.redeployInvitationProcess patch.redeployInvitationProcess.description 0 2009 2010 - - - - - - - - - jbpm - alfresco/workflow/invitation-moderated_processdefinition.xml - text/xml - - - jbpm - alfresco/workflow/invitation-nominated_processdefinition.xml - text/xml - - + + 4.2.x diff --git a/source/java/org/alfresco/repo/admin/patch/impl/CalendarModelUriPatch.java b/source/java/org/alfresco/repo/admin/patch/impl/CalendarModelUriPatch.java deleted file mode 100644 index 2ce013644c..0000000000 --- a/source/java/org/alfresco/repo/admin/patch/impl/CalendarModelUriPatch.java +++ /dev/null @@ -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 . - */ - -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 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 - { - 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 nodeIds = patchDAO.getNodesByTypeUriId(nsId, lower, lower + BATCH_SIZE); - nodeDAO.touchNodes(nodeDAO.getCurrentTransactionId(true), nodeIds); - return nodeIds.size(); - } - } -} diff --git a/source/java/org/alfresco/repo/admin/patch/impl/InvitationMigrationPatch.java b/source/java/org/alfresco/repo/admin/patch/impl/InvitationMigrationPatch.java deleted file mode 100644 index a1851b89fe..0000000000 --- a/source/java/org/alfresco/repo/admin/patch/impl/InvitationMigrationPatch.java +++ /dev/null @@ -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 . - */ -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 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 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 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() - { - public Object doWork() throws Exception - { - // Create a new invitation. - invitationService.inviteNominated(inviteeUserName, Invitation.ResourceType.WEB_SITE, resourceName, roleName, serverPath, acceptUrl, rejectUrl); - return null; - } - - }, inviterUserName); - } - } -} diff --git a/source/java/org/alfresco/repo/admin/patch/impl/MultiTShareExistingTenantsPatch.java b/source/java/org/alfresco/repo/admin/patch/impl/MultiTShareExistingTenantsPatch.java deleted file mode 100644 index e325a927cc..0000000000 --- a/source/java/org/alfresco/repo/admin/patch/impl/MultiTShareExistingTenantsPatch.java +++ /dev/null @@ -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 . - */ -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 workflowDefinitions; - private TenantService tenantService; - - public void setWorkflowDeployer(WorkflowDeployer workflowPatchDeployer) - { - this.workflowPatchDeployer = workflowPatchDeployer; - } - - public void setWorkflowDefinitions(List 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); - } -} diff --git a/source/java/org/alfresco/repo/admin/patch/impl/SpacesStoreGuestPermissionPatch.java b/source/java/org/alfresco/repo/admin/patch/impl/SpacesStoreGuestPermissionPatch.java deleted file mode 100644 index 389c4d68f0..0000000000 --- a/source/java/org/alfresco/repo/admin/patch/impl/SpacesStoreGuestPermissionPatch.java +++ /dev/null @@ -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 . - */ -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 Read permission to Guest in SpacesStore root node. - * Fix for bug ETWOONE-163. - *

- * [KR] Now correctly applies modified permissions to immediate child nodes of the - * root node: - *

- * 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 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); - } -} \ No newline at end of file diff --git a/source/java/org/alfresco/repo/admin/patch/impl/WebSiteAddModeratedPatch.java b/source/java/org/alfresco/repo/admin/patch/impl/WebSiteAddModeratedPatch.java deleted file mode 100644 index b78d385ef6..0000000000 --- a/source/java/org/alfresco/repo/admin/patch/impl/WebSiteAddModeratedPatch.java +++ /dev/null @@ -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 . - */ -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 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 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; - } - -}