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 e5c375d103
commit 2051b0709a
29 changed files with 1344 additions and 198 deletions

View File

@@ -39,7 +39,7 @@
<types>
<type name="wca:webfolder">
<title>AVM Website Folder</title>
<title>WCM Web Project Folder</title>
<parent>wcm:avmfolder</parent>
<properties>
<!-- root name of the avm staging stores for this web folder -->
@@ -76,6 +76,11 @@
<title>Used as a template website</title>
<type>d:boolean</type>
</property>
<!-- Preview URI Service Provider Name (since 3.2) -->
<property name="wca:previewprovidername">
<title>Preview Provider</title>
<type>d:text</type>
</property>
</properties>
<associations>
<child-association name="wca:webuser">

View File

@@ -53,6 +53,7 @@
<property name="personService" ref="PersonService"/>
<property name="sandboxFactory" ref="sandboxFactory"/>
<property name="virtServerRegistry" ref="VirtServerRegistry"/>
<property name="previewURIServiceRegistry" ref="previewURIServiceRegistry"/>
</bean>
@@ -233,4 +234,73 @@
<property name="namespaceService" ref="NamespaceService"/>
</bean>
<!-- PreviewURI Service -->
<!-- PreviewURI service bean - note: named WCMPreviewURIService to allow backwards compatibility with deprecated "PreviewURIService" (as hard-coded in AVMUtil) -->
<bean id="WCMPreviewURIService" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="proxyInterfaces">
<value>org.alfresco.wcm.preview.PreviewURIService</value>
</property>
<property name="target">
<ref bean="previewURIService"/>
</property>
<property name="interceptorNames">
<list>
<idref local="PreviewURIService_transaction"/>
<idref bean="AuditMethodInterceptor"/>
<idref bean="exceptionTranslator"/>
<idref local="PreviewURIService_security"/>
</list>
</property>
</bean>
<!-- PreviewURI Service service transaction bean -->
<bean id="PreviewURIService_transaction" class="org.springframework.transaction.interceptor.TransactionInterceptor">
<property name="transactionManager">
<ref bean="transactionManager"/>
</property>
<property name="transactionAttributes">
<props>
<prop key="get*">${server.transaction.mode.readOnly}</prop>
<prop key="*">${server.transaction.mode.default}</prop>
</props>
</property>
</bean>
<!-- PreviewURIService service security bean -->
<bean id="PreviewURIService_security" class="org.alfresco.repo.security.permissions.impl.AlwaysProceedMethodInterceptor" />
<bean id="previewURIService" class="org.alfresco.wcm.preview.PreviewURIServiceImpl">
<property name="webProjectService" ref="WebProjectService"/>
<property name="previewURIServiceRegistry" ref="previewURIServiceRegistry"/>
</bean>
<!-- override this bean in a custom-wcm-preview-context.xml file to extend/change list of preview providers -->
<bean id="previewURIServiceRegistry" class="org.alfresco.wcm.preview.PreviewURIServiceRegistryImpl">
<property name="defaultProviderName">
<value>Virtualisation Server Preview</value>
</property>
<property name="previewURIServiceProvidersByName">
<map>
<entry key="Virtualisation Server Preview">
<ref bean="virtServerPreviewURIService"/>
</entry>
<!--
<entry key="NOOP Preview">
<ref bean="nullPreviewURIService"/>
</entry>
-->
</map>
</property>
</bean>
<bean id="basePreviewURIServiceProvider" class="org.alfresco.wcm.preview.AbstractPreviewURIServiceProvider" abstract="true"/>
<bean id="virtServerPreviewURIService" class="org.alfresco.wcm.preview.VirtualisationServerPreviewURIService" parent="basePreviewURIServiceProvider">
<property name="avmService" ref="AVMService"/>
<property name="virtServerRegistry" ref="VirtServerRegistry"/>
</bean>
<bean id="nullPreviewURIService" class="org.alfresco.wcm.preview.NullPreviewURIService" parent="basePreviewURIServiceProvider"/>
</beans>

View File

@@ -40,6 +40,7 @@ public interface WCMAppModel
static final QName PROP_SELECTEDDEPLOYTO = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "selecteddeployto");
static final QName PROP_SELECTEDDEPLOYVERSION = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "selecteddeployversion");
static final QName PROP_ISSOURCE = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "issource");
static final QName PROP_PREVIEW_PROVIDER = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "previewprovidername");
static final QName ASSOC_WEBUSER = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "webuser");
static final QName ASSOC_WEBFORM = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "webform");
static final QName ASSOC_WEBWORKFLOWDEFAULTS = QName.createQName(NamespaceService.WCMAPP_MODEL_1_0_URI, "webworkflowdefaults");

View File

@@ -198,7 +198,7 @@ public final class AVM extends BaseScopableProcessorExtension
*/
public String websiteStagingUrl(String storeId)
{
return WCMUtil.buildStoreUrl(this.services.getAVMService(), storeId, getVServerDomain(), getVServerPort());
return this.services.getPreviewURIService().getPreviewURI(storeId, null);
}
/**
@@ -220,9 +220,9 @@ public final class AVM extends BaseScopableProcessorExtension
*
* @return the preview URL to the specified store asset
*/
public String assetUrl(String store, String assetPath)
public String assetUrl(String storeId, String assetPath)
{
return WCMUtil.buildAssetUrl(assetPath, getVServerDomain(), getVServerPort(), WCMUtil.lookupStoreDNS(this.services.getAVMService(), store));
return this.services.getPreviewURIService().getPreviewURI(storeId, assetPath);
}
/**
@@ -241,32 +241,6 @@ public final class AVM extends BaseScopableProcessorExtension
return assetUrl(s[0], s[1]);
}
/**
* @return VServer Port
*/
private String getVServerPort()
{
Integer port = this.services.getVirtServerRegistry().getVirtServerHttpPort();
if (port == null)
{
port = JNDIConstants.DEFAULT_VSERVER_PORT;
}
return port.toString();
}
/**
* @return VServer Domain
*/
private String getVServerDomain()
{
String domain = this.services.getVirtServerRegistry().getVirtServerFQDN();
if (domain == null)
{
domain = JNDIConstants.DEFAULT_VSERVER_IP;
}
return domain;
}
/**
* @return the path to the webapps folder in a standard web store.
*/

View File

@@ -75,6 +75,7 @@ import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.service.transaction.TransactionService;
import org.alfresco.wcm.asset.AssetService;
import org.alfresco.wcm.preview.PreviewURIService;
import org.alfresco.wcm.sandbox.SandboxService;
import org.alfresco.wcm.webproject.WebProjectService;
import org.springframework.beans.BeansException;
@@ -493,6 +494,14 @@ public class ServiceDescriptorRegistry
return (AssetService)getService(ASSET_SERVICE);
}
/* (non-Javadoc)
* @see org.alfresco.service.ServiceRegistry#getPreviewURIService()
*/
public PreviewURIService getPreviewURIService()
{
return (PreviewURIService)getService(PREVIEW_URI_SERVICE);
}
/* (non-Javadoc)
* @see org.alfresco.service.ServiceRegistry#getFormService()
*/

View File

@@ -188,7 +188,7 @@ public class AVM extends BaseTemplateProcessorExtension
*/
public String websiteStagingUrl(String storeId)
{
return WCMUtil.buildStoreUrl(this.services.getAVMService(), storeId, getVServerDomain(), getVServerPort());
return this.services.getPreviewURIService().getPreviewURI(storeId, null);
}
/**
@@ -210,9 +210,9 @@ public class AVM extends BaseTemplateProcessorExtension
*
* @return the preview URL to the specified store asset
*/
public String assetUrl(String store, String assetPath)
public String assetUrl(String storeId, String assetPath)
{
return WCMUtil.buildAssetUrl(assetPath, getVServerDomain(), getVServerPort(), WCMUtil.lookupStoreDNS(this.services.getAVMService(), store));
return this.services.getPreviewURIService().getPreviewURI(storeId, assetPath);
}
/**
@@ -231,32 +231,6 @@ public class AVM extends BaseTemplateProcessorExtension
return assetUrl(s[0], s[1]);
}
/**
* @return VServer Port
*/
private String getVServerPort()
{
Integer port = this.services.getVirtServerRegistry().getVirtServerHttpPort();
if (port == null)
{
port = JNDIConstants.DEFAULT_VSERVER_PORT;
}
return port.toString();
}
/**
* @return VServer Domain
*/
private String getVServerDomain()
{
String domain = this.services.getVirtServerRegistry().getVirtServerFQDN();
if (domain == null)
{
domain = JNDIConstants.DEFAULT_VSERVER_IP;
}
return domain;
}
/**
* @return the path to the webapps folder in a standard web store.
*/

View File

@@ -74,6 +74,7 @@ import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.service.transaction.TransactionService;
import org.alfresco.wcm.asset.AssetService;
import org.alfresco.wcm.preview.PreviewURIService;
import org.alfresco.wcm.sandbox.SandboxService;
import org.alfresco.wcm.webproject.WebProjectService;
@@ -125,21 +126,26 @@ public interface ServiceRegistry
static final QName OWNABLE_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "OwnableService");
static final QName PERSON_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "PersonService");
static final QName SITE_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "SiteService");
static final QName ATTRIBUTE_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "AttributeService");
static final QName THUMBNAIL_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "ThumbnailService");
static final QName TAGGING_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "TaggingService");
static final QName FORM_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "FormService");
static final QName INVITATION_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "InvitationService");
// WCM / AVM
static final QName AVM_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "AVMService");
static final QName AVM_LOCKING_AWARE_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "AVMLockingAwareService");
static final QName AVM_SYNC_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "AVMSyncService");
static final QName CROSS_REPO_COPY_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "CrossRepositoryCopyService");
static final QName ATTRIBUTE_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "AttributeService");
static final QName AVM_LOCKING_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "AVMLockingService");
static final QName VIRT_SERVER_REGISTRY = QName.createQName(NamespaceService.ALFRESCO_URI, "VirtServerRegistry");
static final QName THUMBNAIL_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "ThumbnailService");
static final QName TAGGING_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "TaggingService");
static final QName DEPLOYMENT_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "DeploymentService");
static final QName WEBPROJECT_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "WebProjectService");
static final QName SANDBOX_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "SandboxService");
static final QName ASSET_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "AssetService");
static final QName FORM_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "FormService");
static final QName INVITATION_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "InvitationService");
static final QName PREVIEW_URI_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "WCMPreviewURIService");
// CMIS
static final QName CMIS_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "CMISService");
static final QName CMIS_DICTIONARY_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "CMISDictionaryService");
static final QName CMIS_QUERY_SERVICE = QName.createQName(NamespaceService.ALFRESCO_URI, "CMISQueryService");
@@ -432,7 +438,7 @@ public interface ServiceRegistry
TaggingService getTaggingService();
/**
* Get the Deployment Service
* Get the WCM Deployment Service
* @return the deployment service (or null, if one is not provided)
*/
@NotAuditable
@@ -459,6 +465,13 @@ public interface ServiceRegistry
@NotAuditable
AssetService getAssetService();
/**
* Get the WCM Preview URI Service
* @return
*/
@NotAuditable
PreviewURIService getPreviewURIService();
/**
* Get the form service (or null if one is not provided)
* @return

View File

@@ -49,14 +49,14 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
*/
public class AbstractWCMServiceImplTest extends TestCase
{
private static final String PREVIEW_CONFIG_LOCATION = "classpath:wcm/wcm-test-preview-context.xml";
// override jbpm.job.executor idleInterval to 5s (was 1.5m) for WCM unit tests
private static final String SUBMIT_CONFIG_LOCATION = "classpath:wcm/wcm-jbpm-context.xml";
protected static final long SUBMIT_DELAY = 15000L; // (in millis) 15s - to allow async submit direct workflow to complete (as per 5s idleInterval above)
protected static ApplicationContext ctx =new ClassPathXmlApplicationContext(
new String[] {ApplicationContextHelper.CONFIG_LOCATIONS[0], SUBMIT_CONFIG_LOCATION}
);
// note: all tests share same context (when run via WCMTestSuite)
protected static ApplicationContext ctx = new ClassPathXmlApplicationContext(new String[] {ApplicationContextHelper.CONFIG_LOCATIONS[0], SUBMIT_CONFIG_LOCATION, PREVIEW_CONFIG_LOCATION});;
//
// test data
@@ -94,7 +94,6 @@ public class AbstractWCMServiceImplTest extends TestCase
protected PersonService personService;
private TransactionService transactionService;
@Override
protected void setUp() throws Exception

View File

@@ -28,6 +28,7 @@ import junit.framework.Test;
import junit.framework.TestSuite;
import org.alfresco.wcm.asset.AssetServiceImplTest;
import org.alfresco.wcm.preview.PreviewURIServiceImplTest;
import org.alfresco.wcm.sandbox.SandboxServiceImplTest;
import org.alfresco.wcm.webproject.WebProjectServiceImplTest;
import org.alfresco.wcm.webproject.script.ScriptWebProjectsTest;
@@ -52,7 +53,8 @@ public class WCMTestSuite extends TestSuite
suite.addTestSuite(AssetServiceImplTest.class);
suite.addTestSuite(SandboxServiceImplTest.class);
suite.addTestSuite(ScriptWebProjectsTest.class);
suite.addTestSuite(PreviewURIServiceImplTest.class);
return suite;
}
}

View File

@@ -0,0 +1,64 @@
/*
* 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
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have received a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
package org.alfresco.wcm.preview;
import java.util.ArrayList;
import java.util.List;
/**
* Abstract Preview URI Service Provider
*
* @author janv
*
* @since 3.2
*/
public abstract class AbstractPreviewURIServiceProvider implements PreviewURIServiceProvider
{
/* (non-Javadoc)
* @see org.alfresco.wcm.preview.PreviewURIServiceProvider#getPreviewURI(java.lang.String, java.lang.String, org.alfresco.wcm.preview.PreviewContext)
*/
abstract public String getPreviewURI(String sbStoreId, String relativePath, PreviewContext previewContext);
/* (non-Javadoc)
* @see org.alfresco.wcm.preview.PreviewURIServiceProvider#getPreviewURIs(java.lang.String, java.util.List, org.alfresco.wcm.preview.PreviewContext)
*/
public List<String> getPreviewURIs(String sbStoreId, List<String> relativePaths, PreviewContext previewContext)
{
List<String> previewURIs = null;
if (relativePaths != null)
{
previewURIs = new ArrayList<String>(relativePaths.size());
for (String relativePath : relativePaths)
{
previewURIs.add(getPreviewURI(sbStoreId, relativePath, previewContext));
}
}
return previewURIs;
}
}

View File

@@ -0,0 +1,46 @@
/*
* 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
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have received a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
package org.alfresco.wcm.preview;
/**
* A PreviewURIService that always returns null (no preview URI).
*
* @author Peter Monks, janv
*
* @since 3.2
*/
public class NullPreviewURIService extends AbstractPreviewURIServiceProvider
{
/* (non-Javadoc)
* @see org.alfresco.wcm.preview.PreviewURIServiceProvider#getPreviewURI(java.lang.String, java.lang.String, org.alfresco.wcm.preview.PreviewContext)
*/
@Override
public String getPreviewURI(final String storeId, final String webapp, final PreviewContext previewContext)
{
return(null);
}
}

View File

@@ -0,0 +1,63 @@
/*
* 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
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have received a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
package org.alfresco.wcm.preview;
/**
* Additional context Preview URI Service Providers
*
* @author janv
*
* @since 3.2
*/
public class PreviewContext
{
private String wpStoreId;
private String webApp; // can be null
private String authenticatedUser;
/* package */ PreviewContext(String wpStoreId, String webApp, String authenticatedUser)
{
this.wpStoreId = wpStoreId;
this.webApp = webApp;
this.authenticatedUser = authenticatedUser;
}
public String getWpStoreId()
{
return wpStoreId;
}
public String getWebApp()
{
return webApp;
}
public String getAuthenticatedUser()
{
return authenticatedUser;
}
}

View File

@@ -0,0 +1,76 @@
/*
* 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
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have received a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
package org.alfresco.wcm.preview;
import java.util.List;
import java.util.Set;
/**
* Client API for retrieving/generating preview URIs
*
* @author janv
*
* @since 3.2
*/
public interface PreviewURIService
{
/**
* @param sbStoreId The sandbox store id 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 sandbox and/or asset (<i>may be null</i>).
*/
public String getPreviewURI(String sbStoreId, String pathToAsset);
/**
* @param sbStoreId The sandbox store id to generate the preview URI for.
* @param pathsToAssets List of paths to the assets to generate the preview URI for.
*
* @return The Preview URI for the given assets (<i>may be null</i>).
*/
public List<String> getPreviewURIs(String sbStoreId, List<String> pathsToAssets);
/**
* Return list of registered Preview URI service providers
*
* @return
*/
public Set<String> getProviderNames();
/**
* Return default Preview URI service provider
*
* @return
*/
public String getDefaultProviderName();
/**
* Return Preview URI service provider configured for web project
*
* @return
*/
public String getProviderName(String wpStoreId);
}

View File

@@ -0,0 +1,136 @@
/*
* 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
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
package org.alfresco.wcm.preview;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.util.ParameterCheck;
import org.alfresco.wcm.util.WCMUtil;
import org.alfresco.wcm.webproject.WebProjectService;
/**
* Preview URI Service fundamental API.
* <p>
* This service API is designed to support the Preview URI API
*
* @author janv
*
* @since 3.2
*/
public class PreviewURIServiceImpl implements PreviewURIService
{
private PreviewURIServiceRegistry previewURIProviderRegistry;
private WebProjectService wpService;
public void setPreviewURIServiceRegistry(PreviewURIServiceRegistry previewURIProviderRegistry)
{
this.previewURIProviderRegistry = previewURIProviderRegistry;
}
public void setWebProjectService(WebProjectService wpService)
{
this.wpService = wpService;
}
/* (non-Javadoc)
* @see org.alfresco.wcm.preview.PreviewURIService#getPreviewURI(java.lang.String, java.lang.String)
*/
public String getPreviewURI(String sbStoreId, String pathToAsset)
{
ParameterCheck.mandatoryString("sbStoreId", sbStoreId);
String wpStoreId = WCMUtil.getWebProjectStoreId(sbStoreId);
String authenticatedUser = AuthenticationUtil.getFullyAuthenticatedUser();
String webApp = null;
if (pathToAsset != null)
{
webApp = WCMUtil.getWebapp(WCMUtil.buildPath(sbStoreId, pathToAsset));
}
PreviewContext prevCtx = new PreviewContext(wpStoreId, webApp, authenticatedUser);
return getProvider(wpStoreId).getPreviewURI(sbStoreId, pathToAsset, prevCtx);
}
/* (non-Javadoc)
* @see org.alfresco.wcm.preview.PreviewURIService#getPreviewURIs(java.lang.String, java.util.List)
*/
public List<String> getPreviewURIs(String sbStoreId, List<String> pathsToAssets)
{
ParameterCheck.mandatoryString("sbStoreId", sbStoreId);
ParameterCheck.mandatory("pathsToAssets", pathsToAssets);
String wpStoreId = WCMUtil.getWebProjectStoreId(sbStoreId);
String authenticatedUser = AuthenticationUtil.getFullyAuthenticatedUser();
String webApp = WCMUtil.getCommonWebApp(sbStoreId, pathsToAssets);
PreviewContext prevCtx = new PreviewContext(wpStoreId, webApp, authenticatedUser);
return getProvider(wpStoreId).getPreviewURIs(sbStoreId, pathsToAssets, prevCtx);
}
/* (non-Javadoc)
* @see org.alfresco.wcm.preview.PreviewURIService#getProviderNames()
*/
public Set<String> getProviderNames()
{
Map<String, PreviewURIServiceProvider> previewProviders = previewURIProviderRegistry.getPreviewURIServiceProviders();
return previewProviders.keySet();
}
/* (non-Javadoc)
* @see org.alfresco.wcm.preview.PreviewURIService#getDefaultProviderName()
*/
public String getDefaultProviderName()
{
// delegate
return previewURIProviderRegistry.getDefaultProviderName();
}
/* (non-Javadoc)
* @see org.alfresco.wcm.preview.PreviewURIService#getProviderName(java.lang.String)
*/
public String getProviderName(String wpStoreId)
{
// delegate
return wpService.getPreviewProvider(wpStoreId);
}
private PreviewURIServiceProvider getProvider(String wpStoreId)
{
PreviewURIServiceProvider previewProvider = previewURIProviderRegistry.getPreviewURIServiceProviders().get(getProviderName(wpStoreId));
if (previewProvider == null)
{
previewProvider = previewURIProviderRegistry.getPreviewURIServiceProviders().get(previewURIProviderRegistry.getDefaultProviderName());
}
return previewProvider;
}
}

View File

@@ -0,0 +1,104 @@
/*
* 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
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
package org.alfresco.wcm.preview;
import java.text.MessageFormat;
import java.util.Map;
import org.alfresco.wcm.AbstractWCMServiceImplTest;
import org.alfresco.wcm.webproject.WebProjectInfo;
/**
* Preview URI Service implementation unit test
*
* @author janv
*/
public class PreviewURIServiceImplTest extends AbstractWCMServiceImplTest
{
//
// services
//
private PreviewURIServiceRegistry previewURIServiceRegistry;
private PreviewURIService prevService;
@Override
protected void setUp() throws Exception
{
super.setUp();
// Get the required services
previewURIServiceRegistry = (PreviewURIServiceRegistry)ctx.getBean("previewURIServiceRegistry");
prevService = (PreviewURIService)ctx.getBean("WCMPreviewURIService");
}
@Override
protected void tearDown() throws Exception
{
super.tearDown();
}
public void testSetup()
{
Map<String, PreviewURIServiceProvider> prevURIServiceProviders = previewURIServiceRegistry.getPreviewURIServiceProviders();
System.out.println(prevURIServiceProviders.keySet());
}
public void testDefaultAndNOOP()
{
// Create a web project
WebProjectInfo wpInfo = wpService.createWebProject(TEST_WEBPROJ_DNS+"-previewSimple", TEST_WEBPROJ_NAME+"-previewSimple", TEST_WEBPROJ_TITLE, TEST_WEBPROJ_DESCRIPTION);
assertNotNull(wpInfo);
String stagingPreviewURL = prevService.getPreviewURI(wpInfo.getStagingStoreName(), null);
assertNotNull(stagingPreviewURL);
String expectedURL = MessageFormat.format(VirtualisationServerPreviewURIService.PREVIEW_SANDBOX_URL,
wpInfo.getStoreId(),
VirtualisationServerPreviewURIService.DEFAULT_VSERVER_IP,
""+VirtualisationServerPreviewURIService.DEFAULT_VSERVER_PORT);
assertEquals(expectedURL, stagingPreviewURL);
String nullProvName = null;
Map<String, PreviewURIServiceProvider> prevURIServiceProviders = previewURIServiceRegistry.getPreviewURIServiceProviders();
for (Map.Entry<String, PreviewURIServiceProvider> entry : prevURIServiceProviders.entrySet())
{
PreviewURIServiceProvider prov = entry.getValue();
if (prov instanceof NullPreviewURIService)
{
nullProvName = entry.getKey();
break;
}
}
assertNotNull(nullProvName);
wpInfo.setPreviewProviderName(nullProvName);
wpService.updateWebProject(wpInfo);
stagingPreviewURL = prevService.getPreviewURI(wpInfo.getStagingStoreName(), null); // fails - returns 2 ?
assertNull(stagingPreviewURL);
}
}

View File

@@ -0,0 +1,57 @@
/*
* 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
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have received a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
package org.alfresco.wcm.preview;
import java.util.List;
/**
* SPI (Service Provider Interface) abstraction for generating preview URLs.
*
* @author janv
*
* @since 3.2
*/
public interface PreviewURIServiceProvider
{
/**
* @param sbStoreId The sandbox store id 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).
* @param previewContext Additional preview context
*
* @return The Preview URI for the given sandbox and/or asset (<i>may be null</i>).
*/
public String getPreviewURI(String sbStoreId, String pathToAsset, PreviewContext previewContext);
/**
* @param sbStoreId The sandbox store id to generate the preview URI for.
* @param pathsToAssets The paths to the assets to generate the preview URI for.
* @param previewContext Additional preview context
*
* @return The Preview URIs for the given asset paths (<i>may be null</i>).
*/
public List<String> getPreviewURIs(String sbStoreId, List<String> pathsToAssets, PreviewContext previewContext);
}

View File

@@ -0,0 +1,53 @@
/*
* 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
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have received a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
package org.alfresco.wcm.preview;
import java.util.Map;
/**
* Preview URI Service Provider Registry
*
* @author janv
*
* @since 3.2
*/
public interface PreviewURIServiceRegistry
{
/**
* Return list of registered PreviewURI service providers
*
* @return
*/
public Map<String, PreviewURIServiceProvider> getPreviewURIServiceProviders();
/**
* Return default PreviewURI service provider
*
* @return
*/
public String getDefaultProviderName();
}

View File

@@ -0,0 +1,79 @@
/*
* 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
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
package org.alfresco.wcm.preview;
import java.util.Map;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.util.PropertyCheck;
import org.springframework.beans.factory.InitializingBean;
/**
* Preview URI Service Provider Registry Implementation
*
* @author janv
*
* @since 3.2
*/
public class PreviewURIServiceRegistryImpl implements PreviewURIServiceRegistry, InitializingBean
{
private static final String ERR_INVALID_DEFAULT_PREVIEW_URI_SERVICE = "preview.err.invalid_default_preview_uri_service";
private Map<String, PreviewURIServiceProvider> previewURIServicesByName;
private String defaultPreviewURIServiceName;
public void setPreviewURIServiceProvidersByName(Map<String, PreviewURIServiceProvider> previewURIServicesByName)
{
this.previewURIServicesByName = previewURIServicesByName;
}
public Map<String, PreviewURIServiceProvider> getPreviewURIServiceProviders()
{
return this.previewURIServicesByName;
}
public void setDefaultProviderName(String defaultPreviewURIServiceName)
{
this.defaultPreviewURIServiceName = defaultPreviewURIServiceName;
}
public String getDefaultProviderName()
{
return this.defaultPreviewURIServiceName;
}
public void afterPropertiesSet() throws Exception
{
PropertyCheck.mandatory(this, "previewURIServicesByName", previewURIServicesByName);
PropertyCheck.mandatory(this, "defaultName", defaultPreviewURIServiceName);
// Check that the default preview URI service provider name is valid
if ((defaultPreviewURIServiceName.length() == 0) || (previewURIServicesByName.get(defaultPreviewURIServiceName) == null))
{
AlfrescoRuntimeException.create(ERR_INVALID_DEFAULT_PREVIEW_URI_SERVICE, defaultPreviewURIServiceName, previewURIServicesByName.keySet());
}
}
}

View File

@@ -0,0 +1,91 @@
/*
* 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
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have received a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
package org.alfresco.wcm.preview;
/**
* A PreviewURIService that takes a URI template and replaces the following parameters per request:
* <ul>
* <li>{storeId} - the store Id of the preview request</li>
* <li>{pathToAsset} - the full path and filename of the asset being previewed (including a leading '/')</li>
* </ul>
*
* @author Peter Monks, janv
*
* @since 3.2
*/
public class URITemplatePreviewURIService extends AbstractPreviewURIServiceProvider
{
private final static String URI_TEMPLATE_PARAMETER_STORE_ID = "{storeId}";
private final static String URI_TEMPLATE_PARAMETER_PATH_TO_ASSET = "{pathToAsset}";
protected String uriTemplate;
public void setUriTemplate(String uriTemplate)
{
this.uriTemplate = uriTemplate;
}
public URITemplatePreviewURIService()
{
}
/* (non-Javadoc)
* @see org.alfresco.wcm.preview.PreviewURIServiceProvider#getPreviewURI(java.lang.String, java.lang.String, org.alfresco.wcm.preview.PreviewContext)
*/
public String getPreviewURI(final String storeId, final String pathToAsset, final PreviewContext ignored)
{
String result = uriTemplate;
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

@@ -0,0 +1,156 @@
/*
* 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
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have received a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
package org.alfresco.wcm.preview;
import java.text.MessageFormat;
import org.alfresco.config.JNDIConstants;
import org.alfresco.mbeans.VirtServerRegistry;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.util.ParameterCheck;
import org.alfresco.wcm.util.WCMUtil;
/**
* A PreviewURIService that constructs a virtualisation server URI.
*
* @author Peter Monks, janv
*
* @since 3.2
*/
public class VirtualisationServerPreviewURIService extends AbstractPreviewURIServiceProvider
{
// TODO - remove deprecated constants from JNDIConstants
/**
* Default virtualization server IP address
*/
public final static String DEFAULT_VSERVER_IP = "127-0-0-1.ip.alfrescodemo.net";
/**
* Default virtualization server port number
*/
public final static int DEFAULT_VSERVER_PORT = 8180;
/**
* Virtualization server sandbox URL pattern
*/
public final static String PREVIEW_SANDBOX_URL = "http://{0}.www--sandbox.{1}:{2}";
/**
* Virtualization server asset URL pattern
*/
public final static String PREVIEW_ASSET_URL = "http://{0}.www--sandbox.{1}:{2}{3}";
private AVMService avmService;
private VirtServerRegistry virtSvrRegistry;
public void setAvmService(AVMService avmService)
{
this.avmService = avmService;
}
public void setVirtServerRegistry(VirtServerRegistry virtSvrRegistry)
{
this.virtSvrRegistry = virtSvrRegistry;
}
/* (non-Javadoc)
* @see org.alfresco.wcm.preview.PreviewURIServiceProvider#getPreviewURI(java.lang.String, java.lang.String, org.alfresco.wcm.preview.PreviewContext)
*/
public String getPreviewURI(String sbStoreId, String pathToAsset, PreviewContext ignored)
{
ParameterCheck.mandatoryString("sbStoreId", sbStoreId);
if ((pathToAsset == null) || (pathToAsset.length() == 0))
{
return buildPreviewStoreUrl(sbStoreId, getVServerDomain(), getVServerPort(), WCMUtil.lookupStoreDNS(avmService, sbStoreId));
}
// Sanity checking
if (!pathToAsset.startsWith('/' + JNDIConstants.DIR_DEFAULT_WWW + '/' + JNDIConstants.DIR_DEFAULT_APPBASE))
{
throw new IllegalStateException("Invalid asset path in AVM node ref: " + sbStoreId + ":" + pathToAsset);
}
return buildPreviewAssetUrl(pathToAsset, getVServerDomain(), getVServerPort(), WCMUtil.lookupStoreDNS(avmService, sbStoreId));
}
private String buildPreviewStoreUrl(String sbStoreId, String domain, String port, String dns)
{
return MessageFormat.format(PREVIEW_SANDBOX_URL, dns, domain, port);
}
private String buildPreviewAssetUrl(String assetPath, String domain, String port, String dns)
{
ParameterCheck.mandatoryString("assetPath", assetPath);
if (domain == null || port == null || dns == null)
{
throw new IllegalArgumentException("Domain, port and dns name are mandatory.");
}
if (assetPath.startsWith(JNDIConstants.DIR_DEFAULT_WWW_APPBASE))
{
assetPath = assetPath.substring((JNDIConstants.DIR_DEFAULT_WWW_APPBASE).length());
}
if (assetPath.startsWith(WCMUtil.PATH_SEPARATOR + WCMUtil.DIR_ROOT))
{
assetPath = assetPath.substring((WCMUtil.PATH_SEPARATOR + WCMUtil.DIR_ROOT).length());
}
assetPath = WCMUtil.addLeadingSlash(assetPath);
return MessageFormat.format(PREVIEW_ASSET_URL, dns, domain, port, assetPath);
}
/**
* @return VServer Port
*/
private String getVServerPort()
{
Integer port = (virtSvrRegistry != null ? virtSvrRegistry.getVirtServerHttpPort() : null);
if (port == null)
{
port = DEFAULT_VSERVER_PORT;
}
return port.toString();
}
/**
* @return VServer Domain
*/
private String getVServerDomain()
{
String domain = (virtSvrRegistry != null ? virtSvrRegistry.getVirtServerFQDN() : null);
if (domain == null)
{
domain = DEFAULT_VSERVER_IP;
}
return domain;
}
}

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
* modify it under the terms of the GNU General Public License
@@ -56,6 +56,7 @@ public class SandboxConstants
public final static QName PROP_WEBSITE_NAME = QName.createQName(null, ".website.name");
public final static QName PROP_AUTHOR_NAME = QName.createQName(null, ".author.name");
public final static QName PROP_WEB_PROJECT_NODE_REF = QName.createQName(null, ".web_project.noderef");
public final static QName PROP_WEB_PROJECT_PREVIEW_PROVIDER = QName.createQName(null, ".web_project.previewprovider");
public final static QName PROP_LINK_VALIDATION_REPORT = QName.createQName(null, ".link.validation.report");
public final static QName PROP_LAST_DEPLOYMENT_ID = QName.createQName(null, ".deployment.id");

View File

@@ -466,8 +466,8 @@ public class SandboxServiceImpl implements SandboxService
getSandbox(srcSandboxStoreId); // ignore result
getSandbox(dstSandboxStoreId); // ignore result
String avmSrcPath = srcSandboxStoreId + WCMUtil.AVM_STORE_SEPARATOR + srcRelativePath;
String avmDstPath = dstSandboxStoreId + WCMUtil.AVM_STORE_SEPARATOR + dstRelativePath;
String avmSrcPath = WCMUtil.buildPath(srcSandboxStoreId, srcRelativePath);
String avmDstPath = WCMUtil.buildPath(dstSandboxStoreId, dstRelativePath);
return listChanged(-1, avmSrcPath, -1, avmDstPath, includeDeleted);
}
@@ -635,34 +635,13 @@ public class SandboxServiceImpl implements SandboxService
RetryingTransactionHelper txnHelper = transactionService.getRetryingTransactionHelper();
final List<String> srcPaths = new ArrayList<String>(relativePaths.size());
String derivedWebApp = null;
boolean multiWebAppsFound = false;
for (String relativePath : relativePaths)
{
// Example srcPath:
// mysite--alice:/www/avm_webapps/ROOT/foo.txt
String srcPath = sbStoreId + WCMUtil.AVM_STORE_SEPARATOR + relativePath;
srcPaths.add(srcPath);
// derive webapp for now (TODO check usage)
String srcWebApp = WCMUtil.getWebapp(srcPath);
if (srcWebApp != null)
{
if (derivedWebApp == null)
{
derivedWebApp = srcWebApp;
}
else if (! derivedWebApp.equals(srcWebApp))
{
multiWebAppsFound = true;
}
}
srcPaths.add(WCMUtil.buildPath(sbStoreId, relativePath));
}
final String webApp = (multiWebAppsFound == false ? derivedWebApp : null);
final String webApp = WCMUtil.getCommonWebApp(sbStoreId, relativePaths);
RetryingTransactionCallback<Pair<SandboxInfo, String>> sandboxCallback = new RetryingTransactionCallback<Pair<SandboxInfo, String>>()
{
public Pair<SandboxInfo, String> execute() throws Throwable
@@ -671,10 +650,10 @@ public class SandboxServiceImpl implements SandboxService
return createWorkflowSandbox(finalWorkflowName, finalWorkflowParams, stagingSandboxId, srcPaths, expirationDates);
}
};
// create the workflow sandbox firstly
final Pair<SandboxInfo, String> workflowInfo = txnHelper.doInTransaction(sandboxCallback, false, true);
if (workflowInfo != null)
{
final SandboxInfo wfSandboxInfo = workflowInfo.getFirst();
@@ -685,7 +664,7 @@ public class SandboxServiceImpl implements SandboxService
{
WCMUtil.updateVServerWebapp(virtServerRegistry, virtUpdatePath, true);
}
try
{
RetryingTransactionCallback<String> workflowCallback = new RetryingTransactionCallback<String>()

View File

@@ -24,7 +24,6 @@
*/
package org.alfresco.wcm.util;
import java.text.MessageFormat;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -54,11 +53,8 @@ import org.apache.commons.logging.LogFactory;
/**
* Helper methods and constants related to WCM directories, paths and store name manipulation.
*
* TODO refactor ...
*
* @author Ariel Backenroth
* @author Kevin Roast
*
* @author Ariel Backenroth, Kevin Roast, janv
*/
public class WCMUtil
{
@@ -425,60 +421,6 @@ public class WCMUtil
return WCMUtil.buildSandboxRootPath(storeName) + '/' + webApp;
}
public static String buildStoreUrl(AVMService avmService, String storeName, String domain, String port)
{
ParameterCheck.mandatoryString("storeName", storeName);
if (domain == null || port == null)
{
throw new IllegalArgumentException("Domain and port are mandatory.");
}
// NOTE: for backwards compatibility - avmPath is converted to storeName (path is ignored)
if (storeName.indexOf(AVM_STORE_SEPARATOR) != -1)
{
storeName = storeName.substring(0, storeName.indexOf(AVM_STORE_SEPARATOR));
}
return MessageFormat.format(JNDIConstants.PREVIEW_SANDBOX_URL,
lookupStoreDNS(avmService, storeName),
domain,
port);
}
protected static String buildWebappUrl(AVMService avmService, final String storeName, final String webApp, String domain, String port)
{
ParameterCheck.mandatoryString("webApp", webApp);
return (webApp.equals(DIR_ROOT)
? buildStoreUrl(avmService, storeName, domain, port)
: buildStoreUrl(avmService, storeName, domain, port) + '/' + webApp);
}
public static String buildAssetUrl(String assetPath, String domain, String port, String dns)
{
ParameterCheck.mandatoryString("assetPath", assetPath);
if (domain == null || port == null || dns == null)
{
throw new IllegalArgumentException("Domain, port and dns name are mandatory.");
}
if (assetPath.startsWith(JNDIConstants.DIR_DEFAULT_WWW_APPBASE))
{
assetPath = assetPath.substring((JNDIConstants.DIR_DEFAULT_WWW_APPBASE).length());
}
if (assetPath.startsWith('/' + DIR_ROOT))
{
assetPath = assetPath.substring(('/' + DIR_ROOT).length());
}
if (assetPath.length() == 0 || assetPath.charAt(0) != '/')
{
assetPath = '/' + assetPath;
}
return MessageFormat.format(JNDIConstants.PREVIEW_ASSET_URL, dns, domain, port, assetPath);
}
public static String lookupStoreDNS(AVMService avmService, String store)
{
ParameterCheck.mandatoryString("store", store);
@@ -761,11 +703,59 @@ public class WCMUtil
return storePath;
}
public static String buildPath(String sbStoreId, String relativePath)
{
return sbStoreId + AVM_STORE_SEPARATOR + addLeadingSlash(relativePath);
}
public static String addLeadingSlash(String relativePath)
{
if ((relativePath.length() == 0) || (relativePath.charAt(0) != PATH_SEPARATOR))
{
relativePath = PATH_SEPARATOR + relativePath;
}
return relativePath;
}
// return common web app or null if paths span multiple web apps (or no web app)
public static String getCommonWebApp(String sbStoreId, List<String> storeRelativePaths)
{
String derivedWebApp = null;
boolean multiWebAppsFound = false;
for (String storeRelativePath : storeRelativePaths)
{
// Example srcPath:
// mysite--alice:/www/avm_webapps/ROOT/foo.txt
String srcPath = WCMUtil.buildPath(sbStoreId, storeRelativePath);
// TODO - don't really need the sbStoreId
// derive webapp for now
String srcWebApp = WCMUtil.getWebapp(srcPath);
if (srcWebApp != null)
{
if (derivedWebApp == null)
{
derivedWebApp = srcWebApp;
}
else if (! derivedWebApp.equals(srcWebApp))
{
multiWebAppsFound = true;
}
}
}
return (multiWebAppsFound == false ? derivedWebApp : null);
}
// Component Separator.
protected static final String STORE_SEPARATOR = "--";
public static final String AVM_STORE_SEPARATOR = ":";
public static final char PATH_SEPARATOR = '/';
// names of the stores representing the layers for an AVM website
//XXXarielb this should be private
protected final static String STORE_WORKFLOW = "workflow";

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
* modify it under the terms of the GNU General Public License
@@ -119,4 +119,23 @@ public interface WebProjectInfo
* @param isTemplate set to <tt>true</tt> if this web project can also be used as a template
*/
public void setIsTemplate(boolean isTemplate);
/**
* Get the preview URI service provider name
*
* @since 3.2
*
* @return the preview URI service provider name
*
*/
public String getPreviewProviderName();
/**
* Set the preview URI service provider name
*
* @since 3.2
*
* @param previewURIServiceProviderName the preview URI service provider name to set
*/
public void setPreviewProviderName(String previewURIServiceProviderName);
}

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
* modify it under the terms of the GNU General Public License
@@ -54,24 +54,30 @@ public class WebProjectInfoImpl implements WebProjectInfo
/** Web Project true if the web project can also be used as template */
private boolean isTemplate;
/** Web Project preview provider name (if null then default preview provider will be used) */
private String previewURIServiceProviderName;
/**
* Constructor
*
* @param name name
* @param description description
* @param nodeRef web project node reference
*/
/*package*/ WebProjectInfoImpl(String name, String title, String description, String wpStoreId, String defaultWebApp, boolean isTemplate, NodeRef nodeRef)
public WebProjectInfoImpl(String wpStoreId,
String name,
String title,
String description,
String defaultWebApp,
boolean isTemplate,
NodeRef nodeRef,
String previewProvider)
{
this.wpStoreId = wpStoreId;
this.name = name;
this.title = title;
this.description = description;
this.wpStoreId = wpStoreId;
this.defaultWebApp = defaultWebApp;
this.isTemplate = isTemplate;
this.nodeRef = nodeRef;
this.previewURIServiceProviderName = previewProvider;
}
/**
@@ -187,4 +193,14 @@ public class WebProjectInfoImpl implements WebProjectInfo
{
this.isTemplate = isTemplate;
}
public String getPreviewProviderName()
{
return previewURIServiceProviderName;
}
public void setPreviewProviderName(String previewURIServiceProviderName)
{
this.previewURIServiceProviderName = previewURIServiceProviderName;
}
}

View File

@@ -1,3 +1,27 @@
/*
* 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
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
package org.alfresco.wcm.webproject;
import java.util.List;
@@ -25,7 +49,7 @@ public interface WebProjectService
* Note: the DNS name will be used to generate the web project store id, which can be subsequently retrieved via WebProjectInfo.getStoreId()
*
* @param dnsName DNS name (required, must be unique)
* @param name name (require, must be unique)
* @param name name (required, must be unique)
* @param title title
* @param description description
* @return WebProjectInfo the created web project info
@@ -43,6 +67,8 @@ public interface WebProjectService
* @param description description
* @param sourceNodeRef web project node ref to branch from (can be null)
* @return WebProjectInfo the created web project info
*
* @deprecated see createWebProject(String dnsName, WebProjectInfo wpInfo)
*/
public WebProjectInfo createWebProject(String dnsName, String name, String title, String description, NodeRef sourceNodeRef);
@@ -51,8 +77,8 @@ public interface WebProjectService
* <p>
* Note: the DNS name will be used to generate the web project store id, which can be subsequently retrieved via WebProjectInfo.getStoreId()
*
* @param dnsName DNS name (must be unique)
* @param name name (must be unique)
* @param dnsName DNS name (required, must be unique)
* @param name name (required, must be unique)
* @param title title
* @param description description
* @param defaultWebApp default webapp (if null, will default to ROOT webapp)
@@ -62,6 +88,28 @@ public interface WebProjectService
*/
public WebProjectInfo createWebProject(String dnsName, String name, String title, String description, String defaultWebApp, boolean useAsTemplate, NodeRef sourceNodeRef);
/**
* Create a new web project (with given web project info)
* <p>
* Note: the DNS name will be used to generate the web project store id, which can be subsequently retrieved via WebProjectInfo.getStoreId()
*
* @param wpInfo web project info
*
* Note:
*
* @param dnsName DNS name (required, must be unique)
* @param name name (required, must be unique)
* @param title title
* @param description description
* @param defaultWebApp default webapp (if null, will default to ROOT webapp)
* @param useAsTemplate <tt>true</tt> if this web project can be used as a template to branch from
* @param sourceNodeRef web project node ref to branch from (can be null)
* @param previewProvider preview URI service provider name (must correspond to registered name, if null will be set to default provider)
*
* @return WebProjectInfo the created web project info
*/
public WebProjectInfo createWebProject(WebProjectInfo wpInfo);
/**
* Returns the Web Projects container
*
@@ -136,6 +184,13 @@ public interface WebProjectService
*/
public WebProjectInfo getWebProject(NodeRef wpNodeRef);
/**
* Get preview provider name configured for given web project (if not configured then return default preview provider)
* @param wpStoreId web project store id
* @return previewProviderName preview URI service provide name
*/
public String getPreviewProvider(String wpStoreId);
/**
* Update the web project info
* <p>
@@ -178,9 +233,9 @@ public interface WebProjectService
* <p>
* Current user must be a content manager for the web project
*
* @param wpStoreId web project store id
* @param name webapp name (must be unique within a web project)
* @param description webapp description
* @param wpStoreId web project store id
* @param name webapp name (must be unique within a web project)
* @param description webapp description
*/
public void createWebApp(String wpStoreId, String name, String description);

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
* modify it under the terms of the GNU General Public License
@@ -47,6 +47,7 @@ import org.alfresco.repo.security.permissions.AccessDeniedException;
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
import org.alfresco.repo.transaction.TransactionListenerAdapter;
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
import org.alfresco.service.cmr.avm.AVMNotFoundException;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.avm.locking.AVMLockingService;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
@@ -67,6 +68,8 @@ import org.alfresco.service.namespace.QName;
import org.alfresco.service.namespace.RegexQNamePattern;
import org.alfresco.util.DNSNameMangler;
import org.alfresco.util.ParameterCheck;
import org.alfresco.wcm.preview.PreviewURIServiceRegistry;
import org.alfresco.wcm.sandbox.SandboxConstants;
import org.alfresco.wcm.sandbox.SandboxFactory;
import org.alfresco.wcm.sandbox.SandboxInfo;
import org.alfresco.wcm.sandbox.SandboxFactory.UserRoleWrapper;
@@ -101,6 +104,7 @@ public class WebProjectServiceImpl extends WCMUtil implements WebProjectService
private SandboxFactory sandboxFactory;
private VirtServerRegistry virtServerRegistry;
private PreviewURIServiceRegistry previewURIProviderRegistry;
public void setNodeService(NodeService nodeService)
{
@@ -141,13 +145,17 @@ public class WebProjectServiceImpl extends WCMUtil implements WebProjectService
{
this.sandboxFactory = sandboxFactory;
}
public void setVirtServerRegistry(VirtServerRegistry virtServerRegistry)
{
this.virtServerRegistry = virtServerRegistry;
}
public void setPreviewURIServiceRegistry(PreviewURIServiceRegistry previewURIProviderRegistry)
{
this.previewURIProviderRegistry = previewURIProviderRegistry;
}
/* (non-Javadoc)
* @see org.alfresco.wcm.WebProjectService#createWebProject(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
*/
@@ -169,8 +177,25 @@ public class WebProjectServiceImpl extends WCMUtil implements WebProjectService
*/
public WebProjectInfo createWebProject(String dnsName, String name, String title, String description, String defaultWebApp, boolean useAsTemplate, NodeRef sourceNodeRef)
{
return createWebProject(new WebProjectInfoImpl(dnsName, name, title, description, defaultWebApp, useAsTemplate, sourceNodeRef, null));
}
public WebProjectInfo createWebProject(WebProjectInfo wpInfo)
{
String wpStoreId = wpInfo.getStoreId();
String name = wpInfo.getName();
String title = wpInfo.getTitle();
String description = wpInfo.getDescription();
boolean useAsTemplate = wpInfo.isTemplate();
NodeRef sourceNodeRef = wpInfo.getNodeRef();
String defaultWebApp = wpInfo.getDefaultWebApp();
String previewProviderName = wpInfo.getPreviewProviderName();
ParameterCheck.mandatoryString("wpStoreId", wpStoreId);
ParameterCheck.mandatoryString("name", name);
// Generate web project store id (an AVM store name)
String wpStoreId = DNSNameMangler.MakeDNSName(dnsName);
wpStoreId = DNSNameMangler.MakeDNSName(wpStoreId);
if (wpStoreId.indexOf(WCMUtil.STORE_SEPARATOR) != -1)
{
@@ -182,9 +207,26 @@ public class WebProjectServiceImpl extends WCMUtil implements WebProjectService
throw new IllegalArgumentException("Unexpected store id '"+wpStoreId+"' - should not contain '"+WCMUtil.AVM_STORE_SEPARATOR+"'");
}
if (previewProviderName == null)
{
// default preview URI service provider
previewProviderName = previewURIProviderRegistry.getDefaultProviderName();
}
else if (! previewURIProviderRegistry.getPreviewURIServiceProviders().keySet().contains(previewProviderName))
{
throw new AlfrescoRuntimeException("Cannot update web project '" + wpInfo.getStoreId() + "' - unknown preview URI service provider ("+previewProviderName+")");
}
// default webapp name
defaultWebApp = (defaultWebApp != null && defaultWebApp.length() != 0) ? defaultWebApp : WCMUtil.DIR_ROOT;
// create the website space in the correct parent folder
Map<QName, Serializable> props = new HashMap<QName, Serializable>(1);
props.put(ContentModel.PROP_NAME, name);
props.put(WCMAppModel.PROP_ISSOURCE, useAsTemplate);
props.put(WCMAppModel.PROP_DEFAULTWEBAPP, defaultWebApp);
props.put(WCMAppModel.PROP_AVMSTORE, wpStoreId); // reference to the root AVM store
props.put(WCMAppModel.PROP_PREVIEW_PROVIDER, previewProviderName);
ChildAssociationRef childAssocRef = nodeService.createNode(
getWebProjectsRoot(),
@@ -203,16 +245,6 @@ public class WebProjectServiceImpl extends WCMUtil implements WebProjectService
uiFacetsProps.put(ContentModel.PROP_DESCRIPTION, description);
nodeService.addAspect(wpNodeRef, ApplicationModel.ASPECT_UIFACETS, uiFacetsProps);
// use as template source flag
nodeService.setProperty(wpNodeRef, WCMAppModel.PROP_ISSOURCE, useAsTemplate);
// set the default webapp name for the project
defaultWebApp = (defaultWebApp != null && defaultWebApp.length() != 0) ? defaultWebApp : WCMUtil.DIR_ROOT;
nodeService.setProperty(wpNodeRef, WCMAppModel.PROP_DEFAULTWEBAPP, defaultWebApp);
// set the property on the node to reference the root AVM store
nodeService.setProperty(wpNodeRef, WCMAppModel.PROP_AVMSTORE, wpStoreId);
// branch from source web project, if supplied
String branchStoreId = null;
if (sourceNodeRef != null)
@@ -223,10 +255,11 @@ public class WebProjectServiceImpl extends WCMUtil implements WebProjectService
// create the AVM staging store to represent the newly created location website
sandboxFactory.createStagingSandbox(wpStoreId, wpNodeRef, branchStoreId); // ignore return, fails if web project already exists
String stagingStore = WCMUtil.buildStagingStoreName(wpStoreId);
// create the default webapp folder under the hidden system folders
if (branchStoreId == null)
{
String stagingStore = WCMUtil.buildStagingStoreName(wpStoreId);
String stagingStoreRoot = WCMUtil.buildSandboxRootPath(stagingStore);
avmService.createDirectory(stagingStoreRoot, defaultWebApp);
avmService.addAspect(AVMNodeConverter.ExtendAVMPath(stagingStoreRoot, defaultWebApp), WCMAppModel.ASPECT_WEBAPP);
@@ -235,8 +268,10 @@ public class WebProjectServiceImpl extends WCMUtil implements WebProjectService
// now the sandbox is created set the permissions masks for the store
sandboxFactory.setStagingPermissionMasks(wpStoreId);
// set the property on the node to reference the root AVM store
nodeService.setProperty(wpNodeRef, WCMAppModel.PROP_AVMSTORE, wpStoreId);
// set preview provider on staging store (used for preview lookup)
avmService.setStoreProperty(stagingStore,
SandboxConstants.PROP_WEB_PROJECT_PREVIEW_PROVIDER,
new PropertyValue(DataTypeDefinition.TEXT, previewProviderName));
// inform the locking service about this new instance
avmLockingService.addWebProject(wpStoreId);
@@ -261,8 +296,7 @@ public class WebProjectServiceImpl extends WCMUtil implements WebProjectService
}
// Return created web project info
WebProjectInfo wpInfo = new WebProjectInfoImpl(name, title, description, wpStoreId, defaultWebApp, useAsTemplate, wpNodeRef);
return wpInfo;
return new WebProjectInfoImpl(wpStoreId, name, title, description, defaultWebApp, useAsTemplate, wpNodeRef, previewProviderName);
}
/* (non-Javadoc)
@@ -371,6 +405,8 @@ public class WebProjectServiceImpl extends WCMUtil implements WebProjectService
// get AVM store name of the staging sandbox
final String wpStoreId = wpInfo.getStoreId();
WCMUtil.removeVServerWebapp(virtServerRegistry, WCMUtil.buildStoreWebappPath(wpStoreId, webAppName), true);
AuthenticationUtil.runAs(new RunAsWork<Object>()
{
public Object doWork() throws Exception
@@ -525,6 +561,38 @@ public class WebProjectServiceImpl extends WCMUtil implements WebProjectService
return result;
}
/* (non-Javadoc)
* @see org.alfresco.wcm.webproject.WebProjectService#getPreviewProvider(java.lang.String)
*/
public String getPreviewProvider(String wpStoreId)
{
ParameterCheck.mandatoryString("wpStoreId", wpStoreId);
String previewProviderName = null;
try
{
String stagingStoreId = WCMUtil.buildStagingStoreName(wpStoreId);
PropertyValue pValue = avmService.getStoreProperty(stagingStoreId, SandboxConstants.PROP_WEB_PROJECT_PREVIEW_PROVIDER);
if (pValue != null)
{
previewProviderName = (String)pValue.getValue(DataTypeDefinition.TEXT);
}
}
catch (AVMNotFoundException nfe)
{
logger.warn(wpStoreId + " is not a web project: " + nfe);
}
if (previewProviderName == null)
{
previewProviderName = previewURIProviderRegistry.getDefaultProviderName();
}
return previewProviderName;
}
/* (non-Javadoc)
* @see org.alfresco.wcm.webproject.WebProjectService#getWebProject(org.alfresco.service.cmr.repository.NodeRef)
*/
@@ -544,9 +612,10 @@ public class WebProjectServiceImpl extends WCMUtil implements WebProjectService
String wpStoreId = (String)properties.get(WCMAppModel.PROP_AVMSTORE);
String defaultWebApp = (String)properties.get(WCMAppModel.PROP_DEFAULTWEBAPP);
Boolean useAsTemplate = (Boolean)properties.get(WCMAppModel.PROP_ISSOURCE);
String previewProvider = (String)properties.get(WCMAppModel.PROP_PREVIEW_PROVIDER);
// Create and return the web project info
WebProjectInfo wpInfo = new WebProjectInfoImpl(name, title, description, wpStoreId, defaultWebApp, useAsTemplate, wpNodeRef);
WebProjectInfo wpInfo = new WebProjectInfoImpl(wpStoreId, name, title, description, defaultWebApp, useAsTemplate, wpNodeRef, previewProvider);
return wpInfo;
}
@@ -558,7 +627,21 @@ public class WebProjectServiceImpl extends WCMUtil implements WebProjectService
NodeRef wpNodeRef = getWebProjectNodeFromStore(wpInfo.getStoreId());
if (wpNodeRef == null)
{
throw new AlfrescoRuntimeException("Cannot update web project '" + wpInfo.getStoreId() + "' because it does not exist.");
throw new AlfrescoRuntimeException("Cannot update web project '" + wpInfo.getStoreId() + "' - it does not exist.");
}
if (! listWebApps(wpNodeRef).contains(wpInfo.getDefaultWebApp()))
{
throw new AlfrescoRuntimeException("Cannot update web project '" + wpInfo.getStoreId() + "' - unknown default web app ("+wpInfo.getDefaultWebApp()+")");
}
if (wpInfo.getPreviewProviderName() == null)
{
wpInfo.setPreviewProviderName(previewURIProviderRegistry.getDefaultProviderName());
}
else if (! previewURIProviderRegistry.getPreviewURIServiceProviders().keySet().contains(wpInfo.getPreviewProviderName()))
{
throw new AlfrescoRuntimeException("Cannot update web project '" + wpInfo.getStoreId() + "' - unknown preview URI service provider ("+wpInfo.getPreviewProviderName()+")");
}
// Note: the site preset and short name can not be updated
@@ -571,9 +654,18 @@ public class WebProjectServiceImpl extends WCMUtil implements WebProjectService
properties.put(ContentModel.PROP_DESCRIPTION, wpInfo.getDescription());
properties.put(WCMAppModel.PROP_DEFAULTWEBAPP, wpInfo.getDefaultWebApp());
properties.put(WCMAppModel.PROP_ISSOURCE, wpInfo.isTemplate());
properties.put(WCMAppModel.PROP_PREVIEW_PROVIDER, wpInfo.getPreviewProviderName());
this.nodeService.setProperties(wpNodeRef, properties);
// set preview provider on staging store (used for preview lookup)
String stagingStore = WCMUtil.buildStagingStoreName(wpInfo.getStoreId());
avmService.deleteStoreProperty(stagingStore, SandboxConstants.PROP_WEB_PROJECT_PREVIEW_PROVIDER);
avmService.setStoreProperty(stagingStore,
SandboxConstants.PROP_WEB_PROJECT_PREVIEW_PROVIDER,
new PropertyValue(DataTypeDefinition.TEXT, wpInfo.getPreviewProviderName()));
if (logger.isDebugEnabled())
{
logger.debug("Updated web project: " + wpNodeRef + " (store id: " + wpInfo.getStoreId() + ")");

View File

@@ -457,7 +457,7 @@ public class WebProjectServiceImplTest extends AbstractWCMServiceImplTest
public void testUpdateWebProject()
{
WebProjectInfo wpInfo = new WebProjectInfoImpl(TEST_WEBPROJ_DNS+"-update", TEST_WEBPROJ_NAME+"-update", TEST_WEBPROJ_TITLE, TEST_WEBPROJ_DESCRIPTION, TEST_WEBPROJ_DEFAULT_WEBAPP, false, null);
WebProjectInfo wpInfo = new WebProjectInfoImpl(TEST_WEBPROJ_DNS+"-update", TEST_WEBPROJ_NAME+"-update", TEST_WEBPROJ_TITLE, TEST_WEBPROJ_DESCRIPTION, TEST_WEBPROJ_DEFAULT_WEBAPP, false, null, null);
try
{

View File

@@ -0,0 +1,22 @@
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans>
<bean id="previewURIServiceRegistry" class="org.alfresco.wcm.preview.PreviewURIServiceRegistryImpl">
<property name="defaultProviderName">
<value>Virtualisation Server Preview</value>
</property>
<property name="previewURIServiceProvidersByName">
<map>
<entry key="Virtualisation Server Preview">
<ref bean="virtServerPreviewURIService"/>
</entry>
<entry key="NOOP Preview">
<ref bean="nullPreviewURIService"/>
</entry>
</map>
</property>
</bean>
</beans>