MOB-687 - WCM Deployment - Select multiple test servers

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@14337 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Mark Rogers
2009-05-15 15:35:58 +00:00
parent a20914fa8e
commit 8b53e5f3df
7 changed files with 79 additions and 81 deletions

View File

@@ -1228,7 +1228,7 @@ delete_reports_info=To remove all deployment reports in the web project, click Y
delete_reports_confirm=Are you sure you want to delete all deployment reports across all sandboxes in this webproject? delete_reports_confirm=Are you sure you want to delete all deployment reports across all sandboxes in this webproject?
release_server_title=Release Test Server release_server_title=Release Test Server
release_server_info=To release the test server from this sandbox, click Yes. release_server_info=To release the test server from this sandbox, click Yes.
release_server_confirm=Are you sure you want to release the test server allocated to this sandbox? release_server_confirm=Are you sure you want to release the test server(s) allocated to this sandbox?
website_showallsandboxes=Show All Sandboxes website_showallsandboxes=Show All Sandboxes
# Website actions and dialog messages # Website actions and dialog messages

View File

@@ -25,6 +25,7 @@
package org.alfresco.web.bean.wcm; package org.alfresco.web.bean.wcm;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.List;
import javax.faces.context.FacesContext; import javax.faces.context.FacesContext;
@@ -96,8 +97,8 @@ public class DeleteSandboxDialog extends BaseDialogBean
String mainStore = AVMUtil.buildUserMainStoreName(wpStoreId, username); String mainStore = AVMUtil.buildUserMainStoreName(wpStoreId, username);
// if the sandbox is allocated to a test server release it // if the sandbox is allocated to a test server release it
NodeRef testServer = DeploymentUtil.findAllocatedTestServer(mainStore); List<NodeRef> testServers = DeploymentUtil.findAllocatedTestServers(mainStore);
if (testServer != null) for(NodeRef testServer : testServers)
{ {
getNodeService().setProperty(testServer, WCMAppModel.PROP_DEPLOYSERVERALLOCATEDTO, null); getNodeService().setProperty(testServer, WCMAppModel.PROP_DEPLOYSERVERALLOCATEDTO, null);

View File

@@ -230,13 +230,15 @@ public final class DeploymentUtil
} }
/** /**
* Returns the test server allocated to the given store. * Returns the test servers allocated to the given store.
* *
* @param store The store to get the test server for * @param store The store to get the test server for
* @return The allocated server or null if there isn't one * @return The allocated server(s), an empty list if there isn't one
*/ */
public static NodeRef findAllocatedTestServer(String store) public static List<NodeRef> findAllocatedTestServers(String store)
{ {
List<NodeRef>serverList = new ArrayList<NodeRef>();
FacesContext fc = FacesContext.getCurrentInstance(); FacesContext fc = FacesContext.getCurrentInstance();
SearchService searchService = Repository.getServiceRegistry(fc).getSearchService(); SearchService searchService = Repository.getServiceRegistry(fc).getSearchService();
@@ -257,18 +259,12 @@ public final class DeploymentUtil
results = searchService.query(Repository.getStoreRef(), results = searchService.query(Repository.getStoreRef(),
SearchService.LANGUAGE_LUCENE, query.toString()); SearchService.LANGUAGE_LUCENE, query.toString());
if (results.length() == 1) if (results.length() > 0)
{ {
testServer = results.getNodeRef(0); for(int i = 0; i < results.length(); i++)
} {
else if (results.length() > 1) serverList.add(results.getNodeRef(i));
{ }
// get the first one and warn that we found many!
testServer = results.getNodeRef(0);
if (logger.isWarnEnabled())
logger.warn("More than one allocated test server for store '" +
store + "' was found, should only be one, first one found returned!");
} }
} }
finally finally
@@ -279,7 +275,7 @@ public final class DeploymentUtil
} }
} }
return testServer; return serverList;
} }
/** /**

View File

@@ -162,8 +162,8 @@ public class ManageReviewTaskDialog extends ManageTaskDialog
// if a test server has already been allocated inform the dialog // if a test server has already been allocated inform the dialog
// that an update is needed // that an update is needed
NodeRef testServer = DeploymentUtil.findAllocatedTestServer(this.store); List<NodeRef> testServers = DeploymentUtil.findAllocatedTestServers(this.store);
if (testServer != null) if (!testServers.isEmpty())
{ {
params.put("updateTestServer", "true"); params.put("updateTestServer", "true");
} }

View File

@@ -24,6 +24,7 @@
*/ */
package org.alfresco.web.bean.wcm; package org.alfresco.web.bean.wcm;
import java.util.List;
import java.util.Map; import java.util.Map;
import javax.faces.context.FacesContext; import javax.faces.context.FacesContext;
@@ -70,8 +71,8 @@ public class ReleaseTestServerDialog extends BaseDialogBean
protected String finishImpl(FacesContext context, String outcome) protected String finishImpl(FacesContext context, String outcome)
throws Exception throws Exception
{ {
NodeRef testServer = DeploymentUtil.findAllocatedTestServer(this.store); List<NodeRef> testServers = DeploymentUtil.findAllocatedTestServers(this.store);
if (testServer != null) for(NodeRef testServer : testServers)
{ {
getNodeService().setProperty(testServer, getNodeService().setProperty(testServer,
WCMAppModel.PROP_DEPLOYSERVERALLOCATEDTO, null); WCMAppModel.PROP_DEPLOYSERVERALLOCATEDTO, null);

View File

@@ -244,40 +244,63 @@ public class UIDeployWebsite extends UIInput
// been removed then show a list of available test servers to choose // been removed then show a list of available test servers to choose
// from. // from.
NodeRef allocatedServer = DeploymentUtil.findAllocatedTestServer(getStore()); List<NodeRef> allocatedServers = DeploymentUtil.findAllocatedTestServers(getStore());
if (allocatedServer != null) if (!allocatedServers.isEmpty())
{ {
// there is an allocated server // there is at least one allocated server
renderAllocatedTestServer(context, out, nodeService, allocatedServer); for(NodeRef allocatedServer : allocatedServers)
{
renderAllocatedTestServer(context, out, nodeService, allocatedServer);
}
} }
else else
{ {
// a test server needs to be selected - display the list of test servers // a test server(s) needs to be selected - display the list of test servers
List<NodeRef> refs = DeploymentUtil.findTestServers(webProject, true); List<NodeRef> refs = DeploymentUtil.findTestServers(webProject, true);
// Resolve the unsorted list of NodeRef to a sorted list of DeploymentServerConfig. // Resolve the unsorted list of NodeRef to a sorted list of DeploymentServerConfig.
List<DeploymentServerConfig> servers = toSortedDeploymentServerConfig(nodeService, refs); List<DeploymentServerConfig> servers = toSortedDeploymentServerConfig(nodeService, refs);
if (servers.size() > 0) if (servers.size() > 0)
{ {
boolean first = true; ParentChildCheckboxHelper helper = new ParentChildCheckboxHelper(this.getClientId(context));
String currentDisplayGroup = ""; //boolean first = true;
//String currentDisplayGroup = "";
boolean selected = false;
for (DeploymentServerConfig server: servers) for (DeploymentServerConfig server: servers)
{ {
// Write the display group title if it is a new title // Get the display group
String displayGroup = (String)server.getProperties().get(DeploymentServerConfig.PROP_GROUP); String displayGroup = (String)server.getProperties().get(DeploymentServerConfig.PROP_GROUP);
if(!currentDisplayGroup.equalsIgnoreCase(displayGroup))
{ helper.setCurrentDisplayGroup(displayGroup);
// yes title has changed - write out the new displayGroup if(helper.newGroup)
out.write("<p class='mainSubTitle'>"); {
out.write(displayGroup); out.write("<p class='mainSubTitle'>");
out.write("</p>"); out.write("<input type='checkbox' id='");
currentDisplayGroup = displayGroup; out.write(helper.groupParentId);
} out.write("' value='");
renderTestServer(context, out, nodeService, server.getServerRef(), first); out.write(displayGroup);
first = false; out.write("'");
out.write(" ");
out.write("onClick=\"select_all(\'");
out.write(helper.groupChildName);
out.write("\', this.checked);\" ");
out.write(" /> ");
out.write(displayGroup);
out.write("</p>");
}
if(helper.groupParentId.length() > 0)
{
// render the test server with a child checkbox
renderCheckableServer(context, out, nodeService, server.getServerRef(), selected, helper.groupChildName, helper.groupParentId);
}
else
{
// render the test server without a parent checkbox
renderCheckableServer(context, out, nodeService, server.getServerRef(), selected, this.getClientId(context));
}
} }
} }
else else
@@ -341,12 +364,12 @@ public class UIDeployWebsite extends UIInput
if(helper.groupParentId.length() > 0) if(helper.groupParentId.length() > 0)
{ {
// render the live server with a child checkbox // render the live server with a child checkbox
renderLiveServer(context, out, nodeService, server.getServerRef(), selected, helper.groupChildName, helper.groupParentId); renderCheckableServer(context, out, nodeService, server.getServerRef(), selected, helper.groupChildName, helper.groupParentId);
} }
else else
{ {
// render the live server without a parent checkbox // render the live server without a parent checkbox
renderLiveServer(context, out, nodeService, server.getServerRef(), selected, this.getClientId(context)); renderCheckableServer(context, out, nodeService, server.getServerRef(), selected, this.getClientId(context));
} }
} }
} }
@@ -552,13 +575,13 @@ public class UIDeployWebsite extends UIInput
out.write("</script>\n"); out.write("</script>\n");
} }
private void renderLiveServer(FacesContext context, ResponseWriter out, NodeService nodeService, private void renderCheckableServer(FacesContext context, ResponseWriter out, NodeService nodeService,
NodeRef server, boolean selected, String checkBoxName) throws IOException NodeRef server, boolean selected, String checkBoxName) throws IOException
{ {
renderLiveServer(context, out, nodeService, server, selected, checkBoxName, ""); renderCheckableServer(context, out, nodeService, server, selected, checkBoxName, "");
} }
private void renderLiveServer(FacesContext context, ResponseWriter out, NodeService nodeService, private void renderCheckableServer(FacesContext context, ResponseWriter out, NodeService nodeService,
NodeRef server, boolean selected, String checkBoxName, String parentId) throws IOException NodeRef server, boolean selected, String checkBoxName, String parentId) throws IOException
{ {
String contextPath = context.getExternalContext().getRequestContextPath(); String contextPath = context.getExternalContext().getRequestContextPath();
@@ -596,41 +619,18 @@ public class UIDeployWebsite extends UIInput
renderPanelMiddle(out, contextPath, nodeService, server, true); renderPanelMiddle(out, contextPath, nodeService, server, true);
if (selected == false) // if (selected == false)
{ // {
out.write("<div class='deployPanelServerStatus'><img src='"); // out.write("<div class='deployPanelServerStatus'><img src='");
out.write(contextPath); // out.write(contextPath);
out.write("/images/icons/info_icon.gif' style='vertical-align: -5px;' />&nbsp;"); // out.write("/images/icons/info_icon.gif' style='vertical-align: -5px;' />&nbsp;");
out.write(Application.getMessage(context, "deploy_server_not_selected")); // out.write(Application.getMessage(context, "deploy_server_not_selected"));
out.write("</div>"); // out.write("</div>");
} // }
renderPanelEnd(out, contextPath); renderPanelEnd(out, contextPath);
} }
private void renderTestServer(FacesContext context, ResponseWriter out, NodeService nodeService,
NodeRef server, boolean selected) throws IOException
{
String contextPath = context.getExternalContext().getRequestContextPath();
renderPanelStart(out, contextPath);
out.write("<div class='deployPanelControl'>");
out.write("<input type='radio' name='");
out.write(this.getClientId(context));
out.write("' value='");
out.write(server.toString());
out.write("'");
if (selected)
{
out.write(" checked='checked'");
}
out.write(" /></div>");
renderPanelMiddle(out, contextPath, nodeService, server, true);
renderPanelEnd(out, contextPath);
}
private void renderAllocatedTestServer(FacesContext context, ResponseWriter out, NodeService nodeService, private void renderAllocatedTestServer(FacesContext context, ResponseWriter out, NodeService nodeService,
NodeRef server) throws IOException NodeRef server) throws IOException
{ {

View File

@@ -416,8 +416,8 @@ public class UIUserSandboxes extends SelfRenderingComponent implements Serializa
logger.debug("Building sandbox view for user store: " + mainStore); logger.debug("Building sandbox view for user store: " + mainStore);
// determine if the sandbox has an allocated test server for deployment // determine if the sandbox has an allocated test server for deployment
NodeRef testServer = DeploymentUtil.findAllocatedTestServer(mainStore); List<NodeRef> testServers = DeploymentUtil.findAllocatedTestServers(mainStore);
boolean hasAllocatedTestServer = (testServer != null); boolean hasAllocatedTestServer = (!testServers.isEmpty());
// determine if there are any previous deployment attempts // determine if there are any previous deployment attempts
List<NodeRef> deployAttempts = DeploymentUtil.findDeploymentAttempts(mainStore); List<NodeRef> deployAttempts = DeploymentUtil.findDeploymentAttempts(mainStore);