Commit 5c31dce5 authored by Gianluca Filippone's avatar Gianluca Filippone
Browse files

Fixed EE selection behavior

parent 7fb4ffd1
...@@ -577,7 +577,7 @@ we are happy to inform you that the password request was execute successfully fo ...@@ -577,7 +577,7 @@ we are happy to inform you that the password request was execute successfully fo
<SyncopeSchema id="status"/> <SyncopeSchema id="status"/>
<PlainSchema id="status" mandatoryCondition="true" <PlainSchema id="status" mandatoryCondition="true"
multivalue="0" readonly="0" type="Enum" uniqueConstraint="0" enumerationValues="PENDING CREATE;PENDING UPDATE;PENDING ENACTMENT;STARTED;FROZEN;STOPPED;PENDING DELETE" multivalue="0" readonly="0" type="Enum" uniqueConstraint="0" enumerationValues="CREATED;PENDING UPDATE;PENDING ENACTMENT;STARTED;FROZEN;STOPPED;PENDING DELETE"
anyTypeClass_id="Choreography"/> anyTypeClass_id="Choreography"/>
<SyncopeSchema id="description"/> <SyncopeSchema id="description"/>
......
...@@ -578,7 +578,7 @@ we are happy to inform you that the password request was execute successfully fo ...@@ -578,7 +578,7 @@ we are happy to inform you that the password request was execute successfully fo
   
<SyncopeSchema id="status"/> <SyncopeSchema id="status"/>
<PlainSchema id="status" mandatoryCondition="true" <PlainSchema id="status" mandatoryCondition="true"
multivalue="0" readonly="0" type="Enum" uniqueConstraint="0" enumerationValues="PENDING CREATE;PENDING UPDATE;PENDING ENACTMENT;STARTED;FROZEN;STOPPED;PENDING DELETE" multivalue="0" readonly="0" type="Enum" uniqueConstraint="0" enumerationValues="CREATED;PENDING UPDATE;PENDING ENACTMENT;STARTED;FROZEN;STOPPED;PENDING DELETE"
anyTypeClass_id="Choreography"/> anyTypeClass_id="Choreography"/>
   
<SyncopeSchema id="chorSpec"/> <SyncopeSchema id="chorSpec"/>
...@@ -35,7 +35,6 @@ import org.apache.syncope.common.lib.to.GroupTO; ...@@ -35,7 +35,6 @@ import org.apache.syncope.common.lib.to.GroupTO;
import org.apache.syncope.client.console.wizards.WizardMgtPanel; import org.apache.syncope.client.console.wizards.WizardMgtPanel;
import org.apache.syncope.client.console.wizards.any.AnyWrapper; import org.apache.syncope.client.console.wizards.any.AnyWrapper;
import org.apache.syncope.common.lib.types.AnyTypeKind; import org.apache.syncope.common.lib.types.AnyTypeKind;
import org.apache.syncope.common.lib.types.ClientExceptionType;
import org.apache.syncope.common.lib.types.SchemaType; import org.apache.syncope.common.lib.types.SchemaType;
import org.apache.wicket.PageReference; import org.apache.wicket.PageReference;
import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.ajax.AjaxRequestTarget;
...@@ -157,41 +156,32 @@ public class ChoreographyDirectoryPanel extends GroupDirectoryPanel { ...@@ -157,41 +156,32 @@ public class ChoreographyDirectoryPanel extends GroupDirectoryPanel {
String chorStatus = model.getObject().getPlainAttrMap().get("status").getValues().iterator().next(); String chorStatus = model.getObject().getPlainAttrMap().get("status").getValues().iterator().next();
ChoreographyActionsPanel choreographyActionsPanel = new ChoreographyActionsPanel(componentId); ChoreographyActionsPanel choreographyActionsPanel = new ChoreographyActionsPanel(componentId);
if (chorStatus.equals("PENDING CREATE") || chorStatus.equals("PENDING UPDATE")) { if (chorStatus.equals("CREATED")) {
choreographyActionsPanel.addAction(new IndicatingAjaxLink<Void>("link") { choreographyActionsPanel.addAction(new IndicatingAjaxLink<Void>("link") {
private static final long serialVersionUID = -7978723352517770644L; private static final long serialVersionUID = -7978723352517770644L;
@Override @Override
public void onClick(final AjaxRequestTarget target) { public void onClick(final AjaxRequestTarget target) {
try { try {
String eeKey = choreographyRestClient utilityModal.setContent(new SelectEEModalPanel(
.getChoreographyEE(model.getObject().getKey()).getKey(); utilityModal,
choreographyRestClient.enactChoreography(model.getObject().getKey(), eeKey); model.getObject(),
SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED)); pageRef));
target.add(container); utilityModal.header(Model.of("Select Enactment Engine"));
utilityModal.show(true);
target.add(utilityModal);
} catch (SyncopeClientException e) { } catch (SyncopeClientException e) {
if (e.getType().equals(ClientExceptionType.NotFound)) { LOG.error("While enacting choreography {}", model.getObject().getName(), e);
utilityModal.setContent(new SelectEEModalPanel( SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage())
utilityModal, ? e.getClass().getName() : e.getMessage());
model.getObject(),
pageRef));
utilityModal.header(Model.of("Select Enactment Engine"));
utilityModal.show(true);
target.add(utilityModal);
} else {
LOG.error("While enacting choreography {}", model.getObject().getName(), e);
SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage())
? e.getClass().getName() : e.getMessage());
}
} }
((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target); ((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
} }
}, ChoreographyActionsPanel.ChoreographyActionType.ENACT); }, ChoreographyActionsPanel.ChoreographyActionType.ENACT);
} }
if (!chorStatus.equals("PENDING CREATE") if (!chorStatus.equals("CREATED")
&& !chorStatus.equals("PENDING UPDATE") && !chorStatus.equals("PENDING UPDATE")
&& !chorStatus.equals("PENDING ENACTMENT")) { && !chorStatus.equals("PENDING ENACTMENT")) {
choreographyActionsPanel.addAction(new IndicatingAjaxLink<Void>("link") { choreographyActionsPanel.addAction(new IndicatingAjaxLink<Void>("link") {
......
...@@ -113,12 +113,12 @@ public class SelectEEModalPanel extends AbstractModalPanel<Serializable> { ...@@ -113,12 +113,12 @@ public class SelectEEModalPanel extends AbstractModalPanel<Serializable> {
AnyObjectRestClient anyObjectRestClient = new AnyObjectRestClient(); AnyObjectRestClient anyObjectRestClient = new AnyObjectRestClient();
List<AnyObjectTO> enactmentEngines = anyObjectRestClient.search( List<AnyObjectTO> enactmentEngines = anyObjectRestClient.search(
SyncopeConstants.ROOT_REALM, SyncopeConstants.ROOT_REALM,
new AnyObjectFiqlSearchConditionBuilder("ENACTMENT ENGINE").query(), new AnyObjectFiqlSearchConditionBuilder("ENACTMENT ENGINE").query(),
1, 1,
1, -1,
new SortParam<>("name", false), new SortParam<>("name", false),
"ENACTMENT ENGINE"); "ENACTMENT ENGINE");
setChoiceRenderer(new EnactmentEngineRenderer()); setChoiceRenderer(new EnactmentEngineRenderer());
setChoices(enactmentEngines); setChoices(enactmentEngines);
......
...@@ -16,14 +16,12 @@ limitations under the License. ...@@ -16,14 +16,12 @@ limitations under the License.
--> -->
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org">
<wicket:panel> <wicket:panel>
<span wicket:id="container"> <div wicket:id="container">
<div class="form-group"> <form wicket:id="resizeChoreographyForm">
<form wicket:id="resizeChoreographyForm"> <div class="form-group">
<div class="form-group"> <span wicket:id="size"/>
<span wicket:id="size"/> </div>
</div> </form>
</form> </div>
</div>
</span>
</wicket:panel> </wicket:panel>
</html> </html>
\ No newline at end of file
...@@ -15,15 +15,24 @@ See the License for the specific language governing permissions and ...@@ -15,15 +15,24 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
--> -->
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org">
<wicket:head>
<style>
div.spacer {
height: 100px;
}
</style>
</wicket:head>
<wicket:panel> <wicket:panel>
<span wicket:id="container"> <span wicket:id="container">
<div class="form-group"> <form wicket:id="selectEEForm">
<form wicket:id="selectEEForm"> <div class="form-group">
<fieldset class="form-group"> <span><label>Enactment Engine</label></span>
<fieldset class="input-group">
<select wicket:id="eeSelect"/> <select wicket:id="eeSelect"/>
</fieldset> </fieldset>
</form> <div class="spacer"></div>
</div> </div>
</form>
</span> </span>
</wicket:panel> </wicket:panel>
</html> </html>
...@@ -344,7 +344,7 @@ public class ChoreographyLogic extends AbstractLogic<AbstractBaseBean> { ...@@ -344,7 +344,7 @@ public class ChoreographyLogic extends AbstractLogic<AbstractBaseBean> {
choreography.setRealm(SyncopeConstants.ROOT_REALM); choreography.setRealm(SyncopeConstants.ROOT_REALM);
choreography.getAuxClasses().add("Choreography"); choreography.getAuxClasses().add("Choreography");
choreography.getPlainAttrs().add( choreography.getPlainAttrs().add(
new AttrTO.Builder().schema(CHOREOGRAPHY_STATUS_SCHEMA).value("PENDING CREATE").build()); new AttrTO.Builder().schema(CHOREOGRAPHY_STATUS_SCHEMA).value("CREATED").build());
choreography.getPlainAttrs().add( choreography.getPlainAttrs().add(
new AttrTO.Builder().schema("chorSpec"). new AttrTO.Builder().schema("chorSpec").
value(Base64Utility.encode(choreographyTO.getChorspec())).build()); value(Base64Utility.encode(choreographyTO.getChorspec())).build());
...@@ -418,7 +418,7 @@ public class ChoreographyLogic extends AbstractLogic<AbstractBaseBean> { ...@@ -418,7 +418,7 @@ public class ChoreographyLogic extends AbstractLogic<AbstractBaseBean> {
Map<String, AttrTO> choreographyAttrs = choreography.getPlainAttrMap(); Map<String, AttrTO> choreographyAttrs = choreography.getPlainAttrMap();
if (!choreographyAttrs.containsKey(CHOREOGRAPHY_STATUS_SCHEMA) if (!choreographyAttrs.containsKey(CHOREOGRAPHY_STATUS_SCHEMA)
|| choreographyAttrs.get(CHOREOGRAPHY_STATUS_SCHEMA).getValues().isEmpty() || choreographyAttrs.get(CHOREOGRAPHY_STATUS_SCHEMA).getValues().isEmpty()
|| !"PENDING CREATE".equals(choreographyAttrs.get(CHOREOGRAPHY_STATUS_SCHEMA).getValues().get(0))) { || !"CREATED".equals(choreographyAttrs.get(CHOREOGRAPHY_STATUS_SCHEMA).getValues().get(0))) {
AnyObjectTO enactmentEngine = enactmentEngineForChoreography(choreography.getKey()); AnyObjectTO enactmentEngine = enactmentEngineForChoreography(choreography.getKey());
try { try {
...@@ -471,12 +471,32 @@ public class ChoreographyLogic extends AbstractLogic<AbstractBaseBean> { ...@@ -471,12 +471,32 @@ public class ChoreographyLogic extends AbstractLogic<AbstractBaseBean> {
// Enactment Engine selection // Enactment Engine selection
AnyObjectTO enactmentEngine; AnyObjectTO enactmentEngine;
try { try {
// If already defined, select the enactment engine for the choreography // Prefer always the enactment engine specified as argument
enactmentEngine = enactmentEngineForChoreography(choreography.getKey()); enactmentEngine = enactmentEngineForChoreography(enactmentEngineKey);
} catch (NotFoundException e) { } catch (NotFoundException e) {
try { try {
// If the EE was not already selected, search for the enactment engine and set the relationship // If the EE was not already selected, search for the enactment engine and set the relationship
enactmentEngine = enactmentEngineExists(enactmentEngineKey); enactmentEngine = enactmentEngineExists(enactmentEngineKey);
// Remove all previous memberships of EE with the selected choreography
MembershipCond membershipCond = new MembershipCond();
membershipCond.setGroup(choreography.getKey());
AnyTypeCond anyTypeCond = new AnyTypeCond();
anyTypeCond.setAnyTypeKey(ENACTMENT_ENGINE_TYPE);
SearchCond serviceCond = SearchCond.getAndCond(
SearchCond.getLeafCond(anyTypeCond), SearchCond.getLeafCond(membershipCond));
for (AnyObjectTO service : anyObjectLogic.search(serviceCond,
1, -1, Collections.emptyList(), SyncopeConstants.ROOT_REALM, false)) {
AnyObjectPatch patch = new AnyObjectPatch();
patch.setKey(service.getKey());
patch.getMemberships().add(new MembershipPatch.Builder().
operation(PatchOperation.DELETE).group(choreography.getKey()).build());
anyObjectLogic.update(patch, false);
}
// Add membership with the selected EE
AnyObjectPatch eePatch = new AnyObjectPatch(); AnyObjectPatch eePatch = new AnyObjectPatch();
eePatch.setKey(enactmentEngine.getKey()); eePatch.setKey(enactmentEngine.getKey());
eePatch.getMemberships().add(new MembershipPatch.Builder().group(choreography.getKey()).build()); eePatch.getMemberships().add(new MembershipPatch.Builder().group(choreography.getKey()).build());
...@@ -493,7 +513,7 @@ public class ChoreographyLogic extends AbstractLogic<AbstractBaseBean> { ...@@ -493,7 +513,7 @@ public class ChoreographyLogic extends AbstractLogic<AbstractBaseBean> {
if (choreographyAttrs.containsKey(CHOREOGRAPHY_STATUS_SCHEMA) if (choreographyAttrs.containsKey(CHOREOGRAPHY_STATUS_SCHEMA)
&& !choreographyAttrs.get(CHOREOGRAPHY_STATUS_SCHEMA).getValues().isEmpty() && !choreographyAttrs.get(CHOREOGRAPHY_STATUS_SCHEMA).getValues().isEmpty()
&& "PENDING CREATE".equals(choreographyAttrs.get(CHOREOGRAPHY_STATUS_SCHEMA).getValues().get(0))) { && "CREATED".equals(choreographyAttrs.get(CHOREOGRAPHY_STATUS_SCHEMA).getValues().get(0))) {
String generatedChoreographyId = null; String generatedChoreographyId = null;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment