diff --git a/source/java/org/alfresco/web/bean/wcm/AVMUtil.java b/source/java/org/alfresco/web/bean/wcm/AVMUtil.java index 9e1a00d40f..570f77f19f 100644 --- a/source/java/org/alfresco/web/bean/wcm/AVMUtil.java +++ b/source/java/org/alfresco/web/bean/wcm/AVMUtil.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2008 Alfresco Software Limited. + * Copyright (C) 2005-2009 Alfresco Software Limited. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -299,20 +299,9 @@ public final class AVMUtil extends WCMUtil : buildStoreUrl(store) + '/' + webapp); } - public static String buildAssetUrl(final String avmPath) - { - if (avmPath == null || avmPath.length() == 0) - { - throw new IllegalArgumentException("AVM path is mandatory."); - } - final String[] s = avmPath.split(":"); - if (s.length != 2) - { - throw new IllegalArgumentException("expected exactly one ':' in " + avmPath); - } - return AVMUtil.buildAssetUrl(s[0], s[1]); - } - + /** + * NOTE: do not call directly from client - use getPreviewURI instead + */ public static String buildAssetUrl(String store, String assetPath) { if (store == null || store.length() == 0) @@ -332,6 +321,24 @@ public final class AVMUtil extends WCMUtil return WCMUtil.buildAssetUrl(assetPath, domain, port, dns); } + public static String getPreviewURI(String storeNameOrAvmPath) + { + if (storeNameOrAvmPath == null || storeNameOrAvmPath.length() == 0) + { + throw new IllegalArgumentException("AVM store name or absolute path is mandatory."); + } + final String[] s = storeNameOrAvmPath.split(AVM_STORE_SEPARATOR); + if (s.length == 1) + { + return AVMUtil.getPreviewURI(s[0], null); + } + if (s.length != 2) + { + throw new IllegalArgumentException("expected exactly one ':' in " + storeNameOrAvmPath); + } + return AVMUtil.getPreviewURI(s[0], s[1]); + } + public static String getPreviewURI(final String storeId, final String assetPath) { if (previewURIGenerator == null) diff --git a/source/java/org/alfresco/web/bean/wcm/FileDetailsBean.java b/source/java/org/alfresco/web/bean/wcm/FileDetailsBean.java index 0dd69be433..26140a9bfb 100644 --- a/source/java/org/alfresco/web/bean/wcm/FileDetailsBean.java +++ b/source/java/org/alfresco/web/bean/wcm/FileDetailsBean.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2007 Alfresco Software Limited. + * Copyright (C) 2005-2009 Alfresco Software Limited. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -143,7 +143,7 @@ public class FileDetailsBean extends AVMDetailsBean */ public String getPreviewUrl() { - return AVMUtil.buildAssetUrl(getAvmNode().getPath()); + return AVMUtil.getPreviewURI(getAvmNode().getPath()); } /** diff --git a/source/java/org/alfresco/web/bean/wcm/FolderDetailsBean.java b/source/java/org/alfresco/web/bean/wcm/FolderDetailsBean.java index 12fdbcc6c5..ec06ccb6d2 100644 --- a/source/java/org/alfresco/web/bean/wcm/FolderDetailsBean.java +++ b/source/java/org/alfresco/web/bean/wcm/FolderDetailsBean.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2007 Alfresco Software Limited. + * Copyright (C) 2005-2009 Alfresco Software Limited. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -66,7 +66,7 @@ public class FolderDetailsBean extends AVMDetailsBean */ public String getPreviewUrl() { - return AVMUtil.buildAssetUrl(getAvmNode().getPath()); + return AVMUtil.getPreviewURI(getAvmNode().getPath()); } /** diff --git a/source/java/org/alfresco/web/bean/wcm/SubmitDialog.java b/source/java/org/alfresco/web/bean/wcm/SubmitDialog.java index 914189a8a6..73cd01995f 100644 --- a/source/java/org/alfresco/web/bean/wcm/SubmitDialog.java +++ b/source/java/org/alfresco/web/bean/wcm/SubmitDialog.java @@ -65,7 +65,6 @@ import org.alfresco.web.app.servlet.FacesHelper; import org.alfresco.web.bean.BrowseBean; import org.alfresco.web.bean.dialog.BaseDialogBean; import org.alfresco.web.bean.repository.Repository; -import org.alfresco.web.config.ClientConfigElement; import org.alfresco.web.forms.FormInstanceData; import org.alfresco.web.forms.FormsService; import org.alfresco.web.forms.Rendition; @@ -1045,12 +1044,7 @@ public class SubmitDialog extends BaseDialogBean public String getPreviewUrl() { - ClientConfigElement config = Application.getClientConfig(FacesContext.getCurrentInstance()); - String dns = AVMUtil.lookupStoreDNS(AVMUtil.getStoreName(descriptor.getPath())); - return AVMUtil.buildAssetUrl(AVMUtil.getSandboxRelativePath(descriptor.getPath()), - config.getWCMDomain(), - config.getWCMPort(), - dns); + return AVMUtil.getPreviewURI(descriptor.getPath()); } public AVMNodeDescriptor getDescriptor() diff --git a/source/java/org/alfresco/web/bean/wcm/preview/PreviewURIService.java b/source/java/org/alfresco/web/bean/wcm/preview/PreviewURIService.java index de30a87ca8..8d7ec04103 100644 --- a/source/java/org/alfresco/web/bean/wcm/preview/PreviewURIService.java +++ b/source/java/org/alfresco/web/bean/wcm/preview/PreviewURIService.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2008 Alfresco Software Limited. + * Copyright (C) 2005-2009 Alfresco Software Limited. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -36,7 +36,7 @@ public interface PreviewURIService { /** * @param storeId The id of the store to generate the preview URI for. - * @param pathToAsset The path to the asset to generate the preview URI for. + * @param pathToAsset The path to the asset to generate the preview URI for (can be null or empty, to return preview URL to store) * @return The Preview URI for the given store id and/or asset (may be null). */ String getPreviewURI(String storeId, String pathToAsset); diff --git a/source/java/org/alfresco/web/bean/wcm/preview/VirtualisationServerPreviewURIService.java b/source/java/org/alfresco/web/bean/wcm/preview/VirtualisationServerPreviewURIService.java index 269635f74c..24a6d7c261 100644 --- a/source/java/org/alfresco/web/bean/wcm/preview/VirtualisationServerPreviewURIService.java +++ b/source/java/org/alfresco/web/bean/wcm/preview/VirtualisationServerPreviewURIService.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2008 Alfresco Software Limited. + * Copyright (C) 2005-2009 Alfresco Software Limited. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -43,13 +43,18 @@ public class VirtualisationServerPreviewURIService */ public String getPreviewURI(final String storeId, final String pathToAsset) { + if ((pathToAsset == null) || (pathToAsset.length() == 0)) + { + return AVMUtil.buildStoreUrl(storeId); + } + // Sanity checking if (!pathToAsset.startsWith('/' + JNDIConstants.DIR_DEFAULT_WWW + '/' + JNDIConstants.DIR_DEFAULT_APPBASE)) { throw new IllegalStateException("Invalid asset path in AVM node ref: " + storeId + ":" + pathToAsset); } - return(AVMUtil.buildAssetUrl(storeId, pathToAsset)); + return AVMUtil.buildAssetUrl(storeId, pathToAsset); } } diff --git a/source/java/org/alfresco/web/forms/FormInstanceDataImpl.java b/source/java/org/alfresco/web/forms/FormInstanceDataImpl.java index 301c3aa1fe..03f3019dc9 100644 --- a/source/java/org/alfresco/web/forms/FormInstanceDataImpl.java +++ b/source/java/org/alfresco/web/forms/FormInstanceDataImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2007 Alfresco Software Limited. + * Copyright (C) 2005-2009 Alfresco Software Limited. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -39,14 +39,12 @@ import org.alfresco.model.WCMAppModel; import org.alfresco.repo.avm.AVMNodeConverter; import org.alfresco.repo.domain.PropertyValue; import org.alfresco.service.ServiceRegistry; -import org.alfresco.service.cmr.avm.AVMNotFoundException; import org.alfresco.service.cmr.avm.AVMService; import org.alfresco.service.cmr.avm.locking.AVMLock; import org.alfresco.service.cmr.avm.locking.AVMLockingService; import org.alfresco.service.cmr.dictionary.DataTypeDefinition; import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.StoreRef; -import org.alfresco.service.namespace.QName; import org.alfresco.web.app.servlet.FacesHelper; import org.alfresco.web.bean.repository.Repository; import org.alfresco.web.bean.wcm.AVMUtil; @@ -171,7 +169,7 @@ import org.xml.sax.SAXException; public String getUrl() { - return AVMUtil.buildAssetUrl(this.getPath()); + return AVMUtil.getPreviewURI(this.getPath()); } public List regenerateRenditions() diff --git a/source/java/org/alfresco/web/forms/RenditionImpl.java b/source/java/org/alfresco/web/forms/RenditionImpl.java index c5aa6e7921..e9fbf05778 100644 --- a/source/java/org/alfresco/web/forms/RenditionImpl.java +++ b/source/java/org/alfresco/web/forms/RenditionImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2007 Alfresco Software Limited. + * Copyright (C) 2005-2009 Alfresco Software Limited. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -211,7 +211,7 @@ import org.xml.sax.SAXException; public String getUrl() { - return AVMUtil.buildAssetUrl(this.getPath()); + return AVMUtil.getPreviewURI(this.getPath()); } public String getFileTypeImage() diff --git a/source/java/org/alfresco/web/forms/xforms/XFormsBean.java b/source/java/org/alfresco/web/forms/xforms/XFormsBean.java index f203e6d7a3..4f8318cffa 100644 --- a/source/java/org/alfresco/web/forms/xforms/XFormsBean.java +++ b/source/java/org/alfresco/web/forms/xforms/XFormsBean.java @@ -619,8 +619,8 @@ public class XFormsBean implements Serializable { // It's a web project asset include / import final String baseURI = (uri.charAt(0) == '/' - ? AVMUtil.buildStoreUrl(AVMUtil.getStoreName(cwdAvmPath)) - : AVMUtil.buildAssetUrl(cwdAvmPath)); + ? AVMUtil.getPreviewURI(AVMUtil.getStoreName(cwdAvmPath)) + : AVMUtil.getPreviewURI(cwdAvmPath)); finalURI = baseURI + uri; } diff --git a/source/java/org/alfresco/web/ui/wcm/component/UILinkValidationReport.java b/source/java/org/alfresco/web/ui/wcm/component/UILinkValidationReport.java index e1e45e5a4c..2674ec6649 100644 --- a/source/java/org/alfresco/web/ui/wcm/component/UILinkValidationReport.java +++ b/source/java/org/alfresco/web/ui/wcm/component/UILinkValidationReport.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2007 Alfresco Software Limited. + * Copyright (C) 2005-2009 Alfresco Software Limited. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -45,7 +45,6 @@ import org.alfresco.web.bean.repository.Repository; import org.alfresco.web.bean.wcm.AVMNode; import org.alfresco.web.bean.wcm.AVMUtil; import org.alfresco.web.bean.wcm.LinkValidationState; -import org.alfresco.web.config.ClientConfigElement; import org.alfresco.web.ui.common.ComponentConstants; import org.alfresco.web.ui.common.Utils; import org.alfresco.web.ui.common.component.UIActionLink; @@ -79,8 +78,7 @@ public class UILinkValidationReport extends AbstractLinkValidationReportComponen // ------------------------------------------------------------------------------ // Component implementation - - @SuppressWarnings("unchecked") + @Override public void restoreState(FacesContext context, Object state) { @@ -102,7 +100,6 @@ public class UILinkValidationReport extends AbstractLinkValidationReportComponen return values; } - @SuppressWarnings("unchecked") @Override public void encodeBegin(FacesContext context) throws IOException { @@ -231,16 +228,11 @@ public class UILinkValidationReport extends AbstractLinkValidationReportComponen UIActions actions = aquireFileActions("broken_file_actions", getValue().getStore()); AVMService avmService = Repository.getServiceRegistry(context).getAVMService(); int rootPathIndex = AVMUtil.buildSandboxRootPath(linkState.getStore()).length(); - String dns = AVMUtil.lookupStoreDNS(linkState.getStore()); - ClientConfigElement config = Application.getClientConfig(context); - String wcmDomain = config.getWCMDomain(); - String wcmPort = config.getWCMPort(); - // render each broken file for (String file : brokenFiles) { renderBrokenFile(context, out, file, linkState, actions, avmService, - rootPathIndex, wcmDomain, wcmPort, dns, sectionsExpanded); + rootPathIndex, linkState.getStore(), sectionsExpanded); } } @@ -395,8 +387,7 @@ public class UILinkValidationReport extends AbstractLinkValidationReportComponen protected void renderBrokenFile(FacesContext context, ResponseWriter out, String file, LinkValidationState linkState, UIActions actions, - AVMService avmService, int rootPathIndex, String wcmDomain, - String wcmPort, String dns, boolean brokenLinksExpanded) + AVMService avmService, int rootPathIndex, String storeId, boolean brokenLinksExpanded) throws IOException { // gather the data to show for the file @@ -430,7 +421,7 @@ public class UILinkValidationReport extends AbstractLinkValidationReportComponen AVMNode node = new AVMNode(desc); String assetPath = file.substring(rootPathIndex); - String previewUrl = AVMUtil.buildAssetUrl(assetPath, wcmDomain, wcmPort, dns); + String previewUrl = AVMUtil.getPreviewURI(storeId, assetPath); node.getProperties().put("previewUrl", previewUrl); actions.setContext(node); diff --git a/source/java/org/alfresco/web/ui/wcm/component/UIPendingSubmissions.java b/source/java/org/alfresco/web/ui/wcm/component/UIPendingSubmissions.java index 4320823bab..e999b1b03d 100644 --- a/source/java/org/alfresco/web/ui/wcm/component/UIPendingSubmissions.java +++ b/source/java/org/alfresco/web/ui/wcm/component/UIPendingSubmissions.java @@ -168,7 +168,7 @@ public class UIPendingSubmissions extends SelfRenderingComponent } // get the preview url for the sandbox - String sandboxPreviewUrl = AVMUtil.buildStoreUrl(sandbox); + String sandboxPreviewUrl = AVMUtil.getPreviewURI(sandbox); // get the noderef representing the web project PropertyValue val = Repository.getServiceRegistry(context).getAVMService(). @@ -290,7 +290,7 @@ public class UIPendingSubmissions extends SelfRenderingComponent NodeRef pkg = task.path.instance.workflowPackage; Pair pkgPath = AVMNodeConverter.ToAVMVersionPath(pkg); String workflowStore = AVMUtil.getStoreName(pkgPath.getSecond()); - String workflowPreviewUrl = AVMUtil.buildStoreUrl(workflowStore); + String workflowPreviewUrl = AVMUtil.getPreviewURI(workflowStore); UIActionLink preview = findAction(ACT_PREVIEW, sandbox); if (preview == null)