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());
}
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;
}
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;
}
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);
}
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);
}
}
Aggregations