Merged V3.1 to HEAD

14077: Merged V2.2 to V3.1
        14074: Fix ETWOTWO-929 and ETWOTWO-1175 (WCM preview)


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@14568 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jan Vonka
2009-06-05 17:12:00 +00:00
parent 9c1d8b616d
commit 50827e1bbb
11 changed files with 49 additions and 54 deletions

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
@@ -299,20 +299,9 @@ public final class AVMUtil extends WCMUtil
: buildStoreUrl(store) + '/' + webapp);
}
public static String buildAssetUrl(final String avmPath)
{
if (avmPath == null || avmPath.length() == 0)
{
throw new IllegalArgumentException("AVM path is mandatory.");
}
final String[] s = avmPath.split(":");
if (s.length != 2)
{
throw new IllegalArgumentException("expected exactly one ':' in " + avmPath);
}
return AVMUtil.buildAssetUrl(s[0], s[1]);
}
/**
* NOTE: do not call directly from client - use getPreviewURI instead
*/
public static String buildAssetUrl(String store, String assetPath)
{
if (store == null || store.length() == 0)
@@ -332,6 +321,24 @@ public final class AVMUtil extends WCMUtil
return WCMUtil.buildAssetUrl(assetPath, domain, port, dns);
}
public static String getPreviewURI(String storeNameOrAvmPath)
{
if (storeNameOrAvmPath == null || storeNameOrAvmPath.length() == 0)
{
throw new IllegalArgumentException("AVM store name or absolute path is mandatory.");
}
final String[] s = storeNameOrAvmPath.split(AVM_STORE_SEPARATOR);
if (s.length == 1)
{
return AVMUtil.getPreviewURI(s[0], null);
}
if (s.length != 2)
{
throw new IllegalArgumentException("expected exactly one ':' in " + storeNameOrAvmPath);
}
return AVMUtil.getPreviewURI(s[0], s[1]);
}
public static String getPreviewURI(final String storeId, final String assetPath)
{
if (previewURIGenerator == null)

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
* Copyright (C) 2005-2009 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -143,7 +143,7 @@ public class FileDetailsBean extends AVMDetailsBean
*/
public String getPreviewUrl()
{
return AVMUtil.buildAssetUrl(getAvmNode().getPath());
return AVMUtil.getPreviewURI(getAvmNode().getPath());
}
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
* Copyright (C) 2005-2009 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -66,7 +66,7 @@ public class FolderDetailsBean extends AVMDetailsBean
*/
public String getPreviewUrl()
{
return AVMUtil.buildAssetUrl(getAvmNode().getPath());
return AVMUtil.getPreviewURI(getAvmNode().getPath());
}
/**

View File

@@ -65,7 +65,6 @@ import org.alfresco.web.app.servlet.FacesHelper;
import org.alfresco.web.bean.BrowseBean;
import org.alfresco.web.bean.dialog.BaseDialogBean;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.config.ClientConfigElement;
import org.alfresco.web.forms.FormInstanceData;
import org.alfresco.web.forms.FormsService;
import org.alfresco.web.forms.Rendition;
@@ -1045,12 +1044,7 @@ public class SubmitDialog extends BaseDialogBean
public String getPreviewUrl()
{
ClientConfigElement config = Application.getClientConfig(FacesContext.getCurrentInstance());
String dns = AVMUtil.lookupStoreDNS(AVMUtil.getStoreName(descriptor.getPath()));
return AVMUtil.buildAssetUrl(AVMUtil.getSandboxRelativePath(descriptor.getPath()),
config.getWCMDomain(),
config.getWCMPort(),
dns);
return AVMUtil.getPreviewURI(descriptor.getPath());
}
public AVMNodeDescriptor getDescriptor()

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
@@ -36,7 +36,7 @@ public interface PreviewURIService
{
/**
* @param storeId The id of the store to generate the preview URI for.
* @param pathToAsset The path to the asset to generate the preview URI for.
* @param pathToAsset The path to the asset to generate the preview URI for (can be null or empty, to return preview URL to store)
* @return The Preview URI for the given store id and/or asset (<i>may be null</i>).
*/
String getPreviewURI(String storeId, String pathToAsset);

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
@@ -43,13 +43,18 @@ public class VirtualisationServerPreviewURIService
*/
public String getPreviewURI(final String storeId, final String pathToAsset)
{
if ((pathToAsset == null) || (pathToAsset.length() == 0))
{
return AVMUtil.buildStoreUrl(storeId);
}
// Sanity checking
if (!pathToAsset.startsWith('/' + JNDIConstants.DIR_DEFAULT_WWW + '/' + JNDIConstants.DIR_DEFAULT_APPBASE))
{
throw new IllegalStateException("Invalid asset path in AVM node ref: " + storeId + ":" + pathToAsset);
}
return(AVMUtil.buildAssetUrl(storeId, pathToAsset));
return AVMUtil.buildAssetUrl(storeId, pathToAsset);
}
}