07-12-2006 07:38 AM
07-12-2006 02:36 PM
07-12-2006 06:28 PM
07-13-2006 02:08 AM
07-13-2006 05:35 AM
07-14-2006 08:50 AM
A system error happened during the operation: Transaction didn't commit: Failed to find xml meta-data file within .acp package
07-14-2006 01:28 PM
07-18-2006 01:43 AM
A system error happened during the operation: Transaction didn't commit: A value for the mandatory parameter destination has not been set on the rule item unzip
public class ImporterActionExecuter extends ActionExecuterAbstractBase
{
public static final String NAME = "unzip";
public static final String PARAM_ENCODING = "encoding";
public static final String PARAM_DESTINATION_FOLDER = "destination";
private static final String TEMP_FILE_PREFIX = "alf";
private static final String TEMP_FILE_SUFFIX = ".zip";
/**
* The importer service
*/
private ImporterService importerService;
/**
* The node service
*/
private NodeService nodeService;
/**
* The content service
*/
private ContentService contentService;
/**
* Sets the ImporterService to use
*
* @param importerService The ImporterService
*/
public void setImporterService(ImporterService importerService)
{
this.importerService = importerService;
}
/**
* Sets the NodeService to use
*
* @param nodeService The NodeService
*/
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
}
/**
* Sets the ContentService to use
*
* @param contentService The ContentService
*/
public void setContentService(ContentService contentService)
{
this.contentService = contentService;
}
/**
* @see org.alfresco.repo.action.executer.ActionExecuter#execute(org.alfresco.repo.ref.NodeRef, org.alfresco.repo.ref.NodeRef)
*/
public void executeImpl(Action ruleAction, NodeRef actionedUponNodeRef)
{
if (this.nodeService.exists(actionedUponNodeRef) == true)
{
// The node being passed in should be an Alfresco content package
ContentReader reader = this.contentService.getReader(actionedUponNodeRef, ContentModel.PROP_CONTENT);
if (reader != null)
{
if (MimetypeMap.MIMETYPE_ZIP.equals(reader.getMimetype()))
{
File zipFile = null;
try
{
// unfortunately a ZIP file can not be read directly from an input stream so we have to create
// a temporary file first
zipFile = TempFileProvider.createTempFile(TEMP_FILE_PREFIX, TEMP_FILE_SUFFIX);
reader.getContent(zipFile);
new ZipImportAction().unzip(zipFile.getPath());
}
finally
{
// now the import is done, delete the temporary file
if (zipFile != null)
{
zipFile.delete();
}
}
}
}
}
}
/**
* @see org.alfresco.repo.action.ParameterizedItemAbstractBase#addParameterDefinitions(java.util.List)
*/
protected void addParameterDefinitions(List<ParameterDefinition> paramList)
{
paramList.add(new ParameterDefinitionImpl(PARAM_DESTINATION_FOLDER, DataTypeDefinition.NODE_REF,
true, getParamDisplayLabel(PARAM_DESTINATION_FOLDER)));
paramList.add(new ParameterDefinitionImpl(PARAM_ENCODING, DataTypeDefinition.TEXT,
true, getParamDisplayLabel(PARAM_ENCODING)));
}
}
public class ZipImportAction
{
public void copyInputStream(InputStream in, OutputStream out)
throws IOException
{
byte[] buffer = new byte[1024];
int len;
while ((len = in.read(buffer)) >= 0)
out.write(buffer, 0, len);
in.close();
out.close();
}
public void unzip(String file)
{
Enumeration entries;
ZipFile zipFile;
if (file.length() == 0) {
System.err.println("Usage: Unzip zipfile");
return;
}
try
{
zipFile = new ZipFile(file);
entries = zipFile.entries();
while (entries.hasMoreElements())
{
ZipEntry entry = (ZipEntry) entries.nextElement();
if (entry.isDirectory())
{
// Assume directories are stored parents first then
// children.
System.err.println("Extracting directory: "
+ entry.getName());
// make a new directory
(new File(entry.getName())).mkdir();
continue;
}
System.err.println("Extracting file: " + entry.getName());
copyInputStream(zipFile.getInputStream(entry),
new BufferedOutputStream(new FileOutputStream(entry
.getName())));
}
zipFile.close();
}
catch (IOException ioe)
{
System.err.println("Unhandled exception:");
ioe.printStackTrace();
return;
}
}
}
07-18-2006 03:48 PM
07-19-2006 01:49 AM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.