KEYCLOAK-274 Compact JSON String. Get resource name from DMR.

This commit is contained in:
Stan Silvert 2014-01-30 09:05:27 -05:00
parent c81a08385f
commit c7112dc19f
2 changed files with 3 additions and 9 deletions

View file

@ -58,10 +58,7 @@ public class KeycloakAdapterConfigDeploymentProcessor implements DeploymentUnitP
DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit(); DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY); WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
//TODO: Find context root properly addJSONData(service.getJSON(deploymentName), warMetaData);
String resourceName = deploymentName.substring(0, deploymentName.lastIndexOf('.'));
addJSONData(service.getJSON(deploymentName, resourceName), warMetaData);
//addJSONData(getJSON(), warMetaData); //addJSONData(getJSON(), warMetaData);
} }

View file

@ -161,21 +161,18 @@ public class KeycloakAdapterConfigService implements Service<KeycloakAdapterConf
return null; return null;
} }
public String getJSON(String deploymentName, String resourceName) { public String getJSON(String deploymentName) {
ModelNode deployment = this.deployments.get(deploymentName); ModelNode deployment = this.deployments.get(deploymentName);
String realmName = deployment.get(RealmDefinition.TAG_NAME).asString(); String realmName = deployment.get(RealmDefinition.TAG_NAME).asString();
ModelNode realm = this.realms.get(realmName); ModelNode realm = this.realms.get(realmName);
ModelNode json = new ModelNode(); ModelNode json = new ModelNode();
json.get(RealmDefinition.TAG_NAME).set(realmName); json.get(RealmDefinition.TAG_NAME).set(realmName);
json.get("resource").set(resourceName);
// Realm values set first. Some can be overridden by deployment values. // Realm values set first. Some can be overridden by deployment values.
setJSONValues(json, realm); setJSONValues(json, realm);
setJSONValues(json, deployment); setJSONValues(json, deployment);
return json.toJSONString(true);
// TODO: change this to true to compact the string
return json.toJSONString(false);
} }
private void setJSONValues(ModelNode json, ModelNode values) { private void setJSONValues(ModelNode json, ModelNode values) {