- Added Preview action for individual folders and files to the website browse page
 - Added Preview action for files/folders in the Modified Files list for a user sandbox
   - these changes allow the user to preview any sub-section (folder/weapp) or individual file in the website

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3923 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2006-09-25 16:52:53 +00:00
parent 1b9ca2ac8b
commit 1c87282333
6 changed files with 66 additions and 13 deletions

View File

@@ -824,6 +824,8 @@ avm_node_deleted=Deleted
submit=Submit submit=Submit
submit_success=Successfully submitted item: {0} submit_success=Successfully submitted item: {0}
submitall_success=Successfully submitted sandbox for user: {0} submitall_success=Successfully submitted sandbox for user: {0}
folder_preview=Preview Folder
file_preview=Preview File
# Website actions and dialog messages # Website actions and dialog messages
title_import_content=Import Content into Website title_import_content=Import Content into Website

View File

@@ -45,17 +45,35 @@
</params> </params>
</action> </action>
<!-- Preview folder -->
<action id="preview_folder">
<label-id>folder_preview</label-id>
<image>/images/icons/preview_website.gif</image>
<href>#{actionContext.previewUrl}</href>
<target>new</target>
</action>
<!-- Preview file -->
<action id="preview_file">
<label-id>file_preview</label-id>
<image>/images/icons/preview_website.gif</image>
<href>#{actionContext.previewUrl}</href>
<target>new</target>
</action>
<!-- Actions for a document in the AVM Browse screen --> <!-- Actions for a document in the AVM Browse screen -->
<action-group id="avm_file_browse"> <action-group id="avm_file_browse">
<show-link>false</show-link> <show-link>false</show-link>
<action idref="edit_file" /> <action idref="edit_file" />
<action idref="preview_file" />
<action idref="delete_file" /> <action idref="delete_file" />
</action-group> </action-group>
<!-- Actions for a folder in the AVM Browse screen --> <!-- Actions for a folder in the AVM Browse screen -->
<action-group id="avm_folder_browse"> <action-group id="avm_folder_browse">
<show-link>false</show-link> <show-link>false</show-link>
<action idref="preview_folder" />
<action idref="delete_folder" /> <action idref="delete_folder" />
</action-group> </action-group>
@@ -64,6 +82,7 @@
<show-link>false</show-link> <show-link>false</show-link>
<action idref="edit_file" /> <action idref="edit_file" />
<action idref="submit" /> <action idref="submit" />
<action idref="preview_file" />
<action idref="delete_file" /> <action idref="delete_file" />
</action-group> </action-group>
@@ -71,6 +90,7 @@
<action-group id="avm_folder_modified"> <action-group id="avm_folder_modified">
<show-link>false</show-link> <show-link>false</show-link>
<action idref="submit" /> <action idref="submit" />
<action idref="preview_folder" />
<action idref="delete_folder" /> <action idref="delete_folder" />
</action-group> </action-group>

View File

@@ -29,7 +29,6 @@ import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent; import javax.faces.event.ActionEvent;
import javax.transaction.UserTransaction; import javax.transaction.UserTransaction;
import org.alfresco.config.ConfigService;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.repo.avm.AVMNodeConverter; import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.service.cmr.action.Action; import org.alfresco.service.cmr.action.Action;
@@ -52,7 +51,6 @@ import org.alfresco.web.bean.NavigationBean;
import org.alfresco.web.bean.repository.Node; import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.bean.repository.Repository; import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.config.ClientConfigElement; import org.alfresco.web.config.ClientConfigElement;
import org.alfresco.web.config.ViewsConfigElement;
import org.alfresco.web.ui.common.Utils; import org.alfresco.web.ui.common.Utils;
import org.alfresco.web.ui.common.component.IBreadcrumbHandler; import org.alfresco.web.ui.common.component.IBreadcrumbHandler;
import org.alfresco.web.ui.common.component.UIActionLink; import org.alfresco.web.ui.common.component.UIActionLink;
@@ -517,6 +515,9 @@ public class AVMBrowseBean implements IContextListener
tx = Repository.getUserTransaction(context, true); tx = Repository.getUserTransaction(context, true);
tx.begin(); tx.begin();
String dns = AVMConstants.lookupStoreDNS(getSandbox());
int rootPathIndex = AVMConstants.buildAVMStoreRootPath(getSandbox()).length() + 1;
Map<String, AVMNodeDescriptor> nodes = this.avmService.getDirectoryListing(-1, getCurrentPath()); Map<String, AVMNodeDescriptor> nodes = this.avmService.getDirectoryListing(-1, getCurrentPath());
this.files = new ArrayList<Map>(nodes.size()); this.files = new ArrayList<Map>(nodes.size());
this.folders = new ArrayList<Map>(nodes.size()); this.folders = new ArrayList<Map>(nodes.size());
@@ -526,6 +527,7 @@ public class AVMBrowseBean implements IContextListener
// build the client representation of the AVM node // build the client representation of the AVM node
AVMNode node = new AVMNode(avmRef); AVMNode node = new AVMNode(avmRef);
String path = avmRef.getPath();
// properties specific to folders or files // properties specific to folders or files
if (avmRef.isDirectory()) if (avmRef.isDirectory())
@@ -537,9 +539,15 @@ public class AVMBrowseBean implements IContextListener
{ {
node.getProperties().put("fileType16", Utils.getFileTypeImage(name, true)); node.getProperties().put("fileType16", Utils.getFileTypeImage(name, true));
node.getProperties().put("url", DownloadContentServlet.generateBrowserURL( node.getProperties().put("url", DownloadContentServlet.generateBrowserURL(
AVMNodeConverter.ToNodeRef(-1, avmRef.getPath()), name)); AVMNodeConverter.ToNodeRef(-1, path), name));
this.files.add(node); this.files.add(node);
} }
// common properties
String assetPath = path.substring(rootPathIndex);
String previewUrl = MessageFormat.format(
AVMConstants.PREVIEW_ASSET_URL, dns, this.wcmDomain, this.wcmPort, assetPath);
node.getProperties().put("previewUrl", previewUrl);
} }
// commit the transaction // commit the transaction

View File

@@ -67,19 +67,28 @@ public final class AVMConstants
public static String buildAVMStoreUrl(String store) public static String buildAVMStoreUrl(String store)
{ {
String url = null;; ClientConfigElement config = Application.getClientConfig(FacesContext.getCurrentInstance());
return MessageFormat.format(PREVIEW_SANDBOX_URL, lookupStoreDNS(store), config.getWCMDomain(), config.getWCMPort());
}
public static String buildAVMAssetUrl(String store, String assetPath)
{
ClientConfigElement config = Application.getClientConfig(FacesContext.getCurrentInstance());
return MessageFormat.format(PREVIEW_ASSET_URL, lookupStoreDNS(store), config.getWCMDomain(), config.getWCMPort(), assetPath);
}
public static String lookupStoreDNS(String store)
{
String dns = null;
FacesContext fc = FacesContext.getCurrentInstance(); AVMService avmService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getAVMService();
AVMService avmService = Repository.getServiceRegistry(fc).getAVMService();
ClientConfigElement config = Application.getClientConfig(fc);
Map<QName, PropertyValue> props = avmService.queryStorePropertyKey(store, QName.createQName(null, PROP_DNS + '%')); Map<QName, PropertyValue> props = avmService.queryStorePropertyKey(store, QName.createQName(null, PROP_DNS + '%'));
if (props.size() == 1) if (props.size() == 1)
{ {
String dns = props.entrySet().iterator().next().getKey().getLocalName().substring(PROP_DNS.length()); dns = props.entrySet().iterator().next().getKey().getLocalName().substring(PROP_DNS.length());
url = MessageFormat.format(PREVIEW_SANDBOX_URL, dns, config.getWCMDomain(), config.getWCMPort());
} }
return url; return dns;
} }
// names of the stores representing the layers for an AVM website // names of the stores representing the layers for an AVM website

View File

@@ -18,6 +18,7 @@ package org.alfresco.web.ui.wcm.component;
import java.io.IOException; import java.io.IOException;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.MessageFormat;
import java.util.Date; import java.util.Date;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
@@ -46,6 +47,7 @@ import org.alfresco.web.bean.BrowseBean;
import org.alfresco.web.bean.repository.Repository; import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.bean.wcm.AVMConstants; import org.alfresco.web.bean.wcm.AVMConstants;
import org.alfresco.web.bean.wcm.AVMNode; import org.alfresco.web.bean.wcm.AVMNode;
import org.alfresco.web.config.ClientConfigElement;
import org.alfresco.web.ui.common.ComponentConstants; import org.alfresco.web.ui.common.ComponentConstants;
import org.alfresco.web.ui.common.ConstantMethodBinding; import org.alfresco.web.ui.common.ConstantMethodBinding;
import org.alfresco.web.ui.common.PanelGenerator; import org.alfresco.web.ui.common.PanelGenerator;
@@ -317,6 +319,11 @@ public class UIUserSandboxes extends SelfRenderingComponent
String userStore = userStorePrefix + ":/"; String userStore = userStorePrefix + ":/";
String stagingStore = AVMConstants.buildAVMStagingStoreName(storeRoot) + ":/"; String stagingStore = AVMConstants.buildAVMStagingStoreName(storeRoot) + ":/";
// info we need to calculate preview paths for assets
String dns = AVMConstants.lookupStoreDNS(userStorePrefix);
int rootPathIndex = AVMConstants.buildAVMStoreRootPath(userStorePrefix).length() + 1;
ClientConfigElement config = Application.getClientConfig(fc);
// get the UIActions component responsible for rendering context related user actions // get the UIActions component responsible for rendering context related user actions
// TODO: we may need a component per user instance? (or use evaluators for roles...) // TODO: we may need a component per user instance? (or use evaluators for roles...)
UIActions uiFileActions = aquireUIActions(ACTIONS_FILE, userStorePrefix); UIActions uiFileActions = aquireUIActions(ACTIONS_FILE, userStorePrefix);
@@ -384,6 +391,13 @@ public class UIUserSandboxes extends SelfRenderingComponent
out.write(df.format(new Date(node.getModDate()))); out.write(df.format(new Date(node.getModDate())));
out.write("</td><td>"); out.write("</td><td>");
// build node context required for actions
AVMNode avmNode = new AVMNode(node);
String assetPath = sourcePath.substring(rootPathIndex);
String previewUrl = MessageFormat.format(
AVMConstants.PREVIEW_ASSET_URL, dns, config.getWCMDomain(), config.getWCMPort(), assetPath);
avmNode.getProperties().put("previewUrl", previewUrl);
// size of files // size of files
if (node.isFile()) if (node.isFile())
{ {
@@ -391,7 +405,7 @@ public class UIUserSandboxes extends SelfRenderingComponent
out.write("</td><td>"); out.write("</td><td>");
// add UI actions for this item // add UI actions for this item
uiFileActions.setContext(new AVMNode(node)); uiFileActions.setContext(avmNode);
Utils.encodeRecursive(fc, uiFileActions); Utils.encodeRecursive(fc, uiFileActions);
} }
else else
@@ -399,7 +413,7 @@ public class UIUserSandboxes extends SelfRenderingComponent
out.write("</td><td>"); out.write("</td><td>");
// add UI actions for this item // add UI actions for this item
uiFolderActions.setContext(new AVMNode(node)); uiFolderActions.setContext(avmNode);
Utils.encodeRecursive(fc, uiFolderActions); Utils.encodeRecursive(fc, uiFolderActions);
} }
out.write("</td></tr>"); out.write("</td></tr>");

View File

@@ -165,7 +165,7 @@
</h:outputText> </h:outputText>
</a:column> </a:column>
<%-- Space Actions column --%> <%-- Folder Actions column --%>
<a:column id="col9" actions="true" style="text-align:left"> <a:column id="col9" actions="true" style="text-align:left">
<f:facet name="header"> <f:facet name="header">
<h:outputText id="col9-txt" value="#{msg.actions}"/> <h:outputText id="col9-txt" value="#{msg.actions}"/>