Search in sources :

Example 1 with ResourceHistoryConfTO

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

the class ResourceITCase method history.

@Test
public void history() {
    List<ResourceHistoryConfTO> history = resourceHistoryService.list(RESOURCE_NAME_LDAP);
    assertNotNull(history);
    int pre = history.size();
    ResourceTO ldap = resourceService.read(RESOURCE_NAME_LDAP);
    TraceLevel originalTraceLevel = SerializationUtils.clone(ldap.getUpdateTraceLevel());
    assertEquals(TraceLevel.ALL, originalTraceLevel);
    ProvisionTO originalProvision = SerializationUtils.clone(ldap.getProvision(AnyTypeKind.USER.name()).get());
    assertEquals(ObjectClass.ACCOUNT_NAME, originalProvision.getObjectClass());
    boolean originalFlag = ldap.isRandomPwdIfNotProvided();
    assertTrue(originalFlag);
    ldap.setUpdateTraceLevel(TraceLevel.FAILURES);
    ldap.getProvision(AnyTypeKind.USER.name()).get().setObjectClass("ANOTHER");
    ldap.setRandomPwdIfNotProvided(false);
    resourceService.update(ldap);
    ldap = resourceService.read(RESOURCE_NAME_LDAP);
    assertNotEquals(originalTraceLevel, ldap.getUpdateTraceLevel());
    assertNotEquals(originalProvision.getObjectClass(), ldap.getProvision(AnyTypeKind.USER.name()).get().getObjectClass());
    assertNotEquals(originalFlag, ldap.isRandomPwdIfNotProvided());
    history = resourceHistoryService.list(RESOURCE_NAME_LDAP);
    assertEquals(pre + 1, history.size());
    resourceHistoryService.restore(history.get(0).getKey());
    ldap = resourceService.read(RESOURCE_NAME_LDAP);
    assertEquals(originalTraceLevel, ldap.getUpdateTraceLevel());
    assertEquals(originalProvision.getObjectClass(), ldap.getProvision(AnyTypeKind.USER.name()).get().getObjectClass());
    assertEquals(originalFlag, ldap.isRandomPwdIfNotProvided());
}
Also used : ResourceHistoryConfTO(org.apache.syncope.common.lib.to.ResourceHistoryConfTO) ResourceTO(org.apache.syncope.common.lib.to.ResourceTO) TraceLevel(org.apache.syncope.common.lib.types.TraceLevel) ProvisionTO(org.apache.syncope.common.lib.to.ProvisionTO) Test(org.junit.jupiter.api.Test)

Example 2 with ResourceHistoryConfTO

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

the class ResourceDataBinderImpl method getResourceHistoryConfTO.

@Override
public ResourceHistoryConfTO getResourceHistoryConfTO(final ExternalResourceHistoryConf history) {
    ResourceHistoryConfTO historyTO = new ResourceHistoryConfTO();
    historyTO.setKey(history.getKey());
    historyTO.setCreator(history.getCreator());
    historyTO.setCreation(history.getCreation());
    historyTO.setResourceTO(history.getConf());
    return historyTO;
}
Also used : ResourceHistoryConfTO(org.apache.syncope.common.lib.to.ResourceHistoryConfTO)

Example 3 with ResourceHistoryConfTO

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

the class ResourceHistoryConfDirectoryPanel method getActions.

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

        private static final long serialVersionUID = -3369924994540304232L;

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

        private static final long serialVersionUID = -3369924994540304232L;

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

        private static final long serialVersionUID = -3369924994540304232L;

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

Example 4 with ResourceHistoryConfTO

use of org.apache.syncope.common.lib.to.ResourceHistoryConfTO 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 5 with ResourceHistoryConfTO

use of org.apache.syncope.common.lib.to.ResourceHistoryConfTO 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

ResourceHistoryConfTO (org.apache.syncope.common.lib.to.ResourceHistoryConfTO)5 ConnInstanceHistoryConfTO (org.apache.syncope.common.lib.to.ConnInstanceHistoryConfTO)2 ResourceTO (org.apache.syncope.common.lib.to.ResourceTO)2 IOException (java.io.IOException)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 ConnInstanceTO (org.apache.syncope.common.lib.to.ConnInstanceTO)1 ProvisionTO (org.apache.syncope.common.lib.to.ProvisionTO)1 TraceLevel (org.apache.syncope.common.lib.types.TraceLevel)1 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)1 Test (org.junit.jupiter.api.Test)1