reduced usage of org.slf4j and org.apache.commons.lang3

Signed-off-by: Christian Amend <christian.amend@sap.com>
This commit is contained in:
Klaus Straubinger 2016-01-13 16:14:03 +01:00 committed by Christian Amend
parent 6837fd7651
commit 1b6259b979
16 changed files with 28 additions and 113 deletions

View File

@ -19,9 +19,8 @@
package org.apache.olingo.client.api.communication; package org.apache.olingo.client.api.communication;
import org.apache.http.StatusLine; import org.apache.http.StatusLine;
import org.apache.commons.lang3.StringUtils;
import org.apache.olingo.commons.api.ex.ODataRuntimeException;
import org.apache.olingo.commons.api.ex.ODataError; import org.apache.olingo.commons.api.ex.ODataError;
import org.apache.olingo.commons.api.ex.ODataRuntimeException;
/** /**
* Represents a client error in OData. * Represents a client error in OData.
@ -55,9 +54,9 @@ public class ODataClientErrorException extends ODataRuntimeException {
* @param error OData error to be wrapped. * @param error OData error to be wrapped.
*/ */
public ODataClientErrorException(final StatusLine statusLine, final ODataError error) { public ODataClientErrorException(final StatusLine statusLine, final ODataError error) {
super(error == null super(error == null ?
? statusLine.toString() statusLine.toString() :
: (StringUtils.isBlank(error.getCode()) ? StringUtils.EMPTY : "(" + error.getCode() + ") ") (error.getCode() == null || error.getCode().isEmpty() ? "" : "(" + error.getCode() + ") ")
+ error.getMessage() + " [" + statusLine.toString() + "]"); + error.getMessage() + " [" + statusLine.toString() + "]");
this.statusLine = statusLine; this.statusLine = statusLine;

View File

@ -28,7 +28,6 @@ import java.util.Iterator;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.olingo.client.api.ODataClient; import org.apache.olingo.client.api.ODataClient;
import org.apache.olingo.client.api.data.ResWrap; import org.apache.olingo.client.api.data.ResWrap;
import org.apache.olingo.client.api.serialization.ODataDeserializerException; import org.apache.olingo.client.api.serialization.ODataDeserializerException;
@ -262,12 +261,10 @@ public class ClientEntitySetIterator<T extends ClientEntitySet, E extends Client
os.write('>'); os.write('>');
} }
res = attrsDeclaration == null res = attrsDeclaration == null ? "" : new String(attrsDeclaration, Constants.UTF8).trim();
? StringUtils.EMPTY
: new String(attrsDeclaration, Constants.UTF8).trim();
} catch (Exception e) { } catch (Exception e) {
LOG.error("Error retrieving entities from EntitySet", e); LOG.error("Error retrieving entities from EntitySet", e);
res = StringUtils.EMPTY; res = "";
} }
return res.endsWith("/") ? res.substring(0, res.length() - 1) : res; return res.endsWith("/") ? res.substring(0, res.length() - 1) : res;

View File

@ -18,7 +18,6 @@
*/ */
package org.apache.olingo.client.api.domain; package org.apache.olingo.client.api.domain;
import org.apache.commons.lang3.StringUtils;
import org.apache.olingo.commons.api.Constants; import org.apache.olingo.commons.api.Constants;
import org.apache.olingo.commons.api.format.ContentType; import org.apache.olingo.commons.api.format.ContentType;
@ -78,9 +77,8 @@ public enum ClientLinkType {
* @return <code>ODataLinkType</code> object. * @return <code>ODataLinkType</code> object.
*/ */
public static ClientLinkType fromString(final String rel, final String type) { public static ClientLinkType fromString(final String rel, final String type) {
if (StringUtils.isNotBlank(rel) && rel.startsWith(Constants.NS_MEDIA_EDIT_LINK_REL)) { if (rel != null && rel.startsWith(Constants.NS_MEDIA_EDIT_LINK_REL)) {
return MEDIA_EDIT.setType(type == null || type.isEmpty() ? "*/*" : type);
return MEDIA_EDIT.setType(StringUtils.isBlank(type) ? "*/*" : type);
} }
if (ClientLinkType.ENTITY_NAVIGATION.type.equals(type)) { if (ClientLinkType.ENTITY_NAVIGATION.type.equals(type)) {

View File

@ -18,7 +18,6 @@
*/ */
package org.apache.olingo.client.api.uri; package org.apache.olingo.client.api.uri;
import org.apache.commons.lang3.StringUtils;
/** /**
* URI Segment types. * URI Segment types.
@ -46,8 +45,7 @@ public enum SegmentType {
CROSS_JOIN("$crossjoin"), CROSS_JOIN("$crossjoin"),
ALL("$all"), ALL("$all"),
/** /**
* For query options like as $count that needs to stay in their own segment, right after service root. * For query options like $count that need to stay in their own segment, right after service root.
*
* @see QueryOption#COUNT * @see QueryOption#COUNT
*/ */
ROOT_QUERY_OPTION, ROOT_QUERY_OPTION,
@ -56,7 +54,7 @@ public enum SegmentType {
private final String value; private final String value;
private SegmentType() { private SegmentType() {
this.value = StringUtils.EMPTY; this.value = "";
} }
private SegmentType(final String value) { private SegmentType(final String value) {

View File

@ -20,7 +20,6 @@ package org.apache.olingo.client.core.communication.request.retrieve;
import java.net.URI; import java.net.URI;
import org.apache.commons.lang3.StringUtils;
import org.apache.olingo.client.api.ODataClient; import org.apache.olingo.client.api.ODataClient;
import org.apache.olingo.client.api.communication.request.retrieve.EdmMetadataRequest; import org.apache.olingo.client.api.communication.request.retrieve.EdmMetadataRequest;
import org.apache.olingo.client.api.communication.request.retrieve.ODataDeltaRequest; import org.apache.olingo.client.api.communication.request.retrieve.ODataDeltaRequest;
@ -34,11 +33,11 @@ import org.apache.olingo.client.api.communication.request.retrieve.ODataServiceD
import org.apache.olingo.client.api.communication.request.retrieve.ODataValueRequest; import org.apache.olingo.client.api.communication.request.retrieve.ODataValueRequest;
import org.apache.olingo.client.api.communication.request.retrieve.RetrieveRequestFactory; import org.apache.olingo.client.api.communication.request.retrieve.RetrieveRequestFactory;
import org.apache.olingo.client.api.communication.request.retrieve.XMLMetadataRequest; import org.apache.olingo.client.api.communication.request.retrieve.XMLMetadataRequest;
import org.apache.olingo.client.core.uri.URIUtils;
import org.apache.olingo.client.api.domain.ClientEntity; import org.apache.olingo.client.api.domain.ClientEntity;
import org.apache.olingo.client.api.domain.ClientEntitySet; import org.apache.olingo.client.api.domain.ClientEntitySet;
import org.apache.olingo.client.api.domain.ClientProperty; import org.apache.olingo.client.api.domain.ClientProperty;
import org.apache.olingo.client.api.domain.ClientSingleton; import org.apache.olingo.client.api.domain.ClientSingleton;
import org.apache.olingo.client.core.uri.URIUtils;
public class RetrieveRequestFactoryImpl implements RetrieveRequestFactory { public class RetrieveRequestFactoryImpl implements RetrieveRequestFactory {
@ -82,9 +81,9 @@ public class RetrieveRequestFactoryImpl implements RetrieveRequestFactory {
@Override @Override
public ODataServiceDocumentRequest getServiceDocumentRequest(final String serviceRoot) { public ODataServiceDocumentRequest getServiceDocumentRequest(final String serviceRoot) {
return new ODataServiceDocumentRequestImpl(client, return new ODataServiceDocumentRequestImpl(client,
StringUtils.isNotBlank(serviceRoot) && serviceRoot.endsWith("/") serviceRoot != null && !serviceRoot.isEmpty() && serviceRoot.endsWith("/") ?
? client.newURIBuilder(serviceRoot).build() client.newURIBuilder(serviceRoot).build() :
: client.newURIBuilder(serviceRoot + "/").build()); client.newURIBuilder(serviceRoot + '/').build());
} }
@Override @Override

View File

@ -23,7 +23,6 @@ import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter; import javax.xml.stream.XMLStreamWriter;
import org.apache.commons.lang3.StringUtils;
import org.apache.olingo.commons.api.Constants; import org.apache.olingo.commons.api.Constants;
abstract class AbstractAtomDealer { abstract class AbstractAtomDealer {
@ -89,7 +88,7 @@ abstract class AbstractAtomDealer {
} }
protected void namespaces(final XMLStreamWriter writer) throws XMLStreamException { protected void namespaces(final XMLStreamWriter writer) throws XMLStreamException {
writer.writeNamespace(StringUtils.EMPTY, Constants.NS_ATOM); writer.writeNamespace("", Constants.NS_ATOM);
writer.writeNamespace(XMLConstants.XML_NS_PREFIX, XMLConstants.XML_NS_URI); writer.writeNamespace(XMLConstants.XML_NS_PREFIX, XMLConstants.XML_NS_URI);
writer.writeNamespace(Constants.PREFIX_METADATA, Constants.NS_METADATA); writer.writeNamespace(Constants.PREFIX_METADATA, Constants.NS_METADATA);
writer.writeNamespace(Constants.PREFIX_DATASERVICES, Constants.NS_DATASERVICES); writer.writeNamespace(Constants.PREFIX_DATASERVICES, Constants.NS_DATASERVICES);

View File

@ -20,10 +20,6 @@ package org.apache.olingo.commons.api.data;
import java.util.List; import java.util.List;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.apache.olingo.commons.api.edm.geo.Geospatial; import org.apache.olingo.commons.api.edm.geo.Geospatial;
/** /**
@ -175,19 +171,4 @@ public abstract class Valuable extends Annotatable {
public ValueType getValueType() { public ValueType getValueType() {
return valueType; return valueType;
} }
@Override
public boolean equals(final Object obj) {
return EqualsBuilder.reflectionEquals(this, obj);
}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public String toString() {
return ReflectionToStringBuilder.toString(this, ToStringStyle.MULTI_LINE_STYLE);
}
} }

View File

@ -102,9 +102,7 @@ public abstract class Geospatial implements Serializable {
protected Geospatial(final Dimension dimension, final Type type, final SRID srid) { protected Geospatial(final Dimension dimension, final Type type, final SRID srid) {
this.dimension = dimension; this.dimension = dimension;
this.type = type; this.type = type;
this.srid = srid == null this.srid = srid == null ? new SRID() : srid;
? new SRID()
: srid;
this.srid.setDimension(dimension); this.srid.setDimension(dimension);
} }

View File

@ -18,7 +18,6 @@
*/ */
package org.apache.olingo.commons.core.edm; package org.apache.olingo.commons.core.edm;
import org.apache.commons.lang3.StringUtils;
import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmComplexType; import org.apache.olingo.commons.api.edm.EdmComplexType;
import org.apache.olingo.commons.api.edm.EdmEntityType; import org.apache.olingo.commons.api.edm.EdmEntityType;
@ -54,9 +53,10 @@ public class EdmTypeInfo {
} }
public EdmTypeInfo build() { public EdmTypeInfo build() {
return new EdmTypeInfo(edm, typeExpression.indexOf('.') == -1 && StringUtils.isNotBlank(defaultNamespace) return new EdmTypeInfo(edm,
? defaultNamespace + "." + typeExpression typeExpression.indexOf('.') == -1 && defaultNamespace != null && !defaultNamespace.isEmpty() ?
: typeExpression); defaultNamespace + "." + typeExpression :
typeExpression);
} }
} }
@ -98,7 +98,7 @@ public class EdmTypeInfo {
typeName = baseType.substring(lastDotIdx + 1); typeName = baseType.substring(lastDotIdx + 1);
} }
if (StringUtils.isBlank(typeName)) { if (typeName == null || typeName.isEmpty()) {
throw new IllegalArgumentException("Null or empty type name in " + typeExpression); throw new IllegalArgumentException("Null or empty type name in " + typeExpression);
} }

View File

@ -31,7 +31,6 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.apache.olingo.commons.api.edm.Edm; import org.apache.olingo.commons.api.edm.Edm;
import org.apache.olingo.commons.api.edm.EdmAction; import org.apache.olingo.commons.api.edm.EdmAction;
import org.apache.olingo.commons.api.edm.EdmAnnotations; import org.apache.olingo.commons.api.edm.EdmAnnotations;
@ -444,7 +443,7 @@ public class EdmImplCachingTest {
private static final long serialVersionUID = 3109256773218160485L; private static final long serialVersionUID = 3109256773218160485L;
{ {
put(StringUtils.EMPTY, schema); put("", schema);
} }
}; };
} }

View File

@ -69,10 +69,6 @@
<artifactId>mockito-all</artifactId> <artifactId>mockito-all</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</dependency>
<dependency> <dependency>
<groupId>commons-io</groupId> <groupId>commons-io</groupId>
<artifactId>commons-io</artifactId> <artifactId>commons-io</artifactId>

View File

@ -79,10 +79,6 @@
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId> <artifactId>mockito-all</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@ -33,7 +33,6 @@ import javax.xml.stream.events.Attribute;
import javax.xml.stream.events.StartElement; import javax.xml.stream.events.StartElement;
import javax.xml.stream.events.XMLEvent; import javax.xml.stream.events.XMLEvent;
import org.apache.commons.lang3.StringUtils;
import org.apache.olingo.commons.api.Constants; import org.apache.olingo.commons.api.Constants;
import org.apache.olingo.commons.api.data.AbstractODataObject; import org.apache.olingo.commons.api.data.AbstractODataObject;
import org.apache.olingo.commons.api.data.ComplexValue; import org.apache.olingo.commons.api.data.ComplexValue;
@ -172,8 +171,9 @@ public class ODataXmlDeserializer implements ODataDeserializer {
if (propertyValueQName.equals(start.getName())) { if (propertyValueQName.equals(start.getName())) {
// retrieve name from context // retrieve name from context
final Attribute context = start.getAttributeByName(contextQName); final Attribute context = start.getAttributeByName(contextQName);
if (context != null) { if (context != null && context.getValue() != null) {
property.setName(StringUtils.substringAfterLast(context.getValue(), "/")); final int pos = context.getValue().lastIndexOf('/');
property.setName(pos == -1 ? "" : context.getValue().substring(pos + 1));
} }
} else { } else {
property.setName(start.getName().getLocalPart()); property.setName(start.getName().getLocalPart());

View File

@ -1,20 +0,0 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
org.slf4j.simpleLogger.defaultLogLevel=debug
org.slf4j.simpleLogger.logFile=System.out

View File

@ -54,11 +54,6 @@
<groupId>org.mockito</groupId> <groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId> <artifactId>mockito-all</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>commons-io</groupId> <groupId>commons-io</groupId>
<artifactId>commons-io</artifactId> <artifactId>commons-io</artifactId>

View File

@ -1,20 +0,0 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
org.slf4j.simpleLogger.defaultLogLevel=debug
org.slf4j.simpleLogger.logFile=System.out