You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by kw...@apache.org on 2022/01/18 10:57:18 UTC
[sling-org-apache-sling-jcr-resource] branch master updated: Use JcrConstants
This is an automated email from the ASF dual-hosted git repository.
kwin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-jcr-resource.git
The following commit(s) were added to refs/heads/master by this push:
new 8345f4e Use JcrConstants
8345f4e is described below
commit 8345f4ed4857ed5ca240ac20050b68c84c61646c
Author: Konrad Windszus <kw...@apache.org>
AuthorDate: Tue Jan 18 11:55:17 2022 +0100
Use JcrConstants
Add missing null annotation, fix some error messages and labels
---
.../sling/jcr/resource/internal/JcrModifiableValueMap.java | 3 ++-
.../org/apache/sling/jcr/resource/internal/NodeUtil.java | 6 ------
.../internal/helper/jcr/BinaryDownloadUriProvider.java | 6 +++---
.../resource/internal/helper/jcr/JcrResourceProvider.java | 13 +++++++------
4 files changed, 12 insertions(+), 16 deletions(-)
diff --git a/src/main/java/org/apache/sling/jcr/resource/internal/JcrModifiableValueMap.java b/src/main/java/org/apache/sling/jcr/resource/internal/JcrModifiableValueMap.java
index 445edb1..d28afdd 100644
--- a/src/main/java/org/apache/sling/jcr/resource/internal/JcrModifiableValueMap.java
+++ b/src/main/java/org/apache/sling/jcr/resource/internal/JcrModifiableValueMap.java
@@ -25,6 +25,7 @@ import javax.jcr.Node;
import javax.jcr.RepositoryException;
import javax.jcr.Value;
+import org.apache.jackrabbit.JcrConstants;
import org.apache.sling.api.resource.ModifiableValueMap;
import org.apache.sling.jcr.resource.internal.helper.JcrPropertyMapCacheEntry;
@@ -62,7 +63,7 @@ public class JcrModifiableValueMap
final JcrPropertyMapCacheEntry entry = new JcrPropertyMapCacheEntry(value, this.node);
this.cache.put(key, entry);
final String name = escapeKeyName(key);
- if ( NodeUtil.MIXIN_TYPES.equals(name) ) {
+ if ( JcrConstants.JCR_MIXINTYPES.equals(name) ) {
NodeUtil.handleMixinTypes(node, entry.convertToType(String[].class, node, this.helper.getDynamicClassLoader()));
} else if ( "jcr:primaryType".equals(name) ) {
node.setPrimaryType(entry.convertToType(String.class, node, this.helper.getDynamicClassLoader()));
diff --git a/src/main/java/org/apache/sling/jcr/resource/internal/NodeUtil.java b/src/main/java/org/apache/sling/jcr/resource/internal/NodeUtil.java
index 7f605f5..df852a1 100644
--- a/src/main/java/org/apache/sling/jcr/resource/internal/NodeUtil.java
+++ b/src/main/java/org/apache/sling/jcr/resource/internal/NodeUtil.java
@@ -39,12 +39,6 @@ import org.jetbrains.annotations.NotNull;
public abstract class NodeUtil {
- /** Property for the mixin node types. */
- public static final String MIXIN_TYPES = "jcr:mixinTypes";
-
- /** Property for the node type. */
- public static final String NODE_TYPE = "jcr:primaryType";
-
/**
* Update the mixin node types
*
diff --git a/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/BinaryDownloadUriProvider.java b/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/BinaryDownloadUriProvider.java
index 28edfa0..3aa5abb 100644
--- a/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/BinaryDownloadUriProvider.java
+++ b/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/BinaryDownloadUriProvider.java
@@ -58,7 +58,7 @@ public class BinaryDownloadUriProvider implements URIProvider {
@ObjectClassDefinition(
name = "Apache Sling Binary Download URI Provider",
- description = "Provides URIs for resources containing a primary JCR binary property backed by a blob store with external access")
+ description = "Provides URIs for resources containing a primary JCR binary property backed by a blob store allowing direct HTTP access")
public static @interface Configuration {
@AttributeDefinition(
name = "Content-Disposition",
@@ -101,7 +101,7 @@ public class BinaryDownloadUriProvider implements URIProvider {
}
}
- protected Property getPrimaryProperty(@NotNull Node node) throws RepositoryException {
+ protected @NotNull Property getPrimaryProperty(@NotNull Node node) throws RepositoryException {
return NodeUtil.getPrimaryProperty(node);
}
@@ -113,7 +113,7 @@ public class BinaryDownloadUriProvider implements URIProvider {
Binary binary = binaryProperty.getBinary();
if (!(binary instanceof BinaryDownload)) {
binary.dispose();
- throw new IllegalArgumentException("The property " + binaryProperty.getPath() + " is not backed by an store providing direct downloads");
+ throw new IllegalArgumentException("The property " + binaryProperty.getPath() + " is not backed by a blob store allowing direct HTTP access");
}
BinaryDownload binaryDownload = BinaryDownload.class.cast(binary);
try {
diff --git a/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProvider.java b/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProvider.java
index e2d774a..bdb7790 100644
--- a/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProvider.java
+++ b/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProvider.java
@@ -40,6 +40,7 @@ import javax.jcr.NodeIterator;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
+import org.apache.jackrabbit.JcrConstants;
import org.apache.jackrabbit.api.JackrabbitSession;
import org.apache.jackrabbit.api.security.user.Authorizable;
import org.apache.jackrabbit.api.security.user.UserManager;
@@ -96,9 +97,9 @@ public class JcrResourceProvider extends ResourceProvider<JcrProviderState> {
private static final Set<String> IGNORED_PROPERTIES = new HashSet<>();
static {
- IGNORED_PROPERTIES.add(NodeUtil.MIXIN_TYPES);
- IGNORED_PROPERTIES.add(NodeUtil.NODE_TYPE);
- IGNORED_PROPERTIES.add("jcr:created");
+ IGNORED_PROPERTIES.add(JcrConstants.JCR_MIXINTYPES);
+ IGNORED_PROPERTIES.add(JcrConstants.JCR_PRIMARYTYPE);
+ IGNORED_PROPERTIES.add(JcrConstants.JCR_CREATED);
IGNORED_PROPERTIES.add("jcr:createdBy");
}
@@ -410,7 +411,7 @@ public class JcrResourceProvider extends ResourceProvider<JcrProviderState> {
public Resource create(final @NotNull ResolveContext<JcrProviderState> ctx, final String path, final Map<String, Object> properties)
throws PersistenceException {
// check for node type
- final Object nodeObj = (properties != null ? properties.get(NodeUtil.NODE_TYPE) : null);
+ final Object nodeObj = (properties != null ? properties.get(JcrConstants.JCR_PRIMARYTYPE) : null);
// check for sling:resourcetype
final String nodeType;
if ( nodeObj != null ) {
@@ -459,9 +460,9 @@ public class JcrResourceProvider extends ResourceProvider<JcrProviderState> {
// create modifiable map
final JcrModifiableValueMap jcrMap = new JcrModifiableValueMap(node, ctx.getProviderState().getHelperData());
// check mixin types first
- final Object value = properties.get(NodeUtil.MIXIN_TYPES);
+ final Object value = properties.get(JcrConstants.JCR_MIXINTYPES);
if ( value != null ) {
- jcrMap.put(NodeUtil.MIXIN_TYPES, value);
+ jcrMap.put(JcrConstants.JCR_MIXINTYPES, value);
}
for(final Map.Entry<String, Object> entry : properties.entrySet()) {
if ( !IGNORED_PROPERTIES.contains(entry.getKey()) ) {