@SuppressWarnings("unchecked") private static <T> T buildJava(final Implementation impl) throws ClassNotFoundException { Class<?> clazz; if (CLASS_CACHE.containsKey(impl.getKey())) { clazz = CLASS_CACHE.get(impl.getKey()); } else { clazz = Class.forName(impl.getBody()); CLASS_CACHE.put(impl.getKey(), clazz); } return (T) ApplicationContextProvider.getBeanFactory(). createBean(clazz, AbstractBeanDefinition.AUTOWIRE_BY_TYPE, false); }
@SuppressWarnings("unchecked") private static <T> T buildJava(final Implementation impl) throws ClassNotFoundException { Class<?> clazz; if (CLASS_CACHE.containsKey(impl.getKey())) { clazz = CLASS_CACHE.get(impl.getKey()); } else { clazz = Class.forName(impl.getBody()); CLASS_CACHE.put(impl.getKey(), clazz); } return (T) ApplicationContextProvider.getBeanFactory(). createBean(clazz, AbstractBeanDefinition.AUTOWIRE_BY_TYPE, false); }
@SuppressWarnings("unchecked") private static <T> T buildGroovy(final Implementation impl) throws InstantiationException, IllegalAccessException { Class<?> clazz; if (CLASS_CACHE.containsKey(impl.getKey())) { clazz = CLASS_CACHE.get(impl.getKey()); } else { clazz = GROOVY_CLASSLOADER.parseClass(impl.getBody()); CLASS_CACHE.put(impl.getKey(), clazz); } return (T) ApplicationContextProvider.getBeanFactory(). createBean(clazz, AbstractBeanDefinition.AUTOWIRE_BY_TYPE, false); }
@SuppressWarnings("unchecked") private static <T> T buildGroovy(final Implementation impl) throws InstantiationException, IllegalAccessException { Class<?> clazz; if (CLASS_CACHE.containsKey(impl.getKey())) { clazz = CLASS_CACHE.get(impl.getKey()); } else { clazz = GROOVY_CLASSLOADER.parseClass(impl.getBody()); CLASS_CACHE.put(impl.getKey(), clazz); } return (T) ApplicationContextProvider.getBeanFactory(). createBean(clazz, AbstractBeanDefinition.AUTOWIRE_BY_TYPE, false); }
@Override public Implementation save(final Implementation implementation) { Implementation merged = entityManager().merge(implementation); ImplementationManager.purge(merged.getKey()); return merged; }
@Override public boolean isValid(final Implementation resource, final ConstraintValidatorContext context) { context.disableDefaultConstraintViolation(); if (resource.getKey() == null || !KEY_PATTERN.matcher(resource.getKey()).matches()) { context.buildConstraintViolationWithTemplate( getTemplate(EntityViolationType.InvalidKey, "Invalid implementation key")). addPropertyNode("key").addConstraintViolation(); return false; } return true; } }
jobMap.put(TaskJob.DELEGATE_IMPLEMENTATION, jobDelegate.getKey());
if (reportlet.isPresent()) { try { status.set("Invoking reportlet " + report.getReportlets().get(i).getKey()); reportlet.get().extract(handler, status); } catch (Throwable t) {
@Override public void getReport(final Report report, final ReportTO reportTO) { report.setName(reportTO.getName()); report.setCronExpression(reportTO.getCronExpression()); report.setActive(reportTO.isActive()); ReportTemplate template = reportTemplateDAO.find(reportTO.getTemplate()); if (template == null) { SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.RequiredValuesMissing); sce.getElements().add("template"); throw sce; } report.setTemplate(template); reportTO.getReportlets().forEach(reportletKey -> { Implementation reportlet = implementationDAO.find(reportletKey); if (reportlet == null) { LOG.debug("Invalid " + Implementation.class.getSimpleName() + " {}, ignoring...", reportletKey); } else { report.add(reportlet); } }); // remove all implementations not contained in the TO report.getReportlets().removeIf(reportlet -> !reportTO.getReportlets().contains(reportlet.getKey())); }
@Override public ImplementationTO getImplementationTO(final Implementation implementation) { ImplementationTO implementationTO = new ImplementationTO(); implementationTO.setKey(implementation.getKey()); implementationTO.setEngine(implementation.getEngine()); implementationTO.setType(implementation.getType()); implementationTO.setBody(implementation.getBody()); return implementationTO; } }
removeIf(implementation -> !realmTO.getActions().contains(implementation.getKey()));
@Override public RealmTO getRealmTO(final Realm realm, final boolean admin) { RealmTO realmTO = new RealmTO(); realmTO.setKey(realm.getKey()); realmTO.setName(realm.getName()); realmTO.setParent(realm.getParent() == null ? null : realm.getParent().getKey()); realmTO.setFullPath(realm.getFullPath()); if (admin) { realmTO.setAccountPolicy(realm.getAccountPolicy() == null ? null : realm.getAccountPolicy().getKey()); realmTO.setPasswordPolicy(realm.getPasswordPolicy() == null ? null : realm.getPasswordPolicy().getKey()); realm.getActions().forEach(action -> { realmTO.getActions().add(action.getKey()); }); realm.getTemplates().forEach(template -> { realmTO.getTemplates().put(template.getAnyType().getKey(), template.get()); }); realm.getResources().forEach(resource -> { realmTO.getResources().add(resource.getKey()); }); } return realmTO; }
provisioningTask.getActions().removeIf(impl -> !provisioningTaskTO.getActions().contains(impl.getKey()));
@Override public NotificationTO getNotificationTO(final Notification notification) { NotificationTO notificationTO = new NotificationTO(); notificationTO.setKey(notification.getKey()); notificationTO.setTemplate(notification.getTemplate().getKey()); notificationTO.getEvents().addAll(notification.getEvents()); notificationTO.setRecipientsFIQL(notification.getRecipientsFIQL()); notificationTO.getStaticRecipients().addAll(notification.getStaticRecipients()); notificationTO.setRecipientAttrName(notification.getRecipientAttrName()); notificationTO.setSelfAsRecipient(notification.isSelfAsRecipient()); notificationTO.setSender(notification.getSender()); notificationTO.setSubject(notification.getSubject()); notificationTO.setTraceLevel(notification.getTraceLevel()); notificationTO.setActive(notification.isActive()); notification.getAbouts().forEach(about -> { notificationTO.getAbouts().put(about.getAnyType().getKey(), about.get()); }); if (notification.getRecipientsProvider() != null) { notificationTO.setRecipientsProvider(notification.getRecipientsProvider().getKey()); } return notificationTO; }
removeIf(implementation -> !itemTO.getTransformers().contains(implementation.getKey()));
@Override public PlainSchemaTO getPlainSchemaTO(final String key) { PlainSchema schema = plainSchemaDAO.find(key); if (schema == null) { throw new NotFoundException("Schema '" + key + "'"); } PlainSchemaTO schemaTO = new PlainSchemaTO(); schemaTO.setKey(schema.getKey()); schemaTO.setType(schema.getType()); schemaTO.setCipherAlgorithm(schema.getCipherAlgorithm()); schemaTO.setConversionPattern(schema.getConversionPattern()); schemaTO.setEnumerationKeys(schema.getEnumerationKeys()); schemaTO.setEnumerationValues(schema.getEnumerationValues()); schemaTO.setMandatoryCondition(schema.getMandatoryCondition()); schemaTO.setMimeType(schema.getMimeType()); schemaTO.setMultivalue(schema.isMultivalue()); schemaTO.setReadonly(schema.isReadonly()); schemaTO.setSecretKey(schema.getSecretKey()); schemaTO.setUniqueConstraint(schema.isUniqueConstraint()); labels(schema, schemaTO); schemaTO.setAnyTypeClass(schema.getAnyTypeClass() == null ? null : schema.getAnyTypeClass().getKey()); if (schema.getValidator() != null) { schemaTO.setValidator(schema.getValidator().getKey()); } return schemaTO; }