use of javax.annotation.Nonnull in project jackrabbit-oak by apache.
the class ItemImpl method createMultiState.
@Nonnull
protected PropertyState createMultiState(String oakName, List<Value> values, Type<?> type) throws RepositoryException {
if (values.isEmpty()) {
Type<?> base = type.getBaseType();
if (base == UNDEFINED) {
base = STRING;
}
return PropertyBuilder.array(base).setName(oakName).getPropertyState();
}
if (type == UNDEFINEDS) {
type = Type.fromTag(values.get(0).getType(), true);
}
if (type == NAMES || type == PATHS) {
Type<?> base = type.getBaseType();
List<String> strings = newArrayListWithCapacity(values.size());
for (Value value : values) {
strings.add(getOakValue(value, base));
}
return createProperty(oakName, strings, type);
} else {
return createProperty(oakName, values, type.tag());
}
}
use of javax.annotation.Nonnull in project jackrabbit-oak by apache.
the class NodeImpl method internalSetProperty.
private Property internalSetProperty(final String jcrName, final Value[] values, final int type, final boolean exactTypeMatch) throws RepositoryException {
final String oakName = getOakPathOrThrow(checkNotNull(jcrName));
final PropertyState state = createMultiState(oakName, compact(values), Type.fromTag(type, true));
if (values.length > MV_PROPERTY_WARN_THRESHOLD) {
LOG.warn("Large multi valued property [{}/{}] detected ({} values).", dlg.getPath(), jcrName, values.length);
}
return perform(new ItemWriteOperation<Property>("internalSetProperty") {
@Override
public void checkPreconditions() throws RepositoryException {
super.checkPreconditions();
if (!isCheckedOut() && getOPV(dlg.getTree(), state) != OnParentVersionAction.IGNORE) {
throw new VersionException(format("Cannot set property. Node [%s] is checked in.", getNodePath()));
}
}
@Nonnull
@Override
public Property perform() throws RepositoryException {
return new PropertyImpl(dlg.setProperty(state, exactTypeMatch, false), sessionContext);
}
@Override
public String toString() {
return format("Setting property [%s/%s]", dlg.getPath(), jcrName);
}
});
}
use of javax.annotation.Nonnull in project jackrabbit-oak by apache.
the class LockOperation method perform.
@Nonnull
@Override
public T perform() throws RepositoryException {
session.refresh(true);
NodeDelegate node = session.getNode(path);
if (node != null) {
return perform(node);
} else {
throw new PathNotFoundException("Node " + path + " not found");
}
}
use of javax.annotation.Nonnull in project jackrabbit-oak by apache.
the class EffectiveType method getTypeNames.
@Nonnull
Set<String> getTypeNames() {
Set<String> names = newHashSet();
for (NodeState type : types) {
names.add(type.getName(JCR_NODETYPENAME));
addAll(names, type.getNames(REP_SUPERTYPES));
}
return names;
}
use of javax.annotation.Nonnull in project jackrabbit-oak by apache.
the class UserQueryManager method findAuthorizables.
@Nonnull
private Iterator<Authorizable> findAuthorizables(@Nonnull String statement, long limit, long offset, @Nullable AuthorizableType type) throws RepositoryException {
try {
Result query = root.getQueryEngine().executeQuery(statement, javax.jcr.query.Query.XPATH, limit, offset, NO_BINDINGS, namePathMapper.getSessionLocalMappings());
Iterable<? extends ResultRow> resultRows = query.getRows();
Iterator<Authorizable> authorizables = Iterators.transform(resultRows.iterator(), new ResultRowToAuthorizable(userManager, root, type));
return Iterators.filter(authorizables, new UniqueResultPredicate());
} catch (ParseException e) {
log.warn("Invalid user query: " + statement, e);
throw new RepositoryException(e);
}
}
Aggregations