. Hooks to notify virtualisation server when the following cases occur to a web project:

- Import of website content
 - Edits/uploads to WEB-INF/web.xml, WEB-INF/lib/*, WEB-INF/classes/*
 - Addition of new user sandbox
 - Removal of a user sandbox
. Fix to generation of website preview url in sandbox display when switching between root webapp folders
. Fix to issue when swapping between web projects that did not contain the same webapp context

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4611 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Kevin Roast
2006-12-14 16:18:32 +00:00
parent 036e58985f
commit 35f25777de
11 changed files with 113 additions and 28 deletions

View File

@@ -142,6 +142,9 @@ public class AVMBrowseBean implements IContextListener
/** Current AVM Node action context */
private AVMNode avmNode = null;
/** The last displayed website node id */
private String lastWebsiteId = null;
/** breadcrumb location */
private List<IBreadcrumbHandler> location = null;
@@ -306,8 +309,7 @@ public class AVMBrowseBean implements IContextListener
FacesContext fc = FacesContext.getCurrentInstance();
ResourceBundle msg = Application.getBundle(fc);
Node websiteNode = this.navigator.getCurrentNode();
String storeRoot = (String)websiteNode.getProperties().get(WCMAppModel.PROP_AVMSTORE);
String storeRoot = (String)getWebsite().getProperties().get(WCMAppModel.PROP_AVMSTORE);
String stagingStore = getStagingStore();
AVMStoreDescriptor store = this.avmService.getAVMStore(stagingStore);
if (store != null)
@@ -335,8 +337,7 @@ public class AVMBrowseBean implements IContextListener
*/
public String getStagingStore()
{
Node websiteNode = this.navigator.getCurrentNode();
String storeRoot = (String)websiteNode.getProperties().get(WCMAppModel.PROP_AVMSTORE);
String storeRoot = (String)getWebsite().getProperties().get(WCMAppModel.PROP_AVMSTORE);
return AVMConstants.buildAVMStagingStoreName(storeRoot);
}
@@ -485,7 +486,7 @@ public class AVMBrowseBean implements IContextListener
}
this.sandboxTitle = MessageFormat.format(Application.getMessage(
FacesContext.getCurrentInstance(), MSG_SANDBOXTITLE),
this.navigator.getCurrentNode().getName(),
getWebsite().getName(),
forUser);
}
return this.sandboxTitle;
@@ -528,6 +529,13 @@ public class AVMBrowseBean implements IContextListener
*/
public Node getWebsite()
{
// check to see if the website we are browsing has changed since the last time
if (this.navigator.getCurrentNodeId().equals(this.lastWebsiteId) == false)
{
// clear context when we are browsing a new website
this.lastWebsiteId = this.navigator.getCurrentNodeId();
this.webapp = null;
}
return this.navigator.getCurrentNode();
}
@@ -631,9 +639,8 @@ public class AVMBrowseBean implements IContextListener
if (user.isAdmin() == false)
{
String currentUser = user.getUserName();
Node websiteNode = this.navigator.getCurrentNode();
List<ChildAssociationRef> userInfoRefs = this.nodeService.getChildAssocs(
websiteNode.getNodeRef(), WCMAppModel.ASSOC_WEBUSER, RegexQNamePattern.MATCH_ALL);
getWebsite().getNodeRef(), WCMAppModel.ASSOC_WEBUSER, RegexQNamePattern.MATCH_ALL);
for (ChildAssociationRef ref : userInfoRefs)
{
NodeRef userInfoRef = ref.getChildRef();

View File

@@ -267,7 +267,7 @@ public final class AVMConstants
*
* @return true if the path should require a virtualisation server reload, false otherwise
*/
public static boolean requiresServerReload(String path)
public static boolean requiresVServerUpdate(String path)
{
if (path == null || path.length() == 0)
{
@@ -277,14 +277,45 @@ public final class AVMConstants
return webinfPathPattern.matcher(path).matches();
}
public static void reloadServerOnPath(String path, boolean force)
/**
* Update notification on the virtualisation server webapp as required for the specified path
*
* @param path Path to match against
* @param force True to force update of server even if path does not match
*/
public static void updateVServerWebapp(String path, boolean force)
{
if (force || requiresServerReload(path))
if (force || requiresVServerUpdate(path))
{
VirtServerRegistry vServerRegistry = (VirtServerRegistry)FacesContextUtils.getRequiredWebApplicationContext(
FacesContext.getCurrentInstance()).getBean(BEAN_VIRT_SERVER_REGISTRY);
int webappindex = path.indexOf('/', path.indexOf(DIR_WEBAPPS) + DIR_WEBAPPS.length() + 1);
vServerRegistry.webappUpdated(-1, path.substring(0, webappindex));
int webappIndex = path.indexOf('/', path.indexOf(DIR_WEBAPPS) + DIR_WEBAPPS.length() + 1);
if (webappIndex != -1)
{
path = path.substring(0, webappIndex);
}
vServerRegistry.webappUpdated(-1, path);
}
}
/**
* Removal notification on the virtualisation server webapp as required for the specified path
*
* @param path Path to match against
* @param force True to force update of server even if path does not match
*/
public static void removeVServerWebapp(String path, boolean force)
{
if (force || requiresVServerUpdate(path))
{
VirtServerRegistry vServerRegistry = (VirtServerRegistry)FacesContextUtils.getRequiredWebApplicationContext(
FacesContext.getCurrentInstance()).getBean(BEAN_VIRT_SERVER_REGISTRY);
int webappIndex = path.indexOf('/', path.indexOf(DIR_WEBAPPS) + DIR_WEBAPPS.length() + 1);
if (webappIndex != -1)
{
path = path.substring(0, webappIndex);
}
vServerRegistry.webappRemoved(-1, path);
}
}
@@ -328,10 +359,7 @@ public final class AVMConstants
// patterns for WEB-INF files that require virtualisation server reload
private final static Pattern webinfPathPattern = Pattern.compile(
".*:/" + AVMConstants.DIR_APPBASE + "/" + AVMConstants.DIR_WEBAPPS + "/.*/WEB-INF/(classes/.*)|(lib/.*)|(web.xml)",
".*:/" + AVMConstants.DIR_APPBASE + "/" + AVMConstants.DIR_WEBAPPS +
"/.*/WEB-INF/((classes/.*)|(lib/.*)|(web.xml))",
Pattern.CASE_INSENSITIVE);
//private final static Pattern webinfLibPattern = Pattern.compile(
// ".*:/" + AVMConstants.DIR_APPBASE + "/" + AVMConstants.DIR_WEBAPPS + "/.*/WEB-INF/lib/.*");
//private final static Pattern webinfWebXmlPattern = Pattern.compile(
// ".*:/" + AVMConstants.DIR_APPBASE + "/" + AVMConstants.DIR_WEBAPPS + "/.*/WEB-INF/web.xml");
}

View File

@@ -397,7 +397,6 @@ public class AVMEditBean
// get an updating writer that we can use to modify the content on the current node
ContentWriter writer = this.contentService.getWriter(avmRef, ContentModel.PROP_CONTENT, true);
if (nodeService.hasAspect(avmRef, WCMAppModel.ASPECT_FORM_INSTANCE_DATA))
{
this.editorOutput = formsService.writeXMLToString(this.instanceDataDocument);
@@ -410,7 +409,6 @@ public class AVMEditBean
// regenerate form content
if (nodeService.hasAspect(avmRef, WCMAppModel.ASPECT_FORM_INSTANCE_DATA))
{
formsService.regenerateRenditions(avmRef);
NodeRef[] uploadedFiles = this.formProcessorSession.getUploadedFiles();
final List<AVMDifference> diffList = new ArrayList<AVMDifference>(uploadedFiles.length);
@@ -425,6 +423,8 @@ public class AVMEditBean
this.avmSyncService.update(diffList, null, true, true, true, true, null, null);
}
AVMConstants.updateVServerWebapp(avmNode.getPath(), false);
resetState();
return AlfrescoNavigationHandler.CLOSE_DIALOG_OUTCOME;

View File

@@ -100,6 +100,11 @@ public class AddAvmContentDialog extends AddContentDialog
writer.putContent(strContent == null ? "" : strContent);
}
// reload the virtualisation server as required
if (logger.isDebugEnabled())
logger.debug("Reloading virtualisation server on path: " + path);
AVMConstants.updateVServerWebapp(path, false);
// remember the created node now
this.createdNode = fileNodeRef;
}

View File

@@ -88,6 +88,10 @@ public class DeleteSandboxDialog extends BaseDialogBean
// remove the association to this web project user meta-data
this.nodeService.removeChild(website.getNodeRef(), ref.getChildRef());
// update virtualisation server for the sandbox removal
String path = AVMConstants.buildAVMStoreWebappPath(sandbox, this.avmBrowseBean.getWebapp());
AVMConstants.removeVServerWebapp(path, true);
break;
}
}

View File

@@ -227,6 +227,9 @@ public class ImportWebsiteDialog
// After an import it's a good idea to snapshot the staging store
this.avmService.createSnapshot(store, "Import of file: " + this.fileName, null);
// Reload virtualisation server as required
AVMConstants.updateVServerWebapp(rootPath, true);
}
}
else

View File

@@ -11,6 +11,7 @@ import java.util.Set;
import javax.faces.context.FacesContext;
import org.alfresco.model.WCMAppModel;
import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
@@ -41,6 +42,17 @@ public class InviteWebsiteUsersWizard extends InviteUsersWizard
/** assume we are launching the wizard standalone */
private boolean standalone = true;
/** AVM Browse Bean reference */
protected AVMBrowseBean avmBrowseBean;
/**
* @param avmBrowseBean The AVMBrowseBean to set.
*/
public void setAvmBrowseBean(AVMBrowseBean avmBrowseBean)
{
this.avmBrowseBean = avmBrowseBean;
}
/**
* @see org.alfresco.web.bean.wizard.InviteUsersWizard#init(java.util.Map)
@@ -129,6 +141,7 @@ public class InviteWebsiteUsersWizard extends InviteUsersWizard
{
SandboxFactory.createUserSandbox(
getAvmStore(), this.managers, userRole.getAuthority(), userRole.getRole());
}
}
@@ -149,6 +162,15 @@ public class InviteWebsiteUsersWizard extends InviteUsersWizard
props);
}
}
// reload virtualisation server for the web project
if (isStandalone())
{
String stagingStore = AVMConstants.buildAVMStagingStoreName(getAvmStore());
String path = AVMConstants.buildAVMStoreWebappPath(stagingStore, this.avmBrowseBean.getWebapp());
AVMConstants.updateVServerWebapp(path, true);
}
return outcome;
}

View File

@@ -277,7 +277,7 @@ public final class SandboxFactory
*/
private static void tagStoreDNSPath(AVMService avmService, String store, String... components)
{
String path = store + ":/" + AVMConstants.DIR_APPBASE + '/' + AVMConstants.DIR_WEBAPPS;
String path = AVMConstants.buildAVMStoreRootPath(store);
// DNS name mangle the property name - can only contain value DNS characters!
String dnsProp = AVMConstants.PROP_DNS + DNSNameMangler.MakeDNSName(components);
avmService.setStoreProperty(store, QName.createQName(null, dnsProp),

View File

@@ -111,6 +111,7 @@ public class UIUserSandboxes extends SelfRenderingComponent
private static final String ROLE_CONTENT_MANAGER = "ContentManager";
private static final String REQUEST_FORM_REF = "formref";
private static final String REQUEST_PREVIEW_REF = "prevhref";
private static final String SPACE_ICON = "/images/icons/" + BrowseBean.SPACE_SMALL_DEFAULT + ".gif";
@@ -334,9 +335,12 @@ public class UIUserSandboxes extends SelfRenderingComponent
// direct actions for a sandbox
String websiteUrl = AVMConstants.buildAVMWebappUrl(mainStore, getWebapp());
Map requestMap = context.getExternalContext().getRequestMap();
requestMap.put(REQUEST_PREVIEW_REF, websiteUrl);
Utils.encodeRecursive(context, aquireAction(
context, mainStore, username, ACT_SANDBOX_PREVIEW, "/images/icons/preview_website.gif",
null, null, websiteUrl, null));
null, null, "#{" + REQUEST_PREVIEW_REF + "}", null));
requestMap.remove(REQUEST_PREVIEW_REF);
out.write("&nbsp;");
Utils.encodeRecursive(context, aquireAction(
@@ -967,8 +971,16 @@ public class UIUserSandboxes extends SelfRenderingComponent
control.setAction(new ConstantMethodBinding(outcome));
}
if (url != null)
{
if (url.startsWith("#{") == true)
{
ValueBinding vb = facesApp.createValueBinding(url);
control.setValueBinding("href", vb);
}
else
{
control.setHref(url);
}
control.setTarget("new");
}

View File

@@ -2284,6 +2284,10 @@
<property-name>authorityService</property-name>
<value>#{AuthorityService}</value>
</managed-property>
<managed-property>
<property-name>avmBrowseBean</property-name>
<value>#{AVMBrowseBean}</value>
</managed-property>
</managed-bean>
<managed-bean>

View File

@@ -78,7 +78,7 @@
<nobr>
<%-- More actions menu --%>
<a:menu id="actions-menu" itemSpacing="4" label="#{msg.actions}" image="/images/icons/menu.gif" menuStyleClass="moreActionsMenu" style="white-space:nowrap">
<r:actions id="acts-website" value="browse_website_menu" context="#{NavigationBean.currentNode}" />
<r:actions id="acts-website" value="browse_website_menu" context="#{AVMBrowseBean.website}" />
</a:menu>
</nobr>
</td>
@@ -183,7 +183,7 @@
<a:panel id="sandboxes-panel" border="white" bgcolor="white" titleBorder="blue" titleBgcolor="#D3E6FE" styleClass="mainSubTitle" label="#{msg.user_sandboxes}">
<%-- User Sandboxes List --%>
<w:userSandboxes id="sandboxes" binding="#{AVMBrowseBean.userSandboxes}" value="#{NavigationBean.currentNode.nodeRef}" webapp="#{AVMBrowseBean.webapp}" />
<w:userSandboxes id="sandboxes" binding="#{AVMBrowseBean.userSandboxes}" value="#{AVMBrowseBean.website.nodeRef}" webapp="#{AVMBrowseBean.webapp}" />
</a:panel>