use of org.apache.jackrabbit.oak.spi.xml.PropInfo in project jackrabbit-oak by apache.
the class AccessControlImporterBaseTest method testUnknownRestriction.
@Test(expected = ValueFormatException.class)
public void testUnknownRestriction() throws Exception {
init();
importer.start(aclTree);
importer.startChildInfo(aceInfo, ImmutableList.of(principalInfo, privInfo));
PropInfo invalidRestrProp = new PropInfo("unknown", PropertyType.STRING, createTextValue("val"));
importer.startChildInfo(restrInfo, ImmutableList.of(invalidRestrProp));
importer.endChildInfo();
importer.endChildInfo();
importer.end(aclTree);
}
use of org.apache.jackrabbit.oak.spi.xml.PropInfo in project jackrabbit-oak by apache.
the class AccessControlImporterBaseTest method testImportWithRestrictions.
@Test
public void testImportWithRestrictions() throws Exception {
// single value restriction
PropInfo globInfo = new PropInfo(REP_GLOB, PropertyType.STRING, createTextValue("/*"));
// mv restriction
PropInfo ntNamesInfo = new PropInfo(REP_NT_NAMES, PropertyType.NAME, createTextValues(NodeTypeConstants.NT_OAK_RESOURCE, NodeTypeConstants.NT_OAK_RESOURCE));
// mv restriction with singular value
PropInfo itemNamesInfo = new PropInfo(REP_ITEM_NAMES, PropertyType.NAME, createTextValue("itemName"));
init();
importer.start(aclTree);
importer.startChildInfo(aceInfo, ImmutableList.of(principalInfo, privInfo, globInfo, ntNamesInfo, itemNamesInfo));
importer.endChildInfo();
importer.end(aclTree);
assertImport(aclTree, principalName);
}
use of org.apache.jackrabbit.oak.spi.xml.PropInfo in project jackrabbit-oak by apache.
the class AccessControlImporterIgnoreTest method testImportWithUnknownPrincipal.
@Test
public void testImportWithUnknownPrincipal() throws Exception {
init();
importer.start(aclTree);
PropInfo privs = new PropInfo(REP_PRIVILEGES, PropertyType.NAME, createTextValues(PrivilegeConstants.JCR_READ));
importer.startChildInfo(aceInfo, ImmutableList.of(unknownPrincipalInfo, privs));
importer.endChildInfo();
importer.end(aclTree);
// ace with invalid principal is ignored with this behaviour => ace tree not imported
assertFalse(aclTree.getChildren().iterator().hasNext());
}
use of org.apache.jackrabbit.oak.spi.xml.PropInfo in project jackrabbit-oak by apache.
the class DocViewImportHandler method startElement.
//-------------------------------------------------------< ContentHandler >
/**
* {@inheritDoc}
* <p>
* See also {@link org.apache.jackrabbit.commons.xml.Exporter#exportProperties(Node)}
* regarding special handling of multi-valued properties on export.
*/
@Override
public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException {
// process buffered character data
processCharacters();
try {
NameInfo nameInfo = new NameInfo(qName);
nameInfo = processName(nameInfo);
// properties
String id = null;
String nodeTypeName = null;
Iterable<String> mixinTypes = null;
List<PropInfo> props = new ArrayList<PropInfo>(atts.getLength());
for (int i = 0; i < atts.getLength(); i++) {
if (atts.getURI(i).equals(NamespaceConstants.NAMESPACE_XMLNS)) {
// see http://issues.apache.org/jira/browse/JCR-620#action_12448164
continue;
}
NameInfo propNameInfo = processName(new NameInfo(atts.getQName(i)));
String attrValue = atts.getValue(i);
if (NamespaceRegistry.NAMESPACE_JCR.equals(propNameInfo.getNamespaceUri()) && "primaryType".equals(propNameInfo.getLocalName())) {
// jcr:primaryType
if (!attrValue.isEmpty()) {
//TODO
nodeTypeName = attrValue;
}
} else if (NamespaceRegistry.NAMESPACE_JCR.equals(propNameInfo.getNamespaceUri()) && "mixinTypes".equals(propNameInfo.getLocalName())) {
// jcr:mixinTypes
mixinTypes = parseNames(attrValue);
} else if (NamespaceRegistry.NAMESPACE_JCR.equals(propNameInfo.getNamespaceUri()) && "uuid".equals(propNameInfo.getLocalName())) {
// jcr:uuid
if (!attrValue.isEmpty()) {
id = attrValue;
}
} else {
// always assume single-valued property for the time being
// until a way of properly serializing/detecting multi-valued
// properties on re-import is found (see JCR-325);
// see also DocViewSAXEventGenerator#leavingProperties(Node, int)
// TODO proper multi-value serialization support
TextValue tv = new StringValue(attrValue, sessionContext.getValueFactory(), currentNamePathMapper());
props.add(new PropInfo(propNameInfo.getRepoQualifiedName(), PropertyType.UNDEFINED, tv));
}
}
NodeInfo node = new NodeInfo(nameInfo.getRepoQualifiedName(), nodeTypeName, mixinTypes, id);
// all information has been collected, now delegate to importer
importer.startNode(node, props);
// push current node data onto stack
stack.push(node);
} catch (RepositoryException re) {
throw new SAXException(re);
}
}
use of org.apache.jackrabbit.oak.spi.xml.PropInfo in project jackrabbit-oak by apache.
the class CugImporterTest method testInvalidPropInfo.
@Test
public void testInvalidPropInfo() throws Exception {
createCug(root, SUPPORTED_PATH, "principalName");
Tree parent = root.getTree(SUPPORTED_PATH);
PropInfo propInfo = new PropInfo(JcrConstants.JCR_PRIMARYTYPE, PropertyType.STRING, ImmutableList.of(new TextValue() {
@Override
public String getString() {
return "principalName";
}
@Override
public Value getValue(int targetType) throws RepositoryException {
return getValueFactory(root).createValue("principalName", PropertyType.STRING);
}
@Override
public void dispose() {
}
}));
PropertyDefinition propDef = Mockito.mock(PropertyDefinition.class);
assertFalse(importer.handlePropInfo(parent, propInfo, propDef));
}
Aggregations