mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Big hunk of merge.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3265 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -24,11 +24,11 @@ import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Enumeration;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
import org.alfresco.service.cmr.view.ImportPackageHandler;
|
||||
import org.alfresco.service.cmr.view.ImporterException;
|
||||
import org.apache.tools.zip.ZipEntry;
|
||||
import org.apache.tools.zip.ZipFile;
|
||||
|
||||
|
||||
/**
|
||||
@@ -39,7 +39,8 @@ import org.alfresco.service.cmr.view.ImporterException;
|
||||
public class ACPImportPackageHandler
|
||||
implements ImportPackageHandler
|
||||
{
|
||||
|
||||
public final static String DEFAULT_ENCODING = "UTF-8";
|
||||
|
||||
protected File file;
|
||||
protected ZipFile zipFile;
|
||||
protected String dataFileEncoding;
|
||||
@@ -65,7 +66,9 @@ public class ACPImportPackageHandler
|
||||
log("Importing from zip file " + file.getAbsolutePath());
|
||||
try
|
||||
{
|
||||
zipFile = new ZipFile(file);
|
||||
// NOTE: This encoding allows us to workaround bug...
|
||||
// http://bugs.sun.com/bugdatabase/view_bug.do;:WuuT?bug_id=4820807
|
||||
zipFile = new ZipFile(file, "Cp437");
|
||||
}
|
||||
catch(IOException e)
|
||||
{
|
||||
@@ -86,7 +89,7 @@ public class ACPImportPackageHandler
|
||||
// TODO: First, locate xml meta-data file by name
|
||||
|
||||
// Scan the zip entries one by one (the slow approach)
|
||||
Enumeration entries = zipFile.entries();
|
||||
Enumeration entries = zipFile.getEntries();
|
||||
while(entries.hasMoreElements())
|
||||
{
|
||||
ZipEntry entry = (ZipEntry)entries.nextElement();
|
||||
@@ -113,7 +116,7 @@ public class ACPImportPackageHandler
|
||||
|
||||
// open the meta-data xml file
|
||||
InputStream dataStream = zipFile.getInputStream(xmlMetaDataEntry);
|
||||
Reader inputReader = (dataFileEncoding == null) ? new InputStreamReader(dataStream) : new InputStreamReader(dataStream, dataFileEncoding);
|
||||
Reader inputReader = (dataFileEncoding == null) ? new InputStreamReader(dataStream, DEFAULT_ENCODING) : new InputStreamReader(dataStream, dataFileEncoding);
|
||||
return new BufferedReader(inputReader);
|
||||
}
|
||||
catch(UnsupportedEncodingException e)
|
||||
|
@@ -37,6 +37,8 @@ import org.alfresco.service.cmr.view.ImporterException;
|
||||
public class FileImportPackageHandler
|
||||
implements ImportPackageHandler
|
||||
{
|
||||
public final static String DEFAULT_ENCODING = "UTF-8";
|
||||
|
||||
protected File sourceDir;
|
||||
protected File dataFile;
|
||||
protected String dataFileEncoding;
|
||||
@@ -71,7 +73,7 @@ public class FileImportPackageHandler
|
||||
try
|
||||
{
|
||||
InputStream inputStream = new FileInputStream(dataFile);
|
||||
Reader inputReader = (dataFileEncoding == null) ? new InputStreamReader(inputStream) : new InputStreamReader(inputStream, dataFileEncoding);
|
||||
Reader inputReader = (dataFileEncoding == null) ? new InputStreamReader(inputStream, DEFAULT_ENCODING) : new InputStreamReader(inputStream, dataFileEncoding);
|
||||
return new BufferedReader(inputReader);
|
||||
}
|
||||
catch(UnsupportedEncodingException e)
|
||||
|
@@ -557,9 +557,9 @@ public class ImporterComponent
|
||||
{
|
||||
importContent(nodeRef, property.getKey(), (String)objVal);
|
||||
}
|
||||
else if (objVal instanceof List)
|
||||
else if (objVal instanceof Collection)
|
||||
{
|
||||
for (String value : (List<String>)objVal)
|
||||
for (String value : (Collection<String>)objVal)
|
||||
{
|
||||
importContent(nodeRef, property.getKey(), value);
|
||||
}
|
||||
@@ -716,12 +716,11 @@ public class ImporterComponent
|
||||
if (unresolvedRef != null)
|
||||
{
|
||||
NodeRef nodeRef = resolveImportedNodeRef(importedRef.context.getNodeRef(), unresolvedRef);
|
||||
if (nodeRef == null)
|
||||
// TODO: Provide a better mechanism for invalid references? e.g. report warning
|
||||
if (nodeRef != null)
|
||||
{
|
||||
// TODO: Probably need an alternative mechanism here e.g. report warning
|
||||
throw new ImporterException("Failed to find item referenced (in property " + importedRef.property + ") as " + importedRef.value);
|
||||
resolvedRefs.add(nodeRef);
|
||||
}
|
||||
resolvedRefs.add(nodeRef);
|
||||
}
|
||||
}
|
||||
refProperty = (Serializable)resolvedRefs;
|
||||
@@ -729,11 +728,7 @@ public class ImporterComponent
|
||||
else
|
||||
{
|
||||
refProperty = resolveImportedNodeRef(importedRef.context.getNodeRef(), (String)importedRef.value);
|
||||
if (refProperty == null)
|
||||
{
|
||||
// TODO: Probably need an alternative mechanism here e.g. report warning
|
||||
throw new ImporterException("Failed to find item referenced (in property " + importedRef.property + ") as " + importedRef.value);
|
||||
}
|
||||
// TODO: Provide a better mechanism for invalid references? e.g. report warning
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1024,23 +1019,31 @@ public class ImporterComponent
|
||||
}
|
||||
else
|
||||
{
|
||||
// resolve relative path
|
||||
try
|
||||
{
|
||||
List<NodeRef> nodeRefs = searchService.selectNodes(sourceNodeRef, importedRef, null, namespaceService, false);
|
||||
if (nodeRefs.size() > 0)
|
||||
{
|
||||
nodeRef = nodeRefs.get(0);
|
||||
}
|
||||
}
|
||||
catch(XPathException e)
|
||||
{
|
||||
nodeRef = new NodeRef(importedRef);
|
||||
}
|
||||
catch(AlfrescoRuntimeException e1)
|
||||
{
|
||||
// Note: Invalid reference format - try path search instead
|
||||
}
|
||||
// determine if node reference
|
||||
if (NodeRef.isNodeRef(importedRef))
|
||||
{
|
||||
nodeRef = new NodeRef(importedRef);
|
||||
}
|
||||
else
|
||||
{
|
||||
// resolve relative path
|
||||
try
|
||||
{
|
||||
List<NodeRef> nodeRefs = searchService.selectNodes(sourceNodeRef, importedRef, null, namespaceService, false);
|
||||
if (nodeRefs.size() > 0)
|
||||
{
|
||||
nodeRef = nodeRefs.get(0);
|
||||
}
|
||||
}
|
||||
catch(XPathException e)
|
||||
{
|
||||
nodeRef = new NodeRef(importedRef);
|
||||
}
|
||||
catch(AlfrescoRuntimeException e1)
|
||||
{
|
||||
// Note: Invalid reference format - try path search instead
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nodeRef;
|
||||
@@ -1235,7 +1238,7 @@ public class ImporterComponent
|
||||
NodeRef nodeRef = assocRef.getChildRef();
|
||||
|
||||
// Note: non-admin authorities take ownership of new nodes
|
||||
if (!authorityService.hasAdminAuthority())
|
||||
if (!(authorityService.hasAdminAuthority() || authenticationService.isCurrentUserTheSystemUser()))
|
||||
{
|
||||
ownableService.takeOwnership(nodeRef);
|
||||
}
|
||||
|
@@ -17,7 +17,7 @@
|
||||
<value name="applied-on-date" field="appliedOnDate"/>
|
||||
<value name="was-executed" field="wasExecuted"/>
|
||||
<value name="succeeded" field="succeeded"/>
|
||||
<value name="report" field="report"/>
|
||||
<value name="report" field="report" usage="optional"/>
|
||||
</structure>
|
||||
</collection>
|
||||
</structure>
|
||||
|
@@ -80,4 +80,15 @@ public class MetaDataContext extends ElementContext
|
||||
return properties;
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "MetaDataContext[properties=" + properties.size() + "]";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -49,4 +49,15 @@ public class NodeItemContext extends ElementContext
|
||||
{
|
||||
return nodeContext;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "NodeItemContext[nodeContext=" + nodeContext.toString() + "]";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -197,7 +197,11 @@ public class ViewParser implements Parser
|
||||
// Handle special view directives
|
||||
if (defName.equals(VIEW_METADATA))
|
||||
{
|
||||
parserContext.elementStack.push(new MetaDataContext(defName, (ElementContext)element));
|
||||
MetaDataContext metaDataContext = new MetaDataContext(defName, (ElementContext)element);
|
||||
parserContext.elementStack.push(metaDataContext);
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug(indentLog("Pushed " + metaDataContext, parserContext.elementStack.size() -1));
|
||||
}
|
||||
else if (defName.equals(VIEW_ASPECTS) || defName.equals(VIEW_PROPERTIES) || defName.equals(VIEW_ASSOCIATIONS) || defName.equals(VIEW_ACL))
|
||||
{
|
||||
@@ -210,7 +214,11 @@ public class ViewParser implements Parser
|
||||
throw new ImporterException("Element " + defName + " can only be declared within a node");
|
||||
}
|
||||
NodeContext node = (NodeContext)element;
|
||||
parserContext.elementStack.push(new NodeItemContext(defName, node));
|
||||
NodeItemContext nodeItemContext = new NodeItemContext(defName, node);
|
||||
parserContext.elementStack.push(nodeItemContext);
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug(indentLog("Pushed " + nodeItemContext, parserContext.elementStack.size() -1));
|
||||
|
||||
// process ACL specific attributes
|
||||
if (defName.equals(VIEW_ACL))
|
||||
|
Reference in New Issue
Block a user