mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged DEV/WCM_SERVICES2 to HEAD
12236: Implementation of Sandbox Revert REST API 12305: WCM Services - "asset service" initial checkpoint (more tests to be added) 12334: placeholder for WCM Asset implementation 12338: Check in to get server working ... 12341: WCM Services - "asset service" checkpoint (locking fixes, bulk import, more tests added) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@12544 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
* Copyright (C) 2005-2008 Alfresco Software Limited.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
@@ -29,8 +29,6 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.faces.context.FacesContext;
|
|
||||||
|
|
||||||
import org.alfresco.model.WCMModel;
|
import org.alfresco.model.WCMModel;
|
||||||
import org.alfresco.repo.avm.AVMNodeConverter;
|
import org.alfresco.repo.avm.AVMNodeConverter;
|
||||||
import org.alfresco.repo.domain.PropertyValue;
|
import org.alfresco.repo.domain.PropertyValue;
|
||||||
@@ -41,11 +39,11 @@ import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
|||||||
import org.alfresco.service.cmr.repository.Path;
|
import org.alfresco.service.cmr.repository.Path;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.alfresco.util.Pair;
|
import org.alfresco.util.Pair;
|
||||||
import org.alfresco.web.app.Application;
|
import org.alfresco.wcm.asset.AssetInfo;
|
||||||
|
import org.alfresco.wcm.asset.AssetInfoImpl;
|
||||||
import org.alfresco.web.bean.BrowseBean;
|
import org.alfresco.web.bean.BrowseBean;
|
||||||
import org.alfresco.web.bean.repository.Node;
|
import org.alfresco.web.bean.repository.Node;
|
||||||
import org.alfresco.web.bean.repository.NodePropertyResolver;
|
import org.alfresco.web.bean.repository.NodePropertyResolver;
|
||||||
import org.alfresco.web.config.ClientConfigElement;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Node class representing an AVM specific Node.
|
* Node class representing an AVM specific Node.
|
||||||
@@ -169,6 +167,18 @@ public class AVMNode extends Node implements Map<String, Object>
|
|||||||
private WebProject webProject;
|
private WebProject webProject;
|
||||||
private Boolean workflowInFlight;
|
private Boolean workflowInFlight;
|
||||||
|
|
||||||
|
public AVMNode(final AssetInfo asset)
|
||||||
|
{
|
||||||
|
super(AVMNodeConverter.ToNodeRef(-1, asset.getAvmPath()));
|
||||||
|
|
||||||
|
// TODO - refactor !!
|
||||||
|
this.avmRef = ((AssetInfoImpl)asset).getAVMNodeDescriptor();
|
||||||
|
|
||||||
|
this.version = -1; // TODO: always -1 for now...
|
||||||
|
this.id = asset.getAvmPath();
|
||||||
|
this.deleted = asset.isDeleted();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
* Copyright (C) 2005-2008 Alfresco Software Limited.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
@@ -24,22 +24,17 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.web.bean.wcm;
|
package org.alfresco.web.bean.wcm;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.faces.context.FacesContext;
|
import javax.faces.context.FacesContext;
|
||||||
|
|
||||||
import org.alfresco.model.ApplicationModel;
|
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.repo.avm.AVMNodeConverter;
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.alfresco.repo.domain.PropertyValue;
|
import org.alfresco.wcm.asset.AssetService;
|
||||||
import org.alfresco.service.cmr.avm.AVMService;
|
|
||||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
|
||||||
import org.alfresco.service.cmr.repository.NodeService;
|
|
||||||
import org.alfresco.web.bean.dialog.BaseDialogBean;
|
import org.alfresco.web.bean.dialog.BaseDialogBean;
|
||||||
import org.alfresco.web.bean.repository.Repository;
|
import org.alfresco.web.bean.repository.Repository;
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bean implementation for the AVM "Create Folder" dialog.
|
* Bean implementation for the AVM "Create Folder" dialog.
|
||||||
@@ -50,9 +45,9 @@ public class CreateFolderDialog extends BaseDialogBean
|
|||||||
{
|
{
|
||||||
private static final long serialVersionUID = 5501238017264037644L;
|
private static final long serialVersionUID = 5501238017264037644L;
|
||||||
|
|
||||||
private static final Log logger = LogFactory.getLog(CreateFolderDialog.class);
|
//private static final Log logger = LogFactory.getLog(CreateFolderDialog.class);
|
||||||
|
|
||||||
transient private AVMService avmService;
|
transient private AssetService assetService;
|
||||||
protected AVMBrowseBean avmBrowseBean;
|
protected AVMBrowseBean avmBrowseBean;
|
||||||
|
|
||||||
protected String name;
|
protected String name;
|
||||||
@@ -80,20 +75,20 @@ public class CreateFolderDialog extends BaseDialogBean
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param avmService The avmService to set.
|
* @param assetService The assetService to set.
|
||||||
*/
|
*/
|
||||||
public void setAvmService(AVMService avmService)
|
public void setAssetService(AssetService assetService)
|
||||||
{
|
{
|
||||||
this.avmService = avmService;
|
this.assetService = assetService;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected AVMService getAvmService()
|
protected AssetService getAssetService()
|
||||||
{
|
{
|
||||||
if (avmService == null)
|
if (assetService == null)
|
||||||
{
|
{
|
||||||
avmService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getAVMService();
|
assetService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getAssetService();
|
||||||
}
|
}
|
||||||
return avmService;
|
return assetService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -155,22 +150,23 @@ public class CreateFolderDialog extends BaseDialogBean
|
|||||||
protected String finishImpl(FacesContext context, String outcome) throws Exception
|
protected String finishImpl(FacesContext context, String outcome) throws Exception
|
||||||
{
|
{
|
||||||
String parent = this.avmBrowseBean.getCurrentPath();
|
String parent = this.avmBrowseBean.getCurrentPath();
|
||||||
this.getAvmService().createDirectory(parent, this.name);
|
|
||||||
|
|
||||||
String path = parent + '/' + this.name;
|
Map<QName, Serializable> properties = new HashMap<QName, Serializable>(2);
|
||||||
NodeRef nodeRef = AVMNodeConverter.ToNodeRef(-1, path);
|
if (title != null && title.length() != 0)
|
||||||
this.getNodeService().addAspect(nodeRef, ApplicationModel.ASPECT_UIFACETS, null);
|
|
||||||
if (this.title != null && this.title.length() != 0)
|
|
||||||
{
|
{
|
||||||
this.getAvmService().setNodeProperty(path, ContentModel.PROP_TITLE,
|
properties.put(ContentModel.PROP_TITLE, title);
|
||||||
new PropertyValue(DataTypeDefinition.TEXT, this.title));
|
|
||||||
}
|
}
|
||||||
if (this.description != null && this.description.length() != 0)
|
if (description != null && description.length() != 0)
|
||||||
{
|
{
|
||||||
this.getAvmService().setNodeProperty(path, ContentModel.PROP_DESCRIPTION,
|
properties.put(ContentModel.PROP_DESCRIPTION, description);
|
||||||
new PropertyValue(DataTypeDefinition.TEXT, this.description));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String[] parts = parent.split(":");
|
||||||
|
String sbStoreId = parts[0];
|
||||||
|
String path = parts[1];
|
||||||
|
|
||||||
|
this.getAssetService().createFolder(sbStoreId, path, this.name, properties);
|
||||||
|
|
||||||
return outcome;
|
return outcome;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
* Copyright (C) 2005-2008 Alfresco Software Limited.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
@@ -34,16 +34,12 @@ import javax.faces.model.SelectItem;
|
|||||||
|
|
||||||
import org.alfresco.model.ApplicationModel;
|
import org.alfresco.model.ApplicationModel;
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.model.WCMAppModel;
|
|
||||||
import org.alfresco.repo.avm.AVMNodeConverter;
|
import org.alfresco.repo.avm.AVMNodeConverter;
|
||||||
import org.alfresco.repo.domain.PropertyValue;
|
import org.alfresco.repo.domain.PropertyValue;
|
||||||
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
|
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
|
||||||
|
import org.alfresco.service.cmr.avm.AVMService;
|
||||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.search.ResultSet;
|
|
||||||
import org.alfresco.service.cmr.search.ResultSetRow;
|
|
||||||
import org.alfresco.service.cmr.search.SearchService;
|
|
||||||
import org.alfresco.service.namespace.NamespaceService;
|
|
||||||
import org.alfresco.wcm.webproject.WebProjectInfo;
|
import org.alfresco.wcm.webproject.WebProjectInfo;
|
||||||
import org.alfresco.wcm.webproject.WebProjectService;
|
import org.alfresco.wcm.webproject.WebProjectService;
|
||||||
import org.alfresco.web.app.Application;
|
import org.alfresco.web.app.Application;
|
||||||
@@ -70,6 +66,7 @@ public class CreateLayeredFolderDialog extends CreateFolderDialog
|
|||||||
protected List<SelectItem> webProjects;
|
protected List<SelectItem> webProjects;
|
||||||
|
|
||||||
transient protected WebProjectService wpService;
|
transient protected WebProjectService wpService;
|
||||||
|
transient protected AVMService avmService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param wpService The WebProjectService to set.
|
* @param wpService The WebProjectService to set.
|
||||||
@@ -88,6 +85,23 @@ public class CreateLayeredFolderDialog extends CreateFolderDialog
|
|||||||
return wpService;
|
return wpService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param avmService The avmService to set.
|
||||||
|
*/
|
||||||
|
public void setAvmService(AVMService avmService)
|
||||||
|
{
|
||||||
|
this.avmService = avmService;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected AVMService getAvmService()
|
||||||
|
{
|
||||||
|
if (avmService == null)
|
||||||
|
{
|
||||||
|
avmService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getAVMService();
|
||||||
|
}
|
||||||
|
return avmService;
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
// Dialog implementation
|
// Dialog implementation
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
* Copyright (C) 2005-2008 Alfresco Software Limited.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
@@ -24,40 +24,14 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.web.bean.wcm;
|
package org.alfresco.web.bean.wcm;
|
||||||
|
|
||||||
import java.io.BufferedInputStream;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.faces.context.FacesContext;
|
import javax.faces.context.FacesContext;
|
||||||
import javax.faces.event.ActionEvent;
|
import javax.faces.event.ActionEvent;
|
||||||
import javax.transaction.UserTransaction;
|
|
||||||
|
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
|
||||||
import org.alfresco.model.ApplicationModel;
|
|
||||||
import org.alfresco.model.ContentModel;
|
|
||||||
import org.alfresco.repo.action.executer.ImporterActionExecuter;
|
|
||||||
import org.alfresco.repo.avm.AVMNodeConverter;
|
|
||||||
import org.alfresco.repo.domain.PropertyValue;
|
|
||||||
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||||
import org.alfresco.service.ServiceRegistry;
|
import org.alfresco.wcm.asset.AssetService;
|
||||||
import org.alfresco.service.cmr.avm.AVMService;
|
|
||||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
|
||||||
import org.alfresco.service.cmr.model.FileExistsException;
|
|
||||||
import org.alfresco.service.cmr.model.FileFolderService;
|
|
||||||
import org.alfresco.service.cmr.repository.ContentService;
|
|
||||||
import org.alfresco.service.cmr.repository.MimetypeService;
|
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
|
||||||
import org.alfresco.service.cmr.repository.NodeService;
|
|
||||||
import org.alfresco.service.namespace.QName;
|
|
||||||
import org.alfresco.util.TempFileProvider;
|
|
||||||
import org.alfresco.web.app.AlfrescoNavigationHandler;
|
import org.alfresco.web.app.AlfrescoNavigationHandler;
|
||||||
import org.alfresco.web.app.Application;
|
import org.alfresco.web.app.Application;
|
||||||
import org.alfresco.web.app.context.UIContextService;
|
import org.alfresco.web.app.context.UIContextService;
|
||||||
@@ -65,9 +39,6 @@ import org.alfresco.web.bean.FileUploadBean;
|
|||||||
import org.alfresco.web.bean.dialog.BaseDialogBean;
|
import org.alfresco.web.bean.dialog.BaseDialogBean;
|
||||||
import org.alfresco.web.bean.repository.Repository;
|
import org.alfresco.web.bean.repository.Repository;
|
||||||
import org.alfresco.web.ui.common.Utils;
|
import org.alfresco.web.ui.common.Utils;
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
import org.apache.tools.zip.ZipFile;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Backing bean for the Import Website Content dialog.
|
* Backing bean for the Import Website Content dialog.
|
||||||
@@ -81,56 +52,16 @@ public class ImportWebsiteDialog extends BaseDialogBean
|
|||||||
{
|
{
|
||||||
private static final long serialVersionUID = -432986732265292504L;
|
private static final long serialVersionUID = -432986732265292504L;
|
||||||
|
|
||||||
private static final int BUFFER_SIZE = 16384;
|
//private static Log logger = LogFactory.getLog(ImportWebsiteDialog.class);
|
||||||
private static Log logger = LogFactory.getLog(ImportWebsiteDialog.class);
|
|
||||||
|
|
||||||
protected File file;
|
protected File file;
|
||||||
protected String fileName;
|
protected String fileName;
|
||||||
protected boolean isFinished = false;
|
protected boolean isFinished = false;
|
||||||
protected boolean highByteZip = false;
|
protected boolean highByteZip = false;
|
||||||
|
|
||||||
transient private FileFolderService fileFolderService;
|
|
||||||
transient private ContentService contentService;
|
|
||||||
|
|
||||||
protected AVMBrowseBean avmBrowseBean;
|
protected AVMBrowseBean avmBrowseBean;
|
||||||
|
transient private AssetService assetService;
|
||||||
transient private AVMService avmService;
|
|
||||||
transient private NodeService nodeService;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param contentService The ContentService to set.
|
|
||||||
*/
|
|
||||||
public void setContentService(ContentService contentService)
|
|
||||||
{
|
|
||||||
this.contentService = contentService;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected ContentService getContentService()
|
|
||||||
{
|
|
||||||
if (this.contentService == null)
|
|
||||||
{
|
|
||||||
this.contentService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getContentService();
|
|
||||||
}
|
|
||||||
return this.contentService;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param fileFolderService The FileFolderService to set.
|
|
||||||
*/
|
|
||||||
public void setFileFolderService(FileFolderService fileFolderService)
|
|
||||||
{
|
|
||||||
this.fileFolderService = fileFolderService;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected FileFolderService getFileFolderService()
|
|
||||||
{
|
|
||||||
if (this.fileFolderService == null)
|
|
||||||
{
|
|
||||||
this.fileFolderService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getFileFolderService();
|
|
||||||
}
|
|
||||||
return this.fileFolderService;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param avmBrowseBean The AVMBrowseBean to set.
|
* @param avmBrowseBean The AVMBrowseBean to set.
|
||||||
@@ -141,37 +72,20 @@ public class ImportWebsiteDialog extends BaseDialogBean
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param avmService The AVMService to set.
|
* @param avmService The AssetService to set.
|
||||||
*/
|
*/
|
||||||
public void setAvmService(AVMService avmService)
|
public void setAssetService(AssetService assetService)
|
||||||
{
|
{
|
||||||
this.avmService = avmService;
|
this.assetService = assetService;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected AVMService getAvmService()
|
protected AssetService getAssetService()
|
||||||
{
|
{
|
||||||
if (this.avmService == null)
|
if (this.assetService == null)
|
||||||
{
|
{
|
||||||
this.avmService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getAVMLockingAwareService();
|
this.assetService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getAssetService();
|
||||||
}
|
}
|
||||||
return this.avmService;
|
return this.assetService;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param nodeService The NodeService to set.
|
|
||||||
*/
|
|
||||||
public void setNodeService(NodeService nodeService)
|
|
||||||
{
|
|
||||||
this.nodeService = nodeService;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected NodeService getNodeService()
|
|
||||||
{
|
|
||||||
if (this.nodeService == null)
|
|
||||||
{
|
|
||||||
this.nodeService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getNodeService();
|
|
||||||
}
|
|
||||||
return this.nodeService;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -257,35 +171,28 @@ public class ImportWebsiteDialog extends BaseDialogBean
|
|||||||
{
|
{
|
||||||
this.isFinished = true;
|
this.isFinished = true;
|
||||||
|
|
||||||
UserTransaction tx = null;
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
FacesContext context = FacesContext.getCurrentInstance();
|
FacesContext context = FacesContext.getCurrentInstance();
|
||||||
RetryingTransactionHelper.RetryingTransactionCallback<String> cb =
|
RetryingTransactionHelper.RetryingTransactionCallback<Object> cb =
|
||||||
new RetryingTransactionHelper.RetryingTransactionCallback<String>()
|
new RetryingTransactionHelper.RetryingTransactionCallback<Object>()
|
||||||
{
|
{
|
||||||
public String execute()
|
public Object execute()
|
||||||
{
|
{
|
||||||
// get the AVM path that will contain the imported content
|
// get the AVM path that will contain the imported content
|
||||||
String rootPath = avmBrowseBean.getCurrentPath();
|
String rootPath = avmBrowseBean.getCurrentPath();
|
||||||
|
|
||||||
|
String[] parts = rootPath.split(":");
|
||||||
|
String sbStoreId = parts[0];
|
||||||
|
String parentFolderPath = parts[1];
|
||||||
|
|
||||||
// convert the AVM path to a NodeRef so we can use the NodeService to perform import
|
getAssetService().bulkImport(sbStoreId, parentFolderPath, file, isHighByteZip());
|
||||||
NodeRef importRef = AVMNodeConverter.ToNodeRef(-1, rootPath);
|
|
||||||
processZipImport(file, importRef);
|
return null;
|
||||||
|
|
||||||
// After a bulk import it's a good idea to snapshot the store
|
|
||||||
getAvmService().createSnapshot(
|
|
||||||
AVMUtil.getStoreName(rootPath),
|
|
||||||
"Import of file: " + fileName, null);
|
|
||||||
|
|
||||||
return rootPath;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
String rootPath = Repository.getRetryingTransactionHelper(context).doInTransaction(cb);
|
|
||||||
|
Repository.getRetryingTransactionHelper(context).doInTransaction(cb);
|
||||||
// Reload virtualisation server as required
|
|
||||||
AVMUtil.updateVServerWebapp(rootPath, true);
|
|
||||||
|
|
||||||
UIContextService.getInstance(context).notifyBeans();
|
UIContextService.getInstance(context).notifyBeans();
|
||||||
|
|
||||||
@@ -353,130 +260,6 @@ public class ImportWebsiteDialog extends BaseDialogBean
|
|||||||
ctx.getExternalContext().getSessionMap().remove(FileUploadBean.FILE_UPLOAD_BEAN_NAME);
|
ctx.getExternalContext().getSessionMap().remove(FileUploadBean.FILE_UPLOAD_BEAN_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Process ZIP file for import into an AVM repository store location
|
|
||||||
*
|
|
||||||
* @param file ZIP format file
|
|
||||||
* @param rootRef Root reference of the AVM location to import into
|
|
||||||
*/
|
|
||||||
public void processZipImport(File file, NodeRef rootRef)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// NOTE: This encoding allows us to workaround bug:
|
|
||||||
// http://bugs.sun.com/bugdatabase/view_bug.do;:WuuT?bug_id=4820807
|
|
||||||
ZipFile zipFile = new ZipFile(file, this.highByteZip ? "Cp437" : null);
|
|
||||||
File alfTempDir = TempFileProvider.getTempDir();
|
|
||||||
// build a temp dir name based on the name of the file we are importing
|
|
||||||
File tempDir = new File(alfTempDir.getPath() + File.separatorChar + file.getName() + "_unpack");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
ImporterActionExecuter.extractFile(zipFile, tempDir.getPath());
|
|
||||||
importDirectory(tempDir.getPath(), rootRef);
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
if (tempDir.exists())
|
|
||||||
{
|
|
||||||
ImporterActionExecuter.deleteDir(tempDir);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
throw new AlfrescoRuntimeException("Unable to process Zip file. File may not be of the expected format.", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Recursively import a directory structure into the specified root node
|
|
||||||
*
|
|
||||||
* @param dir The directory of files and folders to import
|
|
||||||
* @param root The root node to import into
|
|
||||||
*/
|
|
||||||
private void importDirectory(String dir, NodeRef root)
|
|
||||||
{
|
|
||||||
ServiceRegistry services = Repository.getServiceRegistry(FacesContext.getCurrentInstance());
|
|
||||||
MimetypeService mimetypeService = services.getMimetypeService();
|
|
||||||
File topdir = new File(dir);
|
|
||||||
if (!topdir.exists()) return;
|
|
||||||
for (File file : topdir.listFiles())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (file.isFile())
|
|
||||||
{
|
|
||||||
// Create a file in the AVM store
|
|
||||||
String avmPath = AVMNodeConverter.ToAVMVersionPath(root).getSecond();
|
|
||||||
String fileName = file.getName();
|
|
||||||
List<QName> aspects = new ArrayList<QName>();
|
|
||||||
aspects.add(ContentModel.ASPECT_TITLED);
|
|
||||||
Map<QName, PropertyValue> properties = new HashMap<QName, PropertyValue>();
|
|
||||||
properties.put(ContentModel.PROP_TITLE,
|
|
||||||
new PropertyValue(DataTypeDefinition.TEXT, fileName));
|
|
||||||
this.getAvmService().createFile(
|
|
||||||
avmPath, fileName,new BufferedInputStream(new FileInputStream(file), BUFFER_SIZE),
|
|
||||||
aspects, properties);
|
|
||||||
|
|
||||||
// TODO: restore this code once performance is acceptable
|
|
||||||
// NodeRef fileRef = AVMNodeConverter.ToNodeRef(-1, filePath);
|
|
||||||
// see AVMBrowseBean.setAVMNodeDescriptor
|
|
||||||
// add titled aspect for the read/edit properties screens
|
|
||||||
// Map<QName, Serializable> titledProps = new HashMap<QName, Serializable>(1, 1.0f);
|
|
||||||
// titledProps.put(ContentModel.PROP_TITLE, fileName);
|
|
||||||
// this.nodeService.addAspect(fileRef, ContentModel.ASPECT_TITLED, titledProps);
|
|
||||||
|
|
||||||
// for now use the avm service directly
|
|
||||||
// String filePath = avmPath + '/' + fileName;
|
|
||||||
// this.avmService.addAspect(filePath, ContentModel.ASPECT_TITLED);
|
|
||||||
// this.avmService.setNodeProperty(filePath, ContentModel.PROP_TITLE,
|
|
||||||
// new PropertyValue(DataTypeDefinition.TEXT, fileName));
|
|
||||||
|
|
||||||
// create content node based on the filename
|
|
||||||
/*FileInfo contentFile = fileFolderService.create(root, fileName, ContentModel.TYPE_AVM_PLAIN_CONTENT);
|
|
||||||
NodeRef content = contentFile.getNodeRef();
|
|
||||||
|
|
||||||
InputStream contentStream = new BufferedInputStream(new FileInputStream(file), BUFFER_SIZE);
|
|
||||||
|
|
||||||
ContentWriter writer = contentService.getWriter(content, ContentModel.PROP_CONTENT, true);
|
|
||||||
writer.setMimetype(mimetypeService.guessMimetype(file.getAbsolutePath()));
|
|
||||||
// TODO: what should we set this too? (definitely not Cp437...!)
|
|
||||||
//writer.setEncoding("Cp437");
|
|
||||||
writer.putContent(contentStream);*/
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//FileInfo fileInfo = fileFolderService.create(root, file.getName(), ContentModel.TYPE_AVM_PLAIN_FOLDER);
|
|
||||||
|
|
||||||
// Create a directory in the AVM store
|
|
||||||
String avmPath = AVMNodeConverter.ToAVMVersionPath(root).getSecond();
|
|
||||||
List<QName> aspects = new ArrayList<QName>();
|
|
||||||
aspects.add(ApplicationModel.ASPECT_UIFACETS);
|
|
||||||
this.getAvmService().createDirectory(avmPath, file.getName(), aspects, null);
|
|
||||||
|
|
||||||
String folderPath = avmPath + '/' + file.getName();
|
|
||||||
NodeRef folderRef = AVMNodeConverter.ToNodeRef(-1, folderPath);
|
|
||||||
importDirectory(file.getPath(), folderRef);
|
|
||||||
|
|
||||||
// TODO: restore this code once performance is acceptable
|
|
||||||
// see AVMBrowseBean.setAVMNodeDescriptor
|
|
||||||
// add the uifacets aspect for the read/edit properties screens
|
|
||||||
// this.nodeService.addAspect(folderRef, ContentModel.ASPECT_UIFACETS, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (FileNotFoundException e)
|
|
||||||
{
|
|
||||||
// TODO: add failed file info to status message?
|
|
||||||
throw new AlfrescoRuntimeException("Failed to process ZIP file.", e);
|
|
||||||
}
|
|
||||||
catch (FileExistsException e)
|
|
||||||
{
|
|
||||||
// TODO: add failed file info to status message?
|
|
||||||
throw new AlfrescoRuntimeException("Failed to process ZIP file.", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String finishImpl(FacesContext context, String outcome) throws Exception
|
protected String finishImpl(FacesContext context, String outcome) throws Exception
|
||||||
{
|
{
|
||||||
|
@@ -478,11 +478,11 @@ public class SubmitDialog extends BaseDialogBean
|
|||||||
// direct submit to the staging area without workflow
|
// direct submit to the staging area without workflow
|
||||||
List<ItemWrapper> items = getSubmitItems();
|
List<ItemWrapper> items = getSubmitItems();
|
||||||
|
|
||||||
List<AVMNodeDescriptor> nodes = new ArrayList<AVMNodeDescriptor>(items.size());
|
List<String> relativePaths = new ArrayList<String>(items.size());
|
||||||
|
|
||||||
for (ItemWrapper wrapper : items)
|
for (ItemWrapper wrapper : items)
|
||||||
{
|
{
|
||||||
nodes.add(wrapper.getDescriptor());
|
relativePaths.add(AVMUtil.getStoreRelativePath(wrapper.getDescriptor().getPath()));
|
||||||
}
|
}
|
||||||
|
|
||||||
String sbStoreId = this.avmBrowseBean.getSandbox();
|
String sbStoreId = this.avmBrowseBean.getSandbox();
|
||||||
@@ -490,7 +490,7 @@ public class SubmitDialog extends BaseDialogBean
|
|||||||
String submitLabel = this.label;
|
String submitLabel = this.label;
|
||||||
String submitComment = this.comment;
|
String submitComment = this.comment;
|
||||||
|
|
||||||
getSandboxService().submitListNodes(sbStoreId, nodes, this.expirationDates, submitLabel, submitComment);
|
getSandboxService().submitList(sbStoreId, relativePaths, this.expirationDates, submitLabel, submitComment);
|
||||||
|
|
||||||
// if we get this far return the default outcome
|
// if we get this far return the default outcome
|
||||||
return this.getDefaultFinishOutcome();
|
return this.getDefaultFinishOutcome();
|
||||||
|
@@ -28,7 +28,6 @@ import java.io.IOException;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
@@ -53,6 +52,8 @@ import org.alfresco.service.cmr.repository.NodeRef;
|
|||||||
import org.alfresco.service.cmr.repository.NodeService;
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
import org.alfresco.service.cmr.security.AccessStatus;
|
import org.alfresco.service.cmr.security.AccessStatus;
|
||||||
import org.alfresco.service.cmr.security.PermissionService;
|
import org.alfresco.service.cmr.security.PermissionService;
|
||||||
|
import org.alfresco.wcm.asset.AssetInfo;
|
||||||
|
import org.alfresco.wcm.asset.AssetInfoImpl;
|
||||||
import org.alfresco.wcm.sandbox.SandboxConstants;
|
import org.alfresco.wcm.sandbox.SandboxConstants;
|
||||||
import org.alfresco.wcm.sandbox.SandboxInfo;
|
import org.alfresco.wcm.sandbox.SandboxInfo;
|
||||||
import org.alfresco.wcm.sandbox.SandboxService;
|
import org.alfresco.wcm.sandbox.SandboxService;
|
||||||
@@ -720,9 +721,9 @@ public class UIUserSandboxes extends SelfRenderingComponent implements Serializa
|
|||||||
|
|
||||||
// compare user sandbox to staging sandbox - filter by current webapp, include deleted items
|
// compare user sandbox to staging sandbox - filter by current webapp, include deleted items
|
||||||
String userStore = AVMUtil.buildUserMainStoreName(storeRoot, username);
|
String userStore = AVMUtil.buildUserMainStoreName(storeRoot, username);
|
||||||
List<AVMNodeDescriptor> nodes = sandboxService.listChangedWebApp(userStore, getWebapp(), true);
|
List<AssetInfo> assets = sandboxService.listChangedWebApp(userStore, getWebapp(), true);
|
||||||
|
|
||||||
if (nodes.size() != 0)
|
if (assets.size() != 0)
|
||||||
{
|
{
|
||||||
// info we need to calculate preview paths for assets
|
// info we need to calculate preview paths for assets
|
||||||
int rootPathIndex = AVMUtil.buildSandboxRootPath(userStore).length();
|
int rootPathIndex = AVMUtil.buildSandboxRootPath(userStore).length();
|
||||||
@@ -735,6 +736,13 @@ public class UIUserSandboxes extends SelfRenderingComponent implements Serializa
|
|||||||
|
|
||||||
String id = getClientId(fc);
|
String id = getClientId(fc);
|
||||||
|
|
||||||
|
// TODO - refactor to AssetInfo and getSelected calls ... etc
|
||||||
|
List<AVMNodeDescriptor> nodes = new ArrayList<AVMNodeDescriptor>(assets.size());
|
||||||
|
for (AssetInfo asset : assets)
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
nodes.add(((AssetInfoImpl)asset).getAVMNodeDescriptor());
|
||||||
|
}
|
||||||
// store lookup of username to list of modified nodes
|
// store lookup of username to list of modified nodes
|
||||||
this.userNodes.put(username, nodes);
|
this.userNodes.put(username, nodes);
|
||||||
|
|
||||||
@@ -781,11 +789,11 @@ public class UIUserSandboxes extends SelfRenderingComponent implements Serializa
|
|||||||
|
|
||||||
// output each of the modified files as a row in the table
|
// output each of the modified files as a row in the table
|
||||||
int rowIndex = 0;
|
int rowIndex = 0;
|
||||||
for (AVMNodeDescriptor node : nodes)
|
for (AssetInfo node : assets)
|
||||||
{
|
{
|
||||||
// TODO: different display cases for diff.getDifferenceCode()?
|
// TODO: different display cases for diff.getDifferenceCode()?
|
||||||
boolean isGhost = node.isDeleted();
|
boolean isGhost = node.isDeleted();
|
||||||
String sourcePath = node.getPath();
|
String sourcePath = node.getAvmPath();
|
||||||
|
|
||||||
// output multi-select checkbox
|
// output multi-select checkbox
|
||||||
out.write("<tr><td><input type='checkbox' name='");
|
out.write("<tr><td><input type='checkbox' name='");
|
||||||
@@ -830,11 +838,11 @@ public class UIUserSandboxes extends SelfRenderingComponent implements Serializa
|
|||||||
out.write("</td><td>");
|
out.write("</td><td>");
|
||||||
|
|
||||||
// created date
|
// created date
|
||||||
out.write(df.format(new Date(node.getCreateDate())));
|
out.write(df.format(node.getCreatedDate()));
|
||||||
out.write("</td><td>");
|
out.write("</td><td>");
|
||||||
|
|
||||||
// modified date
|
// modified date
|
||||||
out.write(df.format(new Date(node.getModDate())));
|
out.write(df.format(node.getModifiedDate()));
|
||||||
out.write("</td><td>");
|
out.write("</td><td>");
|
||||||
|
|
||||||
// build node context required for actions
|
// build node context required for actions
|
||||||
@@ -846,7 +854,7 @@ public class UIUserSandboxes extends SelfRenderingComponent implements Serializa
|
|||||||
// size of files
|
// size of files
|
||||||
if (node.isFile())
|
if (node.isFile())
|
||||||
{
|
{
|
||||||
out.write(getSizeConverter().getAsString(fc, this, node.getLength()));
|
out.write(getSizeConverter().getAsString(fc, this, node.getFileSize()));
|
||||||
out.write("</td><td>");
|
out.write("</td><td>");
|
||||||
|
|
||||||
// add UI actions for this item
|
// add UI actions for this item
|
||||||
@@ -867,7 +875,7 @@ public class UIUserSandboxes extends SelfRenderingComponent implements Serializa
|
|||||||
// must have been deleted from this sandbox - show as ghosted
|
// must have been deleted from this sandbox - show as ghosted
|
||||||
String name = node.getName();
|
String name = node.getName();
|
||||||
out.write("<td width=16>");
|
out.write("<td width=16>");
|
||||||
if (node.isDeletedFile())
|
if (node.isFile() && node.isDeleted())
|
||||||
{
|
{
|
||||||
out.write(Utils.buildImageTag(fc, FileTypeImageUtils.getFileTypeImage(fc, name, true), ""));
|
out.write(Utils.buildImageTag(fc, FileTypeImageUtils.getFileTypeImage(fc, name, true), ""));
|
||||||
out.write("</td><td style='color:#aaaaaa'>");
|
out.write("</td><td style='color:#aaaaaa'>");
|
||||||
@@ -883,17 +891,17 @@ public class UIUserSandboxes extends SelfRenderingComponent implements Serializa
|
|||||||
out.write("</td><td style='color:#aaaaaa'>");
|
out.write("</td><td style='color:#aaaaaa'>");
|
||||||
|
|
||||||
// created date
|
// created date
|
||||||
out.write(df.format(new Date(node.getCreateDate())));
|
out.write(df.format(node.getCreatedDate()));
|
||||||
out.write("</td><td style='color:#aaaaaa'>");
|
out.write("</td><td style='color:#aaaaaa'>");
|
||||||
|
|
||||||
// modified date
|
// modified date
|
||||||
out.write(df.format(new Date(node.getModDate())));
|
out.write(df.format(node.getModifiedDate()));
|
||||||
out.write("</td><td style='color:#aaaaaa'>");
|
out.write("</td><td style='color:#aaaaaa'>");
|
||||||
|
|
||||||
// size of files
|
// size of files
|
||||||
if (node.isFile())
|
if (node.isFile())
|
||||||
{
|
{
|
||||||
out.write(getSizeConverter().getAsString(fc, this, node.getLength()));
|
out.write(getSizeConverter().getAsString(fc, this, node.getFileSize()));
|
||||||
}
|
}
|
||||||
out.write("</td><td style='color:#aaaaaa'>");
|
out.write("</td><td style='color:#aaaaaa'>");
|
||||||
|
|
||||||
|
@@ -3418,20 +3418,8 @@
|
|||||||
<managed-bean-class>org.alfresco.web.bean.wcm.ImportWebsiteDialog</managed-bean-class>
|
<managed-bean-class>org.alfresco.web.bean.wcm.ImportWebsiteDialog</managed-bean-class>
|
||||||
<managed-bean-scope>session</managed-bean-scope>
|
<managed-bean-scope>session</managed-bean-scope>
|
||||||
<managed-property>
|
<managed-property>
|
||||||
<property-name>nodeService</property-name>
|
<property-name>assetService</property-name>
|
||||||
<value>#{nodeService}</value>
|
<value>#{AssetService}</value>
|
||||||
</managed-property>
|
|
||||||
<managed-property>
|
|
||||||
<property-name>fileFolderService</property-name>
|
|
||||||
<value>#{FileFolderService}</value>
|
|
||||||
</managed-property>
|
|
||||||
<managed-property>
|
|
||||||
<property-name>contentService</property-name>
|
|
||||||
<value>#{ContentService}</value>
|
|
||||||
</managed-property>
|
|
||||||
<managed-property>
|
|
||||||
<property-name>avmService</property-name>
|
|
||||||
<value>#{AVMLockingAwareService}</value>
|
|
||||||
</managed-property>
|
</managed-property>
|
||||||
<managed-property>
|
<managed-property>
|
||||||
<property-name>avmBrowseBean</property-name>
|
<property-name>avmBrowseBean</property-name>
|
||||||
@@ -3793,17 +3781,13 @@
|
|||||||
<managed-bean-class>org.alfresco.web.bean.wcm.CreateFolderDialog</managed-bean-class>
|
<managed-bean-class>org.alfresco.web.bean.wcm.CreateFolderDialog</managed-bean-class>
|
||||||
<managed-bean-scope>session</managed-bean-scope>
|
<managed-bean-scope>session</managed-bean-scope>
|
||||||
<managed-property>
|
<managed-property>
|
||||||
<property-name>avmService</property-name>
|
<property-name>assetService</property-name>
|
||||||
<value>#{AVMLockingAwareService}</value>
|
<value>#{AssetService}</value>
|
||||||
</managed-property>
|
</managed-property>
|
||||||
<managed-property>
|
<managed-property>
|
||||||
<property-name>avmBrowseBean</property-name>
|
<property-name>avmBrowseBean</property-name>
|
||||||
<value>#{AVMBrowseBean}</value>
|
<value>#{AVMBrowseBean}</value>
|
||||||
</managed-property>
|
</managed-property>
|
||||||
<managed-property>
|
|
||||||
<property-name>nodeService</property-name>
|
|
||||||
<value>#{NodeService}</value>
|
|
||||||
</managed-property>
|
|
||||||
</managed-bean>
|
</managed-bean>
|
||||||
|
|
||||||
<managed-bean>
|
<managed-bean>
|
||||||
|
Reference in New Issue
Block a user