@Override public String transform(final SchemaTO input) { return input.getKey(); } }, new ArrayList<String>()));
@Override public Response create(final SchemaType schemaType, final SchemaTO schemaTO) { SchemaTO created = logic.create(schemaType, schemaTO); URI location = uriInfo.getAbsolutePathBuilder().path(created.getKey()).build(); return Response.created(location). header(RESTHeaders.RESOURCE_KEY, created.getKey()). build(); }
private List<SchemaTO> getSchemas() { List<SchemaTO> schemas = restClient.getSchemas(this.schemaType, keyword); if (SchemaType.PLAIN == this.schemaType) { List<String> configurations = confRestClient.list().stream(). map(Attr::getSchema).collect(Collectors.toList()); schemas.removeIf(schema -> configurations.contains(schema.getKey())); } return schemas; }
private List<SchemaTO> customizeSchemas( final List<SchemaTO> schemaTOs, final String groupParam, final Map<String, CustomAttribute> customFormAttributes) { if (customFormAttributes.isEmpty()) { return schemaTOs; } final boolean isGroupBlank = StringUtils.isBlank(groupParam); schemaTOs.removeAll(schemaTOs.stream(). filter(schema -> !customFormAttributes.containsKey(isGroupBlank ? schema.getKey() : compositeSchemaKey(groupParam, schema.getKey()))). collect(Collectors.toSet())); Collections.sort(schemaTOs, (schemaTO1, schemaTO2) -> { List<String> order = new ArrayList<>(customFormAttributes.keySet()); return order.indexOf(isGroupBlank ? schemaTO1.getKey() : compositeSchemaKey(groupParam, schemaTO1.getKey())) - order.indexOf(isGroupBlank ? schemaTO2.getKey() : compositeSchemaKey(groupParam, schemaTO2.getKey())); }); return schemaTOs; }
private List<SchemaTO> customizeSchemas( final List<SchemaTO> schemaTOs, final String groupParam, final Map<String, CustomAttribute> customFormAttributes) { if (customFormAttributes.isEmpty()) { return schemaTOs; } final boolean isGroupBlank = StringUtils.isBlank(groupParam); schemaTOs.removeAll(schemaTOs.stream(). filter(schema -> !customFormAttributes.containsKey(isGroupBlank ? schema.getKey() : compositeSchemaKey(groupParam, schema.getKey()))). collect(Collectors.toSet())); Collections.sort(schemaTOs, (schemaTO1, schemaTO2) -> { List<String> order = new ArrayList<>(customFormAttributes.keySet()); return order.indexOf(isGroupBlank ? schemaTO1.getKey() : compositeSchemaKey(groupParam, schemaTO1.getKey())) - order.indexOf(isGroupBlank ? schemaTO2.getKey() : compositeSchemaKey(groupParam, schemaTO2.getKey())); }); return schemaTOs; }
private void setSchemas(final List<String> anyTypeClasses, final Map<String, S> scs) { final List<S> allSchemas; if (anyTypeClasses.isEmpty()) { allSchemas = Collections.emptyList(); } else { allSchemas = schemaRestClient.getSchemas(getSchemaType(), null, anyTypeClasses.toArray(new String[] {})); } scs.clear(); if (reoderSchemas()) { // 1. remove attributes not selected for display allSchemas.removeAll(allSchemas.stream(). filter(schemaTO -> !whichAttrs.contains(schemaTO.getKey())).collect(Collectors.toSet())); } allSchemas.forEach(schemaTO -> { scs.put(schemaTO.getKey(), schemaTO); }); }
public AbstractSchemaDetailsPanel(final String id, final SchemaTO schemaTO) { super(id); AjaxTextFieldPanel key = new AjaxTextFieldPanel("key", getString("key"), new PropertyModel<>(schemaTO, "key")); key.addRequiredLabel(); key.setEnabled(schemaTO == null || schemaTO.getKey() == null || schemaTO.getKey().isEmpty()); add(key); } }
@PreAuthorize("hasRole('" + StandardEntitlement.SCHEMA_UPDATE + "')") public <T extends SchemaTO> void update(final SchemaType schemaType, final T schemaTO) { if (!doesSchemaExist(schemaType, schemaTO.getKey())) { throw new NotFoundException(schemaType + "/" + schemaTO.getKey()); } switch (schemaType) { case VIRTUAL: VirSchema virSchema = virSchemaDAO.find(schemaTO.getKey()); if (virSchema == null) { throw new NotFoundException("Virtual Schema '" + schemaTO.getKey() + "'"); } virSchemaDAO.save(binder.update((VirSchemaTO) schemaTO, virSchema)); break; case DERIVED: DerSchema derSchema = derSchemaDAO.find(schemaTO.getKey()); if (derSchema == null) { throw new NotFoundException("Derived schema '" + schemaTO.getKey() + "'"); } derSchemaDAO.save(binder.update((DerSchemaTO) schemaTO, derSchema)); break; case PLAIN: default: PlainSchema plainSchema = plainSchemaDAO.find(schemaTO.getKey()); if (plainSchema == null) { throw new NotFoundException("Schema '" + schemaTO.getKey() + "'"); } plainSchemaDAO.save(binder.update((PlainSchemaTO) schemaTO, plainSchema)); } }
@Override protected Serializable onApplyInternal(final SchemaTO modelObject) { modelObject.getLabels().clear(); modelObject.getLabels().putAll(translations.getObject().stream(). filter(Objects::nonNull). filter(translation -> translation.getKey() != null). filter(translation -> translation.getValue() != null). collect(Collectors.toMap(MutablePair::getKey, MutablePair::getValue))); if (getOriginalItem() == null || StringUtils.isBlank(getOriginalItem().getKey())) { restClient.create(schemaType, modelObject); } else { restClient.update(schemaType, modelObject); } return null; }
@Override public void onClick(final AjaxRequestTarget target, final SchemaTO ignore) { try { switch (schemaType) { case DERIVED: restClient.deleteDerSchema(model.getObject().getKey()); break; case VIRTUAL: restClient.deleteVirSchema(model.getObject().getKey()); break; default: restClient.deletePlainSchema(model.getObject().getKey()); break; } SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED)); target.add(container); } catch (Exception e) { LOG.error("While deleting {}", model.getObject(), e); SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage()) ? e.getClass().getName() : e.getMessage()); } ((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target); } }, ActionLink.ActionType.DELETE, StandardEntitlement.SCHEMA_DELETE, true);
@PreAuthorize("hasRole('" + StandardEntitlement.SCHEMA_CREATE + "')") @SuppressWarnings("unchecked") public <T extends SchemaTO> T create(final SchemaType schemaType, final T schemaTO) { if (StringUtils.isBlank(schemaTO.getKey())) { SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.RequiredValuesMissing); sce.getElements().add("Schema key"); throw sce; } if (doesSchemaExist(schemaType, schemaTO.getKey())) { throw new DuplicateException(schemaType + "/" + schemaTO.getKey()); } T created; switch (schemaType) { case VIRTUAL: VirSchema virSchema = virSchemaDAO.save(binder.create((VirSchemaTO) schemaTO)); created = (T) binder.getVirSchemaTO(virSchema.getKey()); break; case DERIVED: DerSchema derSchema = derSchemaDAO.save(binder.create((DerSchemaTO) schemaTO)); created = (T) binder.getDerSchemaTO(derSchema.getKey()); break; case PLAIN: default: PlainSchema plainSchema = plainSchemaDAO.save(binder.create((PlainSchemaTO) schemaTO)); created = (T) binder.getPlainSchemaTO(plainSchema.getKey()); } return created; }
key = (String) args[i]; } else if (args[i] instanceof SchemaTO) { key = ((SchemaTO) args[i]).getKey();