Search in sources :

Example 1 with ConnInstanceHistoryConfTO

use of org.apache.syncope.common.lib.to.ConnInstanceHistoryConfTO in project syncope by apache.

the class ConnectorITCase method history.

@Test
public void history() {
    List<ConnInstanceHistoryConfTO> history = connectorHistoryService.list("74141a3b-0762-4720-a4aa-fc3e374ef3ef");
    assertNotNull(history);
    int pre = history.size();
    ConnInstanceTO ldapConn = connectorService.read("74141a3b-0762-4720-a4aa-fc3e374ef3ef", null);
    String originalDisplayName = ldapConn.getDisplayName();
    Set<ConnectorCapability> originalCapabilities = new HashSet<>(ldapConn.getCapabilities());
    ConnConfProperty originalConfProp = SerializationUtils.clone(ldapConn.getConf("maintainPosixGroupMembership").get());
    assertEquals(1, originalConfProp.getValues().size());
    assertEquals("false", originalConfProp.getValues().get(0));
    ldapConn.setDisplayName(originalDisplayName + " modified");
    ldapConn.getCapabilities().clear();
    ldapConn.getConf("maintainPosixGroupMembership").get().getValues().set(0, "true");
    connectorService.update(ldapConn);
    ldapConn = connectorService.read("74141a3b-0762-4720-a4aa-fc3e374ef3ef", null);
    assertNotEquals(originalDisplayName, ldapConn.getDisplayName());
    assertNotEquals(originalCapabilities, ldapConn.getCapabilities());
    assertNotEquals(originalConfProp, ldapConn.getConf("maintainPosixGroupMembership"));
    history = connectorHistoryService.list("74141a3b-0762-4720-a4aa-fc3e374ef3ef");
    assertEquals(pre + 1, history.size());
    connectorHistoryService.restore(history.get(0).getKey());
    ldapConn = connectorService.read("74141a3b-0762-4720-a4aa-fc3e374ef3ef", null);
    assertEquals(originalDisplayName, ldapConn.getDisplayName());
    assertEquals(originalCapabilities, ldapConn.getCapabilities());
    assertEquals(originalConfProp, ldapConn.getConf("maintainPosixGroupMembership").get());
}
Also used : ConnInstanceTO(org.apache.syncope.common.lib.to.ConnInstanceTO) ConnectorCapability(org.apache.syncope.common.lib.types.ConnectorCapability) ConnInstanceHistoryConfTO(org.apache.syncope.common.lib.to.ConnInstanceHistoryConfTO) ConnConfProperty(org.apache.syncope.common.lib.types.ConnConfProperty) GuardedString(org.identityconnectors.common.security.GuardedString) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Example 2 with ConnInstanceHistoryConfTO

use of org.apache.syncope.common.lib.to.ConnInstanceHistoryConfTO in project syncope by apache.

the class HistoryConfDetails method getJSONInfo.

private Pair<String, String> getJSONInfo(final T historyConfTO) {
    // selected configuration instance
    Object conf = null;
    String key = "";
    if (historyConfTO instanceof ConnInstanceHistoryConfTO) {
        ConnInstanceHistoryConfTO historyConf = ConnInstanceHistoryConfTO.class.cast(historyConfTO);
        conf = historyConf.getConnInstanceTO();
        key = historyConf.getKey();
    } else if (historyConfTO instanceof ResourceHistoryConfTO) {
        ResourceHistoryConfTO historyConf = ResourceHistoryConfTO.class.cast(historyConfTO);
        conf = historyConf.getResourceTO();
        key = historyConf.getKey();
    }
    String json = "";
    try {
        json = MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(conf);
    } catch (IOException ex) {
        DirectoryPanel.LOG.error("Error converting objects to JSON", ex);
    }
    return Pair.of(key, json);
}
Also used : ResourceHistoryConfTO(org.apache.syncope.common.lib.to.ResourceHistoryConfTO) ConnInstanceHistoryConfTO(org.apache.syncope.common.lib.to.ConnInstanceHistoryConfTO) IOException(java.io.IOException)

Example 3 with ConnInstanceHistoryConfTO

use of org.apache.syncope.common.lib.to.ConnInstanceHistoryConfTO in project syncope by apache.

the class ConnInstanceHistoryConfDirectoryPanel method getActions.

@Override
public ActionsPanel<ConnInstanceHistoryConfTO> getActions(final IModel<ConnInstanceHistoryConfTO> model) {
    final ActionsPanel<ConnInstanceHistoryConfTO> panel = super.getActions(model);
    final ConnInstanceHistoryConfTO connHistoryConfTO = model.getObject();
    // -- view
    panel.add(new ActionLink<ConnInstanceHistoryConfTO>() {

        private static final long serialVersionUID = -6745431735457245600L;

        @Override
        public void onClick(final AjaxRequestTarget target, final ConnInstanceHistoryConfTO modelObject) {
            ConnInstanceHistoryConfDirectoryPanel.this.getTogglePanel().close(target);
            viewConfiguration(modelObject, target);
            target.add(modal);
        }
    }, ActionLink.ActionType.VIEW, StandardEntitlement.CONNECTOR_HISTORY_LIST);
    // -- restore
    panel.add(new ActionLink<ConnInstanceHistoryConfTO>() {

        private static final long serialVersionUID = -6745431735457245600L;

        @Override
        public void onClick(final AjaxRequestTarget target, final ConnInstanceHistoryConfTO modelObject) {
            try {
                restClient.restore(modelObject.getKey());
                ConnInstanceHistoryConfDirectoryPanel.this.getTogglePanel().close(target);
                target.add(container);
            } catch (SyncopeClientException e) {
                LOG.error("While restoring {}", connHistoryConfTO.getKey(), e);
                SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage()) ? e.getClass().getName() : e.getMessage());
            }
            ((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
        }
    }, ActionLink.ActionType.RESTORE, StandardEntitlement.CONNECTOR_HISTORY_RESTORE);
    // -- delete
    panel.add(new ActionLink<ConnInstanceHistoryConfTO>() {

        private static final long serialVersionUID = -6745431735457245600L;

        @Override
        public void onClick(final AjaxRequestTarget target, final ConnInstanceHistoryConfTO modelObject) {
            try {
                restClient.delete(modelObject.getKey());
                SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
                target.add(container);
                ConnInstanceHistoryConfDirectoryPanel.this.getTogglePanel().close(target);
            } catch (SyncopeClientException e) {
                LOG.error("While deleting {}", connHistoryConfTO.getKey(), e);
                SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage()) ? e.getClass().getName() : e.getMessage());
            }
            ((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
        }
    }, ActionLink.ActionType.DELETE, StandardEntitlement.CONNECTOR_HISTORY_DELETE, true);
    return panel;
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) ConnInstanceHistoryConfTO(org.apache.syncope.common.lib.to.ConnInstanceHistoryConfTO) BasePage(org.apache.syncope.client.console.pages.BasePage)

Example 4 with ConnInstanceHistoryConfTO

use of org.apache.syncope.common.lib.to.ConnInstanceHistoryConfTO in project syncope by apache.

the class ConnInstanceDataBinderImpl method getConnInstanceHistoryConfTO.

@Override
public ConnInstanceHistoryConfTO getConnInstanceHistoryConfTO(final ConnInstanceHistoryConf history) {
    ConnInstanceHistoryConfTO historyTO = new ConnInstanceHistoryConfTO();
    historyTO.setKey(history.getKey());
    historyTO.setCreator(history.getCreator());
    historyTO.setCreation(history.getCreation());
    historyTO.setConnInstanceTO(history.getConf());
    return historyTO;
}
Also used : ConnInstanceHistoryConfTO(org.apache.syncope.common.lib.to.ConnInstanceHistoryConfTO)

Example 5 with ConnInstanceHistoryConfTO

use of org.apache.syncope.common.lib.to.ConnInstanceHistoryConfTO in project syncope by apache.

the class HistoryConfDetails method addCurrentInstanceConf.

@SuppressWarnings("unchecked")
private void addCurrentInstanceConf() {
    T conf = null;
    if (selectedHistoryConfTO instanceof ConnInstanceHistoryConfTO) {
        ConnInstanceTO current = new ConnectorRestClient().read(ConnInstanceHistoryConfTO.class.cast(selectedHistoryConfTO).getConnInstanceTO().getKey());
        conf = (T) new ConnInstanceHistoryConfTO();
        ((ConnInstanceHistoryConfTO) conf).setConnInstanceTO(current);
    } else if (selectedHistoryConfTO instanceof ResourceHistoryConfTO) {
        ResourceTO current = new ResourceRestClient().read(ResourceHistoryConfTO.class.cast(selectedHistoryConfTO).getResourceTO().getKey());
        conf = (T) new ResourceHistoryConfTO();
        ((ResourceHistoryConfTO) conf).setResourceTO(current);
    }
    if (conf != null) {
        conf.setCreator(selectedHistoryConfTO.getCreator());
        conf.setKey("current");
        availableHistoryConfTOs.add(conf);
    }
}
Also used : ConnectorRestClient(org.apache.syncope.client.console.rest.ConnectorRestClient) ResourceHistoryConfTO(org.apache.syncope.common.lib.to.ResourceHistoryConfTO) ResourceTO(org.apache.syncope.common.lib.to.ResourceTO) ConnInstanceTO(org.apache.syncope.common.lib.to.ConnInstanceTO) ConnInstanceHistoryConfTO(org.apache.syncope.common.lib.to.ConnInstanceHistoryConfTO) ResourceRestClient(org.apache.syncope.client.console.rest.ResourceRestClient)

Aggregations

ConnInstanceHistoryConfTO (org.apache.syncope.common.lib.to.ConnInstanceHistoryConfTO)5 ConnInstanceTO (org.apache.syncope.common.lib.to.ConnInstanceTO)2 ResourceHistoryConfTO (org.apache.syncope.common.lib.to.ResourceHistoryConfTO)2 IOException (java.io.IOException)1 HashSet (java.util.HashSet)1 BasePage (org.apache.syncope.client.console.pages.BasePage)1 ConnectorRestClient (org.apache.syncope.client.console.rest.ConnectorRestClient)1 ResourceRestClient (org.apache.syncope.client.console.rest.ResourceRestClient)1 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)1 ResourceTO (org.apache.syncope.common.lib.to.ResourceTO)1 ConnConfProperty (org.apache.syncope.common.lib.types.ConnConfProperty)1 ConnectorCapability (org.apache.syncope.common.lib.types.ConnectorCapability)1 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)1 GuardedString (org.identityconnectors.common.security.GuardedString)1 Test (org.junit.jupiter.api.Test)1