Commit 78080575 authored by Gianluca Filippone's avatar Gianluca Filippone
Browse files

Implemented Synthesis Processor list, add and update on extension

parent a45fc7f7
......@@ -453,8 +453,12 @@ we are happy to inform you that the password request was execute successfully fo
<AnyTypeClass id="Enactment Engine"/>
<AnyType_AnyTypeClass anyType_id="ENACTMENT ENGINE" anyTypeClass_id="Enactment Engine"/>
 
<AnyType id="SYNTHESIS PROCESSOR" kind="ANY_OBJECT"/>
<AnyTypeClass id="Synthesis Processor"/>
<AnyType_AnyTypeClass anyType_id="SYNTHESIS PROCESSOR" anyTypeClass_id="Synthesis Processor"/>
<AnyTypeClass id="Choreography"/>
<AnyTypeClass id="Deployed"/>
 
<RelationshipType id="SERVICE ROLE MEMBERSHIP"
......@@ -603,6 +607,10 @@ we are happy to inform you that the password request was execute successfully fo
<PlainSchema id="enactmentEnginePassword" cipherAlgorithm="AES" secretKey="enactmentEnginePassword" type="Encrypted" mandatoryCondition="false"
multivalue="0" readonly="0" uniqueConstraint="0" anyTypeClass_id="Enactment Engine"/>
 
<SyncopeSchema id="synthesisProcessorBaseURL"/>
<PlainSchema id="synthesisProcessorBaseURL" mandatoryCondition="true"
multivalue="0" readonly="0" type="String" uniqueConstraint="0" anyTypeClass_id="Synthesis Processor"/>
<SyncopeGroup id="0635553c-3f38-4a6d-b555-3c3f382a6ddb" name="ServiceProviderApprover"
realm_id="ea696a4f-e77a-4ef1-be67-8f8093bc8686"
creator="admin" lastModifier="admin"
......@@ -633,6 +641,15 @@ we are happy to inform you that the password request was execute successfully fo
schema_id="enactmentEnginePassword"/>
<APlainAttrValue id="a49233c5-d6d0-4cd7-9233-c5d6d0acd707" attribute_id="c8339c3a-b592-4d6a-b39c-3ab592dd6a93"
stringValue="SxxjoySCp6mqzrV8q/BwXQ=="/>
<AnyObject id="467a4bfb-d9eb-42b1-bbe8-0246e665e47f" name="Default processor"
realm_id="ea696a4f-e77a-4ef1-be67-8f8093bc8686" type_id="SYNTHESIS PROCESSOR"
creator="admin" lastModifier="admin"
creationDate="2017-03-17T16:35:00+0200" lastChangeDate="2017-03-17T16:35:00+0200" />
<APlainAttr id="3ca18013-7efd-462f-84a8-c8dfe059e851" owner_id="467a4bfb-d9eb-42b1-bbe8-0246e665e47f"
schema_id="synthesisProcessorBaseURL"/>
<APlainAttrValue id="4f802e66-a3ba-49dd-825f-9a1c9cbe88cd" attribute_id="3ca18013-7efd-462f-84a8-c8dfe059e851"
stringValue="http://localhost:9080/choremocks/rest/synthesis"/>
<!-- [END] CHOReVOLUTION -->
 
<!-- [START Choreographies -->
......@@ -45,6 +45,12 @@ limitations under the License.
<groupId>org.apache.syncope.client</groupId>
<artifactId>syncope-client-console</artifactId>
</dependency>
<dependency>
<groupId>eu.chorevolution.idm.ext.choreography</groupId>
<artifactId>syncope-ext-choreography-client-console</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
......
/*
* Copyright 2016 The CHOReVOLUTION project.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.syncope.client.console.commons;
import org.apache.syncope.client.console.rest.AbstractAnyRestClient;
import org.apache.syncope.common.lib.to.AnyObjectTO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class SynthesisProcessorDataProvider extends AnyDataProvider<AnyObjectTO> {
private static final long serialVersionUID = 3628773545540989992L;
protected static final Logger LOG = LoggerFactory.getLogger(SynthesisProcessorDataProvider.class);
public SynthesisProcessorDataProvider(
final AbstractAnyRestClient<AnyObjectTO, ?> restClient,
final int paginatorRows,
final boolean filtered,
final String realm,
final String type) {
super(restClient, paginatorRows, filtered, realm, type);
}
@Override
public AnyDataProvider<AnyObjectTO> setFIQL(final String fiql) {
this.fiql = fiql;
LOG.info("Set anyObject search query to '{}'", this.fiql);
return this;
}
}
/*
* Copyright 2016 The CHOReVOLUTION project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.syncope.client.console.pages;
import org.apache.syncope.client.console.BookmarkablePageLinkBuilder;
import org.apache.syncope.client.console.rest.AnyObjectRestClient;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.syncope.common.lib.to.AnyObjectTO;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.request.mapper.parameter.PageParameters;
public class SynthesisProcessorDetailPage extends BaseExtPage {
private static final long serialVersionUID = 1092769178017851238L;
private final AnyObjectRestClient restClient;
private final String synthesisProcessorKey;
private final AnyObjectTO synthesisProcessor;
public SynthesisProcessorDetailPage(final PageParameters parameters) {
super(parameters);
restClient = new AnyObjectRestClient();
synthesisProcessorKey = parameters.get("sp").toString();
synthesisProcessor = restClient.read(synthesisProcessorKey);
//SynthesisProcessorRestClient synthesisProcessorRestClient = new SynthesisProcessorRestClient();
// Set page title
body.add(new Label("header", getString("sp") + " " + synthesisProcessor.getName()));
body.add(BookmarkablePageLinkBuilder.build("dashboard", "dashboardBr", Dashboard.class));
body.add(BookmarkablePageLinkBuilder.build("synthesisProcessorBr", SynthesisProcessorPage.class));
body.add(new Label("synthesisProcessorName", synthesisProcessor.getName()));
WebMarkupContainer content = new WebMarkupContainer("content");
content.setOutputMarkupId(true);
//CONTENT!
// Re-enable when entilements for this service will be defined
//MetaDataRoleAuthorizationStrategy.authorize(content, ENABLE, CamelEntitlement.ROUTE_LIST);
body.add(content);
}
}
......@@ -15,21 +15,31 @@
*/
package org.apache.syncope.client.console.pages;
import de.agilecoders.wicket.core.markup.html.bootstrap.dialog.Modal;
import eu.chorevolution.idm.common.ChorevolutionEntitlement;
import java.io.Serializable;
import org.apache.syncope.client.console.BookmarkablePageLinkBuilder;
import org.apache.syncope.client.console.annotations.ExtPage;
import org.apache.syncope.client.console.panels.AddSynthesisProcessorModalPanel;
import org.apache.syncope.client.console.panels.SynthesisProcessorDirectoryPanel;
import org.apache.syncope.client.console.wicket.markup.html.bootstrap.dialog.BaseModal;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.model.Model;
import org.apache.wicket.request.mapper.parameter.PageParameters;
@ExtPage(label = "Synthesis Processors", icon = "fa-wrench",
listEntitlement = ChorevolutionEntitlement.CHOREOGRAPHY_LIST, priority = 100)
public class SynthesisProcessorPage extends BaseExtPage {
public static final String PREF_EE_PAGINATOR_ROWS = "synthesisprocessor.paginator.rows";
public static final String PREF_SYNTH_PAGINATOR_ROWS = "synthesisprocessor.paginator.rows";
private static final long serialVersionUID = -337325733703904383L;
private final BaseModal<Serializable> utilityModal = new BaseModal<>("addSynthesisProcessorModal");
private final WebMarkupContainer content;
public SynthesisProcessorPage(final PageParameters parameters) {
......@@ -40,8 +50,37 @@ public class SynthesisProcessorPage extends BaseExtPage {
content = new WebMarkupContainer("content");
content.setOutputMarkupId(true);
content.add(new Label("synthesisprocessors", "Synthesis Processors Page"));
content.add(new SynthesisProcessorDirectoryPanel("synthesisprocessors", getPageReference()));
content.add(new AjaxLink("addLink") {
private static final long serialVersionUID = 4879178530891785513L;
@Override
public void onClick(final AjaxRequestTarget target) {
utilityModal.header(Model.of("New Synthesis Processor"));
utilityModal.setContent(new AddSynthesisProcessorModalPanel(utilityModal, getPageReference()));
utilityModal.show(true);
target.add(utilityModal);
}
});
utilityModal.size(Modal.Size.Large);
utilityModal.addSubmitButton();
utilityModal.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {
private static final long serialVersionUID = -4920274615194015386L;
@Override
public void onClose(final AjaxRequestTarget target) {
target.add(new SynthesisProcessorDirectoryPanel("synthesisprocessors", getPageReference()));
target.add(content);
utilityModal.show(false);
}
});
body.add(utilityModal);
body.add(content);
body.setOutputMarkupId(true);
}
......
/*
* Copyright 2016 The CHOReVOLUTION project.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.syncope.client.console.panels;
import java.io.Serializable;
import org.apache.syncope.client.console.wicket.markup.html.bootstrap.dialog.BaseModal;
import org.apache.syncope.client.console.wicket.markup.html.form.AjaxTextFieldPanel;
import org.apache.syncope.client.console.wicket.markup.html.form.FieldPanel;
import org.apache.wicket.PageReference;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.model.Model;
public abstract class AbstractSynthesisProcessorModalPanel extends AbstractModalPanel<Serializable> {
private static final long serialVersionUID = 1570261203472359825L;
protected final BaseModal<Serializable> modal;
protected final FieldPanel<String> nameInput;
protected final FieldPanel<String> urlInput;
public AbstractSynthesisProcessorModalPanel(
final BaseModal<Serializable> modal,
final PageReference pageRef) {
super(modal, pageRef);
this.modal = modal;
final WebMarkupContainer container = new WebMarkupContainer("container");
container.setOutputMarkupId(true);
add(container);
final Form<String> form = new Form<>("AddEEForm");
form.setMarkupId("AddEEForm");
form.setOutputMarkupId(true);
container.add(form);
this.nameInput = new AjaxTextFieldPanel("name", "Name", new Model<>(), true);
nameInput.setRequired(true);
nameInput.addRequiredLabel();
form.add(nameInput);
this.urlInput = new AjaxTextFieldPanel("url", "Base URL", new Model<>(), true);
urlInput.setRequired(true);
urlInput.addRequiredLabel();
form.add(urlInput);
}
}
/*
* Copyright 2016 The CHOReVOLUTION project.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.syncope.client.console.panels;
import eu.chorevolution.idm.common.to.SynthesisProcessorTO;
import java.io.Serializable;
import org.apache.commons.lang3.StringUtils;
import org.apache.syncope.client.console.SyncopeConsoleSession;
import org.apache.syncope.client.console.commons.Constants;
import org.apache.syncope.client.console.pages.BasePage;
import static org.apache.syncope.client.console.panels.AbstractModalPanel.LOG;
import org.apache.syncope.client.console.rest.SynthesisProcessorRestClient;
import org.apache.syncope.client.console.wicket.markup.html.bootstrap.dialog.BaseModal;
import org.apache.syncope.common.lib.SyncopeClientException;
import org.apache.wicket.PageReference;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.html.form.Form;
public class AddSynthesisProcessorModalPanel extends AbstractSynthesisProcessorModalPanel {
private static final long serialVersionUID = -3706242199931379878L;
private final SynthesisProcessorRestClient restClient;
public AddSynthesisProcessorModalPanel(final BaseModal<Serializable> modal, final PageReference pageRef) {
super(modal, pageRef);
this.restClient = new SynthesisProcessorRestClient();
}
@Override
public void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
try {
SynthesisProcessorTO synthesisProcessorTO = new SynthesisProcessorTO();
synthesisProcessorTO.setName(nameInput.getModelObject());
synthesisProcessorTO.setBaseUrl(urlInput.getModelObject());
restClient.create(synthesisProcessorTO);
modal.close(target);
SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
} catch (SyncopeClientException e) {
LOG.error("While creating new Synthesis Processor", e);
SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage())
? e.getClass().getName() : e.getMessage());
}
((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
}
}
/*
* Copyright 2016 The CHOReVOLUTION project.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.syncope.client.console.panels;
import eu.chorevolution.idm.common.to.SynthesisProcessorTO;
import java.io.Serializable;
import org.apache.commons.lang3.StringUtils;
import org.apache.syncope.client.console.SyncopeConsoleSession;
import org.apache.syncope.client.console.commons.Constants;
import org.apache.syncope.client.console.pages.BasePage;
import static org.apache.syncope.client.console.panels.AbstractModalPanel.LOG;
import org.apache.syncope.client.console.rest.SynthesisProcessorRestClient;
import org.apache.syncope.client.console.wicket.markup.html.bootstrap.dialog.BaseModal;
import org.apache.syncope.common.lib.SyncopeClientException;
import org.apache.syncope.common.lib.to.AnyObjectTO;
import org.apache.wicket.PageReference;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.html.form.Form;
public class EditSynthesisProcessorModalPanel extends AbstractSynthesisProcessorModalPanel {
private static final long serialVersionUID = -6768757286301114525L;
private final AnyObjectTO synthesisProcessor;
private final SynthesisProcessorRestClient restClient;
public EditSynthesisProcessorModalPanel(
final BaseModal<Serializable> modal,
final PageReference pageRef,
final AnyObjectTO synthesisProcessor) {
super(modal, pageRef);
this.synthesisProcessor = synthesisProcessor;
this.restClient = new SynthesisProcessorRestClient();
nameInput.setModelObject(synthesisProcessor.getName());
urlInput.setModelObject(synthesisProcessor.getPlainAttrMap()
.get("synthesisProcessorBaseURL").getValues().get(0));
}
@Override
public void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
try {
SynthesisProcessorTO synthesisProcessorTO = new SynthesisProcessorTO();
synthesisProcessorTO.setKey((synthesisProcessor.getKey()));
synthesisProcessorTO.setName(nameInput.getModelObject());
synthesisProcessorTO.setBaseUrl(urlInput.getModelObject());
restClient.update(synthesisProcessorTO);
modal.close(target);
SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
} catch (SyncopeClientException e) {
LOG.error("While updating Synthesis Processor", e);
SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage())
? e.getClass().getName() : e.getMessage());
}
((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
}
}
package org.apache.syncope.client.console.panels;
import de.agilecoders.wicket.core.markup.html.bootstrap.dialog.Modal;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import org.apache.syncope.client.console.commons.AnyDataProvider;
import org.apache.syncope.client.console.commons.SynthesisProcessorDataProvider;
import org.apache.syncope.client.console.pages.SynthesisProcessorDetailPage;
import org.apache.syncope.client.console.pages.SynthesisProcessorPage;
import org.apache.syncope.client.console.wicket.markup.html.bootstrap.dialog.BaseModal;
import org.apache.syncope.common.lib.search.AnyObjectFiqlSearchConditionBuilder;
import org.apache.syncope.common.lib.to.AnyObjectTO;
import org.apache.syncope.common.lib.types.AnyTypeKind;
import org.apache.wicket.PageReference;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxLink;
import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow;
import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator;
import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn;
import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.model.ResourceModel;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.springframework.util.ReflectionUtils;
/*
* Copyright 2017 The CHOReVOLUTION project.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
public class SynthesisProcessorDirectoryPanel extends AnyObjectDirectoryPanel {
private static final long serialVersionUID = 7303610381539502741L;
private final BaseModal<Serializable> utilityModal = new BaseModal<>("outer");
public SynthesisProcessorDirectoryPanel(final String id, final PageReference pageRef) {
super(id, new Builder(AnyTypeKind.ANY_OBJECT.name(), pageRef), false);
utilityModal.addSubmitButton();
utilityModal.size(Modal.Size.Medium);
addOuterObject(utilityModal);
utilityModal.setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {
private static final long serialVersionUID = 8804221891699487139L;
@Override
public void onClose(final AjaxRequestTarget target) {
target.add(container);
utilityModal.show(false);
}
});
}
@Override
protected String paginatorRowsKey() {
return SynthesisProcessorPage.PREF_SYNTH_PAGINATOR_ROWS;
}
@Override
protected AnyDataProvider<AnyObjectTO> dataProvider() {
final SynthesisProcessorDataProvider dp
= new SynthesisProcessorDataProvider(restClient, rows, filtered, realm, type);
return dp.setFIQL(new AnyObjectFiqlSearchConditionBuilder("SYNTHESIS PROCESSOR").query());
}
@Override
protected List<IColumn<AnyObjectTO, String>> getColumns() {
final List<IColumn<AnyObjectTO, String>> columns = new ArrayList<>();
addPropertyColumn("key", ReflectionUtils.findField(AnyObjectTO.class, "key"), columns);
addPropertyColumn("name", ReflectionUtils.findField(AnyObjectTO.class, "name"), columns);
columns.add(new AbstractColumn<AnyObjectTO, String>(new ResourceModel("", "Base URL")) {
private static final long serialVersionUID = 2054811145491901166L;
@Override
public void populateItem(
final Item<ICellPopulator<AnyObjectTO>> item,
final String componentId,
final IModel<AnyObjectTO> model) {
Label label = new Label(
componentId, model.getObject().getPlainAttrMap().get("synthesisProcessorBaseURL")
.getValues().iterator().next());
item.add(label);
}
});
columns.add(new AbstractColumn<AnyObjectTO, String>(new ResourceModel("actions", "")) {
private static final long serialVersionUID = -5137819175810948915L;
@Override
public String getCssClass() {
return "action";
}
@Override