MOB-690 - WCM PreviewURIService - checkpoint

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@14642 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jan Vonka
2009-06-10 17:04:09 +00:00
parent b25922058e
commit 1f961e31f7
13 changed files with 176 additions and 156 deletions

View File

@@ -1073,6 +1073,7 @@ website_details=Web Project Details
create_website_step1_title=Step One - Web Project Details create_website_step1_title=Step One - Web Project Details
create_website_step1_desc=Enter the information about the web project. create_website_step1_desc=Enter the information about the web project.
website_dnsname=DNS name website_dnsname=DNS name
website_preview_provider=Preview Provider
validation_invalid_dns_name=Invalid website DNS name: only alpha-numeric and non-initial/final hyphen characters are allowed (max length < 64). validation_invalid_dns_name=Invalid website DNS name: only alpha-numeric and non-initial/final hyphen characters are allowed (max length < 64).
website_webapp=Default Webapp website_webapp=Default Webapp
website_createfrom=Create From Existing Web Project website_createfrom=Create From Existing Web Project

View File

@@ -649,6 +649,8 @@
<property-sheet> <property-sheet>
<show-property name="wca:avmstore" read-only="true" /> <show-property name="wca:avmstore" read-only="true" />
<show-property name="wca:defaultwebapp" read-only="true" /> <show-property name="wca:defaultwebapp" read-only="true" />
<show-property name="wca:issource" component-generator="CheckboxGenerator" read-only="true"/>
<show-property name="wca:previewprovidername" read-only="true" />
<show-property name="app:icon" show-in-view-mode="false" show-in-edit-mode="false" /> <show-property name="app:icon" show-in-view-mode="false" show-in-edit-mode="false" />
</property-sheet> </property-sheet>
</config> </config>

View File

@@ -35,15 +35,14 @@ import org.alfresco.config.ConfigService;
import org.alfresco.config.JNDIConstants; import org.alfresco.config.JNDIConstants;
import org.alfresco.mbeans.VirtServerRegistry; import org.alfresco.mbeans.VirtServerRegistry;
import org.alfresco.repo.avm.AVMNodeConverter; import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.avm.AVMNotFoundException; import org.alfresco.service.cmr.avm.AVMNotFoundException;
import org.alfresco.service.cmr.avm.AVMService; import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.wcm.util.WCMUtil; import org.alfresco.wcm.util.WCMUtil;
import org.alfresco.web.app.Application; import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Repository; import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.bean.wcm.preview.PreviewURIService; import org.alfresco.web.bean.wcm.preview.PreviewURIService;
import org.alfresco.web.bean.wcm.preview.VirtualisationServerPreviewURIService; import org.apache.commons.logging.Log;
import org.alfresco.web.config.ClientConfigElement; import org.apache.commons.logging.LogFactory;
import org.springframework.web.context.WebApplicationContext; import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.jsf.FacesContextUtils; import org.springframework.web.jsf.FacesContextUtils;
@@ -57,6 +56,8 @@ import org.springframework.web.jsf.FacesContextUtils;
*/ */
public final class AVMUtil extends WCMUtil public final class AVMUtil extends WCMUtil
{ {
private static Log logger = LogFactory.getLog(AVMUtil.class);
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
public static enum PathRelation public static enum PathRelation
@@ -270,14 +271,6 @@ public final class AVMUtil extends WCMUtil
return WCMUtil.buildStoreWebappPath(storeName, webapp); return WCMUtil.buildStoreWebappPath(storeName, webapp);
} }
public static String buildStoreUrl(String store)
{
ServiceRegistry serviceRegistry = Repository.getServiceRegistry(FacesContext.getCurrentInstance());
AVMService avmService = serviceRegistry.getAVMService();
ClientConfigElement config = Application.getClientConfig(FacesContext.getCurrentInstance());
return WCMUtil.buildStoreUrl(avmService, store, config.getWCMDomain(), config.getWCMPort());
}
public static String buildWebappUrl(final String avmPath) public static String buildWebappUrl(final String avmPath)
{ {
if (avmPath == null || avmPath.length() == 0) if (avmPath == null || avmPath.length() == 0)
@@ -295,30 +288,8 @@ public final class AVMUtil extends WCMUtil
throw new IllegalArgumentException("Webapp name is mandatory."); throw new IllegalArgumentException("Webapp name is mandatory.");
} }
return (webapp.equals(DIR_ROOT) return (webapp.equals(DIR_ROOT)
? buildStoreUrl(store) ? getPreviewURI(store)
: buildStoreUrl(store) + '/' + webapp); : getPreviewURI(store) + '/' + webapp);
}
/**
* NOTE: do not call directly from client - use getPreviewURI instead
*/
public static String buildAssetUrl(String store, String assetPath)
{
if (store == null || store.length() == 0)
{
throw new IllegalArgumentException("Store name is mandatory.");
}
if (assetPath == null || assetPath.length() == 0)
{
throw new IllegalArgumentException("Asset path is mandatory.");
}
ClientConfigElement config = Application.getClientConfig(FacesContext.getCurrentInstance());
return buildAssetUrl(assetPath, config.getWCMDomain(), config.getWCMPort(), lookupStoreDNS(store));
}
public static String buildAssetUrl(String assetPath, String domain, String port, String dns)
{
return WCMUtil.buildAssetUrl(assetPath, domain, port, dns);
} }
public static String getPreviewURI(String storeNameOrAvmPath) public static String getPreviewURI(String storeNameOrAvmPath)
@@ -327,48 +298,47 @@ public final class AVMUtil extends WCMUtil
{ {
throw new IllegalArgumentException("AVM store name or absolute path is mandatory."); throw new IllegalArgumentException("AVM store name or absolute path is mandatory.");
} }
final String[] s = storeNameOrAvmPath.split(AVM_STORE_SEPARATOR); final String[] s = storeNameOrAvmPath.split(WCMUtil.AVM_STORE_SEPARATOR);
if (s.length == 1) if (s.length == 1)
{ {
return AVMUtil.getPreviewURI(s[0], null); return getPreviewURI(s[0], null);
} }
if (s.length != 2) if (s.length != 2)
{ {
throw new IllegalArgumentException("expected exactly one ':' in " + storeNameOrAvmPath); throw new IllegalArgumentException("expected exactly one ':' in " + storeNameOrAvmPath);
} }
return AVMUtil.getPreviewURI(s[0], s[1]); return getPreviewURI(s[0], s[1]);
} }
public static String getPreviewURI(final String storeId, final String assetPath) public static String getPreviewURI(String storeId, String assetPath)
{ {
if (previewURIGenerator == null) if (! deprecatedPreviewURIGeneratorChecked)
{ {
if (deprecatedPreviewURIGenerator == null)
{
// backwards compatibility - will hide new implementation, until custom providers/context are migrated
WebApplicationContext wac = FacesContextUtils.getRequiredWebApplicationContext( WebApplicationContext wac = FacesContextUtils.getRequiredWebApplicationContext(
FacesContext.getCurrentInstance()); FacesContext.getCurrentInstance());
if (wac.containsBean(SPRING_BEAN_NAME_PREVIEW_URI_SERVICE)) if (wac.containsBean(SPRING_BEAN_NAME_PREVIEW_URI_SERVICE))
{ {
// if the bean is present retrieve it // if the bean is present retrieve it
previewURIGenerator = (PreviewURIService)wac.getBean(SPRING_BEAN_NAME_PREVIEW_URI_SERVICE, deprecatedPreviewURIGenerator = (PreviewURIService)wac.getBean(SPRING_BEAN_NAME_PREVIEW_URI_SERVICE,
PreviewURIService.class); PreviewURIService.class);
}
else logger.warn("Found deprecated '"+SPRING_BEAN_NAME_PREVIEW_URI_SERVICE+"' config - which will be used instead of new 'WCMPreviewURIService' until migrated (changing web project preview provider will have no effect)");
{
// Backwards compatibility - if the new Spring bean doesn't exist, default to the
// existing behaviour (create a URL to the virtualisation server).
previewURIGenerator = new VirtualisationServerPreviewURIService();
} }
} }
return previewURIGenerator.getPreviewURI(storeId, assetPath); deprecatedPreviewURIGeneratorChecked = true;
} }
public static String lookupStoreDNS(String store) if (deprecatedPreviewURIGenerator != null)
{ {
final ServiceRegistry serviceRegistry = return deprecatedPreviewURIGenerator.getPreviewURI(storeId, assetPath);
Repository.getServiceRegistry(FacesContext.getCurrentInstance()); }
final AVMService avmService = serviceRegistry.getAVMService();
return WCMUtil.lookupStoreDNS(avmService, store); return getPreviewURIService().getPreviewURI(storeId, assetPath);
} }
/** /**
@@ -443,9 +413,7 @@ public final class AVMUtil extends WCMUtil
*/ */
public static void makeAllDirectories(final String avmDirectoryPath) public static void makeAllDirectories(final String avmDirectoryPath)
{ {
final ServiceRegistry serviceRegistry = final AVMService avmService = getAVMService();
Repository.getServiceRegistry(FacesContext.getCurrentInstance());
final AVMService avmService = serviceRegistry.getAVMService();
// LOGGER.debug("mkdir -p " + avmDirectoryPath); // LOGGER.debug("mkdir -p " + avmDirectoryPath);
String s = avmDirectoryPath; String s = avmDirectoryPath;
final Stack<String[]> dirNames = new Stack<String[]>(); final Stack<String[]> dirNames = new Stack<String[]>();
@@ -496,6 +464,16 @@ public final class AVMUtil extends WCMUtil
return Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getVirtServerRegistry(); return Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getVirtServerRegistry();
} }
private static AVMService getAVMService()
{
return Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getAVMService();
}
private static org.alfresco.wcm.preview.PreviewURIService getPreviewURIService()
{
return Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getPreviewURIService();
}
private static ConfigElement getDeploymentConfig() private static ConfigElement getDeploymentConfig()
{ {
if ((deploymentConfig == null) || (Application.isDynamicConfig(FacesContext.getCurrentInstance()))) if ((deploymentConfig == null) || (Application.isDynamicConfig(FacesContext.getCurrentInstance())))
@@ -541,6 +519,8 @@ public final class AVMUtil extends WCMUtil
private static ConfigElement deploymentConfig = null; private static ConfigElement deploymentConfig = null;
private static ConfigElement linksManagementConfig = null; private static ConfigElement linksManagementConfig = null;
// deprecated
private final static String SPRING_BEAN_NAME_PREVIEW_URI_SERVICE = "PreviewURIService"; private final static String SPRING_BEAN_NAME_PREVIEW_URI_SERVICE = "PreviewURIService";
private static PreviewURIService previewURIGenerator = null; private static PreviewURIService deprecatedPreviewURIGenerator = null;
private static boolean deprecatedPreviewURIGeneratorChecked = false;
} }

View File

@@ -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 * 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
@@ -31,6 +31,7 @@ import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
import javax.faces.context.FacesContext; import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent; import javax.faces.event.ActionEvent;
@@ -50,8 +51,10 @@ import org.alfresco.service.cmr.workflow.WorkflowService;
import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.QName;
import org.alfresco.service.namespace.RegexQNamePattern; import org.alfresco.service.namespace.RegexQNamePattern;
import org.alfresco.util.ExpiringValueCache; import org.alfresco.util.ExpiringValueCache;
import org.alfresco.wcm.preview.PreviewURIService;
import org.alfresco.wcm.util.WCMUtil; import org.alfresco.wcm.util.WCMUtil;
import org.alfresco.wcm.webproject.WebProjectInfo; import org.alfresco.wcm.webproject.WebProjectInfo;
import org.alfresco.wcm.webproject.WebProjectInfoImpl;
import org.alfresco.wcm.webproject.WebProjectService; import org.alfresco.wcm.webproject.WebProjectService;
import org.alfresco.web.app.AlfrescoNavigationHandler; import org.alfresco.web.app.AlfrescoNavigationHandler;
import org.alfresco.web.app.Application; import org.alfresco.web.app.Application;
@@ -112,19 +115,21 @@ public class CreateWebsiteWizard extends BaseWizardBean
protected String webapp = WEBAPP_DEFAULT; protected String webapp = WEBAPP_DEFAULT;
protected String createFrom = null; protected String createFrom = null;
protected boolean isSource; protected boolean isSource;
protected String previewProvider;
protected NodeRef wpNodeRef; protected NodeRef wpNodeRef;
protected String[] sourceWebProject = null; protected String[] sourceWebProject = null;
protected ExpiringValueCache<List<UIListItem>> webProjectsList; protected ExpiringValueCache<List<UIListItem>> webProjectsList;
protected List<SelectItem> webappsList; protected List<SelectItem> webappsList;
protected List<SelectItem> previewProvidersList;
protected boolean showAllSourceProjects; protected boolean showAllSourceProjects;
protected String websiteDescriptionAttribute; protected String websiteDescriptionAttribute;
transient private WorkflowService workflowService; transient private WorkflowService workflowService;
transient private PersonService personService; transient private PersonService personService;
transient private FormsService formsService; transient private FormsService formsService;
transient private WebProjectService wpService; transient private WebProjectService wpService;
transient private PreviewURIService previewURIService;
/** set true when an option in the Create From screen is changed - this is used as an /** set true when an option in the Create From screen is changed - this is used as an
indicator to reload the wizard data model from the selected source web project */ indicator to reload the wizard data model from the selected source web project */
@@ -183,6 +188,7 @@ public class CreateWebsiteWizard extends BaseWizardBean
this.sourceWebProject = null; this.sourceWebProject = null;
this.createFromValueChanged = false; this.createFromValueChanged = false;
this.showAllSourceProjects = false; this.showAllSourceProjects = false;
this.websiteDescriptionAttribute = null;
} }
private void clearFormsWorkflowsDeploymentAndUsers() private void clearFormsWorkflowsDeploymentAndUsers()
@@ -222,7 +228,7 @@ public class CreateWebsiteWizard extends BaseWizardBean
sourceNodeRef = new NodeRef(this.sourceWebProject[0]); sourceNodeRef = new NodeRef(this.sourceWebProject[0]);
} }
WebProjectInfo wpInfo = getWebProjectService().createWebProject(this.dnsName, this.name, this.title, this.description, this.webapp, this.isSource, sourceNodeRef); WebProjectInfo wpInfo = getWebProjectService().createWebProject(new WebProjectInfoImpl(this.dnsName, this.name, this.title, this.description, this.webapp, this.isSource, sourceNodeRef, this.previewProvider));
String avmStore = wpInfo.getStoreId(); String avmStore = wpInfo.getStoreId();
NodeRef wpNodeRef = wpInfo.getNodeRef(); NodeRef wpNodeRef = wpInfo.getNodeRef();
@@ -406,6 +412,7 @@ public class CreateWebsiteWizard extends BaseWizardBean
this.webapp = wpInfo.getDefaultWebApp(); this.webapp = wpInfo.getDefaultWebApp();
this.isSource = wpInfo.isTemplate(); this.isSource = wpInfo.isTemplate();
this.wpNodeRef = wpInfo.getNodeRef(); this.wpNodeRef = wpInfo.getNodeRef();
this.previewProvider = wpInfo.getPreviewProviderName();
} }
if (loadUsers) if (loadUsers)
@@ -593,11 +600,28 @@ public class CreateWebsiteWizard extends BaseWizardBean
{ {
if (wpService == null) if (wpService == null)
{ {
wpService = (WebProjectService) FacesHelper.getManagedBean(FacesContext.getCurrentInstance(), "WebProjectService"); wpService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getWebProjectService();
} }
return wpService; return wpService;
} }
/**
* @param previewURIService The PreviewURIService to set.
*/
public void setPreviewURIService(final PreviewURIService previewURIService)
{
this.previewURIService = previewURIService;
}
protected PreviewURIService getPreviewURIService()
{
if (previewURIService == null)
{
previewURIService = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getPreviewURIService();
}
return previewURIService;
}
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
// Bean getters and setters // Bean getters and setters
@@ -705,6 +729,16 @@ public class CreateWebsiteWizard extends BaseWizardBean
this.webapp = webapp; this.webapp = webapp;
} }
public String getPreviewProvider()
{
return this.previewProvider;
}
public void setPreviewProvider(String previewProvider)
{
this.previewProvider = previewProvider;
}
/** /**
* @return the create from selection value * @return the create from selection value
*/ */
@@ -852,6 +886,31 @@ public class CreateWebsiteWizard extends BaseWizardBean
return this.webappsList; return this.webappsList;
} }
public List<SelectItem> getPreviewProvidersList()
{
if (this.previewProvidersList == null)
{
// create list of preview providers
String defaultPreviewProvider = getPreviewURIService().getDefaultProviderName();
Set<String> previewProviders = getPreviewURIService().getProviderNames();
this.previewProvidersList = new ArrayList<SelectItem>(previewProviders.size());
this.previewProvidersList.add(new SelectItem(defaultPreviewProvider, defaultPreviewProvider));
for (String previewProvider : previewProviders)
{
if (! previewProvider.equals(defaultPreviewProvider))
{
this.previewProvidersList.add(new SelectItem(previewProvider, previewProvider));
}
}
}
return this.previewProvidersList;
}
/** /**
* @see org.alfresco.web.bean.wizard.BaseWizardBean#next() * @see org.alfresco.web.bean.wizard.BaseWizardBean#next()
*/ */
@@ -1387,6 +1446,7 @@ public class CreateWebsiteWizard extends BaseWizardBean
attribute.append(DescriptionAttributeHelper.getTableLine(fc, "title", getTitle())); attribute.append(DescriptionAttributeHelper.getTableLine(fc, "title", getTitle()));
attribute.append(DescriptionAttributeHelper.getTableLine(fc, "description", attribute.append(DescriptionAttributeHelper.getTableLine(fc, "description",
DescriptionAttributeHelper.getDescriptionNotEmpty(fc, getDescription()), false)); DescriptionAttributeHelper.getDescriptionNotEmpty(fc, getDescription()), false));
attribute.append(DescriptionAttributeHelper.getTableLine(fc, "website_preview_provider", getPreviewProvider()));
attribute.append(DescriptionAttributeHelper.getTableEnd()); attribute.append(DescriptionAttributeHelper.getTableEnd());
return attribute.toString(); return attribute.toString();
} }

View File

@@ -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 * 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
@@ -31,7 +31,6 @@ import java.util.Map;
import javax.faces.context.FacesContext; import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem; import javax.faces.model.SelectItem;
import org.alfresco.model.ContentModel;
import org.alfresco.model.WCMAppModel; import org.alfresco.model.WCMAppModel;
import org.alfresco.service.cmr.repository.ChildAssociationRef; import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
@@ -117,6 +116,7 @@ public class EditWebsiteWizard extends CreateWebsiteWizard
wpInfo.setTitle(this.title); wpInfo.setTitle(this.title);
wpInfo.setDescription(this.description); wpInfo.setDescription(this.description);
wpInfo.setIsTemplate(this.isSource); wpInfo.setIsTemplate(this.isSource);
wpInfo.setPreviewProviderName(this.previewProvider);
getWebProjectService().updateWebProject(wpInfo); getWebProjectService().updateWebProject(wpInfo);

View File

@@ -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 * 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
@@ -25,22 +25,19 @@
package org.alfresco.web.bean.wcm.preview; package org.alfresco.web.bean.wcm.preview;
/** /**
* A PreviewURIService that always returns null (no preview URI). * A PreviewURIService that always returns null (no preview URI).
* *
* @author Peter Monks (peter.monks@alfresco.com) * @author Peter Monks (peter.monks@alfresco.com)
* @version $Id$ *
* @since 2.2.1
*
* @deprecated see org.alfresco.web.bean.wcm.preview.NullPreviewURIService
*/ */
public class NullPreviewURIService public class NullPreviewURIService extends org.alfresco.wcm.preview.NullPreviewURIService implements PreviewURIService
implements PreviewURIService
{ {
/**
* @see org.alfresco.web.bean.wcm.preview.PreviewURIService#getPreviewURI(java.lang.String, java.lang.String)
*/
public String getPreviewURI(final String storeId, final String webapp) public String getPreviewURI(final String storeId, final String webapp)
{ {
return(null); return super.getPreviewURI(storeId, webapp, null);
} }
} }

View File

@@ -30,7 +30,10 @@ package org.alfresco.web.bean.wcm.preview;
* Abstraction for generating preview URLs. * Abstraction for generating preview URLs.
* *
* @author Peter Monks (peter.monks@alfresco.com) * @author Peter Monks (peter.monks@alfresco.com)
* @version $Id$ *
* @since 2.2.1
*
* @deprecated see org.alfresco.wcm.preview.PreviewURIServiceProvider
*/ */
public interface PreviewURIService public interface PreviewURIService
{ {

View File

@@ -40,10 +40,12 @@ import org.alfresco.util.Pair;
* is being generated for. * is being generated for.
* *
* @author Peter Monks (peter.monks@alfresco.com) * @author Peter Monks (peter.monks@alfresco.com)
* @version $Id$ *
* @since 2.2.1
*
* @deprecated see org.alfresco.wcm.preview.*
*/ */
public class StoreSpecificPreviewURIService public class StoreSpecificPreviewURIService implements PreviewURIService
implements PreviewURIService
{ {
private final List<Pair<Pattern, PreviewURIService>> storeURIGenerators; private final List<Pair<Pattern, PreviewURIService>> storeURIGenerators;
private final PreviewURIService fallback; private final PreviewURIService fallback;

View File

@@ -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 * 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,18 +34,13 @@ package org.alfresco.web.bean.wcm.preview;
* </ul> * </ul>
* *
* @author Peter Monks (peter.monks@alfresco.com) * @author Peter Monks (peter.monks@alfresco.com)
* @version $Id$ *
* @since 2.2.1
*
* @deprecated see org.alfresco.wcm.preview.URITemplatePreviewURIService
*/ */
public class URITemplatePreviewURIService public class URITemplatePreviewURIService extends org.alfresco.wcm.preview.URITemplatePreviewURIService implements PreviewURIService
implements PreviewURIService
{ {
private final static String URI_TEMPLATE_PARAMETER_STORE_ID = "{storeId}";
private final static String URI_TEMPLATE_PARAMETER_PATH_TO_ASSET = "{pathToAsset}";
private final String uriTemplate;
public URITemplatePreviewURIService(final String uriTemplate) public URITemplatePreviewURIService(final String uriTemplate)
{ {
// PRECONDITIONS // PRECONDITIONS
@@ -55,40 +50,8 @@ public class URITemplatePreviewURIService
this.uriTemplate = uriTemplate; this.uriTemplate = uriTemplate;
} }
public String getPreviewURI(final String storeId, final String webapp)
/**
* @see org.alfresco.web.bean.wcm.preview.PreviewURIService#getPreviewURI(java.lang.String, java.lang.String)
*/
public String getPreviewURI(final String storeId, final String pathToAsset)
{ {
String result = uriTemplate; return super.getPreviewURI(storeId, webapp, null);
if (uriTemplate.contains(URI_TEMPLATE_PARAMETER_STORE_ID))
{
if (storeId != null && storeId.trim().length() > 0)
{
result = result.replace(URI_TEMPLATE_PARAMETER_STORE_ID, storeId);
} }
else
{
// Shouldn't ever happen (store ids are always provided), but better to be safe than sorry
result = result.replace(URI_TEMPLATE_PARAMETER_STORE_ID, "");
}
}
if (uriTemplate.contains(URI_TEMPLATE_PARAMETER_PATH_TO_ASSET))
{
if (pathToAsset != null && pathToAsset.trim().length() > 0)
{
result = result.replace(URI_TEMPLATE_PARAMETER_PATH_TO_ASSET, pathToAsset);
}
else
{
result = result.replace(URI_TEMPLATE_PARAMETER_PATH_TO_ASSET, "");
}
}
return(result);
}
} }

View File

@@ -25,37 +25,34 @@
package org.alfresco.web.bean.wcm.preview; package org.alfresco.web.bean.wcm.preview;
import org.alfresco.config.JNDIConstants; import javax.faces.context.FacesContext;
import org.alfresco.web.bean.wcm.AVMUtil;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.web.bean.repository.Repository;
/** /**
* A PreviewURIService that constructs a virtualisation server URI. * A PreviewURIService that constructs a virtualisation server URI.
* *
* @author Peter Monks (peter.monks@alfresco.com) * @author Peter Monks (peter.monks@alfresco.com)
* @version $Id$ *
* @since 2.2.1
*
* @deprecated see org.alfresco.wcm.preview.VirtualisationServerPreviewURIService
*/ */
public class VirtualisationServerPreviewURIService public class VirtualisationServerPreviewURIService extends org.alfresco.wcm.preview.VirtualisationServerPreviewURIService implements PreviewURIService
implements PreviewURIService
{ {
/** /**
* @see org.alfresco.web.bean.wcm.preview.PreviewURIService#getPreviewURI(java.lang.String, java.lang.String) * @see org.alfresco.web.bean.wcm.preview.PreviewURIService#getPreviewURI(java.lang.String, java.lang.String)
*/ */
public String getPreviewURI(final String storeId, final String pathToAsset) public String getPreviewURI(final String sbStoreId, final String pathToAsset)
{ {
if ((pathToAsset == null) || (pathToAsset.length() == 0)) ServiceRegistry serviceRegistry = Repository.getServiceRegistry(FacesContext.getCurrentInstance());
{
return AVMUtil.buildStoreUrl(storeId);
}
// Sanity checking this.setAvmService(serviceRegistry.getAVMService());
if (!pathToAsset.startsWith('/' + JNDIConstants.DIR_DEFAULT_WWW + '/' + JNDIConstants.DIR_DEFAULT_APPBASE)) this.setVirtServerRegistry(serviceRegistry.getVirtServerRegistry());
{
throw new IllegalStateException("Invalid asset path in AVM node ref: " + storeId + ":" + pathToAsset);
}
return AVMUtil.buildAssetUrl(storeId, pathToAsset); return super.getPreviewURI(sbStoreId, pathToAsset, null);
} }
} }

View File

@@ -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 * 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

View File

@@ -377,7 +377,7 @@ public class RenderingEngineTemplateImpl
final String formInstanceDataAvmPath = formInstanceData.getPath(); final String formInstanceDataAvmPath = formInstanceData.getPath();
final String renditionAvmPath = rendition.getPath(); final String renditionAvmPath = rendition.getPath();
final String parentPath = AVMNodeConverter.SplitBase(formInstanceDataAvmPath)[0]; final String parentPath = AVMNodeConverter.SplitBase(formInstanceDataAvmPath)[0];
final String sandboxUrl = AVMUtil.buildStoreUrl(AVMUtil.getStoreName(formInstanceDataAvmPath)); final String sandboxUrl = AVMUtil.getPreviewURI(AVMUtil.getStoreName(formInstanceDataAvmPath));
final String webappUrl = AVMUtil.buildWebappUrl(formInstanceDataAvmPath); final String webappUrl = AVMUtil.buildWebappUrl(formInstanceDataAvmPath);
final HashMap<QName, Object> model = new HashMap<QName, Object>(); final HashMap<QName, Object> model = new HashMap<QName, Object>();
// add simple scalar parameters // add simple scalar parameters

View File

@@ -185,5 +185,20 @@
<f:verbatim> <f:verbatim>
</td> </td>
</tr> </tr>
<tr>
<td></td>
<td>
</f:verbatim>
<h:outputText value="#{msg.website_preview_provider}:"/>
<f:verbatim>
</td>
<td>
</f:verbatim>
<h:selectOneMenu id="previewprovider" value="#{WizardManager.bean.previewProvider}">
<f:selectItems value="#{WizardManager.bean.previewProvidersList}" />
</h:selectOneMenu>
<f:verbatim>
</td>
</tr>
</table> </table>
</f:verbatim> </f:verbatim>