private DerivedDataFunction createFunction(final FunctionDescription function) throws RepositoryException { try { Class clazz = Class.forName(function.getClassName()); DerivedDataFunction func = (DerivedDataFunction) clazz.newInstance(); func.setValueFactory(session.getValueFactory()); return func; } catch (ClassNotFoundException e) { throw new RepositoryException("No such function", e); } catch (InstantiationException e) { throw new RepositoryException("Can't create function", e); } catch (IllegalAccessException e) { throw new RepositoryException("Can't access function", e); } }
private boolean updateRelatedProperty(final Node modified, final Collection<String> dependencies) throws RepositoryException { if (modified.isNodeType(JcrConstants.MIX_REFERENCEABLE)) { dependencies.remove(modified.getIdentifier()); } Value[] dependenciesValues = new Value[dependencies.size()]; int i = 0; for (String dependency : dependencies) { dependenciesValues[i++] = session.getValueFactory().createValue(dependency, PropertyType.REFERENCE); } Value[] oldDependenciesValues = null; if (modified.hasProperty(HippoNodeType.HIPPO_RELATED)) { oldDependenciesValues = modified.getProperty(HippoNodeType.HIPPO_RELATED).getValues(); } final boolean changed = !((oldDependenciesValues == null && dependenciesValues.length == 0) || Arrays.equals(oldDependenciesValues, dependenciesValues)); if (changed && modified.isNodeType(HippoNodeType.NT_DERIVED)) { JcrUtils.ensureIsCheckedOut(modified); if (dependenciesValues.length == 0) { modified.getProperty(HippoNodeType.HIPPO_RELATED).remove(); } else { modified.setProperty(HippoNodeType.HIPPO_RELATED, dependenciesValues, PropertyType.REFERENCE); } } return changed; }