Search in sources :

Example 81 with Nonnull

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());
    }
}
Also used : Value(javax.jcr.Value) Nonnull(javax.annotation.Nonnull)

Example 82 with Nonnull

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);
        }
    });
}
Also used : Nonnull(javax.annotation.Nonnull) RepositoryException(javax.jcr.RepositoryException) Property(javax.jcr.Property) PropertyState(org.apache.jackrabbit.oak.api.PropertyState) VersionException(javax.jcr.version.VersionException)

Example 83 with Nonnull

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");
    }
}
Also used : PathNotFoundException(javax.jcr.PathNotFoundException) NodeDelegate(org.apache.jackrabbit.oak.jcr.delegate.NodeDelegate) Nonnull(javax.annotation.Nonnull)

Example 84 with Nonnull

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;
}
Also used : NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) Nonnull(javax.annotation.Nonnull)

Example 85 with Nonnull

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);
    }
}
Also used : Authorizable(org.apache.jackrabbit.api.security.user.Authorizable) RepositoryException(javax.jcr.RepositoryException) ParseException(java.text.ParseException) Result(org.apache.jackrabbit.oak.api.Result) Nonnull(javax.annotation.Nonnull)

Aggregations

Nonnull (javax.annotation.Nonnull)2624 Nullable (javax.annotation.Nullable)338 ArrayList (java.util.ArrayList)336 ItemStack (net.minecraft.item.ItemStack)327 List (java.util.List)305 Map (java.util.Map)229 Layer (com.simiacryptus.mindseye.lang.Layer)188 Tensor (com.simiacryptus.mindseye.lang.Tensor)185 Arrays (java.util.Arrays)182 Collectors (java.util.stream.Collectors)169 IOException (java.io.IOException)165 JsonObject (com.google.gson.JsonObject)156 HashMap (java.util.HashMap)145 IntStream (java.util.stream.IntStream)145 Test (org.junit.Test)143 LoggerFactory (org.slf4j.LoggerFactory)138 Logger (org.slf4j.Logger)137 Result (com.simiacryptus.mindseye.lang.Result)130 TensorList (com.simiacryptus.mindseye.lang.TensorList)123 DeltaSet (com.simiacryptus.mindseye.lang.DeltaSet)111