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