Author: fmartelli Date: Thu Mar 14 16:51:13 2013 New Revision: 1456529 URL: http://svn.apache.org/r1456529 Log: SYNCOPE-198: provided table implementation and bulk actions for resources and connectors
Modified: syncope/trunk/client/src/main/java/org/apache/syncope/client/services/proxy/ConnectorServiceProxy.java syncope/trunk/client/src/main/java/org/apache/syncope/client/services/proxy/ResourceServiceProxy.java syncope/trunk/common/src/main/java/org/apache/syncope/common/services/ConnectorService.java syncope/trunk/common/src/main/java/org/apache/syncope/common/services/ResourceService.java syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/Resources.java syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/AjaxDataTablePanel.java syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ConnectorRestClient.java syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ResourceRestClient.java syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/Resources.html syncope/trunk/console/src/test/java/org/apache/syncope/console/ConnInstanceTestITCase.java syncope/trunk/console/src/test/java/org/apache/syncope/console/ResourceTestITCase.java syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ConnInstanceController.java syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ResourceController.java syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ConnectorServiceImpl.java syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ResourceServiceImpl.java syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ConnInstanceTestITCase.java syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ResourceTestITCase.java syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/TaskTestITCase.java Modified: syncope/trunk/client/src/main/java/org/apache/syncope/client/services/proxy/ConnectorServiceProxy.java URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/client/services/proxy/ConnectorServiceProxy.java?rev=1456529&r1=1456528&r2=1456529&view=diff ============================================================================== --- syncope/trunk/client/src/main/java/org/apache/syncope/client/services/proxy/ConnectorServiceProxy.java (original) +++ syncope/trunk/client/src/main/java/org/apache/syncope/client/services/proxy/ConnectorServiceProxy.java Thu Mar 14 16:51:13 2013 @@ -24,6 +24,8 @@ import java.util.Arrays; import java.util.List; import javax.ws.rs.core.Response; import org.apache.syncope.common.services.ConnectorService; +import org.apache.syncope.common.to.BulkAction; +import org.apache.syncope.common.to.BulkActionRes; import org.apache.syncope.common.to.ConnBundleTO; import org.apache.syncope.common.to.ConnInstanceTO; import org.apache.syncope.common.to.SchemaTO; @@ -119,4 +121,9 @@ public class ConnectorServiceProxy exten public void reload() { getRestTemplate().postForLocation(baseUrl + "connector/reload", null); } + + @Override + public BulkActionRes bulkAction(final BulkAction bulkAction) { + return getRestTemplate().postForObject(baseUrl + "connector/bulk", bulkAction, BulkActionRes.class); + } } Modified: syncope/trunk/client/src/main/java/org/apache/syncope/client/services/proxy/ResourceServiceProxy.java URL: http://svn.apache.org/viewvc/syncope/trunk/client/src/main/java/org/apache/syncope/client/services/proxy/ResourceServiceProxy.java?rev=1456529&r1=1456528&r2=1456529&view=diff ============================================================================== --- syncope/trunk/client/src/main/java/org/apache/syncope/client/services/proxy/ResourceServiceProxy.java (original) +++ syncope/trunk/client/src/main/java/org/apache/syncope/client/services/proxy/ResourceServiceProxy.java Thu Mar 14 16:51:13 2013 @@ -31,6 +31,8 @@ import javax.ws.rs.core.Response; import org.apache.syncope.common.SyncopeConstants; import org.apache.syncope.common.services.ResourceService; +import org.apache.syncope.common.to.BulkAction; +import org.apache.syncope.common.to.BulkActionRes; import org.apache.syncope.common.to.ConnObjectTO; import org.apache.syncope.common.to.PropagationActionClassTO; import org.apache.syncope.common.to.ResourceTO; @@ -110,4 +112,9 @@ public class ResourceServiceProxy extend return getRestTemplate().postForObject(baseUrl + "resource/check.json", resourceTO, Boolean.class). booleanValue(); } + + @Override + public BulkActionRes bulkAction(final BulkAction bulkAction) { + return getRestTemplate().postForObject(baseUrl + "resource/bulk", bulkAction, BulkActionRes.class); + } } Modified: syncope/trunk/common/src/main/java/org/apache/syncope/common/services/ConnectorService.java URL: http://svn.apache.org/viewvc/syncope/trunk/common/src/main/java/org/apache/syncope/common/services/ConnectorService.java?rev=1456529&r1=1456528&r2=1456529&view=diff ============================================================================== --- syncope/trunk/common/src/main/java/org/apache/syncope/common/services/ConnectorService.java (original) +++ syncope/trunk/common/src/main/java/org/apache/syncope/common/services/ConnectorService.java Thu Mar 14 16:51:13 2013 @@ -29,6 +29,8 @@ import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.QueryParam; import javax.ws.rs.core.Response; +import org.apache.syncope.common.to.BulkAction; +import org.apache.syncope.common.to.BulkActionRes; import org.apache.syncope.common.to.ConnBundleTO; import org.apache.syncope.common.to.ConnInstanceTO; import org.apache.syncope.common.to.SchemaTO; @@ -124,4 +126,8 @@ public interface ConnectorService { @POST @Path("reload") void reload(); + + @POST + @Path("bulk") + BulkActionRes bulkAction(BulkAction bulkAction); } \ No newline at end of file Modified: syncope/trunk/common/src/main/java/org/apache/syncope/common/services/ResourceService.java URL: http://svn.apache.org/viewvc/syncope/trunk/common/src/main/java/org/apache/syncope/common/services/ResourceService.java?rev=1456529&r1=1456528&r2=1456529&view=diff ============================================================================== --- syncope/trunk/common/src/main/java/org/apache/syncope/common/services/ResourceService.java (original) +++ syncope/trunk/common/src/main/java/org/apache/syncope/common/services/ResourceService.java Thu Mar 14 16:51:13 2013 @@ -28,7 +28,8 @@ import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.core.Response; - +import org.apache.syncope.common.to.BulkAction; +import org.apache.syncope.common.to.BulkActionRes; import org.apache.syncope.common.to.ConnObjectTO; import org.apache.syncope.common.to.PropagationActionClassTO; import org.apache.syncope.common.to.ResourceTO; @@ -106,4 +107,7 @@ public interface ResourceService { @Path("{resourceName}") void update(@PathParam("resourceName") String resourceName, ResourceTO resourceTO); + @POST + @Path("bulk") + BulkActionRes bulkAction(BulkAction bulkAction); } Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/Resources.java URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/Resources.java?rev=1456529&r1=1456528&r2=1456529&view=diff ============================================================================== --- syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/Resources.java (original) +++ syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/Resources.java Thu Mar 14 16:51:13 2013 @@ -19,6 +19,7 @@ package org.apache.syncope.console.pages; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.Iterator; import java.util.List; @@ -28,6 +29,8 @@ import org.apache.syncope.common.validat import org.apache.syncope.console.commons.Constants; import org.apache.syncope.console.commons.PreferenceManager; import org.apache.syncope.console.commons.SortableDataProviderComparator; +import org.apache.syncope.console.pages.panels.AbstractSearchResultPanel; +import org.apache.syncope.console.pages.panels.AjaxDataTablePanel; import org.apache.syncope.console.rest.ConnectorRestClient; import org.apache.syncope.console.rest.ResourceRestClient; import org.apache.syncope.console.wicket.ajax.markup.html.ClearIndicatingAjaxLink; @@ -42,12 +45,13 @@ import org.apache.wicket.ajax.attributes import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior; import org.apache.wicket.ajax.markup.html.AjaxLink; import org.apache.wicket.authroles.authorization.strategies.role.metadata.MetaDataRoleAuthorizationStrategy; +import org.apache.wicket.event.IEvent; import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow; -import org.apache.wicket.extensions.ajax.markup.html.repeater.data.table.AjaxFallbackDefaultDataTable; import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator; import org.apache.wicket.extensions.markup.html.repeater.data.sort.SortOrder; 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.extensions.markup.html.repeater.data.table.ISortableDataProvider; import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn; import org.apache.wicket.extensions.markup.html.repeater.util.SortableDataProvider; import org.apache.wicket.markup.html.WebMarkupContainer; @@ -58,7 +62,7 @@ import org.apache.wicket.markup.repeater import org.apache.wicket.model.AbstractReadOnlyModel; import org.apache.wicket.model.IModel; import org.apache.wicket.model.PropertyModel; -import org.apache.wicket.model.ResourceModel; +import org.apache.wicket.model.StringResourceModel; import org.apache.wicket.request.mapper.parameter.PageParameters; import org.apache.wicket.spring.injection.annot.SpringBean; @@ -151,11 +155,12 @@ public class Resources extends BasePage } private void setupResources() { - List<IColumn> columns = new ArrayList<IColumn>(); + List<IColumn<ResourceTO, String>> columns = new ArrayList<IColumn<ResourceTO, String>>(); - columns.add(new PropertyColumn(new ResourceModel("name"), "name", "name")); + columns.add(new PropertyColumn(new StringResourceModel("name", this, null), "name", "name")); - columns.add(new AbstractColumn<ResourceTO, String>(new ResourceModel("connector", "connector")) { + columns.add(new AbstractColumn<ResourceTO, String>( + new StringResourceModel("connector", this, null, "connector")) { private static final long serialVersionUID = 8263694778917279290L; @@ -196,12 +201,12 @@ public class Resources extends BasePage } }); - columns.add(new PropertyColumn(new ResourceModel("propagationPrimary"), "propagationPrimary", - "propagationPrimary")); - columns.add(new PropertyColumn(new ResourceModel("propagationPriority"), "propagationPriority", - "propagationPriority")); + columns.add(new PropertyColumn(new StringResourceModel( + "propagationPrimary", this, null), "propagationPrimary", "propagationPrimary")); + columns.add(new PropertyColumn(new StringResourceModel( + "propagationPriority", this, null), "propagationPriority", "propagationPriority")); - columns.add(new AbstractColumn<ResourceTO, String>(new ResourceModel("actions", "")) { + columns.add(new AbstractColumn<ResourceTO, String>(new StringResourceModel("actions", this, null, "")) { private static final long serialVersionUID = 2054811145491901166L; @@ -266,8 +271,16 @@ public class Resources extends BasePage } }); - final AjaxFallbackDefaultDataTable table = new AjaxFallbackDefaultDataTable("resourceDatatable", columns, - new ResourcesProvider(), resourcePaginatorRows); + final AjaxDataTablePanel<ResourceTO, String> table = new AjaxDataTablePanel<ResourceTO, String>( + "resourceDatatable", + columns, + (ISortableDataProvider<ResourceTO, String>) new ResourcesProvider(), + resourcePaginatorRows, + Arrays.asList(new ActionLink.ActionType[]{ActionLink.ActionType.DELETE}), + resourceRestClient, + "name", + "Resources", + getPageReference()); resourceContainer = new WebMarkupContainer("resourceContainer"); resourceContainer.add(table); @@ -339,19 +352,19 @@ public class Resources extends BasePage } private void setupConnectors() { - List<IColumn> columns = new ArrayList<IColumn>(); + List<IColumn<ConnInstanceTO, String>> columns = new ArrayList<IColumn<ConnInstanceTO, String>>(); - columns.add(new PropertyColumn(new ResourceModel("id"), "id", "id")); - - columns.add(new PropertyColumn(new ResourceModel("name"), "connectorName", "connectorName")); - - columns.add(new PropertyColumn(new ResourceModel("displayName"), "displayName", "displayName")); - - columns.add(new PropertyColumn(new ResourceModel("version"), "version", "version")); - - columns.add(new PropertyColumn(new ResourceModel("bundleName"), "bundleName", "bundleName")); - - columns.add(new AbstractColumn<ConnInstanceTO, String>(new ResourceModel("actions", "")) { + columns.add(new PropertyColumn( + new StringResourceModel("id", this, null), "id", "id")); + columns.add(new PropertyColumn( + new StringResourceModel("name", this, null), "connectorName", "connectorName")); + columns.add(new PropertyColumn( + new StringResourceModel("displayName", this, null), "displayName", "displayName")); + columns.add(new PropertyColumn( + new StringResourceModel("version", this, null), "version", "version")); + columns.add(new PropertyColumn( + new StringResourceModel("bundleName", this, null), "bundleName", "bundleName")); + columns.add(new AbstractColumn<ConnInstanceTO, String>(new StringResourceModel("actions", this, null, "")) { private static final long serialVersionUID = 2054811145491901166L; @@ -413,8 +426,16 @@ public class Resources extends BasePage } }); - final AjaxFallbackDefaultDataTable table = new AjaxFallbackDefaultDataTable("connectorDatatable", columns, - new ConnectorsProvider(), connectorPaginatorRows); + final AjaxDataTablePanel<ConnInstanceTO, String> table = new AjaxDataTablePanel<ConnInstanceTO, String>( + "connectorDatatable", + columns, + (ISortableDataProvider<ConnInstanceTO, String>) new ConnectorsProvider(), + connectorPaginatorRows, + Arrays.asList(new ActionLink.ActionType[]{ActionLink.ActionType.DELETE}), + connectorRestClient, + "id", + "Connectors", + getPageReference()); connectorContainer = new WebMarkupContainer("connectorContainer"); connectorContainer.add(table); @@ -579,4 +600,12 @@ public class Resources extends BasePage return connectorRestClient.getAllConnectors(); } } + + @Override + public void onEvent(final IEvent<?> event) { + if (event.getPayload() instanceof AbstractSearchResultPanel.EventDataWrapper) { + ((AbstractSearchResultPanel.EventDataWrapper) event.getPayload()).getTarget().add(resourceContainer); + ((AbstractSearchResultPanel.EventDataWrapper) event.getPayload()).getTarget().add(connectorContainer); + } + } } \ No newline at end of file Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/AjaxDataTablePanel.java URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/AjaxDataTablePanel.java?rev=1456529&r1=1456528&r2=1456529&view=diff ============================================================================== --- syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/AjaxDataTablePanel.java (original) +++ syncope/trunk/console/src/main/java/org/apache/syncope/console/pages/panels/AjaxDataTablePanel.java Thu Mar 14 16:51:13 2013 @@ -170,4 +170,8 @@ public class AjaxDataTablePanel<T, S> ex public final long getPageCount() { return dataTable.getPageCount(); } + + public void setItemsPerPage(final int resourcePaginatorRows) { + dataTable.setItemsPerPage(resourcePaginatorRows); + } } Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ConnectorRestClient.java URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ConnectorRestClient.java?rev=1456529&r1=1456528&r2=1456529&view=diff ============================================================================== --- syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ConnectorRestClient.java (original) +++ syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ConnectorRestClient.java Thu Mar 14 16:51:13 2013 @@ -25,6 +25,8 @@ import java.util.List; import java.util.Set; import org.apache.syncope.common.services.ConnectorService; import org.apache.syncope.common.services.ResourceService; +import org.apache.syncope.common.to.BulkAction; +import org.apache.syncope.common.to.BulkActionRes; import org.apache.syncope.common.to.ConnBundleTO; import org.apache.syncope.common.to.ConnInstanceTO; import org.apache.syncope.common.to.ResourceTO; @@ -192,4 +194,8 @@ public class ConnectorRestClient extends public void reload() { getService(ConnectorService.class).reload(); } + + public BulkActionRes bulkAction(final BulkAction action) { + return getService(ConnectorService.class).bulkAction(action); + } } Modified: syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ResourceRestClient.java URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ResourceRestClient.java?rev=1456529&r1=1456528&r2=1456529&view=diff ============================================================================== --- syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ResourceRestClient.java (original) +++ syncope/trunk/console/src/main/java/org/apache/syncope/console/rest/ResourceRestClient.java Thu Mar 14 16:51:13 2013 @@ -18,11 +18,11 @@ */ package org.apache.syncope.console.rest; -import java.util.ArrayList; import java.util.List; import java.util.Set; - import org.apache.syncope.common.services.ResourceService; +import org.apache.syncope.common.to.BulkAction; +import org.apache.syncope.common.to.BulkActionRes; import org.apache.syncope.common.to.PropagationActionClassTO; import org.apache.syncope.common.to.ResourceTO; import org.apache.syncope.common.util.CollectionWrapper; @@ -83,4 +83,8 @@ public class ResourceRestClient extends public void delete(final String name) { getService(ResourceService.class).delete(name); } + + public BulkActionRes bulkAction(final BulkAction action) { + return getService(ResourceService.class).bulkAction(action); + } } Modified: syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/Resources.html URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/Resources.html?rev=1456529&r1=1456528&r2=1456529&view=diff ============================================================================== --- syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/Resources.html (original) +++ syncope/trunk/console/src/main/resources/org/apache/syncope/console/pages/Resources.html Thu Mar 14 16:51:13 2013 @@ -28,8 +28,7 @@ under the License. <div id="tabs-1"> <div id="users-contain" class="ui-widget" style="width:inherit"> <span wicket:id="resourceContainer"> - <table class="ui-widget ui-widget-content table-hover" - wicket:id="resourceDatatable"/> + <span wicket:id="resourceDatatable">[resources]</span> </span> <span style="float:right"> @@ -51,8 +50,7 @@ under the License. <div id="tabs-2"> <div id="users-contain" class="ui-widget" style="width:inherit"> <span wicket:id="connectorContainer"> - <table class="ui-widget ui-widget-content table-hover" - wicket:id="connectorDatatable"/> + <span wicket:id="connectorDatatable">[connectors]</span> </span> <span style="float:right"> Modified: syncope/trunk/console/src/test/java/org/apache/syncope/console/ConnInstanceTestITCase.java URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/test/java/org/apache/syncope/console/ConnInstanceTestITCase.java?rev=1456529&r1=1456528&r2=1456529&view=diff ============================================================================== --- syncope/trunk/console/src/test/java/org/apache/syncope/console/ConnInstanceTestITCase.java (original) +++ syncope/trunk/console/src/test/java/org/apache/syncope/console/ConnInstanceTestITCase.java Thu Mar 14 16:51:13 2013 @@ -49,7 +49,7 @@ public class ConnInstanceTestITCase exte selenium.waitForCondition("selenium.isElementPresent(\"//div[@id='tabs']\");", "30000"); selenium.click("//div[3]/ul/li[2]/a"); - selenium.click("//tr[4]/td[6]/div/span[9]/a"); + selenium.click("//tr[4]/td[7]/div/span[9]/a"); selenium.waitForCondition("" + "selenium.isElementPresent(\"//div[2]/form/div[2]/div/div/div[3]/div[2]/span/select\");", "30000"); @@ -70,7 +70,7 @@ public class ConnInstanceTestITCase exte selenium.waitForCondition("selenium.isElementPresent(\"//div[@id='tabs']\");", "30000"); selenium.click("//div[3]/ul/li[2]/a"); - selenium.click("//tr[4]/td[6]/div/span[11]/a"); + selenium.click("//tr[4]/td[7]/div/span[11]/a"); assertTrue(selenium.getConfirmation().matches("^Do you really want to delete the selected item[\\s\\S]$")); @@ -85,7 +85,7 @@ public class ConnInstanceTestITCase exte selenium.waitForCondition("selenium.isElementPresent(\"//div[@id='tabs']\");", "30000"); selenium.click("//div[3]/ul/li[2]/a"); - selenium.click("//tr[2]/td[6]/div/span[9]/a"); + selenium.click("//tr[2]/td[7]/div/span[9]/a"); selenium.waitForCondition( "selenium.isElementPresent(\"//select[@name='version:dropDownChoiceField']\");", "30000"); Modified: syncope/trunk/console/src/test/java/org/apache/syncope/console/ResourceTestITCase.java URL: http://svn.apache.org/viewvc/syncope/trunk/console/src/test/java/org/apache/syncope/console/ResourceTestITCase.java?rev=1456529&r1=1456528&r2=1456529&view=diff ============================================================================== --- syncope/trunk/console/src/test/java/org/apache/syncope/console/ResourceTestITCase.java (original) +++ syncope/trunk/console/src/test/java/org/apache/syncope/console/ResourceTestITCase.java Thu Mar 14 16:51:13 2013 @@ -42,7 +42,7 @@ public class ResourceTestITCase extends selenium.waitForCondition("selenium.isElementPresent(\"//div[@id='tabs']\");", "30000"); - selenium.click("//td[5]/div/span[9]/a"); + selenium.click("//td[6]/div/span[9]/a"); selenium.waitForCondition("selenium.isElementPresent(" + "\"//form/div[3]/div/span/div/div/div/label[text()='Name']\");", "30000"); @@ -64,7 +64,7 @@ public class ResourceTestITCase extends selenium.waitForCondition("selenium.isElementPresent(\"//div[@id='tabs']\");", "30000"); - selenium.click("//tr[3]/td[5]/div/span[11]/a"); + selenium.click("//tr[3]/td[6]/div/span[11]/a"); assertTrue(selenium.getConfirmation().matches("^Do you really want to delete the selected item[\\s\\S]$")); } @@ -75,7 +75,7 @@ public class ResourceTestITCase extends selenium.waitForCondition("selenium.isElementPresent(\"//div[@id='tabs']\");", "30000"); - selenium.click("//td[5]/div/span[9]/a"); + selenium.click("//td[6]/div/span[9]/a"); selenium.waitForCondition("selenium.isElementPresent(" + "\"//form/div[3]/div/span/div/div/div/label[text()='Name']\");", "30000"); @@ -97,7 +97,7 @@ public class ResourceTestITCase extends selenium.waitForCondition("selenium.isElementPresent(\"//div[@id='tabs']\");", "30000"); - selenium.click("//*[@id=\"users-contain\"]//*[div=\"ws-target-resource-delete\"]/../td[5]/div/span[9]/a"); + selenium.click("//*[@id=\"users-contain\"]//*[div=\"ws-target-resource-delete\"]/../td[6]/div/span[9]/a"); selenium.waitForCondition("selenium.isElementPresent(" + "\"//form/div[3]/div/span/div/div/div/label[text()='Name']\");", "30000"); Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ConnInstanceController.java URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ConnInstanceController.java?rev=1456529&r1=1456528&r2=1456529&view=diff ============================================================================== --- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ConnInstanceController.java (original) +++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ConnInstanceController.java Thu Mar 14 16:51:13 2013 @@ -25,6 +25,8 @@ import java.util.Locale; import java.util.Set; import javax.servlet.http.HttpServletResponse; import org.apache.commons.lang.StringUtils; +import org.apache.syncope.common.to.BulkAction; +import org.apache.syncope.common.to.BulkActionRes; import org.apache.syncope.common.to.ConnBundleTO; import org.apache.syncope.common.to.ConnInstanceTO; import org.apache.syncope.common.types.AuditElements.Category; @@ -393,4 +395,28 @@ public class ConnInstanceController exte auditManager.audit(Category.connector, ConnectorSubCategory.reload, Result.success, "Successfully reloaded all connector bundles and instances"); } + + @PreAuthorize("hasRole('CONNECTOR_DELETE') and #bulkAction.operation == #bulkAction.operation.DELETE") + @RequestMapping(method = RequestMethod.POST, value = "/bulk") + public BulkActionRes bulkAction(@RequestBody final BulkAction bulkAction) { + LOG.debug("Bulk action '{}' called on '{}'", bulkAction.getOperation(), bulkAction.getTargets()); + + BulkActionRes res = new BulkActionRes(); + + switch (bulkAction.getOperation()) { + case DELETE: + for (String id : bulkAction.getTargets()) { + try { + res.add(delete(Long.valueOf(id)).getId(), BulkActionRes.Status.SUCCESS); + } catch (Exception e) { + LOG.error("Error performing delete for connector {}", id, e); + res.add(id, BulkActionRes.Status.FAILURE); + } + } + break; + default: + } + + return res; + } } \ No newline at end of file Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ResourceController.java URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ResourceController.java?rev=1456529&r1=1456528&r2=1456529&view=diff ============================================================================== --- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ResourceController.java (original) +++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ResourceController.java Thu Mar 14 16:51:13 2013 @@ -23,6 +23,8 @@ import java.util.Set; import javax.persistence.EntityExistsException; import javax.servlet.http.HttpServletResponse; import org.apache.commons.lang.StringUtils; +import org.apache.syncope.common.to.BulkAction; +import org.apache.syncope.common.to.BulkActionRes; import org.apache.syncope.common.to.ConnObjectTO; import org.apache.syncope.common.to.ResourceTO; import org.apache.syncope.common.types.AttributableType; @@ -299,4 +301,28 @@ public class ResourceController extends return new ModelAndView().addObject(result); } + + @PreAuthorize("hasRole('RESOURCE_DELETE') and #bulkAction.operation == #bulkAction.operation.DELETE") + @RequestMapping(method = RequestMethod.POST, value = "/bulk") + public BulkActionRes bulkAction(@RequestBody final BulkAction bulkAction) { + LOG.debug("Bulk action '{}' called on '{}'", bulkAction.getOperation(), bulkAction.getTargets()); + + BulkActionRes res = new BulkActionRes(); + + switch (bulkAction.getOperation()) { + case DELETE: + for (String name : bulkAction.getTargets()) { + try { + res.add(delete(name).getName(), BulkActionRes.Status.SUCCESS); + } catch (Exception e) { + LOG.error("Error performing delete for resource {}", name, e); + res.add(name, BulkActionRes.Status.FAILURE); + } + } + break; + default: + } + + return res; + } } Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ConnectorServiceImpl.java URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ConnectorServiceImpl.java?rev=1456529&r1=1456528&r2=1456529&view=diff ============================================================================== --- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ConnectorServiceImpl.java (original) +++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ConnectorServiceImpl.java Thu Mar 14 16:51:13 2013 @@ -25,6 +25,8 @@ import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; import org.apache.syncope.common.SyncopeConstants; import org.apache.syncope.common.services.ConnectorService; +import org.apache.syncope.common.to.BulkAction; +import org.apache.syncope.common.to.BulkActionRes; import org.apache.syncope.common.to.ConnBundleTO; import org.apache.syncope.common.to.ConnInstanceTO; import org.apache.syncope.common.to.SchemaTO; @@ -111,4 +113,9 @@ public class ConnectorServiceImpl implem public void reload() { connInstanceController.reload(); } + + @Override + public BulkActionRes bulkAction(final BulkAction bulkAction) { + return connInstanceController.bulkAction(bulkAction); + } } Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ResourceServiceImpl.java URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ResourceServiceImpl.java?rev=1456529&r1=1456528&r2=1456529&view=diff ============================================================================== --- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ResourceServiceImpl.java (original) +++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ResourceServiceImpl.java Thu Mar 14 16:51:13 2013 @@ -27,6 +27,8 @@ import javax.ws.rs.core.UriInfo; import org.apache.syncope.common.SyncopeConstants; import org.apache.syncope.common.services.ResourceService; +import org.apache.syncope.common.to.BulkAction; +import org.apache.syncope.common.to.BulkActionRes; import org.apache.syncope.common.to.ConnObjectTO; import org.apache.syncope.common.to.PropagationActionClassTO; import org.apache.syncope.common.to.ResourceTO; @@ -100,4 +102,9 @@ public class ResourceServiceImpl impleme public void setUriInfo(final UriInfo ui) { this.uriInfo = ui; } + + @Override + public BulkActionRes bulkAction(final BulkAction bulkAction) { + return resourceController.bulkAction(bulkAction); + } } Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ConnInstanceTestITCase.java URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ConnInstanceTestITCase.java?rev=1456529&r1=1456528&r2=1456529&view=diff ============================================================================== --- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ConnInstanceTestITCase.java (original) +++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ConnInstanceTestITCase.java Thu Mar 14 16:51:13 2013 @@ -23,17 +23,20 @@ import static org.junit.Assert.assertFal import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import java.io.IOException; import java.io.InputStream; import java.util.Collections; import java.util.HashSet; +import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Properties; import java.util.Set; import javax.ws.rs.core.Response; import org.apache.commons.io.IOUtils; +import org.apache.syncope.common.to.BulkAction; import org.apache.syncope.common.to.ConnBundleTO; import org.apache.syncope.common.to.ConnInstanceTO; import org.apache.syncope.common.to.MappingItemTO; @@ -646,4 +649,45 @@ public class ConnInstanceTestITCase exte public void reload() { connectorService.reload(); } + + @Test + public void bulkAction() { + final BulkAction bulkAction = new BulkAction(); + bulkAction.setOperation(BulkAction.Type.DELETE); + + ConnInstanceTO conn = connectorService.read(101L); + + conn.setId(0); + conn.setDisplayName("forBulk1"); + + bulkAction.addTarget(String.valueOf( + getObject(connectorService.create(conn), ConnInstanceTO.class, connectorService).getId())); + + conn.setDisplayName("forBulk2"); + + bulkAction.addTarget(String.valueOf( + getObject(connectorService.create(conn), ConnInstanceTO.class, connectorService).getId())); + + + Iterator<String> iter = bulkAction.getTargets().iterator(); + + assertNotNull(connectorService.read(Long.valueOf(iter.next()))); + assertNotNull(connectorService.read(Long.valueOf(iter.next()))); + + connectorService.bulkAction(bulkAction); + + iter = bulkAction.getTargets().iterator(); + + try { + connectorService.read(Long.valueOf(iter.next())); + fail(); + } catch (SyncopeClientCompositeErrorException e) { + } + + try { + connectorService.read(Long.valueOf(iter.next())); + fail(); + } catch (SyncopeClientCompositeErrorException e) { + } + } } Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ResourceTestITCase.java URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ResourceTestITCase.java?rev=1456529&r1=1456528&r2=1456529&view=diff ============================================================================== --- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ResourceTestITCase.java (original) +++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/ResourceTestITCase.java Thu Mar 14 16:51:13 2013 @@ -32,6 +32,7 @@ import java.util.List; import java.util.Set; import javax.ws.rs.core.Response; +import org.apache.syncope.common.to.BulkAction; import org.apache.syncope.common.to.MappingItemTO; import org.apache.syncope.common.to.MappingTO; @@ -410,6 +411,35 @@ public class ResourceTestITCase extends } } + @Test + public void bulkAction() { + resourceService.create(buildResourceTO("forBulk1")); + resourceService.create(buildResourceTO("forBulk2")); + + assertNotNull(resourceService.read("forBulk1")); + assertNotNull(resourceService.read("forBulk2")); + + final BulkAction bulkAction = new BulkAction(); + bulkAction.setOperation(BulkAction.Type.DELETE); + + bulkAction.addTarget(String.valueOf("forBulk1")); + bulkAction.addTarget(String.valueOf("forBulk2")); + + resourceService.bulkAction(bulkAction); + + try { + resourceService.read("forBulk1"); + fail(); + } catch (SyncopeClientCompositeErrorException e) { + } + + try { + resourceService.read("forBulk2"); + fail(); + } catch (SyncopeClientCompositeErrorException e) { + } + } + private ResourceTO buildResourceTO(String resourceName) { ResourceTO resourceTO = new ResourceTO(); Modified: syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/TaskTestITCase.java URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/TaskTestITCase.java?rev=1456529&r1=1456528&r2=1456529&view=diff ============================================================================== --- syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/TaskTestITCase.java (original) +++ syncope/trunk/core/src/test/java/org/apache/syncope/core/rest/TaskTestITCase.java Thu Mar 14 16:51:13 2013 @@ -24,6 +24,7 @@ import static org.junit.Assert.assertNot import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; +import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Set; @@ -35,6 +36,7 @@ import org.apache.syncope.common.search. import org.apache.syncope.common.search.NodeCond; import org.apache.syncope.common.services.InvalidSearchConditionException; import org.apache.syncope.common.to.AttributeTO; +import org.apache.syncope.common.to.BulkAction; import org.apache.syncope.common.to.JobClassTO; import org.apache.syncope.common.to.MembershipTO; import org.apache.syncope.common.to.NotificationTO; @@ -883,6 +885,34 @@ public class TaskTestITCase extends Abst } } + @Test + public void bulkAction() { + final List<PropagationTaskTO> before = (List<PropagationTaskTO>) taskService.list(TaskType.PROPAGATION); + + // create user with testdb resource + final UserTO userTO = UserTestITCase.getUniqueSampleTO("taskb...@apache.org"); + userTO.addResource("resource-testdb"); + createUser(userTO); + + final List<PropagationTaskTO> after = + new ArrayList<PropagationTaskTO>((List<PropagationTaskTO>) taskService.list(TaskType.PROPAGATION)); + + after.removeAll(before); + + assertFalse(after.isEmpty()); + + final BulkAction bulkAction = new BulkAction(); + bulkAction.setOperation(BulkAction.Type.DELETE); + + for (TaskTO taskTO : after) { + bulkAction.addTarget(String.valueOf(taskTO.getId())); + } + + taskService.bulkAction(bulkAction); + + assertFalse(taskService.list(TaskType.PROPAGATION).containsAll(after)); + } + /** * remove initial and synchronized users to make test re-runnable */