use of org.apache.syncope.common.lib.to.AnyTypeClassTO in project syncope by apache.
the class ProvisionAuxClassesPanel method onBeforeRender.
@Override
protected void onBeforeRender() {
super.onBeforeRender();
IModel<List<String>> model;
List<String> choices;
if (provision == null) {
model = new ListModel<>(Collections.<String>emptyList());
choices = Collections.emptyList();
} else {
model = new PropertyModel<>(provision, "auxClasses");
choices = new ArrayList<>();
AnyTypeTO anyType = null;
try {
anyType = new AnyTypeRestClient().read(provision.getAnyType());
} catch (Exception e) {
LOG.error("Could not read AnyType {}", provision.getAnyType(), e);
}
if (anyType != null) {
for (AnyTypeClassTO aux : new AnyTypeClassRestClient().list()) {
if (!anyType.getClasses().contains(aux.getKey())) {
choices.add(aux.getKey());
}
}
}
}
addOrReplace(new AjaxPalettePanel.Builder<String>().build("auxClasses", model, new ListModel<>(choices)).hideLabel().setOutputMarkupId(true).setEnabled(provision != null));
}
use of org.apache.syncope.common.lib.to.AnyTypeClassTO in project syncope by apache.
the class ResourceMappingPanel method setAttrNames.
@Override
protected void setAttrNames(final AjaxTextFieldPanel toBeUpdated) {
toBeUpdated.setRequired(true);
toBeUpdated.setEnabled(true);
Set<String> choices = new HashSet<>();
if (SyncopeConstants.REALM_ANYTYPE.equals(provision.getAnyType())) {
choices.add("key");
choices.add("name");
choices.add("fullpath");
} else {
AnyTypeTO anyType = null;
try {
anyType = anyTypeRestClient.read(provision.getAnyType());
} catch (Exception e) {
LOG.error("Could not read AnyType {}", provision.getAnyType(), e);
}
List<AnyTypeClassTO> anyTypeClassTOs = new ArrayList<>();
if (anyType != null) {
try {
anyTypeClassTOs.addAll(anyTypeClassRestClient.list(anyType.getClasses()));
} catch (Exception e) {
LOG.error("Could not read AnyType classes for {}", anyType.getClasses(), e);
}
}
for (String auxClass : provision.getAuxClasses()) {
try {
anyTypeClassTOs.add(anyTypeClassRestClient.read(auxClass));
} catch (Exception e) {
LOG.error("Could not read AnyTypeClass for {}", auxClass, e);
}
}
switch(provision.getAnyType()) {
case "USER":
choices.addAll(USER_FIELD_NAMES);
break;
case "GROUP":
choices.addAll(GROUP_FIELD_NAMES);
break;
default:
choices.addAll(ANY_OBJECT_FIELD_NAMES);
}
for (AnyTypeClassTO anyTypeClassTO : anyTypeClassTOs) {
choices.addAll(anyTypeClassTO.getPlainSchemas());
choices.addAll(anyTypeClassTO.getDerSchemas());
choices.addAll(anyTypeClassTO.getVirSchemas());
}
}
final List<String> names = new ArrayList<>(choices);
Collections.sort(names);
toBeUpdated.setChoices(names);
}
use of org.apache.syncope.common.lib.to.AnyTypeClassTO in project syncope by apache.
the class AnyTypeClassLogic method delete.
@PreAuthorize("hasRole('" + StandardEntitlement.ANYTYPECLASS_DELETE + "')")
public AnyTypeClassTO delete(final String key) {
AnyTypeClass anyTypeClass = anyTypeClassDAO.find(key);
if (anyTypeClass == null) {
LOG.error("Could not find anyTypeClass '" + key + "'");
throw new NotFoundException(key);
}
AnyTypeClassTO deleted = binder.getAnyTypeClassTO(anyTypeClass);
anyTypeClassDAO.delete(key);
return deleted;
}
Aggregations