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
<SyncopeSchema id="status"/>
<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"/>
<SyncopeSchema id="description"/>
......
......@@ -578,7 +578,7 @@ we are happy to inform you that the password request was execute successfully fo
 
<SyncopeSchema id="status"/>
<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"/>
 
<SyncopeSchema id="chorSpec"/>
......@@ -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.any.AnyWrapper;
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.wicket.PageReference;
import org.apache.wicket.ajax.AjaxRequestTarget;
......@@ -157,41 +156,32 @@ public class ChoreographyDirectoryPanel extends GroupDirectoryPanel {
String chorStatus = model.getObject().getPlainAttrMap().get("status").getValues().iterator().next();
ChoreographyActionsPanel choreographyActionsPanel = new ChoreographyActionsPanel(componentId);
if (chorStatus.equals("PENDING CREATE") || chorStatus.equals("PENDING UPDATE")) {
if (chorStatus.equals("CREATED")) {
choreographyActionsPanel.addAction(new IndicatingAjaxLink<Void>("link") {
private static final long serialVersionUID = -7978723352517770644L;
@Override
public void onClick(final AjaxRequestTarget target) {
try {
String eeKey = choreographyRestClient
.getChoreographyEE(model.getObject().getKey()).getKey();
choreographyRestClient.enactChoreography(model.getObject().getKey(), eeKey);
SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
target.add(container);
utilityModal.setContent(new SelectEEModalPanel(
utilityModal,
model.getObject(),
pageRef));
utilityModal.header(Model.of("Select Enactment Engine"));
utilityModal.show(true);
target.add(utilityModal);
} catch (SyncopeClientException e) {
if (e.getType().equals(ClientExceptionType.NotFound)) {
utilityModal.setContent(new SelectEEModalPanel(
utilityModal,
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());
}
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);
}
}, ChoreographyActionsPanel.ChoreographyActionType.ENACT);
}
if (!chorStatus.equals("PENDING CREATE")
if (!chorStatus.equals("CREATED")
&& !chorStatus.equals("PENDING UPDATE")
&& !chorStatus.equals("PENDING ENACTMENT")) {
choreographyActionsPanel.addAction(new IndicatingAjaxLink<Void>("link") {
......
......@@ -113,12 +113,12 @@ public class SelectEEModalPanel extends AbstractModalPanel<Serializable> {
AnyObjectRestClient anyObjectRestClient = new AnyObjectRestClient();
List<AnyObjectTO> enactmentEngines = anyObjectRestClient.search(
SyncopeConstants.ROOT_REALM,
new AnyObjectFiqlSearchConditionBuilder("ENACTMENT ENGINE").query(),
1,
1,
new SortParam<>("name", false),
"ENACTMENT ENGINE");
SyncopeConstants.ROOT_REALM,
new AnyObjectFiqlSearchConditionBuilder("ENACTMENT ENGINE").query(),
1,
-1,
new SortParam<>("name", false),
"ENACTMENT ENGINE");
setChoiceRenderer(new EnactmentEngineRenderer());
setChoices(enactmentEngines);
......
......@@ -16,14 +16,12 @@ limitations under the License.
-->
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org">
<wicket:panel>
<span wicket:id="container">
<div class="form-group">
<form wicket:id="resizeChoreographyForm">
<div class="form-group">
<span wicket:id="size"/>
</div>
</form>
</div>
</span>
<div wicket:id="container">
<form wicket:id="resizeChoreographyForm">
<div class="form-group">
<span wicket:id="size"/>
</div>
</form>
</div>
</wicket:panel>
</html>
\ No newline at end of file
......@@ -15,15 +15,24 @@ See the License for the specific language governing permissions and
limitations under the License.
-->
<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>
<span wicket:id="container">
<div class="form-group">
<form wicket:id="selectEEForm">
<fieldset class="form-group">
<form wicket:id="selectEEForm">
<div class="form-group">
<span><label>Enactment Engine</label></span>
<fieldset class="input-group">
<select wicket:id="eeSelect"/>
</fieldset>
</form>
</div>
<div class="spacer"></div>
</div>
</form>
</span>
</wicket:panel>
</html>
......@@ -344,7 +344,7 @@ public class ChoreographyLogic extends AbstractLogic<AbstractBaseBean> {
choreography.setRealm(SyncopeConstants.ROOT_REALM);
choreography.getAuxClasses().add("Choreography");
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(
new AttrTO.Builder().schema("chorSpec").
value(Base64Utility.encode(choreographyTO.getChorspec())).build());
......@@ -418,7 +418,7 @@ public class ChoreographyLogic extends AbstractLogic<AbstractBaseBean> {
Map<String, AttrTO> choreographyAttrs = choreography.getPlainAttrMap();
if (!choreographyAttrs.containsKey(CHOREOGRAPHY_STATUS_SCHEMA)
|| 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());
try {
......@@ -471,12 +471,32 @@ public class ChoreographyLogic extends AbstractLogic<AbstractBaseBean> {
// Enactment Engine selection
AnyObjectTO enactmentEngine;
try {
// If already defined, select the enactment engine for the choreography
enactmentEngine = enactmentEngineForChoreography(choreography.getKey());
// Prefer always the enactment engine specified as argument
enactmentEngine = enactmentEngineForChoreography(enactmentEngineKey);
} catch (NotFoundException e) {
try {
// If the EE was not already selected, search for the enactment engine and set the relationship
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();
eePatch.setKey(enactmentEngine.getKey());
eePatch.getMemberships().add(new MembershipPatch.Builder().group(choreography.getKey()).build());
......@@ -493,7 +513,7 @@ public class ChoreographyLogic extends AbstractLogic<AbstractBaseBean> {
if (choreographyAttrs.containsKey(CHOREOGRAPHY_STATUS_SCHEMA)
&& !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;
......
Markdown is supported
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