use of org.apache.jackrabbit.core.nodetype.InvalidNodeTypeDefException in project jackrabbit by apache.
the class ClusterNode method process.
/**
* {@inheritDoc}
*/
public void process(NodeTypeRecord record) {
if (nodeTypeListener == null) {
String msg = "NodeType listener unavailable.";
log.error(msg);
return;
}
Collection coll = record.getCollection();
try {
switch(record.getOperation()) {
case NodeTypeRecord.REGISTER:
nodeTypeListener.externalRegistered(coll);
break;
case NodeTypeRecord.UNREGISTER:
nodeTypeListener.externalUnregistered(coll);
break;
case NodeTypeRecord.REREGISTER:
QNodeTypeDefinition ntd = (QNodeTypeDefinition) coll.iterator().next();
nodeTypeListener.externalReregistered(ntd);
break;
}
} catch (InvalidNodeTypeDefException e) {
String msg = "Unable to deliver node type operation: " + e.getMessage();
log.error(msg);
} catch (RepositoryException e) {
String msg = "Unable to deliver node type operation: " + e.getMessage();
log.error(msg);
}
}
use of org.apache.jackrabbit.core.nodetype.InvalidNodeTypeDefException in project jackrabbit by apache.
the class NodeTypeReader method getPropDef.
/**
* Returns the property definition specified by the current element.
*
* @return property definition
* @throws InvalidNodeTypeDefException if the definition is invalid
* @throws NameException if the definition contains an
* illegal name
* @throws NamespaceException if a namespace is not defined
*/
private QPropertyDefinitionBuilder getPropDef() throws InvalidNodeTypeDefException, NameException, NamespaceException {
QPropertyDefinitionBuilder def = new QPropertyDefinitionBuilder();
String name = walker.getAttribute(Constants.NAME_ATTRIBUTE);
if (name.equals("*")) {
def.setName(NameConstants.ANY_NAME);
} else {
def.setName(resolver.getQName(name));
}
// simple attributes
def.setAutoCreated(Boolean.valueOf(walker.getAttribute(Constants.AUTOCREATED_ATTRIBUTE)));
def.setMandatory(Boolean.valueOf(walker.getAttribute(Constants.MANDATORY_ATTRIBUTE)));
def.setProtected(Boolean.valueOf(walker.getAttribute(Constants.PROTECTED_ATTRIBUTE)));
def.setOnParentVersion(OnParentVersionAction.valueFromName(walker.getAttribute(Constants.ONPARENTVERSION_ATTRIBUTE)));
def.setMultiple(Boolean.valueOf(walker.getAttribute(Constants.MULTIPLE_ATTRIBUTE)));
def.setFullTextSearchable(Boolean.valueOf(walker.getAttribute(Constants.ISFULLTEXTSEARCHABLE_ATTRIBUTE)));
def.setQueryOrderable(Boolean.valueOf(walker.getAttribute(Constants.ISQUERYORDERABLE_ATTRIBUTE)));
String s = walker.getAttribute(Constants.AVAILABLEQUERYOPERATORS_ATTRIBUTE);
if (s != null && s.length() > 0) {
String[] ops = s.split(" ");
List<String> queryOps = new ArrayList<String>();
for (String op1 : ops) {
String op = op1.trim();
if (op.equals(Constants.EQ_ENTITY)) {
queryOps.add(QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO);
} else if (op.equals(Constants.NE_ENTITY)) {
queryOps.add(QueryObjectModelConstants.JCR_OPERATOR_NOT_EQUAL_TO);
} else if (op.equals(Constants.LT_ENTITY)) {
queryOps.add(QueryObjectModelConstants.JCR_OPERATOR_LESS_THAN);
} else if (op.equals(Constants.LE_ENTITY)) {
queryOps.add(QueryObjectModelConstants.JCR_OPERATOR_LESS_THAN_OR_EQUAL_TO);
} else if (op.equals(Constants.GT_ENTITY)) {
queryOps.add(QueryObjectModelConstants.JCR_OPERATOR_GREATER_THAN);
} else if (op.equals(Constants.GE_ENTITY)) {
queryOps.add(QueryObjectModelConstants.JCR_OPERATOR_GREATER_THAN_OR_EQUAL_TO);
} else if (op.equals(Constants.LIKE_ENTITY)) {
queryOps.add(QueryObjectModelConstants.JCR_OPERATOR_LIKE);
} else {
throw new InvalidNodeTypeDefException("'" + op + "' is not a valid query operator");
}
}
def.setAvailableQueryOperators(queryOps.toArray(new String[queryOps.size()]));
}
def.setRequiredType(PropertyType.valueFromName(walker.getAttribute(Constants.REQUIREDTYPE_ATTRIBUTE)));
// value constraints
if (walker.enterElement(Constants.VALUECONSTRAINTS_ELEMENT)) {
List<QValueConstraint> constraints = new ArrayList<QValueConstraint>();
int type = def.getRequiredType();
while (walker.iterateElements(Constants.VALUECONSTRAINT_ELEMENT)) {
String constraint = walker.getContent();
try {
constraints.add(ValueConstraint.create(type, constraint.trim(), resolver));
} catch (InvalidConstraintException e) {
throw new InvalidNodeTypeDefException("Invalid value constraint " + constraint, e);
}
}
def.setValueConstraints(constraints.toArray(new QValueConstraint[constraints.size()]));
walker.leaveElement();
}
// default values
if (walker.enterElement(Constants.DEFAULTVALUES_ELEMENT)) {
List<InternalValue> values = new ArrayList<InternalValue>();
int type = def.getRequiredType();
if (type == PropertyType.UNDEFINED) {
type = PropertyType.STRING;
}
while (walker.iterateElements(Constants.DEFAULTVALUE_ELEMENT)) {
String value = walker.getContent();
try {
Value v = ValueHelper.convert(value, type, valueFactory);
values.add((InternalValue) ValueFormat.getQValue(v, resolver, qValueFactory));
} catch (RepositoryException e) {
throw new InvalidNodeTypeDefException("Unable to create default value: " + value, e);
}
}
def.setDefaultValues(values.toArray(new InternalValue[values.size()]));
walker.leaveElement();
}
return def;
}
use of org.apache.jackrabbit.core.nodetype.InvalidNodeTypeDefException in project jackrabbit by apache.
the class LostFromCacheIssueTest method setUp.
public void setUp() throws Exception {
super.setUp();
Workspace workspace = superuser.getWorkspace();
NamespaceRegistry namespaceRegistry = workspace.getNamespaceRegistry();
NodeTypeManager ntmgr = workspace.getNodeTypeManager();
NodeTypeRegistry nodetypeRegistry = ((NodeTypeManagerImpl) ntmgr).getNodeTypeRegistry();
try {
namespaceRegistry.registerNamespace(NAMESPACE_PREFIX, NAMESPACE_URI);
} catch (NamespaceException ignore) {
//already exists
}
QNodeTypeDefinition nodeTypeDefinition = new QNodeTypeDefinitionImpl(((SessionImpl) superuser).getQName(NODETYPE_1), Name.EMPTY_ARRAY, Name.EMPTY_ARRAY, true, false, true, false, null, QPropertyDefinition.EMPTY_ARRAY, QNodeDefinition.EMPTY_ARRAY);
try {
nodetypeRegistry.registerNodeType(nodeTypeDefinition);
} catch (InvalidNodeTypeDefException ignore) {
//already exists
}
nodeTypeDefinition = new QNodeTypeDefinitionImpl(((SessionImpl) superuser).getQName(NODETYPE_2), Name.EMPTY_ARRAY, Name.EMPTY_ARRAY, true, false, true, false, null, QPropertyDefinition.EMPTY_ARRAY, QNodeDefinition.EMPTY_ARRAY);
try {
nodetypeRegistry.registerNodeType(nodeTypeDefinition);
} catch (InvalidNodeTypeDefException ignore) {
//already exists
}
getOrCreate(superuser.getRootNode(), TESTNODE_PATH);
superuser.save();
}
use of org.apache.jackrabbit.core.nodetype.InvalidNodeTypeDefException in project jackrabbit by apache.
the class TestAll method testInvalidXMLNodeTypes.
/** Test for same node type name on node type import. */
public void testInvalidXMLNodeTypes() throws Exception {
JackrabbitNodeTypeManager ntm = (JackrabbitNodeTypeManager) superuser.getWorkspace().getNodeTypeManager();
try {
ntm.registerNodeTypes(TestAll.class.getResourceAsStream(TEST_SAME_NT_NAME_XML_NODETYPES), JackrabbitNodeTypeManager.TEXT_XML);
fail("Importing multiple node types with the same name must fail");
} catch (RepositoryException e) {
if (e.getCause() instanceof InvalidNodeTypeDefException) {
// Expected
} else {
throw e;
}
}
}
use of org.apache.jackrabbit.core.nodetype.InvalidNodeTypeDefException in project jackrabbit by apache.
the class TestAll method testInvalidCNDNodeTypes.
/** Test for same node type name on node type import. */
public void testInvalidCNDNodeTypes() throws Exception {
JackrabbitNodeTypeManager ntm = (JackrabbitNodeTypeManager) superuser.getWorkspace().getNodeTypeManager();
try {
ntm.registerNodeTypes(TestAll.class.getResourceAsStream(TEST_SAME_NT_NAME_CND_NODETYPES), JackrabbitNodeTypeManager.TEXT_X_JCR_CND);
fail("Importing multiple node types with the same name must fail");
} catch (RepositoryException e) {
if (e.getCause() instanceof InvalidNodeTypeDefException) {
// Expected
} else {
throw e;
}
}
}
Aggregations