diff --git a/config/alfresco/messages/patch-service.properties b/config/alfresco/messages/patch-service.properties
index 3f92ab65f4..cbeed23b3b 100644
--- a/config/alfresco/messages/patch-service.properties
+++ b/config/alfresco/messages/patch-service.properties
@@ -130,10 +130,13 @@ patch.linkNodeExtension.rewritten=Name ''{0}'' rewritten to ''{1}''
patch.systemRegistryBootstrap.description=Bootstraps the node that will hold system registry metadata.
-patch.userAndPersonUserNamesAsIdentifiers.description=Reindex user:user and cm:person uids as identifiers
+patch.userAndPersonUserNamesAsIdentifiers.description=Reindex usr:user and cm:person uids as identifiers
patch.userAndPersonUserNamesAsIdentifiers.result=Reindexed user:user and cm:person uids as identifiers
patch.contentFormFolderType.description=Update WCM Content Form folder type.
patch.contentFormFolderType.result=Updated {0} WCM Content Form objects to 'wcm:formfolder' type.
-patch.webscripts.description=Adds Web Scripts to Data Dictionary.
\ No newline at end of file
+patch.webscripts.description=Adds Web Scripts to Data Dictionary.
+
+patch.groupNamesAsIdentifiers.description=Reindex usr:authorityContainer gids as identifiers
+patch.groupNamesAsIdentifiers.result=Reindex usr:authorityContainer gids as identifiers
\ No newline at end of file
diff --git a/config/alfresco/model/contentModel.xml b/config/alfresco/model/contentModel.xml
index 21a70e7091..4ce7ae1014 100644
--- a/config/alfresco/model/contentModel.xml
+++ b/config/alfresco/model/contentModel.xml
@@ -142,6 +142,8 @@
Person
sys:base
+
+
d:text
true
diff --git a/config/alfresco/patch/patch-services-context.xml b/config/alfresco/patch/patch-services-context.xml
index 70f68ddfeb..2f8cd053f9 100644
--- a/config/alfresco/patch/patch-services-context.xml
+++ b/config/alfresco/patch/patch-services-context.xml
@@ -669,6 +669,21 @@
classpath:alfresco/dbscripts/upgrade/2.0/${db.script.dialect}/AlfrescoSchemaUpdate-2.0-AVMFKIndexes.sql
+
+
+ patch.groupNamesAsIdentifiers
+ patch.groupNamesAsIdentifiers.description
+ 0
+ 38
+ 39
+
+
+
+
+
+
+
+
patch.webscripts
diff --git a/source/java/org/alfresco/repo/admin/patch/AbstractPatch.java b/source/java/org/alfresco/repo/admin/patch/AbstractPatch.java
index 85cd679dac..864a7a3ce2 100644
--- a/source/java/org/alfresco/repo/admin/patch/AbstractPatch.java
+++ b/source/java/org/alfresco/repo/admin/patch/AbstractPatch.java
@@ -32,6 +32,7 @@ import java.util.List;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.repo.node.integrity.IntegrityChecker;
import org.alfresco.repo.security.authentication.AuthenticationComponent;
+import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.transaction.TransactionUtil;
import org.alfresco.repo.transaction.TransactionUtil.TransactionWork;
import org.alfresco.service.cmr.admin.PatchException;
@@ -263,6 +264,7 @@ public abstract class AbstractPatch implements Patch
{
return this.dependsOn;
}
+
/**
* Set all the dependencies for this patch. It should not be executed
* before all the dependencies have been applied.
@@ -334,19 +336,28 @@ public abstract class AbstractPatch implements Patch
// execute in a transaction
try
{
- TransactionWork patchWork = new TransactionWork()
+ AuthenticationUtil.RunAsWork authorisedPathWork = new AuthenticationUtil.RunAsWork()
{
public String doWork() throws Exception
{
- // downgrade integrity checking
- IntegrityChecker.setWarnInTransaction();
+ TransactionWork patchWork = new TransactionWork()
+ {
+ public String doWork() throws Exception
+ {
- String report = applyInternal();
- // done
- return report;
- };
+ // downgrade integrity checking
+ IntegrityChecker.setWarnInTransaction();
+
+ String report = applyInternal();
+ // done
+ return report;
+ }
+ };
+
+ return TransactionUtil.executeInNonPropagatingUserTransaction(transactionService, patchWork);
+ }
};
- String report = TransactionUtil.executeInNonPropagatingUserTransaction(transactionService, patchWork);
+ String report = AuthenticationUtil.runAs(authorisedPathWork, AuthenticationUtil.getSystemUserName());
// the patch was successfully applied
applied = true;
// done
diff --git a/source/java/org/alfresco/repo/admin/patch/impl/GroupTokenisationPatch.java b/source/java/org/alfresco/repo/admin/patch/impl/GroupTokenisationPatch.java
new file mode 100644
index 0000000000..27499851a1
--- /dev/null
+++ b/source/java/org/alfresco/repo/admin/patch/impl/GroupTokenisationPatch.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright (C) 2005-2007 Alfresco Software Limited.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program 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 General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ * As a special exception to the terms and conditions of version 2.0 of
+ * the GPL, you may redistribute this Program in connection with Free/Libre
+ * and Open Source Software ("FLOSS") applications as described in Alfresco's
+ * FLOSS exception. You should have recieved a copy of the text describing
+ * the FLOSS exception, and it is also available here:
+ * http://www.alfresco.com/legal/licensing
+ */
+
+package org.alfresco.repo.admin.patch.impl;
+
+import org.alfresco.i18n.I18NUtil;
+import org.alfresco.repo.admin.patch.AbstractPatch;
+import org.alfresco.repo.importer.ImporterBootstrap;
+import org.alfresco.repo.search.Indexer;
+import org.alfresco.repo.search.IndexerAndSearcher;
+import org.alfresco.service.cmr.repository.StoreRef;
+import org.alfresco.service.cmr.search.ResultSet;
+import org.alfresco.service.cmr.search.ResultSetRow;
+import org.alfresco.service.cmr.search.SearchParameters;
+import org.alfresco.service.cmr.search.SearchService;
+
+/**
+ * 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 GroupTokenisationPatch extends AbstractPatch
+{
+ private static final String MSG_SUCCESS = "patch.groupNamesAsIdentifiers.result";
+
+ private ImporterBootstrap userImporterBootstrap;
+ private IndexerAndSearcher indexerAndSearcher;
+
+
+ public GroupTokenisationPatch()
+ {
+
+ }
+
+ public void setUserImporterBootstrap(ImporterBootstrap userImporterBootstrap)
+ {
+ this.userImporterBootstrap = userImporterBootstrap;
+ }
+
+ public void setIndexerAndSearcher(IndexerAndSearcher indexerAndSearcher)
+ {
+ this.indexerAndSearcher = indexerAndSearcher;
+ }
+
+ @Override
+ protected String applyInternal() throws Exception
+ {
+ reindex("TYPE:\"usr:authorityContainer\"", userImporterBootstrap.getStoreRef());
+ return I18NUtil.getMessage(MSG_SUCCESS);
+ }
+
+ private void reindex(String query, StoreRef store)
+ {
+ SearchParameters sp = new SearchParameters();
+ sp.setLanguage(SearchService.LANGUAGE_LUCENE);
+ sp.setQuery(query);
+ sp.addStore(store);
+ ResultSet rs = null;
+ try
+ {
+ rs = searchService.query(sp);
+ for(ResultSetRow row : rs)
+ {
+ Indexer indexer = indexerAndSearcher.getIndexer(row.getNodeRef().getStoreRef());
+ indexer.updateNode(row.getNodeRef());
+ }
+ }
+ finally
+ {
+ if(rs != null)
+ {
+ rs.close();
+ }
+ }
+ }
+}
diff --git a/source/java/org/alfresco/repo/admin/patch/impl/RSSTemplatesFolderPatch.java b/source/java/org/alfresco/repo/admin/patch/impl/RSSTemplatesFolderPatch.java
index f65741f772..9a5e0d1234 100644
--- a/source/java/org/alfresco/repo/admin/patch/impl/RSSTemplatesFolderPatch.java
+++ b/source/java/org/alfresco/repo/admin/patch/impl/RSSTemplatesFolderPatch.java
@@ -236,17 +236,9 @@ public class RSSTemplatesFolderPatch extends AbstractPatch
true);
// import the content
- try
- {
- authenticationComponent.setCurrentUser(authenticationComponent.getSystemUserName());
-
- importContent();
- }
- finally
- {
- authenticationComponent.clearCurrentSecurityContext();
- }
-
+
+ importContent();
+
msg = I18NUtil.getMessage(MSG_CREATED, rssFolderNodeRef);
}
else
diff --git a/source/java/org/alfresco/repo/search/impl/lucene/LuceneAnalyser.java b/source/java/org/alfresco/repo/search/impl/lucene/LuceneAnalyser.java
index a3f1b9f935..bf7329da0b 100644
--- a/source/java/org/alfresco/repo/search/impl/lucene/LuceneAnalyser.java
+++ b/source/java/org/alfresco/repo/search/impl/lucene/LuceneAnalyser.java
@@ -166,7 +166,8 @@ public class LuceneAnalyser extends Analyzer
// Temporary fix for person and user uids
if (propertyQName.equals(ContentModel.PROP_USER_USERNAME)
- || propertyQName.equals(ContentModel.PROP_USERNAME))
+ || propertyQName.equals(ContentModel.PROP_USERNAME)
+ || propertyQName.equals(ContentModel.PROP_AUTHORITY_NAME))
{
analyser = new VerbatimAnalyser(true);
}
diff --git a/source/java/org/alfresco/repo/search/impl/lucene/LuceneIndexerImpl2.java b/source/java/org/alfresco/repo/search/impl/lucene/LuceneIndexerImpl2.java
index 8c79485f19..1d0b8da11b 100644
--- a/source/java/org/alfresco/repo/search/impl/lucene/LuceneIndexerImpl2.java
+++ b/source/java/org/alfresco/repo/search/impl/lucene/LuceneIndexerImpl2.java
@@ -1745,8 +1745,8 @@ public class LuceneIndexerImpl2 extends LuceneBase2 implements LuceneIndexer2
}
else if (isText)
{
- // Temporary special case for uids
- if(propertyName.equals(ContentModel.PROP_USER_USERNAME) || propertyName.equals(ContentModel.PROP_USERNAME))
+ // Temporary special case for uids and gids
+ if(propertyName.equals(ContentModel.PROP_USER_USERNAME) || propertyName.equals(ContentModel.PROP_USERNAME) || propertyName.equals(ContentModel.PROP_AUTHORITY_NAME))
{
doc.add(new Field(attributeName, strValue, fieldStore, fieldIndex, Field.TermVector.NO));
}
diff --git a/source/java/org/alfresco/repo/search/impl/lucene/index/IndexInfo.java b/source/java/org/alfresco/repo/search/impl/lucene/index/IndexInfo.java
index 82549291a5..e8c9805805 100644
--- a/source/java/org/alfresco/repo/search/impl/lucene/index/IndexInfo.java
+++ b/source/java/org/alfresco/repo/search/impl/lucene/index/IndexInfo.java
@@ -66,6 +66,8 @@ import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.MultiReader;
import org.apache.lucene.index.Term;
+import org.apache.lucene.index.TermDocs;
+import org.apache.lucene.index.TermEnum;
import org.apache.lucene.search.Hits;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Searcher;
@@ -442,10 +444,15 @@ public class IndexInfo
long docs = writer.docCount();
writer.close();
- indexEntries.put(OLD_INDEX, new IndexEntry(IndexType.INDEX, OLD_INDEX, "",
- TransactionStatus.COMMITTED, "", docs, 0, false));
+ IndexEntry entry = new IndexEntry(IndexType.INDEX, OLD_INDEX, "",
+ TransactionStatus.COMMITTED, "", docs, 0, false);
+ indexEntries.put(OLD_INDEX, entry);
writeStatus();
+
+ // The index exists and we should initialise the single reader
+ registerReferenceCountingIndexReader(entry.getName(),
+ buildReferenceCountingIndexReader(entry.getName()));
}
catch (IOException e)
{
@@ -2105,8 +2112,9 @@ public class IndexInfo
* Helper to print out index information
*
* @param args
+ * @throws Throwable
*/
- public static void main(String[] args)
+ public static void main(String[] args) throws Throwable
{
String indexLocation = args[0];
@@ -2128,6 +2136,46 @@ public class IndexInfo
{
ii.releaseWriteLock();
}
+ IndexReader reader = ii.getMainIndexReferenceCountingReadOnlyIndexReader();
+ TermEnum terms = reader.terms(new Term("@{archiweb.model}instance", ""));
+ while(terms.next() && terms.term().field().equals("@{archiweb.model}instance"))
+ {
+ System.out.println("F = " +terms.term().field() + " V = "+terms.term().text() + " F = "+terms.docFreq());
+ }
+ terms.close();
+ long start = System.currentTimeMillis();
+ TermDocs termDocs = reader.termDocs(new Term("@{archiweb.model}instance", "tfl"));
+ while(termDocs.next())
+ {
+ //System.out.println("Doc = " + termDocs.doc());
+ Document doc = reader.document(termDocs.doc());
+ doc.getField("ID");
+ //System.out.println("Ref = "+doc.getField("ID"));
+ }
+ termDocs.close();
+ System.out.println("Time = "+((System.currentTimeMillis() - start)/1000.0f));
+
+
+
+ terms = reader.terms(new Term("TYPE", ""));
+ while(terms.next() && terms.term().field().equals("TYPE"))
+ {
+ System.out.println("F = " +terms.term().field() + " V = "+terms.term().text() + " F = "+terms.docFreq());
+ }
+ terms.close();
+ start = System.currentTimeMillis();
+ termDocs = reader.termDocs(new Term("TYPE","{archiweb.model}tfdoc"));
+ while(termDocs.next())
+ {
+ //System.out.println("Doc = " + termDocs.doc());
+ Document doc = reader.document(termDocs.doc());
+ doc.getField("ID");
+ //System.out.println("Ref = "+doc.getField("ID"));
+ }
+ termDocs.close();
+ System.out.println("Time = "+((System.currentTimeMillis() - start)/1000.0f));
+
+ //+@\{archiweb.model\}instance:TFL*
}
}
diff --git a/source/java/org/alfresco/repo/security/authentication/userModel.xml b/source/java/org/alfresco/repo/security/authentication/userModel.xml
index f4a13c7fe3..3818aef28a 100644
--- a/source/java/org/alfresco/repo/security/authentication/userModel.xml
+++ b/source/java/org/alfresco/repo/security/authentication/userModel.xml
@@ -26,6 +26,8 @@
Alfresco User Type
usr:authority
+
+
d:text
@@ -60,6 +62,8 @@
Alfresco Authority Type
usr:authority
+
+
d:text