diff --git a/config/alfresco/core-services-context.xml b/config/alfresco/core-services-context.xml
index ca14f5d719..35571c25a1 100644
--- a/config/alfresco/core-services-context.xml
+++ b/config/alfresco/core-services-context.xml
@@ -92,7 +92,8 @@
alfresco.messages.content-service
alfresco.messages.coci-service
alfresco.messages.template-service
- alfresco.messages.lock-service
+ alfresco.messages.lock-service
+ alfresco.messages.patch-service
diff --git a/config/alfresco/messages/patch-service.properties b/config/alfresco/messages/patch-service.properties
new file mode 100644
index 0000000000..93cf17db62
--- /dev/null
+++ b/config/alfresco/messages/patch-service.properties
@@ -0,0 +1,14 @@
+# PatchService messages
+patch.service.not_relevant=Not relevant to schema {0}
+patch.executer.not_executed=Applied patch (not executed): \nID: {0}\nRESULT: \n{1}
+patch.executer.executed=Applied patch: \nID: {0}\nRESULT: \n{1}
+patch.executer.failed=Failed to apply patch: \nID: {0}\nRESULT: \n{1}
+
+# Individual patch messages
+
+patch.savedSearchesFolder.description=Ensures the existence of the 'Saved Searches' folder.
+patch.savedSearchesFolder.result.exists=The saved searches folder already exists: {0}
+patch.savedSearchesFolder.result.created=The saved searches folder successfully created: {0}
+
+patch.updatePermissionData.description=Update permission entries from 'folder' to 'cmobject'.
+patch.updatePermissionData.result=Created the following permission reference names: {0}. \nUpdated {1} permission entries.
diff --git a/config/alfresco/patch/patch-services-context.xml b/config/alfresco/patch/patch-services-context.xml
index 88fa1e711f..57868a42d5 100644
--- a/config/alfresco/patch/patch-services-context.xml
+++ b/config/alfresco/patch/patch-services-context.xml
@@ -79,7 +79,7 @@
patch.savedSearchesFolder
- Ensures the existence of the 'Saved Searches' folder
+ patch.savedSearchesFolder.description
0
1
2
@@ -97,6 +97,17 @@
+
+ patch.updatePermissionData
+ patch.updatePermissionData.description
+ 0
+ 2
+ 3
+
+
+
+
+
diff --git a/config/alfresco/version.properties b/config/alfresco/version.properties
index 512aa3b749..695b488544 100644
--- a/config/alfresco/version.properties
+++ b/config/alfresco/version.properties
@@ -15,4 +15,4 @@ version.edition=Open Source
# Schema number
-version.schema=2
+version.schema=3
diff --git a/source/java/org/alfresco/repo/admin/patch/AbstractPatch.java b/source/java/org/alfresco/repo/admin/patch/AbstractPatch.java
index 17e5f79f63..5629712c8f 100644
--- a/source/java/org/alfresco/repo/admin/patch/AbstractPatch.java
+++ b/source/java/org/alfresco/repo/admin/patch/AbstractPatch.java
@@ -268,7 +268,7 @@ public abstract class AbstractPatch implements Patch
return report;
};
};
- String report = TransactionUtil.executeInUserTransaction(transactionService, patchWork);
+ String report = TransactionUtil.executeInNonPropagatingUserTransaction(transactionService, patchWork);
// the patch was successfully applied
applied = true;
// done
diff --git a/source/java/org/alfresco/repo/admin/patch/PatchExecuter.java b/source/java/org/alfresco/repo/admin/patch/PatchExecuter.java
index 6bfb3897fd..ec5673c780 100644
--- a/source/java/org/alfresco/repo/admin/patch/PatchExecuter.java
+++ b/source/java/org/alfresco/repo/admin/patch/PatchExecuter.java
@@ -20,6 +20,7 @@ import java.util.Date;
import java.util.List;
import org.alfresco.error.AlfrescoRuntimeException;
+import org.alfresco.i18n.I18NUtil;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -31,6 +32,10 @@ import org.apache.commons.logging.LogFactory;
*/
public class PatchExecuter
{
+ private static final String MSG_NOT_EXECUTED = "patch.executer.not_executed";
+ private static final String MSG_EXECUTED = "patch.executer.executed";
+ private static final String MSG_FAILED = "patch.executer.failed";
+
private static Log logger = LogFactory.getLog(PatchExecuter.class);
private PatchService patchService;
@@ -72,22 +77,16 @@ public class PatchExecuter
if (!patchInfo.getWasExecuted())
{
// the patch was not executed
- logger.debug("Applied patch (not executed): \n" +
- " ID: " + patchInfo.getId() + "\n" +
- " RESULT: " + patchInfo.getReport());
+ logger.debug(I18NUtil.getMessage(MSG_NOT_EXECUTED, patchInfo.getId(), patchInfo.getReport()));
}
else if (patchInfo.getSucceeded())
{
- logger.info("Applied patch: \n" +
- " ID: " + patchInfo.getId() + "\n" +
- " RESULT: " + patchInfo.getReport());
+ logger.info(I18NUtil.getMessage(MSG_EXECUTED, patchInfo.getId(), patchInfo.getReport()));
}
else
{
succeeded = false;
- logger.error("Failed to apply patch: \n" +
- " ID: " + patchInfo.getId() + "\n" +
- " RESULT: " + patchInfo.getReport());
+ logger.error(I18NUtil.getMessage(MSG_FAILED, patchInfo.getId(), patchInfo.getReport()));
}
}
// generate an error if there was a failure
diff --git a/source/java/org/alfresco/repo/admin/patch/PatchServiceImpl.java b/source/java/org/alfresco/repo/admin/patch/PatchServiceImpl.java
index ea7b5da3bd..78b5895cfa 100644
--- a/source/java/org/alfresco/repo/admin/patch/PatchServiceImpl.java
+++ b/source/java/org/alfresco/repo/admin/patch/PatchServiceImpl.java
@@ -22,6 +22,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.alfresco.i18n.I18NUtil;
import org.alfresco.repo.domain.AppliedPatch;
import org.alfresco.service.cmr.admin.PatchException;
import org.alfresco.service.descriptor.Descriptor;
@@ -41,6 +42,8 @@ import org.apache.commons.logging.LogFactory;
*/
public class PatchServiceImpl implements PatchService
{
+ private static final String MSG_NOT_RELEVANT = "patch.service.not_relevant";
+
private static final Date ZERO_DATE = new Date(0L);
private static final Date INFINITE_DATE = new Date(Long.MAX_VALUE);
@@ -171,9 +174,7 @@ public class PatchServiceImpl implements PatchService
if (!applies)
{
// create a dummy report
- StringBuilder sb = new StringBuilder(128);
- sb.append("Not relevant to schema " + repoDescriptor.getSchema());
- report = sb.toString();
+ report = I18NUtil.getMessage(MSG_NOT_RELEVANT, repoDescriptor.getSchema());
success = true; // this succeeded because it didn't need to be applied
}
else
@@ -201,7 +202,7 @@ public class PatchServiceImpl implements PatchService
appliedPatch = patchDaoService.newAppliedPatch(patch.getId());
}
// fill in the record's details
- appliedPatch.setDescription(patch.getDescription());
+ appliedPatch.setDescription(I18NUtil.getMessage(patch.getDescription()));
appliedPatch.setFixesFromSchema(patch.getFixesFromSchema());
appliedPatch.setFixesToSchema(patch.getFixesToSchema());
appliedPatch.setTargetSchema(patch.getTargetSchema()); // the schema the server is expecting
diff --git a/source/java/org/alfresco/repo/admin/patch/impl/PermissionDataPatch.java b/source/java/org/alfresco/repo/admin/patch/impl/PermissionDataPatch.java
new file mode 100644
index 0000000000..1597068fbc
--- /dev/null
+++ b/source/java/org/alfresco/repo/admin/patch/impl/PermissionDataPatch.java
@@ -0,0 +1,118 @@
+/*
+ * Copyright (C) 2005 Alfresco, Inc.
+ *
+ * Licensed under the Mozilla Public License version 1.1
+ * with a permitted attribution clause. You may obtain a
+ * copy of the License at
+ *
+ * http://www.alfresco.org/legal/license.txt
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ */
+package org.alfresco.repo.admin.patch.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.alfresco.i18n.I18NUtil;
+import org.alfresco.repo.admin.patch.AbstractPatch;
+import org.alfresco.repo.security.permissions.impl.hibernate.PermissionReference;
+import org.alfresco.repo.security.permissions.impl.hibernate.PermissionReferenceImpl;
+import org.alfresco.service.namespace.NamespaceService;
+import org.hibernate.Query;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.springframework.orm.hibernate3.HibernateCallback;
+import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
+
+/**
+ * The roles defined in permissionsDefinition.xml moved from cm:folder to cm:cmobject.
+ * This effects the data stored in the node_perm_entry table.
+ *
+ * JIRA: {@link http://www.alfresco.org/jira/browse/AR-344 AR-344}
+ *
+ * @author Derek Hulley
+ */
+public class PermissionDataPatch extends AbstractPatch
+{
+ private static final String MSG_SUCCESS = "patch.updatePermissionData.result";
+
+ private HibernateHelper helper;
+
+ public PermissionDataPatch()
+ {
+ helper = new HibernateHelper();
+ }
+
+ public void setSessionFactory(SessionFactory sessionFactory)
+ {
+ this.helper.setSessionFactory(sessionFactory);
+ }
+
+ @Override
+ protected String applyInternal() throws Exception
+ {
+ List createdNames = helper.createPermissionReferences();
+ int updatedEntries = helper.updatePermissionEntries();
+
+ // build the result message
+ String msg = I18NUtil.getMessage(MSG_SUCCESS, createdNames, updatedEntries);
+ // done
+ return msg;
+ }
+
+ private static class HibernateHelper extends HibernateDaoSupport
+ {
+ private static final String TYPE_NAME_OLD = "folder";
+ private static final String TYPE_NAME_NEW = "cmobject";
+ private static final String[] NAMES = new String[] {"Coordinator", "Contributor", "Editor", "Guest"};
+ private static final String QUERY_UPDATE_PERM_ENTRY_TYPENAME = "permission.patch.UpdatePermissionEntryTypeName";
+
+ public List createPermissionReferences()
+ {
+ List createdNames = new ArrayList(4);
+ for (String name : NAMES)
+ {
+ // create permission references as required, double checking for their existence first
+ PermissionReference ref = new PermissionReferenceImpl();
+ ref.setTypeUri(NamespaceService.CONTENT_MODEL_1_0_URI);
+ ref.setTypeName(TYPE_NAME_NEW);
+ ref.setName(name);
+
+ // it acts as its own key
+ PermissionReference found = (PermissionReference) getHibernateTemplate().get(PermissionReferenceImpl.class, ref);
+
+ if (found == null)
+ {
+ // it was not found, so create it
+ getHibernateTemplate().save(ref);
+ createdNames.add(name);
+ }
+ }
+ return createdNames;
+ }
+
+ public int updatePermissionEntries()
+ {
+ HibernateCallback callback = new HibernateCallback()
+ {
+ public Object doInHibernate(Session session)
+ {
+ Query query = session.getNamedQuery(HibernateHelper.QUERY_UPDATE_PERM_ENTRY_TYPENAME);
+ query.setString("typeNameNew", TYPE_NAME_NEW)
+ .setString("typeNameOld", TYPE_NAME_OLD);
+ int updateCount = query.executeUpdate();
+ return new Integer(updateCount);
+ }
+ };
+ Integer updateCount = (Integer) getHibernateTemplate().execute(callback);
+ // done
+ return updateCount.intValue();
+ }
+ }
+}
diff --git a/source/java/org/alfresco/repo/admin/patch/impl/SavedSearchFolderPatch.java b/source/java/org/alfresco/repo/admin/patch/impl/SavedSearchFolderPatch.java
index c71390851b..f13996176d 100644
--- a/source/java/org/alfresco/repo/admin/patch/impl/SavedSearchFolderPatch.java
+++ b/source/java/org/alfresco/repo/admin/patch/impl/SavedSearchFolderPatch.java
@@ -22,6 +22,7 @@ import java.util.List;
import java.util.Map;
import java.util.Properties;
+import org.alfresco.i18n.I18NUtil;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.admin.patch.AbstractPatch;
import org.alfresco.repo.importer.ImporterBootstrap;
@@ -49,8 +50,8 @@ import org.alfresco.service.namespace.QName;
*/
public class SavedSearchFolderPatch extends AbstractPatch
{
- private static final String MSG_EXISTS = "The saved searches folder already exists: %s.";
- private static final String MSG_CREATED = "The saved searches folder successfully created: %s.";
+ private static final String MSG_EXISTS = "patch.savedSearchesFolder.result.exists";
+ private static final String MSG_CREATED = "patch.savedSearchesFolder.result.created";
private static final String PROPERTY_COMPANY_HOME_CHILDNAME = "spaces.company_home.childname";
private static final String PROPERTY_DICTIONARY_CHILDNAME = "spaces.dictionary.childname";
@@ -166,13 +167,13 @@ public class SavedSearchFolderPatch extends AbstractPatch
if (nodeRefs.size() == 1)
{
// it already exists
- msg = String.format(MSG_EXISTS, new Object[] {nodeRefs.get(0)});
+ msg = I18NUtil.getMessage(MSG_EXISTS, nodeRefs.get(0));
}
else
{
// create it
NodeRef savedSearchesFolderNodeRef = createFolder(dictionaryNodeRef, configuration);
- msg = String.format(MSG_CREATED, new Object[] {savedSearchesFolderNodeRef});
+ msg = I18NUtil.getMessage(MSG_CREATED, savedSearchesFolderNodeRef);
}
// done
return msg;
diff --git a/source/java/org/alfresco/repo/security/permissions/impl/hibernate/Permission.hbm.xml b/source/java/org/alfresco/repo/security/permissions/impl/hibernate/Permission.hbm.xml
index 48d6a2e47a..7b436eb7d2 100644
--- a/source/java/org/alfresco/repo/security/permissions/impl/hibernate/Permission.hbm.xml
+++ b/source/java/org/alfresco/repo/security/permissions/impl/hibernate/Permission.hbm.xml
@@ -139,5 +139,15 @@
where
recipient = :recipientKey
+
+
+ update
+ org.alfresco.repo.security.permissions.impl.hibernate.PermissionEntryImpl as entry
+ set
+ typeName = :typeNameNew
+ where
+ typeName = :typeNameOld and
+ name in ('Coordinator', 'Contributor', 'Editor', 'Guest')
+
\ No newline at end of file