@Override public String getIntAttrName() { return virSchema.getKey(); }
: virSchemaDAO.findByKeyword(keyword) : virSchemaDAO.findByAnyTypeClasses(classes)).stream(). map(schema -> (T) binder.getVirSchemaTO(schema.getKey())).collect(Collectors.toList()); break;
protected void fillTO( final AnyTO anyTO, final String realmFullPath, final Collection<? extends AnyTypeClass> auxClasses, final Collection<? extends PlainAttr<?>> plainAttrs, final Map<DerSchema, String> derAttrs, final Map<VirSchema, List<String>> virAttrs, final Collection<? extends ExternalResource> resources, final boolean details) { anyTO.setRealm(realmFullPath); anyTO.getAuxClasses().addAll(auxClasses.stream().map(Entity::getKey).collect(Collectors.toList())); plainAttrs.forEach(plainAttr -> { anyTO.getPlainAttrs().add(new AttrTO.Builder(). schema(plainAttr.getSchema().getKey()). values(plainAttr.getValuesAsStrings()).build()); }); derAttrs.forEach((schema, value) -> { anyTO.getDerAttrs().add(new AttrTO.Builder().schema(schema.getKey()).value(value).build()); }); virAttrs.forEach((schema, values) -> { anyTO.getVirAttrs().add(new AttrTO.Builder().schema(schema.getKey()).values(values).build()); }); anyTO.getResources().addAll(resources.stream().map(Entity::getKey).collect(Collectors.toSet())); }
if (ownedResources.contains(schema.getProvision().getResource())) { VirAttrCacheValue virAttrCacheValue = virAttrCache.get(any.getType().getKey(), any.getKey(), schema.getKey()); virAttrCacheValue.setValues(attr.getValue()); virAttrCache.put( any.getType().getKey(), any.getKey(), schema.getKey(), virAttrCacheValue); LOG.debug("Values for {} set in cache: {}", schema, virAttrCacheValue);
}). forEach(provision -> virSchemaDAO.findByProvision(provision). forEach(schema -> virSchemaDAO.delete(schema.getKey())));
@Override public boolean isValid(final Object object, final ConstraintValidatorContext context) { String key = null; if (object instanceof PlainSchema) { key = ((PlainSchema) object).getKey(); } else if (object instanceof DerSchema) { key = ((DerSchema) object).getKey(); } else if (object instanceof VirSchema) { key = ((VirSchema) object).getKey(); } boolean isValid = KEY_PATTERN.matcher(key).matches(); if (!isValid) { context.disableDefaultConstraintViolation(); context.buildConstraintViolationWithTemplate( getTemplate(EntityViolationType.InvalidKey, "Invalid schema key")). addPropertyNode("key").addConstraintViolation(); } else if (JPAAnyUtils.matchesFieldName(key)) { context.disableDefaultConstraintViolation(); context.buildConstraintViolationWithTemplate( getTemplate(EntityViolationType.InvalidKey, "Schema key not allowed: " + key)). addPropertyNode("key").addConstraintViolation(); return false; } return isValid; } }
protected MembershipTO getMembershipTO( final Collection<? extends PlainAttr<?>> plainAttrs, final Map<DerSchema, String> derAttrs, final Map<VirSchema, List<String>> virAttrs, final Membership<? extends Any<?>> membership) { MembershipTO membershipTO = new MembershipTO.Builder(). group(membership.getRightEnd().getKey(), membership.getRightEnd().getName()). build(); plainAttrs.forEach(plainAttr -> { membershipTO.getPlainAttrs().add(new AttrTO.Builder(). schema(plainAttr.getSchema().getKey()). values(plainAttr.getValuesAsStrings()). build()); }); derAttrs.forEach((schema, value) -> { membershipTO.getDerAttrs().add(new AttrTO.Builder(). schema(schema.getKey()). value(value). build()); }); virAttrs.forEach((schema, values) -> { membershipTO.getVirAttrs().add(new AttrTO.Builder(). schema(schema.getKey()). values(values). build()); }); return membershipTO; }
@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; }
provisionTO.getVirSchemas().add(virSchema.getKey());
@Override public VirSchemaTO getVirSchemaTO(final String key) { VirSchema schema = virSchemaDAO.find(key); if (schema == null) { throw new NotFoundException("Virtual Schema '" + key + "'"); } VirSchemaTO schemaTO = new VirSchemaTO(); schemaTO.setKey(schema.getKey()); schemaTO.setExtAttrName(schema.getExtAttrName()); schemaTO.setReadonly(schema.isReadonly()); labels(schema, schemaTO); schemaTO.setAnyTypeClass(schema.getAnyTypeClass() == null ? null : schema.getAnyTypeClass().getKey()); schemaTO.setResource(schema.getProvision().getResource().getKey()); schemaTO.setAnyType(schema.getProvision().getAnyType().getKey()); return schemaTO; } }