You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by an...@apache.org on 2015/08/13 14:22:36 UTC
svn commit: r1695698 - in /jackrabbit/oak/trunk:
oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/
oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/write/
Author: angela
Date: Thu Aug 13 12:22:36 2015
New Revision: 1695698
URL: http://svn.apache.org/r1695698
Log:
OAK-2674 : Fix FindBug Issues
Modified:
jackrabbit/oak/trunk/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/PropertiesUtil.java
jackrabbit/oak/trunk/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/package-info.java
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/write/NamedTemplate.java
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/write/NodeTypeTemplateImpl.java
Modified: jackrabbit/oak/trunk/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/PropertiesUtil.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/PropertiesUtil.java?rev=1695698&r1=1695697&r2=1695698&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/PropertiesUtil.java (original)
+++ jackrabbit/oak/trunk/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/PropertiesUtil.java Thu Aug 13 12:22:36 2015
@@ -39,19 +39,23 @@ import static com.google.common.base.Obj
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
/**
- * The <code>PropertiesUtil</code> is a utility class providing some
+ * The {@code PropertiesUtil} is a utility class providing some
* useful utility methods for converting property types.
*/
-public class PropertiesUtil {
+public final class PropertiesUtil {
+
private static Logger log = LoggerFactory.getLogger(PropertiesUtil.class);
+ private PropertiesUtil() {}
+
/**
* Returns the boolean value of the parameter or the
- * <code>defaultValue</code> if the parameter is <code>null</code>.
- * If the parameter is not a <code>Boolean</code> it is converted
- * by calling <code>Boolean.valueOf</code> on the string value of the
+ * {@code defaultValue} if the parameter is {@code null}.
+ * If the parameter is not a {@code Boolean} it is converted
+ * by calling {@code Boolean.valueOf} on the string value of the
* object.
- * @param propValue the property value or <code>null</code>
+ *
+ * @param propValue the property value or {@code null}
* @param defaultValue the default boolean value
*/
public static boolean toBoolean(Object propValue, boolean defaultValue) {
@@ -67,8 +71,8 @@ public class PropertiesUtil {
/**
* Returns the parameter as a string or the
- * <code>defaultValue</code> if the parameter is <code>null</code>.
- * @param propValue the property value or <code>null</code>
+ * {@code defaultValue} if the parameter is {@code null}.
+ * @param propValue the property value or {@code null}
* @param defaultValue the default string value
*/
public static String toString(Object propValue, String defaultValue) {
@@ -78,10 +82,11 @@ public class PropertiesUtil {
/**
* Returns the parameter as a long or the
- * <code>defaultValue</code> if the parameter is <code>null</code> or if
- * the parameter is not a <code>Long</code> and cannot be converted to
- * a <code>Long</code> from the parameter's string value.
- * @param propValue the property value or <code>null</code>
+ * {@code defaultValue} if the parameter is {@code null} or if
+ * the parameter is not a {@code Long} and cannot be converted to
+ * a {@code Long} from the parameter's string value.
+ *
+ * @param propValue the property value or {@code null}
* @param defaultValue the default long value
*/
public static long toLong(Object propValue, long defaultValue) {
@@ -101,10 +106,11 @@ public class PropertiesUtil {
/**
* Returns the parameter as an integer or the
- * <code>defaultValue</code> if the parameter is <code>null</code> or if
- * the parameter is not an <code>Integer</code> and cannot be converted to
- * an <code>Integer</code> from the parameter's string value.
- * @param propValue the property value or <code>null</code>
+ * {@code defaultValue} if the parameter is {@code null} or if
+ * the parameter is not an {@code Integer} and cannot be converted to
+ * an {@code Integer} from the parameter's string value.
+ *
+ * @param propValue the property value or {@code null}
* @param defaultValue the default integer value
*/
public static int toInteger(Object propValue, int defaultValue) {
@@ -124,10 +130,11 @@ public class PropertiesUtil {
/**
* Returns the parameter as a double or the
- * <code>defaultValue</code> if the parameter is <code>null</code> or if
- * the parameter is not a <code>Double</code> and cannot be converted to
- * a <code>Double</code> from the parameter's string value.
- * @param propValue the property value or <code>null</code>
+ * {@code defaultValue} if the parameter is {@code null} or if
+ * the parameter is not a {@code Double} and cannot be converted to
+ * a {@code Double} from the parameter's string value.
+ *
+ * @param propValue the property value or {@code null}
* @param defaultValue the default double value
*/
public static double toDouble(Object propValue, double defaultValue) {
@@ -147,11 +154,12 @@ public class PropertiesUtil {
/**
* Returns the parameter as a single value. If the
- * parameter is neither an array nor a <code>java.util.Collection</code> the
+ * parameter is neither an array nor a {@code java.util.Collection} the
* parameter is returned unmodified. If the parameter is a non-empty array,
* the first array element is returned. If the property is a non-empty
- * <code>java.util.Collection</code>, the first collection element is returned.
- * Otherwise <code>null</code> is returned.
+ * {@code java.util.Collection}, the first collection element is returned.
+ * Otherwise {@code null} is returned.
+ *
* @param propValue the parameter to convert.
*/
public static Object toObject(Object propValue) {
@@ -174,8 +182,9 @@ public class PropertiesUtil {
* element array. If the parameter is an array, the elements are converted to
* String objects and returned as an array. If the parameter is a collection, the
* collection elements are converted to String objects and returned as an array.
- * Otherwise (if the parameter is <code>null</code>) <code>null</code> is
+ * Otherwise (if the parameter is {@code null}) {@code null} is
* returned.
+ *
* @param propValue The object to convert.
*/
public static String[] toStringArray(Object propValue) {
@@ -188,8 +197,9 @@ public class PropertiesUtil {
* element array. If the parameter is an array, the elements are converted to
* String objects and returned as an array. If the parameter is a collection, the
* collection elements are converted to String objects and returned as an array.
- * Otherwise (if the property is <code>null</code>) a provided default value is
+ * Otherwise (if the property is {@code null}) a provided default value is
* returned.
+ *
* @param propValue The object to convert.
* @param defaultArray The default array to return.
*/
@@ -238,7 +248,7 @@ public class PropertiesUtil {
* objects are not supported
*
* @param instance bean to populate
- * @param config propertires to set in the passed bean
+ * @param config properties to set in the passed bean
* @param validate Flag to validate the configured bean property names against
* the configured bean class
*/
@@ -320,7 +330,7 @@ public class PropertiesUtil {
} catch (InvocationTargetException e) {
throw new RuntimeException(
"Property " + name + " of class "
- + className + " can not be set to \"" + value + "\"",
+ + className + " can not be set to \"" + value + '"',
e);
} catch (IllegalAccessException e) {
throw new RuntimeException(
Modified: jackrabbit/oak/trunk/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/package-info.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/package-info.java?rev=1695698&r1=1695697&r2=1695698&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/package-info.java (original)
+++ jackrabbit/oak/trunk/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/package-info.java Thu Aug 13 12:22:36 2015
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-@Version("1.2.0")
+@Version("2.0.0")
@Export(optional = "provide:=true")
package org.apache.jackrabbit.oak.commons;
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/write/NamedTemplate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/write/NamedTemplate.java?rev=1695698&r1=1695697&r2=1695698&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/write/NamedTemplate.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/write/NamedTemplate.java Thu Aug 13 12:22:36 2015
@@ -18,6 +18,7 @@ package org.apache.jackrabbit.oak.plugin
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import javax.jcr.nodetype.ConstraintViolationException;
import org.apache.jackrabbit.oak.namepath.JcrNameParser;
@@ -34,11 +35,11 @@ abstract class NamedTemplate {
private String oakName = null; // not defined by default
- protected NamedTemplate(NameMapper mapper) {
+ protected NamedTemplate(@Nonnull NameMapper mapper) {
this.mapper = mapper;
}
- protected NamedTemplate(NameMapper mapper, String jcrName)
+ protected NamedTemplate(@Nonnull NameMapper mapper, @Nullable String jcrName)
throws ConstraintViolationException {
this(mapper);
if (jcrName != null) {
@@ -131,8 +132,8 @@ abstract class NamedTemplate {
* @throws ConstraintViolationException if name is invalid or {@code null}
*/
@Nonnull
- protected String getOakNameOrThrowConstraintViolation(
- @CheckForNull String jcrName) throws ConstraintViolationException {
+ protected String getOakNameOrThrowConstraintViolation(@CheckForNull String jcrName)
+ throws ConstraintViolationException {
if (jcrName == null) {
throw new ConstraintViolationException("Missing JCR name");
}
@@ -154,8 +155,8 @@ abstract class NamedTemplate {
* @throws ConstraintViolationException if the name is invalid
*/
@CheckForNull
- protected String getOakNameAllowNullOrThrowConstraintViolation(
- @CheckForNull String jcrName) throws ConstraintViolationException {
+ protected String getOakNameAllowNullOrThrowConstraintViolation(@CheckForNull String jcrName)
+ throws ConstraintViolationException {
if (jcrName == null) {
return null;
} else {
@@ -174,8 +175,8 @@ abstract class NamedTemplate {
* @throws ConstraintViolationException if names are invalid or {@code null}
*/
@Nonnull
- protected String[] getOakNamesOrThrowConstraintViolation(
- @CheckForNull String[] jcrNames) throws ConstraintViolationException {
+ protected String[] getOakNamesOrThrowConstraintViolation(@CheckForNull String[] jcrNames)
+ throws ConstraintViolationException {
if (jcrNames != null) {
String[] oakNames = new String[jcrNames.length];
for (int i = 0; i < jcrNames.length; i++) {
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/write/NodeTypeTemplateImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/write/NodeTypeTemplateImpl.java?rev=1695698&r1=1695697&r2=1695698&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/write/NodeTypeTemplateImpl.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/nodetype/write/NodeTypeTemplateImpl.java Thu Aug 13 12:22:36 2015
@@ -51,8 +51,7 @@ import org.apache.jackrabbit.oak.api.Tre
import org.apache.jackrabbit.oak.api.Type;
import org.apache.jackrabbit.oak.namepath.NameMapper;
-class NodeTypeTemplateImpl extends NamedTemplate
- implements NodeTypeTemplate {
+class NodeTypeTemplateImpl extends NamedTemplate implements NodeTypeTemplate {
private static final PropertyDefinition[] EMPTY_PROPERTY_DEFINITION_ARRAY =
new PropertyDefinition[0];
@@ -77,11 +76,11 @@ class NodeTypeTemplateImpl extends Named
private List<NodeDefinitionTemplateImpl> nodeDefinitionTemplates = null;
- NodeTypeTemplateImpl(NameMapper mapper) {
+ NodeTypeTemplateImpl(@Nonnull NameMapper mapper) {
super(mapper);
}
- NodeTypeTemplateImpl(NameMapper mapper, NodeTypeDefinition definition)
+ NodeTypeTemplateImpl(@Nonnull NameMapper mapper, @Nonnull NodeTypeDefinition definition)
throws ConstraintViolationException {
super(mapper, definition.getName());
@@ -127,8 +126,11 @@ class NodeTypeTemplateImpl extends Named
* @return The node type tree.
* @throws RepositoryException if this type could not be written
*/
- Tree writeTo(Tree parent, boolean allowUpdate) throws RepositoryException {
+ Tree writeTo(@Nonnull Tree parent, boolean allowUpdate) throws RepositoryException {
String oakName = getOakName();
+ if (oakName == null) {
+ throw new RepositoryException("Cannot register node type: name is missing.");
+ }
Tree type = parent.getChild(oakName);
if (!type.exists()) {