use of org.apache.syncope.common.lib.to.ConnInstanceTO in project syncope by apache.
the class TopologyTogglePanel method getConnectorFragment.
private Fragment getConnectorFragment(final TopologyNode node, final PageReference pageRef) {
Fragment fragment = new Fragment("actions", "connectorActions", this);
AjaxLink<String> delete = new IndicatingOnConfirmAjaxLink<String>("delete", true) {
private static final long serialVersionUID = 3776750333491622263L;
@Override
public void onClick(final AjaxRequestTarget target) {
try {
connectorRestClient.delete(String.class.cast(node.getKey()));
target.appendJavaScript(String.format("jsPlumb.remove('%s');", node.getKey()));
SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
toggle(target, false);
} catch (SyncopeClientException e) {
LOG.error("While deleting resource {}", node.getKey(), e);
SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage()) ? e.getClass().getName() : e.getMessage());
}
((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
}
};
MetaDataRoleAuthorizationStrategy.authorize(delete, RENDER, StandardEntitlement.CONNECTOR_DELETE);
fragment.add(delete);
AjaxLink<String> create = new IndicatingAjaxLink<String>("create") {
private static final long serialVersionUID = 3776750333491622263L;
@Override
public void onClick(final AjaxRequestTarget target) {
final ResourceTO modelObject = new ResourceTO();
modelObject.setConnector(String.class.cast(node.getKey()));
modelObject.setConnectorDisplayName(node.getDisplayName());
final IModel<ResourceTO> model = new CompoundPropertyModel<>(modelObject);
modal.setFormModel(model);
target.add(modal.setContent(new ResourceWizardBuilder(modelObject, pageRef).build(BaseModal.CONTENT_ID, AjaxWizard.Mode.CREATE)));
modal.header(new Model<>(MessageFormat.format(getString("resource.new"), node.getKey())));
modal.show(true);
}
@Override
public String getAjaxIndicatorMarkupId() {
return Constants.VEIL_INDICATOR_MARKUP_ID;
}
};
MetaDataRoleAuthorizationStrategy.authorize(create, RENDER, StandardEntitlement.RESOURCE_CREATE);
fragment.add(create);
AjaxLink<String> edit = new IndicatingAjaxLink<String>("edit") {
private static final long serialVersionUID = 3776750333491622263L;
@Override
public void onClick(final AjaxRequestTarget target) {
ConnInstanceTO connInstance = connectorRestClient.read(String.class.cast(node.getKey()));
final IModel<ConnInstanceTO> model = new CompoundPropertyModel<>(connInstance);
modal.setFormModel(model);
target.add(modal.setContent(new ConnectorWizardBuilder(connInstance, pageRef).build(BaseModal.CONTENT_ID, SyncopeConsoleSession.get().owns(StandardEntitlement.CONNECTOR_UPDATE, connInstance.getAdminRealm()) ? AjaxWizard.Mode.EDIT : AjaxWizard.Mode.READONLY)));
modal.header(new Model<>(MessageFormat.format(getString("connector.edit"), connInstance.getDisplayName())));
modal.show(true);
}
@Override
public String getAjaxIndicatorMarkupId() {
return Constants.VEIL_INDICATOR_MARKUP_ID;
}
};
MetaDataRoleAuthorizationStrategy.authorize(edit, RENDER, StandardEntitlement.CONNECTOR_READ);
fragment.add(edit);
AjaxLink<String> history = new IndicatingAjaxLink<String>("history") {
private static final long serialVersionUID = -1876519166660008562L;
@Override
public void onClick(final AjaxRequestTarget target) {
String connKey = String.class.cast(node.getKey());
ConnInstanceTO connInstance = connectorRestClient.read(connKey);
target.add(historyModal.setContent(new HistoryConfList<>(historyModal, connKey, pageRef, connInstance)));
historyModal.header(new Model<>(MessageFormat.format(getString("connector.menu.history"), node.getDisplayName())));
historyModal.show(true);
}
@Override
public String getAjaxIndicatorMarkupId() {
return Constants.VEIL_INDICATOR_MARKUP_ID;
}
};
MetaDataRoleAuthorizationStrategy.authorize(history, RENDER, StandardEntitlement.CONNECTOR_HISTORY_LIST);
fragment.add(history);
return fragment;
}
use of org.apache.syncope.common.lib.to.ConnInstanceTO in project syncope by apache.
the class TopologyTogglePanel method getLocationFragment.
private Fragment getLocationFragment(final TopologyNode node, final PageReference pageRef) {
Fragment fragment = new Fragment("actions", "locationActions", this);
AjaxLink<String> create = new IndicatingAjaxLink<String>("create") {
private static final long serialVersionUID = 3776750333491622263L;
@Override
public void onClick(final AjaxRequestTarget target) {
final ConnInstanceTO modelObject = new ConnInstanceTO();
modelObject.setLocation(node.getKey());
final IModel<ConnInstanceTO> model = new CompoundPropertyModel<>(modelObject);
modal.setFormModel(model);
target.add(modal.setContent(new ConnectorWizardBuilder(modelObject, pageRef).build(BaseModal.CONTENT_ID, AjaxWizard.Mode.CREATE)));
modal.header(new Model<>(MessageFormat.format(getString("connector.new"), node.getKey())));
modal.show(true);
}
@Override
public String getAjaxIndicatorMarkupId() {
return Constants.VEIL_INDICATOR_MARKUP_ID;
}
};
fragment.add(create);
MetaDataRoleAuthorizationStrategy.authorize(create, RENDER, StandardEntitlement.CONNECTOR_CREATE);
return fragment;
}
use of org.apache.syncope.common.lib.to.ConnInstanceTO in project syncope by apache.
the class ConnInstanceDataBinderImpl method getConnInstanceTO.
@Override
public ConnInstanceTO getConnInstanceTO(final ConnInstance connInstance) {
ConnInstanceTO connInstanceTO = new ConnInstanceTO();
Pair<URI, ConnectorInfo> info = connIdBundleManager.getConnectorInfo(connInstance);
BeanUtils.copyProperties(connInstance, connInstanceTO, IGNORE_PROPERTIES);
connInstanceTO.setAdminRealm(connInstance.getAdminRealm().getFullPath());
connInstanceTO.setLocation(info.getLeft().toASCIIString());
connInstanceTO.getConf().addAll(connInstance.getConf());
// refresh stored properties in the given connInstance with direct information from underlying connector
ConfigurationProperties properties = connIdBundleManager.getConfigurationProperties(info.getRight());
properties.getPropertyNames().forEach(propName -> {
ConnConfPropSchema schema = build(properties.getProperty(propName));
Optional<ConnConfProperty> property = connInstanceTO.getConf(propName);
if (!property.isPresent()) {
property = Optional.of(new ConnConfProperty());
connInstanceTO.getConf().add(property.get());
}
property.get().setSchema(schema);
});
Collections.sort(connInstanceTO.getConf());
// pool configuration
if (connInstance.getPoolConf() != null && (connInstance.getPoolConf().getMaxIdle() != null || connInstance.getPoolConf().getMaxObjects() != null || connInstance.getPoolConf().getMaxWait() != null || connInstance.getPoolConf().getMinEvictableIdleTimeMillis() != null || connInstance.getPoolConf().getMinIdle() != null)) {
ConnPoolConfTO poolConf = new ConnPoolConfTO();
BeanUtils.copyProperties(connInstance.getPoolConf(), poolConf);
connInstanceTO.setPoolConf(poolConf);
}
return connInstanceTO;
}
use of org.apache.syncope.common.lib.to.ConnInstanceTO in project syncope by apache.
the class ConnectorLogic method delete.
@PreAuthorize("hasRole('" + StandardEntitlement.CONNECTOR_DELETE + "')")
public ConnInstanceTO delete(final String key) {
ConnInstance connInstance = connInstanceDAO.authFind(key);
if (connInstance == null) {
throw new NotFoundException("Connector '" + key + "'");
}
Set<String> effectiveRealms = RealmUtils.getEffective(AuthContextUtils.getAuthorizations().get(StandardEntitlement.CONNECTOR_DELETE), connInstance.getAdminRealm().getFullPath());
securityChecks(effectiveRealms, connInstance.getAdminRealm().getFullPath(), connInstance.getKey());
if (!connInstance.getResources().isEmpty()) {
SyncopeClientException associatedResources = SyncopeClientException.build(ClientExceptionType.AssociatedResources);
connInstance.getResources().forEach(resource -> {
associatedResources.getElements().add(resource.getKey());
});
throw associatedResources;
}
ConnInstanceTO deleted = binder.getConnInstanceTO(connInstance);
connInstanceDAO.delete(key);
return deleted;
}
use of org.apache.syncope.common.lib.to.ConnInstanceTO in project syncope by apache.
the class ConnectorLogic method buildObjectClassInfo.
@PreAuthorize("hasRole('" + StandardEntitlement.CONNECTOR_READ + "')")
public List<ConnIdObjectClassTO> buildObjectClassInfo(final ConnInstanceTO connInstanceTO, final boolean includeSpecial) {
ConnInstanceTO actual = connInstanceTO;
ConnInstance existing = connInstanceDAO.find(connInstanceTO.getKey());
if (existing != null) {
actual = binder.getConnInstanceTO(existing);
}
Set<ObjectClassInfo> objectClassInfo = connFactory.createConnector(connFactory.buildConnInstanceOverride(actual, connInstanceTO.getConf(), null)).getObjectClassInfo();
return objectClassInfo.stream().map(info -> {
ConnIdObjectClassTO connIdObjectClassTO = new ConnIdObjectClassTO();
connIdObjectClassTO.setType(info.getType());
connIdObjectClassTO.setAuxiliary(info.isAuxiliary());
connIdObjectClassTO.setContainer(info.isContainer());
connIdObjectClassTO.getAttributes().addAll(info.getAttributeInfo().stream().filter(attrInfo -> includeSpecial || !AttributeUtil.isSpecialName(attrInfo.getName())).map(AttributeInfo::getName).collect(Collectors.toList()));
return connIdObjectClassTO;
}).collect(Collectors.toList());
}
Aggregations