Merged V2.0 to HEAD

5425: AR-1309
   5426: AR-1342
   5427: AWC-1157


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5480 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2007-04-11 21:46:19 +00:00
parent 529c4840e9
commit f43d8864cb
10 changed files with 203 additions and 27 deletions

View File

@@ -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<String> patchWork = new TransactionWork<String>()
AuthenticationUtil.RunAsWork<String> authorisedPathWork = new AuthenticationUtil.RunAsWork<String>()
{
public String doWork() throws Exception
{
// downgrade integrity checking
IntegrityChecker.setWarnInTransaction();
TransactionWork<String> patchWork = new TransactionWork<String>()
{
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

View File

@@ -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();
}
}
}
}

View File

@@ -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

View File

@@ -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);
}

View File

@@ -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));
}

View File

@@ -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*
}
}

View File

@@ -26,6 +26,8 @@
<title>Alfresco User Type</title>
<parent>usr:authority</parent>
<properties>
<!-- The tokenisation set here is ignored - it is fixed for this type -->
<!-- This is so you can not break person lookup -->
<property name="usr:username">
<type>d:text</type>
</property>
@@ -60,6 +62,8 @@
<title>Alfresco Authority Type</title>
<parent>usr:authority</parent>
<properties>
<!-- The tokenisation set here is ignored - it is fixed for this type -->
<!-- This is so you can not break group lookup -->
<property name="usr:authorityName">
<type>d:text</type>
</property>