1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.syncope.client.console.panels;
20
21 import java.io.Serializable;
22 import org.apache.syncope.client.console.rest.RealmRestClient;
23 import org.apache.syncope.client.console.wizards.BaseAjaxWizardBuilder;
24 import org.apache.syncope.common.lib.to.ProvisioningResult;
25 import org.apache.syncope.common.lib.to.RealmTO;
26 import org.apache.wicket.PageReference;
27 import org.apache.wicket.behavior.AttributeAppender;
28 import org.apache.wicket.extensions.wizard.WizardModel;
29 import org.apache.wicket.extensions.wizard.WizardStep;
30
31 public class RealmWizardBuilder extends BaseAjaxWizardBuilder<RealmTO> {
32
33 private static final long serialVersionUID = 5945391813567245081L;
34
35 protected final RealmRestClient realmRestClient;
36
37 protected String parentPath;
38
39 public RealmWizardBuilder(final RealmRestClient realmRestClient, final PageReference pageRef) {
40 super(new RealmTO(), pageRef);
41 this.realmRestClient = realmRestClient;
42 }
43
44 @Override
45 protected Serializable onApplyInternal(final RealmTO modelObject) {
46 ProvisioningResult<RealmTO> result;
47 if (modelObject.getKey() == null) {
48 result = realmRestClient.create(this.parentPath, modelObject);
49 } else {
50 result = realmRestClient.update(modelObject);
51 }
52 return result;
53 }
54
55 @Override
56 protected WizardModel buildModelSteps(final RealmTO modelObject, final WizardModel wizardModel) {
57 wizardModel.add(new Realm(modelObject));
58 return wizardModel;
59 }
60
61 public static class Realm extends WizardStep {
62
63 private static final long serialVersionUID = -2123790676338327104L;
64
65 public Realm(final RealmTO modelObject) {
66 RealmDetails realmDetail = new RealmDetails("details", modelObject);
67 realmDetail.add(new AttributeAppender("style", "overflow-x:hidden;"));
68 add(realmDetail);
69 }
70 }
71
72 public void setParentPath(final String parentPath) {
73 this.parentPath = parentPath;
74 }
75 }