Merged V2.1 to HEAD

6636: Temporary hack to fix build.  
   6637: Better handling of binary string bufs, disable link validation when poll interval is <= 0
   6638: Forgotten files for TXT to PDF transformer.
   6639: Fix for AWC-1541
   6641: Fix for WCM-792.
   6642: A little extra PropertyValue support for createNode, too.
   6643: Fix for WCM-791
   6644: Closure of AR-1528: Check concurrency handling of DuplicateChildNodeNameException
   6647: Fix WCM-794
   6648: WCM-656
   6650: Applied user supplied patch to fix AWC-1546 - Cannot mount AVM using CIFS on new alfresco installation.
   6651: Index tidy ups
   6654: Various minor updates for passthru authentication debugging and error handling.
   6657: Fix for WCM-799 (Some items selected for submission were not present)
   6659: Updated installers.
   6660: Partial fix to AWC-1524
   6661: Fix WCM-803
   6664: Including  hibernate-3.2.1.jar in $VIRTUAL_TOMCAT_HOME/server/lib/ 
   6665: adding an automated unit test for output path patterns.
   6668: Fixed to add shale-test-1.0.4.jar to Eclipse classpath (PHH oked)
   6681: Fixes WCM-811 - Lookup.getIndirectionPath() had a bit of a howler in it.
   6684: UncategorizedSQLException with the word 'deadlock' in the message is now cause for retrying a transaction.
   6691: Fix for WCM-813 (lock not removed when expiration date set and no workflow on web project)
   6696: Imporved SSO filters for SiteMinder etc + test filter
   6697: Support for scheduled import
   6699: Fix for the compliation target:  compile-benchmarkframework 
   6701: Fix for 1.6 JVMs (1.5 gets by with lucky ordering)


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6749 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2007-09-11 04:18:53 +00:00
parent f4f0f51a7d
commit a4b4ca69ec
27 changed files with 1110 additions and 205 deletions

View File

@@ -0,0 +1,242 @@
/*
* 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.importer;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.Reader;
import java.util.List;
import java.util.Set;
import javax.transaction.UserTransaction;
import org.alfresco.repo.cache.SimpleCache;
import org.alfresco.repo.security.authentication.AuthenticationComponent;
import org.alfresco.repo.security.authentication.ldap.LDAPGroupExportSource;
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.namespace.QName;
import org.alfresco.service.transaction.TransactionService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class FileSourceImporter implements ImporterJobSPI
{
private static Log s_logger = LogFactory.getLog(FileSourceImporter.class);
private ImporterService importerService;
private String fileLocation;
private AuthenticationComponent authenticationComponent;
private StoreRef storeRef;
private String path;
private boolean clearAllChildren;
private NodeService nodeService;
private SearchService searchService;
private NamespacePrefixResolver namespacePrefixResolver;
private TransactionService transactionService;
private Set<SimpleCache> caches;
public FileSourceImporter()
{
super();
}
public void setImporterService(ImporterService importerService)
{
this.importerService = importerService;
}
public void setFileLocation(String fileLocation)
{
this.fileLocation = fileLocation;
}
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 setCaches(Set<SimpleCache> caches)
{
this.caches = caches;
}
public void setAuthenticationComponent(AuthenticationComponent authenticationComponent)
{
this.authenticationComponent = authenticationComponent;
}
public void setSearchService(SearchService searchService)
{
this.searchService = searchService;
}
@SuppressWarnings("unchecked")
public void doImport()
{
UserTransaction userTransaction = null;
try
{
long start = System.nanoTime();
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());
}
}
}
if (caches != null)
{
for (SimpleCache cache : caches)
{
cache.clear();
}
}
Reader reader = new BufferedReader(new FileReader(fileLocation));
Location location = new Location(storeRef);
location.setPath(path);
importerService.importView(reader, location, REPLACE_BINDING, null);
reader.close();
if (caches != null)
{
for (SimpleCache cache : caches)
{
cache.clear();
}
}
userTransaction.commit();
long end = System.nanoTime();
s_logger.info("Imported "+fileLocation+ " in "+((end-start)/1e9f) + " seconds");
}
catch (Throwable t)
{
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();
}
}
private static ImporterBinding REPLACE_BINDING = new ImporterBinding()
{
public UUID_BINDING getUUIDBinding()
{
return UUID_BINDING.UPDATE_EXISTING;
}
public String getValue(String key)
{
return null;
}
public boolean allowReferenceWithinTransaction()
{
return false;
}
public QName[] getExcludedClasses()
{
return null;
}
};
}