Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PAYARA-1713 Add occupied context roots to virtual server list #1709

Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -444,5 +444,85 @@ public static void getHistoricHealthcheckMessages(HandlerContext handlerCtx){
}
handlerCtx.setOutputValue("result", messages);
}

/**
* Gets the context roots of all deployed applications on the domain.
* This is outputted as List<Map<String, String>> for usage within the Virtual-Servers page.
* @param handlerCtx
*/
@Handler(id = "py.getVirtualServersAttributes",
input = {
@HandlerInput(name = "configName", type = String.class, required = true),
@HandlerInput(name = "sessionScopeRestURL", type = String.class, required = true),
@HandlerInput(name = "parentEndpoint", type = String.class, required = true),
@HandlerInput(name = "childType", type = String.class, required = true),
@HandlerInput(name = "skipList", type = List.class, required = false),
@HandlerInput(name = "includeList", type = List.class, required = false),
@HandlerInput(name = "id", type = String.class, required = true)},
output = {
@HandlerOutput(name = "result", type = java.util.List.class)
})
public static void getVirtualServersAttributes(HandlerContext handlerCtx) {
String parentEndpoint = (String) handlerCtx.getInputValue("parentEndpoint");
String childType = (String) handlerCtx.getInputValue("childType");
String configName = (String) handlerCtx.getInputValue("configName");
String sessionScopeRestURL = (String) handlerCtx.getInputValue("sessionScopeRestURL");
sessionScopeRestURL = sessionScopeRestURL.endsWith("/") ? sessionScopeRestURL : sessionScopeRestURL + "/";
String serverName = "";

try {
List<Map> table = RestUtil.buildChildEntityList(
(String)handlerCtx.getInputValue("parentEndpoint"),
(String)handlerCtx.getInputValue("childType"),
(List)handlerCtx.getInputValue("skipList"),
(List)handlerCtx.getInputValue("includeList"),
(String)handlerCtx.getInputValue("id"));

List<String> instances = RestUtil.getChildList(sessionScopeRestURL + "servers/server");
for (String instance : instances) {
String configRef = (String) RestUtil.getAttributesMap(instance).get("configRef");
if (configRef.equals(configName)) {
serverName = instance.substring(instance.lastIndexOf("/") + 1);
}
}

String deployedApplicationsEndpoint = sessionScopeRestURL + "servers/server/" + serverName + "/application-ref";
List<String> deployedApplications = RestUtil.getChildList(deployedApplicationsEndpoint);
List<String> virtualServers = RestUtil.getChildList(parentEndpoint + "/" + childType);
List<String> applications = RestUtil.getChildList(sessionScopeRestURL + "applications/application");

for (String virtualServer : virtualServers) {
String instanceName = virtualServer.substring(virtualServer.lastIndexOf("/") + 1);

for (int i = 0; i < deployedApplications.size(); i++) {
deployedApplications.set(i, deployedApplications.get(i)
.substring(deployedApplications.get(i).lastIndexOf("/") + 1));
}

String contextRoots = "";

for (String application : applications) {
String applicationName = application.substring(application.lastIndexOf("/") + 1);
if (deployedApplications.contains(applicationName)
&& instanceName.equals((String) RestUtil.getAttributesMap(
deployedApplicationsEndpoint + "/" + applicationName).get("virtualServers"))) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploying to multiple virtual servers causes nothing to be displayed! I would split the get(virtualservers) statement on commas and check each value

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done :)

if (!contextRoots.equals("")) {
contextRoots += "<br>" + RestUtil.getAttributesMap(application).get("contextRoot");
} else {
contextRoots += RestUtil.getAttributesMap(application).get("contextRoot");
}
} // else get docroot
}

for (Map row : table) {
if (row.get("name").equals(instanceName)) {
row.put("contextRoot", contextRoots);
}
}
}
handlerCtx.setOutputValue("result", table);
} catch (Exception ex) {
GuiUtil.handleException(handlerCtx, ex);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,87 +40,94 @@

-->

<!-- Portions Copyright [2017] [Payara Foundation and/or its affiliates.] -->

<!-- configuration/virtualServers.jsf -->


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add Payara coyright

<!initPage
setResourceBundle(key="i18n_web" bundle="org.glassfish.web.admingui.Strings");
setResourceBundle(key="help_web" bundle="org.glassfish.web.admingui.Helplinks");
/>
setResourceBundle(key="help_web" bundle="org.glassfish.web.admingui.Helplinks");
/>
<!composition template="/templates/default.layout"
guiTitle="$resource{i18n_web.vs.ListPageTitle}"
guiTemplateOnLoad="admingui.nav.refreshTree('treeForm:tree:configurations:#{pageSession.configName}:virtualServers');">

<!define name="content">
<event>
<event>
<!beforeCreate
getRequestValue(key="configName" value=>$page{configName} );
urlencode(value="#{pageSession.configName}" encoding="UTF-8" result="#{pageSession.encodedConfigName}");
setPageSessionAttribute(key="childType" value="virtual-server");
setPageSessionAttribute(key="parentUrl", value="#{sessionScope.REST_URL}/configs/config/#{pageSession.encodedConfigName}/http-service");
setPageSessionAttribute(key="selfUrl", value="#{pageSession.parentUrl}/#{pageSession.childType}");
setPageSessionAttribute(key="rest-api" value="true");
gf.getChildList(parentEndpoint="#{pageSession.parentUrl}", childType="#{pageSession.childType}", id="id", result="#{requestScope.listOfRows}");
createMap(result="#{pageSession.valueMap}");
mapPut(map="#{pageSession.valueMap}" key="target" value="#{pageSession.configName}");
setPageSessionAttribute(key="confirmDeleteMsg" value="$resource{i18n_web.msg.JS.confirmDeleteVS}");
setPageSessionAttribute(key="createLink" value="#{request.contextPath}/web/configuration/virtualServerNew.jsf?configName=#{configName}");
setPageSessionAttribute(key="listLink" value="#{request.contextPath}/web/configuration/virtualServers.jsf?configName=#{configName}");
setPageSessionAttribute(key="editLink" value="#{request.contextPath}/web/configuration/virtualServerEdit.jsf?configName=#{configName}");
setPageSessionAttribute(key="tableTitle" value="$resource{i18n_web.vs.TableTitle}");
setPageSessionAttribute(key="additionalDeleteHandler" value="checkVsOfAppRef");
setPageSessionAttribute(key="additionalDeleteHandlerArgs" value="");
urlencode(value="#{pageSession.configName}" encoding="UTF-8" result="#{pageSession.encodedConfigName}");
setPageSessionAttribute(key="childType" value="virtual-server");
setPageSessionAttribute(key="parentUrl", value="#{sessionScope.REST_URL}/configs/config/#{pageSession.encodedConfigName}/http-service");
setPageSessionAttribute(key="selfUrl", value="#{pageSession.parentUrl}/#{pageSession.childType}");
setPageSessionAttribute(key="rest-api" value="true");
createMap(result="#{pageSession.valueMap}");
mapPut(map="#{pageSession.valueMap}" key="target" value="#{pageSession.configName}");
setPageSessionAttribute(key="confirmDeleteMsg" value="$resource{i18n_web.msg.JS.confirmDeleteVS}");
setPageSessionAttribute(key="createLink" value="#{request.contextPath}/web/configuration/virtualServerNew.jsf?configName=#{configName}");
setPageSessionAttribute(key="listLink" value="#{request.contextPath}/web/configuration/virtualServers.jsf?configName=#{configName}");
setPageSessionAttribute(key="editLink" value="#{request.contextPath}/web/configuration/virtualServerEdit.jsf?configName=#{configName}");
setPageSessionAttribute(key="tableTitle" value="$resource{i18n_web.vs.TableTitle}");
setPageSessionAttribute(key="additionalDeleteHandler" value="checkVsOfAppRef");
setPageSessionAttribute(key="additionalDeleteHandlerArgs" value="");
py.getVirtualServersAttributes(configName="#{pageSession.configName}" sessionScopeRestURL="#{sessionScope.REST_URL}", parentEndpoint="#{pageSession.parentUrl}", childType="#{pageSession.childType}", id="id", result="#{requestScope.newListOfRows}");
/>
</event>
" <script type="text/javascript">admingui.nav.selectTreeNodeById(admingui.nav.TREE_ID+":configurations:#{pageSession.encodedConfigName}:virtualServers");</script>

</event>
"<script type="text/javascript">admingui.nav.selectTreeNodeById(admingui.nav.TREE_ID + ":configurations:#{pageSession.encodedConfigName}:virtualServers");</script>"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly this one, but there's a " at the top of the virtual servers page!


<sun:form id="propertyForm">
<sun:form id="propertyForm">
#include "/common/shared/alertMsg.inc"
<sun:title id="propertyContentPage" title="$resource{i18n_web.vs.ListPageTitle}"
helpText="$resource{i18n_web.vs.ListPageHelp}" />
<sun:title id="propertyContentPage" title="$resource{i18n_web.vs.ListPageTitle}"
helpText="$resource{i18n_web.vs.ListPageHelp}" />
#include "/common/shared/configNameSection.inc"
<sun:table id="configs" title="#{tableTitle}"
deselectMultipleButton="$boolean{true}"
deselectMultipleButtonOnClick="setTimeout('admingui.table.changeOneTableButton(\\\\\'#{pageSession.topActionGroup}\\\\\', \\\\\'#{pageSession.tableId}\\\\\');', 0)"
selectMultipleButton="$boolean{true}"
selectMultipleButtonOnClick="setTimeout('admingui.table.changeOneTableButton(\\\\\'#{pageSession.topActionGroup}\\\\\', \\\\\'#{pageSession.tableId}\\\\\');', 0)" >
<!afterCreate
getClientId(component="$this{component}" clientId=>$page{tableId});
/>
<sun:table id="configs" title="#{tableTitle}"
deselectMultipleButton="$boolean{true}"
deselectMultipleButtonOnClick="setTimeout('admingui.table.changeOneTableButton(\\\\\'#{pageSession.topActionGroup}\\\\\', \\\\\'#{pageSession.tableId}\\\\\');', 0)"
selectMultipleButton="$boolean{true}"
selectMultipleButtonOnClick="setTimeout('admingui.table.changeOneTableButton(\\\\\'#{pageSession.topActionGroup}\\\\\', \\\\\'#{pageSession.tableId}\\\\\');', 0)" >
<!afterCreate
getClientId(component="$this{component}" clientId=>$page{tableId});
/>

#include "/common/shared/listTableConfigButtons.inc"

<sun:tableRowGroup id="rowGroup1" selected="#{td.value.selected}" data={"$attribute{listOfRows}"} sourceVar="td">
<!afterCreate
getClientId(component="$this{component}" clientId=>$page{tableRowGroupId});
/>
<sun:tableRowGroup id="rowGroup1" selected="#{td.value.selected}" data={"$attribute{newListOfRows}"} sourceVar="td">
<!afterCreate
getClientId(component="$this{component}" clientId=>$page{tableRowGroupId});
/>
<sun:tableColumn headerText="$resource{i18n.common.SelectHeader}" selectId="select" rowHeader="$boolean{false}" id="col0">
<sun:checkbox id="select"
toolTip="$resource{i18n.common.select}"
selected="#{td.value.selected}"
selectedValue="$boolean{true}"
onClick="setTimeout('admingui.table.changeOneTableButton(\\\\\'#{pageSession.topActionGroup}\\\\\', \\\\\'#{pageSession.tableId}\\\\\'); admingui.table.initAllRows(\\\\\'#{pageSession.tableId}\\\\\');', 0);"
/>
<sun:checkbox id="select"
toolTip="$resource{i18n.common.select}"
selected="#{td.value.selected}"
selectedValue="$boolean{true}"
onClick="setTimeout('admingui.table.changeOneTableButton(\\\\\'#{pageSession.topActionGroup}\\\\\', \\\\\'#{pageSession.tableId}\\\\\'); admingui.table.initAllRows(\\\\\'#{pageSession.tableId}\\\\\');', 0);"
/>
</sun:tableColumn>

<sun:tableColumn headerText="$resource{i18n.common.name.header}" sort="name" rowHeader="$boolean{true}" id="col1">
<sun:hyperlink id="link" text="#{td.value.name}"
url="#{pageSession.editLink}&name=#{td.value.name}" />
url="#{pageSession.editLink}&name=#{td.value.name}" />
</sun:tableColumn>

<sun:tableColumn headerText="$resource{i18n_web.vs.StateTableColumn}" sort="state" rowHeader="$boolean{false}" id="col2">
<sun:tableColumn headerText="$resource{i18n_web.vs.StateTableColumn}" sort="state" rowHeader="$boolean{false}" id="col2">
<staticText id="stateCol" value="#{td.value.state}" />
</sun:tableColumn>

<sun:tableColumn headerText="$resource{i18n_web.vs.DefaultWebTableColumn}" sort="defaultWebModule" rowHeader="$boolean{false}" id="col3">
<staticText id="stateCol" value="#{td.value.defaultWebModule}" />
</sun:tableColumn>

<sun:tableColumn headerText="Context Root" sort="contextRoot" rowHeader="$boolean{false}" id="col4">
<staticText id="contextCol" value="#{td.value.contextRoot}" />
</sun:tableColumn>
</sun:tableRowGroup>
</sun:table>
</sun:table>

<sun:hidden id="helpKey" value="$resource{help_web.virtualServers}" />
</sun:form>
"<br>
<sun:hidden id="helpKey" value="$resource{help_web.virtualServers}" />
</sun:form>
"<br>
#include "/common/shared/changeButtonsJS.inc"
</define>
</composition>
Expand Down