use of org.apache.jackrabbit.spi.commons.conversion.MalformedPathException in project jackrabbit by apache.
the class LockManagerImpl method consolidateEvents.
/**
* Consolidate an event iterator obtained from observation, merging
* add and remove operations on nodes with the same UUID into a move
* operation.
*/
@SuppressWarnings("unchecked")
private Iterator<HierarchyEvent> consolidateEvents(EventIterator events) {
LinkedMap eventMap = new LinkedMap();
while (events.hasNext()) {
EventImpl event = (EventImpl) events.nextEvent();
HierarchyEvent he;
try {
he = new HierarchyEvent(event.getChildId(), sysSession.getQPath(event.getPath()).getNormalizedPath(), event.getType());
} catch (MalformedPathException e) {
log.info("Unable to get event's path: " + e.getMessage());
continue;
} catch (RepositoryException e) {
log.info("Unable to get event's path: " + e.getMessage());
continue;
}
HierarchyEvent heExisting = (HierarchyEvent) eventMap.get(he.id);
if (heExisting != null) {
heExisting.merge(he);
} else {
eventMap.put(he.id, he);
}
}
return eventMap.values().iterator();
}
use of org.apache.jackrabbit.spi.commons.conversion.MalformedPathException in project jackrabbit by apache.
the class ValueFactoryQImpl method createValue.
/**
* {@inheritDoc}
*/
public Value createValue(String value, int type) throws ValueFormatException {
try {
QValue qvalue;
if (type == PropertyType.NAME) {
Name name = resolver.getQName(value);
qvalue = qfactory.create(name);
} else if (type == PropertyType.PATH) {
Path path = resolver.getQPath(value, false);
qvalue = qfactory.create(path);
} else {
qvalue = qfactory.create(value, type);
}
return new QValueValue(qvalue, resolver);
} catch (IllegalNameException ex) {
throw new ValueFormatException(ex);
} catch (MalformedPathException ex) {
throw new ValueFormatException(ex);
} catch (NamespaceException ex) {
throw new ValueFormatException(ex);
} catch (ValueFormatException ex) {
throw ex;
} catch (RepositoryException ex) {
throw new ValueFormatException(ex);
}
}
use of org.apache.jackrabbit.spi.commons.conversion.MalformedPathException in project jackrabbit by apache.
the class ValueFormatTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
idResolver = new IdentifierResolver() {
public Path getPath(String identifier) throws MalformedPathException {
throw new UnsupportedOperationException();
}
public void checkFormat(String identifier) throws MalformedPathException {
// nop
}
};
NameResolver nResolver = new ParsingNameResolver(NameFactoryImpl.getInstance(), new DummyNamespaceResolver());
PathResolver pResolver = new ParsingPathResolver(PathFactoryImpl.getInstance(), nResolver, idResolver);
resolver = new DefaultNamePathResolver(nResolver, pResolver);
qvFactory = QValueFactoryImpl.getInstance();
vFactory = new ValueFactoryQImpl(qvFactory, resolver);
}
use of org.apache.jackrabbit.spi.commons.conversion.MalformedPathException in project jackrabbit by apache.
the class JCRSQLQueryBuilder method createRelationQueryNode.
// ------------------------< internal >--------------------------------------
/**
* Creates a new {@link org.apache.jackrabbit.spi.commons.query.RelationQueryNode}.
*
* @param parent the parent node for the created <code>RelationQueryNode</code>.
* @param propertyName the property name for the relation.
* @param operationType the operation type.
* @param literal the literal value for the relation or
* <code>null</code> if the relation does not have a
* literal (e.g. IS NULL).
* @return a <code>RelationQueryNode</code>.
* @throws IllegalArgumentException if the literal value does not conform
* to its type. E.g. a malformed String representation of a date.
*/
private RelationQueryNode createRelationQueryNode(QueryNode parent, Name propertyName, int operationType, ASTLiteral literal) throws IllegalArgumentException {
RelationQueryNode node = null;
try {
Path relPath = null;
if (propertyName != null) {
PathBuilder builder = new PathBuilder();
builder.addLast(propertyName);
relPath = builder.getPath();
}
if (literal == null) {
node = factory.createRelationQueryNode(parent, operationType);
node.setRelativePath(relPath);
} else if (literal.getType() == QueryConstants.TYPE_DATE) {
SimpleDateFormat format = new SimpleDateFormat(DATE_PATTERN);
Date date = format.parse(literal.getValue());
node = factory.createRelationQueryNode(parent, operationType);
node.setRelativePath(relPath);
node.setDateValue(date);
} else if (literal.getType() == QueryConstants.TYPE_DOUBLE) {
double d = Double.parseDouble(literal.getValue());
node = factory.createRelationQueryNode(parent, operationType);
node.setRelativePath(relPath);
node.setDoubleValue(d);
} else if (literal.getType() == QueryConstants.TYPE_LONG) {
long l = Long.parseLong(literal.getValue());
node = factory.createRelationQueryNode(parent, operationType);
node.setRelativePath(relPath);
node.setLongValue(l);
} else if (literal.getType() == QueryConstants.TYPE_STRING) {
node = factory.createRelationQueryNode(parent, operationType);
node.setRelativePath(relPath);
node.setStringValue(literal.getValue());
} else if (literal.getType() == QueryConstants.TYPE_TIMESTAMP) {
Calendar c = ISO8601.parse(literal.getValue());
node = factory.createRelationQueryNode(parent, operationType);
node.setRelativePath(relPath);
node.setDateValue(c.getTime());
}
} catch (java.text.ParseException e) {
throw new IllegalArgumentException(e.toString());
} catch (NumberFormatException e) {
throw new IllegalArgumentException(e.toString());
} catch (MalformedPathException e) {
// path is always valid, but throw anyway
throw new IllegalArgumentException(e.getMessage());
}
if (node == null) {
throw new IllegalArgumentException("Unknown type for literal: " + literal.getType());
}
return node;
}
use of org.apache.jackrabbit.spi.commons.conversion.MalformedPathException in project jackrabbit by apache.
the class OrderQueryNode method createPath.
// --------------------------------< internal >------------------------------
/**
* Creates a path with a single element out of the given <code>name</code>.
*
* @param name the name to create the path from.
* @return a path with a single element.
*/
private static Path createPath(Name name) {
try {
PathBuilder builder = new PathBuilder();
builder.addLast(name);
return builder.getPath();
} catch (MalformedPathException e) {
// never happens, we just added an element
throw new InternalError();
}
}
Aggregations