From a59f7df7845ede39c9fe99265e37ba14757b8d67 Mon Sep 17 00:00:00 2001 From: Andrew Berezovskyi Date: Sat, 16 Apr 2022 17:32:39 +0200 Subject: [PATCH] Fix all syntax & reference javadoc errors and turn on lint Signed-off-by: Andrew Berezovskyi --- .../eclipse/lyo/client/OslcOAuthClient.java | 5 - .../lyo/client/query/OslcQueryResult.java | 1 - .../eclipse/lyo/core/query/QueryUtils.java | 92 ++++++++-------- .../eclipse/lyo/oslc4j/core/OSLC4JUtils.java | 104 ++++++++---------- .../eclipse/lyo/oslc4j/core/model/Link.java | 3 +- pom.xml | 3 +- .../internals/query/JenaQueryExecutor.java | 6 +- 7 files changed, 96 insertions(+), 118 deletions(-) diff --git a/client/oslc-client/src/main/java/org/eclipse/lyo/client/OslcOAuthClient.java b/client/oslc-client/src/main/java/org/eclipse/lyo/client/OslcOAuthClient.java index 8a6cb3a1e..cca96897b 100644 --- a/client/oslc-client/src/main/java/org/eclipse/lyo/client/OslcOAuthClient.java +++ b/client/oslc-client/src/main/java/org/eclipse/lyo/client/OslcOAuthClient.java @@ -47,11 +47,6 @@ public class OslcOAuthClient implements IOslcClient { /** * Initialize an OAuthClient with the required OAuth URLs - * @param requestTokenURL - * @param authorizationTokenURL - * @param accessTokenURL - * @param consumerKey - * @param consumerSecret */ public OslcOAuthClient( OAuthAccessor accessor, diff --git a/client/oslc-client/src/main/java/org/eclipse/lyo/client/query/OslcQueryResult.java b/client/oslc-client/src/main/java/org/eclipse/lyo/client/query/OslcQueryResult.java index 62c7c68e1..432a1c7c7 100644 --- a/client/oslc-client/src/main/java/org/eclipse/lyo/client/query/OslcQueryResult.java +++ b/client/oslc-client/src/main/java/org/eclipse/lyo/client/query/OslcQueryResult.java @@ -159,7 +159,6 @@ public boolean hasNext() { /** * @return the next page of results - * @throws NoSuchElementException if there is no next page */ public OslcQueryResult next() { return new OslcQueryResult(this); diff --git a/core/oslc-query/src/main/java/org/eclipse/lyo/core/query/QueryUtils.java b/core/oslc-query/src/main/java/org/eclipse/lyo/core/query/QueryUtils.java index b7362873a..9e768dda1 100644 --- a/core/oslc-query/src/main/java/org/eclipse/lyo/core/query/QueryUtils.java +++ b/core/oslc-query/src/main/java/org/eclipse/lyo/core/query/QueryUtils.java @@ -1,5 +1,6 @@ +package org.eclipse.lyo.core.query; /* - * Copyright (c) 2020 Contributors to the Eclipse Foundation + * Copyright (c) 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -11,7 +12,6 @@ * * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause */ -package org.eclipse.lyo.core.query; import java.lang.reflect.Proxy; import java.util.ArrayList; @@ -34,7 +34,7 @@ /** * Utility methods for parsing various OSLC HTTP query - * parameter clauses; e.g. oslc.where + * parameter clauses; e.g. {@code oslc.where} */ public class QueryUtils { @@ -74,9 +74,9 @@ public class QueryUtils CommonTree rawTree = parser.oslc_prefixes().getTree(); - checkErrors(parser.getErrors());; + checkErrors(parser.getErrors()); - PrefixMap prefixMap = + PrefixMap prefixMap = new PrefixMap(rawTree.getChildCount()); for (int index = 0; index < rawTree.getChildCount(); index++) { @@ -127,9 +127,9 @@ public class QueryUtils OslcWhereParser.oslc_where_return resultTree = parser.oslc_where(); - checkErrors(parser.getErrors());; + checkErrors(parser.getErrors()); - CommonTree rawTree = (CommonTree)resultTree.getTree(); + CommonTree rawTree = resultTree.getTree(); Tree child = rawTree.getChild(0); if (child.getType() == Token.INVALID_TOKEN_TYPE) { @@ -172,9 +172,9 @@ public class QueryUtils OslcSelectParser.oslc_select_return resultTree = parser.oslc_select(); - checkErrors(parser.getErrors());; + checkErrors(parser.getErrors()); - CommonTree rawTree = (CommonTree)resultTree.getTree(); + CommonTree rawTree = resultTree.getTree(); if (rawTree.getType() == Token.INVALID_TOKEN_TYPE) { throw ((CommonErrorNode)rawTree).trappedException; @@ -184,7 +184,7 @@ public class QueryUtils Proxy.newProxyInstance(SelectClause.class.getClassLoader(), new Class[] { SelectClause.class, Properties.class }, new PropertiesInvocationHandler( - (CommonTree)resultTree.getTree(), + resultTree.getTree(), prefixMap)); } catch (RecognitionException e) { @@ -217,9 +217,9 @@ public class QueryUtils OslcSelectParser.oslc_select_return resultTree = parser.oslc_select(); - checkErrors(parser.getErrors());; + checkErrors(parser.getErrors()); - CommonTree rawTree = (CommonTree)resultTree.getTree(); + CommonTree rawTree = resultTree.getTree(); if (rawTree.getType() == Token.INVALID_TOKEN_TYPE) { throw ((CommonErrorNode)rawTree).trappedException; @@ -229,7 +229,7 @@ public class QueryUtils Proxy.newProxyInstance(PropertiesClause.class.getClassLoader(), new Class[] { PropertiesClause.class, Properties.class }, new PropertiesInvocationHandler( - (CommonTree)resultTree.getTree(), + resultTree.getTree(), prefixMap)); } catch (RecognitionException e) { @@ -262,9 +262,9 @@ public class QueryUtils OslcOrderByParser.oslc_order_by_return resultTree = parser.oslc_order_by(); - checkErrors(parser.getErrors());; + checkErrors(parser.getErrors()); - CommonTree rawTree = (CommonTree)resultTree.getTree(); + CommonTree rawTree = resultTree.getTree(); Tree child = rawTree.getChild(0); if (child.getType() == Token.INVALID_TOKEN_TYPE) { @@ -283,7 +283,7 @@ public class QueryUtils /** * Create a map representation of the {@link Properties} returned - * from parsing oslc.properties or olsc.select URL query + * from parsing {@code oslc.properties} or {@code oslc.select} URL query * parameters suitable for generating a property result from an * HTTP GET request.

* @@ -312,7 +312,7 @@ public class QueryUtils for (Property property : children) { - PName pname = null; + PName pname; String propertyName = null; if (! property.isWildcard()) { @@ -403,12 +403,12 @@ public class QueryUtils } /** - * Parse a oslc.searchTerms expression + * Parse an {@code oslc.searchTerms} expression * *

Note: {@link Object#toString()} of result has been overridden to * return input expression. * - * @param searchTermsExpression contents of an oslc.searchTerms HTTP query + * @param searchTermsExpression contents of an {@code oslc.searchTerms} HTTP query * parameter * * @return the parsed search terms clause @@ -427,9 +427,9 @@ public class QueryUtils OslcSearchTermsParser.oslc_search_terms_return resultTree = parser.oslc_search_terms(); - checkErrors(parser.getErrors());; + checkErrors(parser.getErrors()); - CommonTree rawTree = (CommonTree)resultTree.getTree(); + CommonTree rawTree = resultTree.getTree(); Tree child = rawTree.getChild(0); if (child.getType() == Token.INVALID_TOKEN_TYPE) { @@ -469,7 +469,7 @@ private static class StringList extends ArrayList public String toString() { - StringBuffer buffer = new StringBuffer(); + StringBuilder buffer = new StringBuilder(); boolean first = true; for (String string : this) { @@ -492,7 +492,7 @@ private static class StringList extends ArrayList } /** - * Implementation of a Map prefixMap + * Implementation of a {@code Map prefixMap} */ private static class PrefixMap extends HashMap { @@ -505,7 +505,7 @@ private static class PrefixMap extends HashMap public String toString() { - StringBuffer buffer = new StringBuffer(); + StringBuilder buffer = new StringBuilder(); Iterator keys = this.keySet().iterator(); boolean first = true; @@ -602,8 +602,8 @@ private static class BothWildcardPropertiesImpl } /** - * Merge into {@link #lhs} properties those of {@link #rhs} property - * map, merging any common, nested property maps + * Merge into {@code lhs} properties those of {@code rhs} property + * map, merging any common, nested property maps. * * @param lhs target of property map merge * @param rhs source of property map merge @@ -614,37 +614,35 @@ private static class BothWildcardPropertiesImpl Map rhs ) { - Iterator propertyNames = rhs.keySet().iterator(); - while (propertyNames.hasNext()) { + for (String propertyName : rhs.keySet()) { - String propertyName = propertyNames.next(); - @SuppressWarnings("unchecked") - Map lhsNestedProperties = - (Map)lhs.get(propertyName); - @SuppressWarnings("unchecked") - Map rhsNestedProperties = - (Map)rhs.get(propertyName); + @SuppressWarnings("unchecked") + Map lhsNestedProperties = + (Map) lhs.get(propertyName); + @SuppressWarnings("unchecked") + Map rhsNestedProperties = + (Map) rhs.get(propertyName); - if (lhsNestedProperties == rhsNestedProperties) { - continue; - } + if (lhsNestedProperties == rhsNestedProperties) { + continue; + } - if (lhsNestedProperties == null || - lhsNestedProperties == OSLC4JConstants.OSL4J_PROPERTY_SINGLETON) { + if (lhsNestedProperties == null || + lhsNestedProperties == OSLC4JConstants.OSL4J_PROPERTY_SINGLETON) { - lhs.put(propertyName, rhsNestedProperties); + lhs.put(propertyName, rhsNestedProperties); - continue; - } + continue; + } - mergePropertyMaps(lhsNestedProperties, rhsNestedProperties); - } + mergePropertyMaps(lhsNestedProperties, rhsNestedProperties); + } } /** * Check list of errors from parsing some expression, generating - * @{link {@link ParseException} if there are any. + * {@link ParseException} if there are any. * * @param errors list of errors, hopefully empty * @@ -657,7 +655,7 @@ private static class BothWildcardPropertiesImpl return; } - StringBuffer buffer = new StringBuffer(); + StringBuilder buffer = new StringBuilder(); boolean first = true; for (String error : errors) { diff --git a/core/oslc4j-core/src/main/java/org/eclipse/lyo/oslc4j/core/OSLC4JUtils.java b/core/oslc4j-core/src/main/java/org/eclipse/lyo/oslc4j/core/OSLC4JUtils.java index 49e3610d9..d704b1fcc 100644 --- a/core/oslc4j-core/src/main/java/org/eclipse/lyo/oslc4j/core/OSLC4JUtils.java +++ b/core/oslc4j-core/src/main/java/org/eclipse/lyo/oslc4j/core/OSLC4JUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Contributors to the Eclipse Foundation + * Copyright (c) 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -365,7 +365,7 @@ public static boolean isHostResolutionDisabled() { } /** - * Return if the query result list type will be http://www.w3.org/2000/01/rdf-schema#Container + * Return if the query result list type will be http://www.w3.org/2000/01/rdf-schema#Container * or there will be no type. Default is no type. */ public static boolean isQueryResultListAsContainer() { @@ -537,7 +537,7 @@ public static void setInferTypeFromShape(String inferTypeFromShape) { */ private static Boolean parseBooleanPropertyOrDefault(final String key, final boolean defaultValue) { - Boolean value = null; + Boolean value; final String property = System.getProperty(key); if (Strings.isNullOrEmpty(property)) { value = defaultValue; @@ -683,62 +683,52 @@ private static boolean isXmlLiteralProperty(final URI propValueType) { * @param property * Property information * @return Java object related to the Resource Shape type. - * @throws DatatypeConfigurationException - * , IllegalArgumentException, InstantiationException, - * InvocationTargetException - * + * */ - public static RDFDatatype getDataTypeBasedOnResourceShapeType(final HashSet - rdfTypesList, - final Property property ) - { - if (null != rdfTypesList && !rdfTypesList.isEmpty() && null != property ) - { - try { - // get the pre-defined list of ResourceShapes - List shapes = OSLC4JUtils.getShapes(); - - if (null != shapes && !shapes.isEmpty()) { - - // try to find the attribute type in the list of - // resource shapes - String propertyName = property.getURI(); - - TypeMapper typeMapper = TypeMapper.getInstance(); - - for (ResourceShape shape : shapes) { - - // ensure that the current resource shape matches the resource rdf:type - if (doesResourceShapeMatchRdfTypes(shape, rdfTypesList)) { - - org.eclipse.lyo.oslc4j.core.model.Property[] props = shape - .getProperties(); - - for (org.eclipse.lyo.oslc4j.core.model.Property prop : props) { - URI propDefinition = prop.getPropertyDefinition(); - - if (propertyName.equals(propDefinition.toString())) { - URI propValueType = prop.getValueType(); + public static RDFDatatype getDataTypeBasedOnResourceShapeType(final HashSet rdfTypesList, + final Property property) { + if (null != rdfTypesList && !rdfTypesList.isEmpty() && null != property) { + try { + // get the pre-defined list of ResourceShapes + List shapes = OSLC4JUtils.getShapes(); + + if (null != shapes && !shapes.isEmpty()) { + // try to find the attribute type in the list of + // resource shapes + String propertyName = property.getURI(); + + TypeMapper typeMapper = TypeMapper.getInstance(); + + for (ResourceShape shape : shapes) { + // ensure that the current resource shape matches the resource rdf:type + if (doesResourceShapeMatchRdfTypes(shape, rdfTypesList)) { + org.eclipse.lyo.oslc4j.core.model.Property[] props = shape.getProperties(); + + for (org.eclipse.lyo.oslc4j.core.model.Property prop : props) { + URI propDefinition = prop.getPropertyDefinition(); + + if (propertyName.equals(propDefinition.toString())) { + URI propValueType = prop.getValueType(); + + if (null == propValueType) { + continue; + } + return typeMapper.getTypeByName(propValueType.toString()); + } + } + } + } + } + } catch (Exception e) { + // if there is any error, return null + // TODO Andrew@2017-07-18: Throw an exception instead of throwing null + log.warn("Could not find Data Type <{}> based on shape", property, e); + return null; + } + } + return null; + } - if (null == propValueType) { - continue; - } - return typeMapper.getTypeByName(propValueType.toString()); - } - } - } - } - } - } catch (Exception e) { - // if there is any error, return null - // TODO Andrew@2017-07-18: Throw an exception instead of throwing null - log.warn("Could not find Data Type <{}> based on shape", property, e); - return null; - } - } - return null; - } - /** * @see OSLC4JConstants#LYO_STORE_PAGING_UNSAFE * @return the boolean value of org.eclipse.lyo.oslc4j.unsafePaging diff --git a/core/oslc4j-core/src/main/java/org/eclipse/lyo/oslc4j/core/model/Link.java b/core/oslc4j-core/src/main/java/org/eclipse/lyo/oslc4j/core/model/Link.java index bf951e964..7ea6ddb78 100644 --- a/core/oslc4j-core/src/main/java/org/eclipse/lyo/oslc4j/core/model/Link.java +++ b/core/oslc4j-core/src/main/java/org/eclipse/lyo/oslc4j/core/model/Link.java @@ -22,8 +22,7 @@ /** * Special OSLC link type. Differs from {@link URI} since it can hold a label, * expressed in RDF using reification. - * @see OSLC Core - * Specification 2.0, Appendix C: Guidance on Links & Relationships + * @see OSLC Core Specification 2.0, Appendix C: Guidance on Links & Relationships */ public class Link extends AbstractReifiedResource { private String label; diff --git a/pom.xml b/pom.xml index 9f766a6cb..9566236c3 100644 --- a/pom.xml +++ b/pom.xml @@ -430,7 +430,8 @@ maven-javadoc-plugin 3.3.2 - none + + all,-accessibility,-html,-missing https://docs.oracle.com/en/java/javase/11/docs/api/ https://jena.apache.org/documentation/javadoc/jena/ diff --git a/store/store-core/src/main/java/org/eclipse/lyo/store/internals/query/JenaQueryExecutor.java b/store/store-core/src/main/java/org/eclipse/lyo/store/internals/query/JenaQueryExecutor.java index 10a2570af..fa21247c4 100644 --- a/store/store-core/src/main/java/org/eclipse/lyo/store/internals/query/JenaQueryExecutor.java +++ b/store/store-core/src/main/java/org/eclipse/lyo/store/internals/query/JenaQueryExecutor.java @@ -1,9 +1,7 @@ package org.eclipse.lyo.store.internals.query; -import java.io.InputStream; - /* - * Copyright (c) 2020 Contributors to the Eclipse Foundation + * Copyright (c) 2022 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. @@ -42,7 +40,6 @@ public interface JenaQueryExecutor { /** * Prepares a SPARQL Update processor (write-only). * - * @param query SPARQL query string * @return prepared processor */ UpdateProcessor prepareSparqlUpdate(final UpdateRequest updateRequest); @@ -50,7 +47,6 @@ public interface JenaQueryExecutor { /** * Prepares a SPARQL Update processor (write-only). * - * @param query SPARQL query string * @return prepared processor */ UpdateProcessor prepareSparqlUpdate(final Update update);