. Removed addition of TITLED and UIFACETS aspects to files and folders during import/create

- now added "on demand" during first display of Details dialog as otherwise performance issues make a website import unfeasible:

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3994 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2006-10-02 17:53:54 +00:00
parent 0dc8a68d44
commit 443aaf3419
5 changed files with 46 additions and 9 deletions

View File

@@ -16,10 +16,12 @@
*/ */
package org.alfresco.web.bean.wcm; package org.alfresco.web.bean.wcm;
import java.io.Serializable;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.ResourceBundle; import java.util.ResourceBundle;
@@ -433,7 +435,26 @@ public class AVMBrowseBean implements IContextListener
*/ */
public void setAVMNodeDescriptor(AVMNodeDescriptor avmRef) public void setAVMNodeDescriptor(AVMNodeDescriptor avmRef)
{ {
this.avmNode = new AVMNode(avmRef); AVMNode avmNode = new AVMNode(avmRef);
// TODO: remove this once we can add the aspect quickly in the ImportWebsiteDialog!
if (avmNode.isDirectory())
{
if (this.nodeService.hasAspect(avmNode.getNodeRef(), ContentModel.ASPECT_UIFACETS) == false)
{
this.nodeService.addAspect(avmNode.getNodeRef(), ContentModel.ASPECT_UIFACETS, null);
}
}
else
{
if (this.nodeService.hasAspect(avmNode.getNodeRef(), ContentModel.ASPECT_TITLED) == false)
{
// 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, avmNode.getName());
this.nodeService.addAspect(avmNode.getNodeRef(), ContentModel.ASPECT_TITLED, titledProps);
}
}
this.avmNode = avmNode;
} }
/** /**

View File

@@ -388,7 +388,6 @@ public class AVMEditBean
{ {
// clean up and clear action context // clean up and clear action context
clearUpload(); clearUpload();
this.avmBrowseBean.setAvmNode(null);
setDocumentContent(null); setDocumentContent(null);
setEditorOutput(null); setEditorOutput(null);
} }

View File

@@ -80,6 +80,16 @@ public class AVMNode implements Map<String, Object>
{ {
return AVMNodeConverter.ToNodeRef(this.version, this.path); return AVMNodeConverter.ToNodeRef(this.version, this.path);
} }
public boolean isDirectory()
{
return this.avmRef.isDirectory();
}
public boolean isFile()
{
return this.avmRef.isFile();
}
/** /**
* @return All the properties known about this node. * @return All the properties known about this node.

View File

@@ -200,6 +200,8 @@ public class ImportWebsiteDialog
tx = Repository.getUserTransaction(context); tx = Repository.getUserTransaction(context);
tx.begin(); tx.begin();
// TODO: explicit permission check for WRITE on website node for this user
// import the content into the appropriate store for the website // import the content into the appropriate store for the website
String storeRoot = (String)this.navigationBean.getCurrentNode().getProperties().get( String storeRoot = (String)this.navigationBean.getCurrentNode().getProperties().get(
ContentModel.PROP_AVMSTORE); ContentModel.PROP_AVMSTORE);
@@ -395,7 +397,6 @@ public class ImportWebsiteDialog
private void importDirectory(String dir, NodeRef root) private void importDirectory(String dir, NodeRef root)
{ {
ServiceRegistry services = Repository.getServiceRegistry(FacesContext.getCurrentInstance()); ServiceRegistry services = Repository.getServiceRegistry(FacesContext.getCurrentInstance());
NodeService nodeService = services.getNodeService();
MimetypeService mimetypeService = services.getMimetypeService(); MimetypeService mimetypeService = services.getMimetypeService();
File topdir = new File(dir); File topdir = new File(dir);
for (File file : topdir.listFiles()) for (File file : topdir.listFiles())
@@ -404,6 +405,7 @@ public class ImportWebsiteDialog
{ {
if (file.isFile()) if (file.isFile())
{ {
// Create a file in the AVM store
String avmPath = AVMNodeConverter.ToAVMVersionPath(root).getSecond(); String avmPath = AVMNodeConverter.ToAVMVersionPath(root).getSecond();
String fileName = file.getName(); String fileName = file.getName();
this.avmService.createFile( this.avmService.createFile(
@@ -412,10 +414,12 @@ public class ImportWebsiteDialog
String filePath = avmPath + '/' + fileName; String filePath = avmPath + '/' + fileName;
NodeRef fileRef = AVMNodeConverter.ToNodeRef(-1, filePath); NodeRef fileRef = AVMNodeConverter.ToNodeRef(-1, filePath);
// TODO: restore this code once performance is acceptable
// see AVMBrowseBean.setAVMNodeDescriptor
// add titled aspect for the read/edit properties screens // add titled aspect for the read/edit properties screens
Map<QName, Serializable> titledProps = new HashMap<QName, Serializable>(1, 1.0f); //Map<QName, Serializable> titledProps = new HashMap<QName, Serializable>(1, 1.0f);
titledProps.put(ContentModel.PROP_TITLE, fileName); //titledProps.put(ContentModel.PROP_TITLE, fileName);
this.nodeService.addAspect(fileRef, ContentModel.ASPECT_TITLED, titledProps); //this.nodeService.addAspect(fileRef, ContentModel.ASPECT_TITLED, titledProps);
// create content node based on the filename // create content node based on the filename
/*FileInfo contentFile = fileFolderService.create(root, fileName, ContentModel.TYPE_AVM_PLAIN_CONTENT); /*FileInfo contentFile = fileFolderService.create(root, fileName, ContentModel.TYPE_AVM_PLAIN_CONTENT);
@@ -433,15 +437,18 @@ public class ImportWebsiteDialog
{ {
//FileInfo fileInfo = fileFolderService.create(root, file.getName(), ContentModel.TYPE_AVM_PLAIN_FOLDER); //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(); String avmPath = AVMNodeConverter.ToAVMVersionPath(root).getSecond();
avmService.createDirectory(avmPath, file.getName()); this.avmService.createDirectory(avmPath, file.getName());
String folderPath = avmPath + '/' + file.getName(); String folderPath = avmPath + '/' + file.getName();
NodeRef folderRef = AVMNodeConverter.ToNodeRef(-1, folderPath); NodeRef folderRef = AVMNodeConverter.ToNodeRef(-1, folderPath);
importDirectory(file.getPath(), folderRef); 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 // add the uifacets aspect for the read/edit properties screens
this.nodeService.addAspect(folderRef, ContentModel.ASPECT_UIFACETS, null); //this.nodeService.addAspect(folderRef, ContentModel.ASPECT_UIFACETS, null);
} }
} }
catch (FileNotFoundException e) catch (FileNotFoundException e)

View File

@@ -617,7 +617,7 @@
<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>nodeService</property-name>
<value>#{NodeService}</value> <value>#{nodeService}</value>
</managed-property> </managed-property>
<managed-property> <managed-property>
<property-name>fileFolderService</property-name> <property-name>fileFolderService</property-name>