/** * {@inheritDoc} */ @Override public void onProperty(Property prop, int level) throws RepositoryException { if (ignored.contains(prop.getName()) && prop.getDefinition().isProtected()) { return; } props.add(prop); }
public boolean canRemoveProperty(String s) { boolean canRemovePrp = true; Iterator it = ntd.getPropertyDefinitionTemplates().iterator(); PropertyDefinition pd = null; while (it.hasNext()) { pd = (PropertyDefinitionTemplate) it.next(); if (((pd != null) && pd.getName().equals(s) && (pd.isProtected() || pd.isMandatory()))) { canRemovePrp = false; return canRemovePrp; } } return canRemovePrp; }
private void checkProtectedProperty(@NotNull Tree parent, @NotNull PropertyState property) throws RepositoryException { ReadOnlyNodeTypeManager nodeTypeManager = authorizable.getUserManager().getNodeTypeManager(); PropertyDefinition def = nodeTypeManager.getDefinition(parent, property, false); if (def.isProtected()) { throw new ConstraintViolationException( "Attempt to set an protected property " + property.getName()); } }
private void checkProtectedProperty(@NotNull Tree parent, @NotNull PropertyState property) throws RepositoryException { ReadOnlyNodeTypeManager nodeTypeManager = authorizable.getUserManager().getNodeTypeManager(); PropertyDefinition def = nodeTypeManager.getDefinition(parent, property, false); if (def.isProtected()) { throw new ConstraintViolationException( "Attempt to set an protected property " + property.getName()); } }
private void checkProtectedProperty(@Nonnull Tree parent, @Nonnull PropertyState property) throws RepositoryException { ReadOnlyNodeTypeManager nodeTypeManager = authorizable.getUserManager().getNodeTypeManager(); PropertyDefinition def = nodeTypeManager.getDefinition(parent, property, false); if (def.isProtected()) { throw new ConstraintViolationException( "Attempt to set an protected property " + property.getName()); } }
@Override protected void removeProperties(final Node node) throws RepositoryException { for (Property property : new PropertyIterable(node.getProperties())) { if (property.getDefinition().isProtected()) { continue; } String name = property.getName(); if (Arrays.binarySearch(PROTECTED_PROPERTIES, name) >= 0) { continue; } property.remove(); } }
protected void removeProperties(final Node node) throws RepositoryException { for (Property property : new PropertyIterable(node.getProperties())) { if (!property.getDefinition().isProtected()) { property.remove(); } } }
public static void saveProperties(Node node, List<HstPropertyDefinition> definitions, Map<String, Object> properties) throws RepositoryException { for (PropertyIterator propertyIterator = node.getProperties(); propertyIterator.hasNext(); ) { Property prop = propertyIterator.nextProperty(); if (prop.getDefinition().isProtected()) { continue; } prop.remove(); } for (HstPropertyDefinition definition : definitions) { if (properties.containsKey(definition.getName()) && properties.get(definition.getName()) != null) { setHstValueToJcr(node, definition, properties.get(definition.getName())); } } }
private static void checkProtected(Property prop) throws RepositoryException { assertTrue(prop.getDefinition().isProtected()); }
private static void checkProtected(Property prop) throws RepositoryException { assertTrue(prop.getDefinition().isProtected()); }
public boolean isPropertyProtectedOrNewAutoCreated(final Object n, final String name) throws PersistenceException { final Node node = (Node)n; try { final PropertyDefinition pd = this.searchPropertyDefinition(node, name); if ( pd != null ) { // SLING-2877 (autocreated check is only required for new nodes) if ( (node.isNew() && pd.isAutoCreated()) || pd.isProtected() ) { return true; } } } catch ( final RepositoryException re) { throw new PersistenceException(re.getMessage(), re); } return false; }
@Override public void setProperty(final PropInfo propInfo) throws RepositoryException { if (propInfo != null && getCurrent() != null && Arrays.binarySearch(PROTECTED, propInfo.getName()) < 0) { PropertyDefinition definition = propInfo.getApplicablePropertyDef(getCurrentNodeTypes()); if (definition == null) { log.error("Unable to create property from PropInfo " + propInfo + ": No applicable property definition"); } else if (!definition.isProtected()) { if (propInfo.isMultiple()) { getCurrent().setProperty(propInfo.getName(), propInfo.getValues(), propInfo.getType()); } else { getCurrent().setProperty(propInfo.getName(), propInfo.getValue(), propInfo.getType()); } } } }
@Override public void checkRemoveProperty(PropertyState property) throws RepositoryException { PropertyDefinition definition = getDefinition(property); if (definition.isProtected()) { return; } if (!definition.getDeclaringNodeType().canRemoveProperty(property.getName())) { throw new ConstraintViolationException("Cannot remove property '" + property.getName() + '\''); } }
@Override public void checkRemoveProperty(PropertyState property) throws RepositoryException { PropertyDefinition definition = getDefinition(property); if (definition.isProtected()) { return; } if (!definition.getDeclaringNodeType().canRemoveProperty(property.getName())) { throw new ConstraintViolationException("Cannot remove property '" + property.getName() + '\''); } }
@Override public void checkRemoveProperty(PropertyState property) throws RepositoryException { PropertyDefinition definition = getDefinition(property); if (definition.isProtected()) { return; } if (!definition.getDeclaringNodeType().canRemoveProperty(property.getName())) { throw new ConstraintViolationException("Cannot remove property '" + property.getName() + '\''); } }
@Override protected Item createRemoveItem() throws NotExecutableException, RepositoryException, LockException, ConstraintViolationException, ItemExistsException, NoSuchNodeTypeException, VersionException { Property removeProperty; if (testRootNode.hasProperty(propertyName1)) { removeProperty = testRootNode.getProperty(propertyName1); if (removeProperty.getDefinition().isProtected() || removeProperty.getDefinition().isMandatory()) { throw new NotExecutableException("Property to be remove must be mandatory nor protected '" + propertyName1 + "'."); } } else { removeProperty = testRootNode.setProperty(propertyName1, "anyString"); } // make sure the new node is persisted. testRootNode.save(); return removeProperty; }
public void testGroupGetProperties() throws RepositoryException, NotExecutableException { AuthorizableImpl group = (AuthorizableImpl) getTestGroup(superuser); NodeImpl n = group.getNode(); for (PropertyIterator it = n.getProperties(); it.hasNext();) { PropertyImpl p = (PropertyImpl) it.nextProperty(); if (p.getDefinition().isProtected()) { assertFalse(group.hasProperty(p.getName())); assertNull(group.getProperty(p.getName())); } else { // authorizable defined property assertTrue(group.hasProperty(p.getName())); assertNotNull(group.getProperty(p.getName())); } } }
@Test public void testUserGetProperties() throws RepositoryException, NotExecutableException { Node n = getNode(user, superuser); for (PropertyIterator it = n.getProperties(); it.hasNext();) { Property p = it.nextProperty(); if (p.getDefinition().isProtected()) { assertFalse(user.hasProperty(p.getName())); assertNull(user.getProperty(p.getName())); } else { // authorizable defined property assertTrue(user.hasProperty(p.getName())); assertNotNull(user.getProperty(p.getName())); } } }
@Test public void testGroupGetProperties() throws RepositoryException, NotExecutableException { Node n = getNode(group, superuser); for (PropertyIterator it = n.getProperties(); it.hasNext();) { Property prop = it.nextProperty(); if (prop.getDefinition().isProtected()) { assertFalse(group.hasProperty(prop.getName())); assertNull(group.getProperty(prop.getName())); } else { // authorizable defined property assertTrue(group.hasProperty(prop.getName())); assertNotNull(group.getProperty(prop.getName())); } } }
public void testUserGetProperties() throws RepositoryException, NotExecutableException { AuthorizableImpl user = (AuthorizableImpl) getTestUser(superuser); NodeImpl n = user.getNode(); for (PropertyIterator it = n.getProperties(); it.hasNext();) { PropertyImpl p = (PropertyImpl) it.nextProperty(); if (p.getDefinition().isProtected()) { assertFalse(user.hasProperty(p.getName())); assertNull(user.getProperty(p.getName())); } else { // authorizable defined property assertTrue(user.hasProperty(p.getName())); assertNotNull(user.getProperty(p.getName())); } } }