mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Ldap progress and user/person search
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2201 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -24,11 +24,22 @@ import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
import java.util.List;
|
||||
|
||||
import javax.transaction.UserTransaction;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.search.SearchService;
|
||||
import org.alfresco.service.cmr.view.ImporterBinding;
|
||||
import org.alfresco.service.cmr.view.ImporterService;
|
||||
import org.alfresco.service.cmr.view.Location;
|
||||
import org.alfresco.service.namespace.NamespacePrefixResolver;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.alfresco.util.TempFileProvider;
|
||||
import org.dom4j.io.OutputFormat;
|
||||
import org.dom4j.io.XMLWriter;
|
||||
@@ -39,9 +50,21 @@ public class ExportSourceImporter implements ImporterJobSPI
|
||||
|
||||
private ExportSource exportSource;
|
||||
|
||||
private AuthenticationComponent authenticationComponent;
|
||||
|
||||
private StoreRef storeRef;
|
||||
|
||||
private String path;
|
||||
|
||||
private boolean clearAllChildren;
|
||||
|
||||
private NodeService nodeService;
|
||||
|
||||
private SearchService searchService;
|
||||
|
||||
private NamespacePrefixResolver namespacePrefixResolver;
|
||||
|
||||
private TransactionService transactionService;
|
||||
|
||||
public ExportSourceImporter()
|
||||
{
|
||||
@@ -58,10 +81,68 @@ public class ExportSourceImporter implements ImporterJobSPI
|
||||
this.exportSource = exportSource;
|
||||
}
|
||||
|
||||
public void setClearAllChildren(boolean clearAllChildren)
|
||||
{
|
||||
this.clearAllChildren = clearAllChildren;
|
||||
}
|
||||
|
||||
public void setPath(String path)
|
||||
{
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public void setStoreRef(String storeRef)
|
||||
{
|
||||
this.storeRef = new StoreRef(storeRef);
|
||||
}
|
||||
|
||||
public void setTransactionService(TransactionService transactionService)
|
||||
{
|
||||
this.transactionService = transactionService;
|
||||
}
|
||||
|
||||
public void setNamespacePrefixResolver(NamespacePrefixResolver namespacePrefixResolver)
|
||||
{
|
||||
this.namespacePrefixResolver = namespacePrefixResolver;
|
||||
}
|
||||
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
this.nodeService = nodeService;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void setAuthenticationComponent(AuthenticationComponent authenticationComponent)
|
||||
{
|
||||
this.authenticationComponent = authenticationComponent;
|
||||
}
|
||||
|
||||
public void setSearchService(SearchService searchService)
|
||||
{
|
||||
this.searchService = searchService;
|
||||
}
|
||||
|
||||
public void doImport()
|
||||
{
|
||||
UserTransaction userTransaction = null;
|
||||
try
|
||||
{
|
||||
userTransaction = transactionService.getUserTransaction();
|
||||
userTransaction.begin();
|
||||
authenticationComponent.setSystemUserAsCurrentUser();
|
||||
if(clearAllChildren)
|
||||
{
|
||||
List<NodeRef> refs = searchService.selectNodes(nodeService.getRootNode(storeRef), path, null, namespacePrefixResolver, false);
|
||||
for(NodeRef ref: refs)
|
||||
{
|
||||
for(ChildAssociationRef car: nodeService.getChildAssocs(ref))
|
||||
{
|
||||
nodeService.deleteNode(car.getChildRef());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File tempFile = TempFileProvider.createTempFile("ExportSourceImporter-", ".xml");
|
||||
Writer writer = new BufferedWriter(new FileWriter(tempFile));
|
||||
XMLWriter xmlWriter = createXMLExporter(writer);
|
||||
@@ -75,10 +156,17 @@ public class ExportSourceImporter implements ImporterJobSPI
|
||||
|
||||
importerService.importView(reader, location, REPLACE_BINDING, null);
|
||||
reader.close();
|
||||
userTransaction.commit();
|
||||
}
|
||||
catch (IOException io)
|
||||
catch(Throwable t)
|
||||
{
|
||||
throw new ExportSourceImporterException("Failed to import", io);
|
||||
try { if (userTransaction != null) {userTransaction.rollback();} } catch (Exception ex) {}
|
||||
try {authenticationComponent.clearCurrentSecurityContext(); } catch (Exception ex) {}
|
||||
throw new ExportSourceImporterException("Failed to import", t);
|
||||
}
|
||||
finally
|
||||
{
|
||||
authenticationComponent.clearCurrentSecurityContext();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,7 +189,7 @@ public class ExportSourceImporter implements ImporterJobSPI
|
||||
|
||||
public UUID_BINDING getUUIDBinding()
|
||||
{
|
||||
return UUID_BINDING.REPLACE_EXISTING;
|
||||
return UUID_BINDING.UPDATE_EXISTING;
|
||||
}
|
||||
|
||||
public String getValue(String key)
|
||||
|
Reference in New Issue
Block a user