Skip to content

Commit

Permalink
feature/MGR-114 (#30) node specific configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
juliankahl committed Jun 24, 2021
1 parent c036a1f commit 62814ff
Show file tree
Hide file tree
Showing 16 changed files with 461 additions and 74 deletions.
10 changes: 10 additions & 0 deletions application-home/application.xml
Expand Up @@ -118,6 +118,11 @@
<permission id="cache.elements.list" />
<permission id="cache.statistics.clear" />
<permission id="cache.statistics.list" />
<!-- node -->
<permission id="node.properties" />
<permission id="node.property.create" />
<permission id="node.property.edit" />
<permission id="node.property.delete" />
</role>

<role>
Expand Down Expand Up @@ -316,6 +321,11 @@
<permission id="cache.elements.list">Show a list of cached elements per site</permission>
<permission id="cache.statistics.clear">Clear cache statistics</permission>
<permission id="cache.statistics.list">Show cache statistics per site</permission>
<!-- node -->
<permission id="node.properties">Show a node's properties</permission>
<permission id="node.property.create">Create a node property</permission>
<permission id="node.property.edit">Edit a node property</permission>
<permission id="node.property.delete">Delete a node property</permission>
</permissions>

<properties>
Expand Down
2 changes: 1 addition & 1 deletion application-home/conf/datasources/ds-clusterState.xml
Expand Up @@ -111,7 +111,7 @@
</field>
</meta-data>
<linkpanel location="inline" id="actions">
<link target="/system/${current.nodeId}#tab_clusterState" mode="intern" default="true">
<link target="/system/node/update/${current.nodeId}#tab_clusterState" mode="intern" default="true">
<icon>preview</icon>
<label id="show" />
</link>
Expand Down
62 changes: 62 additions & 0 deletions application-home/conf/datasources/ds-properties.xml
Expand Up @@ -70,6 +70,68 @@
</bean>
</datasource>

<datasource id="node-properties">
<config>
<title>node.properties</title>
<permissions>
<permission ref="node.properties" mode="set" />
</permissions>
<params>
<param name="nodeId" />
<param name="propertyId" />
</params>
<meta-data bindClass="org.appng.api.model.Property" result-selector="${current.name eq propertyId}">
<field name="shortName" type="text" displayLength="50">
<sort name="name" />
<label>name</label>
</field>
<field name="displayValue" type="longtext" displayLength="120">
<label>activeValue</label>
</field>
<field name="description" type="text" displayLength="400">
<label>description</label>
</field>
<field name="changedValue" type="image">
<label></label>
<icon condition="${!current.changedValue}">led_orange</icon>
<icon condition="${current.changedValue}">led_green</icon>
</field>
<field type="linkpanel" name="actions">
<label>actions</label>
</field>
</meta-data>
<linkpanel id="other" location="both">
<link mode="intern" target="/system/node/update/${nodeId}/node-property/create#tab_clusterState">
<label>property.create</label>
<icon>new</icon>
<permissions>
<permission ref="node.property.create" mode="set" />
</permissions>
</link>
</linkpanel>
<linkpanel id="actions" location="inline">
<link mode="intern" target="/system/node/update/${nodeId}/node-property/update/${current.name}#tab_clusterState" default="true">
<label>edit</label>
<icon>edit</icon>
<permissions>
<permission ref="node.property.edit" mode="set" />
</permissions>
</link>
<link mode="intern" target="/system/node/update/${nodeId}/node-property/delete-node-property/${current.name}#tab_clusterState">
<label>delete</label>
<icon>delete</icon>
<confirmation id="property.delete.confirm" params="#{shortName}" />
<permissions>
<permission ref="node.property.delete" mode="set" />
</permissions>
</link>
</linkpanel>
</config>
<bean id="properties">
<option name="properties" nodeId="${nodeId}" />
</bean>
</datasource>

<datasource id="site-properties">
<config>
<title>site.properties</title>
Expand Down
59 changes: 59 additions & 0 deletions application-home/conf/events/ev-properties.xml
Expand Up @@ -61,6 +61,65 @@
</bean>
</action>

<!-- node properties -->
<action id="create-node-property">
<config>
<title>property.create</title>
<permissions>
<permission ref="node.property.create" mode="set" />
</permissions>
<params>
<param name="form_action" />
<param name="nodeId" />
</params>
</config>
<condition expression="${form_action eq 'create-node-property' and not empty nodeId}" />
<datasource id="new-property" />
<bean id="properties">
<option name="action" id="create" />
<option name="properties" nodeId="${nodeId}" />
</bean>
</action>
<action id="update-node-property">
<config>
<title>property.edit</title>
<permissions>
<permission ref="node.property.edit" mode="set" />
</permissions>
<params>
<param name="form_action" />
<param name="propertyId" />
</params>
</config>
<condition expression="${form_action eq 'update-node-property' and not empty propertyId}" />
<datasource id="property">
<params>
<param name="id">${propertyId}</param>
</params>
</datasource>
<bean id="properties">
<option name="property" id="${propertyId}" />
<option name="action" id="update" />
</bean>
</action>
<action id="delete-node-property">
<config>
<title>property.delete</title>
<permissions>
<permission ref="node.property.delete" mode="set" />
</permissions>
<params>
<param name="form_action" />
<param name="propertyId" />
</params>
</config>
<condition expression="${form_action eq 'delete-node-property' and not empty propertyId}" />
<bean id="properties">
<option name="property" id="${propertyId}" />
<option name="action" id="delete" />
</bean>
</action>

<!-- site properties -->
<action id="create-site-property">
<config>
Expand Down
54 changes: 45 additions & 9 deletions application-home/conf/pages/pg-system.xml
Expand Up @@ -13,7 +13,9 @@
<url-param name="entity" />
<url-param name="action" />
<url-param name="id" />
<url-param name="entity2id" />
<url-param name="entity2" />
<url-param name="action2" />
<url-param name="id2" />
</url-params>
<get-params>
<get-param name="action" />
Expand Down Expand Up @@ -88,32 +90,59 @@
<element>
<datasource id="clusterState">
<params>
<param name="nodeId">${entity}</param>
<param name="nodeId">${id}</param>
</params>
</datasource>
</element>
<element>
<datasource id="siteState">
<params>
<param name="nodeId">${entity}</param>
<param name="nodeId">${id}</param>
</params>
<condition expression="${not empty entity}" />
<condition expression="${entity eq 'node' and not empty id}" />
</datasource>
</element>
<element passive="true">
<action id="create-node-property" onSuccess="/system/node/update/${id}#tab_clusterState" eventId="propertyEvent">
<params>
<param name="form_action">${form_action}</param>
<param name="nodeId">${id}</param>
</params>
<condition expression="${entity eq 'node' and action eq 'update' and not empty id and entity2 eq 'node-property' and action2 eq 'create'}" />
</action>
</element>
<element passive="true">
<action id="update-node-property" onSuccess="/system/node/update/${id}#tab_clusterState" eventId="propertyEvent">
<params>
<param name="form_action">${form_action}</param>
<param name="propertyId">${id2}</param>
</params>
<condition expression="${entity eq 'node' and action eq 'update' and not empty id and entity2 eq 'node-property' and action2 eq 'update' and not empty id2}" />
</action>
</element>
<element>
<datasource id="node-properties">
<params>
<param name="nodeId">${id}</param>
<param name="propertyId">${id2}</param>
</params>
<condition expression="${entity eq 'node' and not empty id}" />
</datasource>
</element>
<element>
<datasource id="clusterStateProps">
<params>
<param name="nodeId">${entity}</param>
<param name="nodeId">${id}</param>
</params>
<condition expression="${not empty entity}" />
<condition expression="${entity eq 'node' and not empty id}" />
</datasource>
</element>
<element>
<datasource id="clusterStateEnv">
<params>
<param name="nodeId">${entity}</param>
<param name="nodeId">${id}</param>
</params>
<condition expression="${not empty entity}" />
<condition expression="${entity eq 'node' and not empty id}" />
</datasource>
</element>
</section>
Expand Down Expand Up @@ -146,9 +175,16 @@
</params>
</action>
</element>
<element>
<action eventId="propertyEvent" id="delete-node-property" onSuccess="/system/node/${id}/update#tab_clusterState">
<params>
<param name="form_action">${action2}</param>
<param name="propertyId">${id2}</param>
</params>
</action>
</element>
</section>

</structure>
</page>
</pages>

1 change: 1 addition & 0 deletions application-home/dictionary/manager-messages.properties
Expand Up @@ -172,6 +172,7 @@ migration.success=Migration of database successful!
minConnections=Min. number of connections
mode=Mode
name=Name
node.properties=Node Properties
nodeId=Node ID
nonHeap.max=non-heap max.
nonHeap.used=non-heap used
Expand Down
Expand Up @@ -57,6 +57,7 @@ public class Properties extends ServiceAware implements ActionProvider<PropertyF
public DataContainer getData(Site site, Application application, Environment environment, Options options,
Request request, FieldProcessor fp) {
Service service = getService();
String nodeId = options.getString(PROPERTIES, "nodeId");
Integer siteId = options.getInteger(PROPERTIES, "siteId");
Integer applicationId = options.getInteger(PROPERTIES, "applicationId");
String propertyName = options.getString(PROPERTY, "id");
Expand All @@ -65,7 +66,7 @@ public DataContainer getData(Site site, Application application, Environment env
data = service.getNewProperty(fp);
} else {
try {
data = service.searchProperties(fp, siteId, applicationId, propertyName);
data = service.searchProperties(fp, nodeId, siteId, applicationId, propertyName);
if (null != data.getItem()) {
PropertyForm propertyForm = (PropertyForm) data.getItem();
PropertyWrapper propertyWrapper = new PropertyWrapper(propertyForm.getProperty());
Expand Down Expand Up @@ -123,9 +124,10 @@ public void perform(Site site, Application application, Environment environment,
try {
if (ACTION_CREATE.equals(action)) {
errorMessage = MessageConstants.PROPERTY_CREATE_ERROR;
String nodeId = options.getString(PROPERTIES, "nodeId");
Integer siteId = options.getInteger(PROPERTIES, "siteId");
Integer applicationId = options.getInteger(PROPERTIES, "applicationId");
service.createProperty(request, propertyForm, siteId, applicationId, fp);
service.createProperty(request, propertyForm, nodeId, siteId, applicationId, fp);
okMessage = MessageConstants.PROPERTY_CREATED;
} else if (ACTION_UPDATE.equals(action)) {
errorMessage = MessageConstants.PROPERTY_UPDATE_ERROR;
Expand Down
Expand Up @@ -1485,7 +1485,7 @@ public DataContainer searchPermissions(FieldProcessor fp, Integer permissionId,
return data;
}

public DataContainer searchProperties(FieldProcessor fp, Integer siteId, Integer appId, String propertyName)
public DataContainer searchProperties(FieldProcessor fp, String nodeId, Integer siteId, Integer appId, String propertyName)
throws BusinessException {
DataContainer data = new DataContainer(fp);
if (propertyName != null && propertyName.length() > 0) {
Expand All @@ -1498,21 +1498,31 @@ public DataContainer searchProperties(FieldProcessor fp, Integer siteId, Integer
}
data.setItem(new PropertyForm(property));
} else {
Page<PropertyImpl> properties = getProperties(siteId, appId, fp.getPageable());
Page<PropertyImpl> properties;
Pageable pageable = fp.getPageable();
if (nodeId != null) {
properties = getNodeProperties(nodeId, pageable);
} else {
properties = getProperties(siteId, appId, pageable);
}
data.setPage(properties);
}
return data;
}

public void createProperty(Request request, PropertyForm propertyForm, Integer siteId, Integer appId,
public void createProperty(Request request, PropertyForm propertyForm, String nodeId, Integer siteId, Integer appId,
FieldProcessor fp) throws BusinessException {
try {
PropertyImpl property = propertyForm.getProperty();
if (checkPropertyExists(siteId, appId, property)) {
fp.addErrorMessage(request.getMessage(MessageConstants.PROPERTY_EXISTS));
throw new BusinessException("property already exists!");
if (nodeId != null) {
createNodeProperty(nodeId, property);
} else {
createProperty(siteId, appId, property);
if (checkPropertyExists(siteId, appId, property)) {
fp.addErrorMessage(request.getMessage(MessageConstants.PROPERTY_EXISTS));
throw new BusinessException("property already exists!");
} else {
createProperty(siteId, appId, property);
}
}
} catch (Exception e) {
request.handleException(fp, e);
Expand Down
Expand Up @@ -76,9 +76,9 @@ public interface Service {

void createSubject(Request request, Locale locale, SubjectForm form, FieldProcessor fp, PasswordPolicy policy) throws BusinessException;

void createProperty(Request request, PropertyForm propertyForm, Integer siteId, Integer appId, FieldProcessor fp)
void createProperty(Request request, PropertyForm propertyForm, String nodeId, Integer siteId, Integer appId, FieldProcessor fp)
throws BusinessException;

void createPermission(Request request, PermissionImpl permission, Integer appId, FieldProcessor fp)
throws BusinessException;

Expand Down Expand Up @@ -118,7 +118,7 @@ DataContainer searchSubjects(Request request, FieldProcessor fp, Integer subject

DataContainer searchPermissions(FieldProcessor fp, Integer permissionId, Integer appId) throws BusinessException;

DataContainer searchProperties(FieldProcessor fp, Integer siteId, Integer appId, String propertyName)
DataContainer searchProperties(FieldProcessor fp, String nodeId, Integer siteId, Integer appId, String propertyName)
throws BusinessException;

void updateGroup(Request request, Site site, GroupForm groupForm, FieldProcessor fp) throws BusinessException;
Expand Down

0 comments on commit 62814ff

Please sign in to comment.