Misc: fixing the critical errors reported by Apache Analysis tool

This commit is contained in:
Ramesh Reddy 2015-09-09 10:08:03 -05:00
parent e981aaad79
commit 93992f9135
4 changed files with 14 additions and 20 deletions

View File

@ -714,7 +714,7 @@ public class DataRequest extends ServiceRequest {
break;
}
} catch (IOException e) {
new DeserializerException("Error reading raw value",
throw new DeserializerException("Error reading raw value",
SerializerException.MessageKeys.IO_EXCEPTION);
}
} while (true);

View File

@ -164,25 +164,26 @@ public class EntityResponse extends ServiceResponse {
}
public static String buildLocation(String baseURL, Entity entity, String enitySetName, EdmEntityType type) {
String location = baseURL + "/" + enitySetName + "(";
StringBuilder location = new StringBuilder();
location.append(baseURL).append("/").append(enitySetName).append("(");
int i = 0;
boolean usename = type.getKeyPredicateNames().size() > 1;
for (String key : type.getKeyPredicateNames()) {
if (i > 0) {
location += ",";
location.append(",");
}
i++;
if (usename) {
location += (key + "=");
location.append(key).append("=");
}
if (entity.getProperty(key).getType().equals("Edm.String")) {
location = location + "'" + entity.getProperty(key).getValue().toString() + "'";
location.append("'").append(entity.getProperty(key).getValue().toString()).append("'");
} else {
location = location + entity.getProperty(key).getValue().toString();
location.append(entity.getProperty(key).getValue().toString());
}
}
location += ")";
return location;
location.append(")");
return location.toString();
}
}

View File

@ -159,9 +159,8 @@ public class ODataXmlDeserializer implements ODataDeserializer {
values.add(complex(reader, event.asStartElement(), (EdmComplexType) edmType));
} else if (edmType instanceof EdmEnumType) {
values.add(readEnum(reader, event.asStartElement()));
} else {
// do not add null or empty values
}
// do not add null or empty values
}
if (event.isEndElement() && start.getName().equals(event.asEndElement().getName())) {
@ -247,9 +246,8 @@ public class ODataXmlDeserializer implements ODataDeserializer {
} else if (edmType instanceof EdmEnumType) {
valuable.setValue(ValueType.ENUM, readEnum(reader, start));
valuable.setType(edmType.getFullQualifiedName().getFullQualifiedNameAsString());
} else {
// do not add null or empty values
}
// do not add null or empty values
}
@Override

View File

@ -588,18 +588,14 @@ public class ODataXmlSerializer extends AbstractODataSerializer {
final ExpandOption innerExpand, final SelectOption innerSelect, final XMLStreamWriter writer)
throws XMLStreamException, SerializerException {
if (property.isCollection()) {
if (navigationLink == null || navigationLink.getInlineEntitySet() == null) {
// nothing to write.
} else {
if (navigationLink != null && navigationLink.getInlineEntitySet() != null) {
writer.writeStartElement(ATOM, "feed", NS_ATOM);
writeEntitySet(metadata, property.getType(), navigationLink.getInlineEntitySet(), innerExpand,
innerSelect, writer);
writer.writeEndElement();
}
} else {
if (navigationLink == null || navigationLink.getInlineEntity() == null) {
// nothing to write
} else {
if (navigationLink != null && navigationLink.getInlineEntity() != null) {
writeEntity(metadata, property.getType(), navigationLink.getInlineEntity(), null,
innerExpand, innerSelect, writer, false);
}
@ -756,9 +752,8 @@ public class ODataXmlSerializer extends AbstractODataSerializer {
isNullable, maxLength, precision, scale, isUnicode);
if (value == null) {
writer.writeAttribute(DATA, NS_DATA, "null", "true");
} else if (type == EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Boolean)) {
writer.writeCharacters(value);
} else if (type == EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Byte)
|| type == EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Boolean)
|| type == EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Decimal)
|| type == EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Double)
|| type == EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Int16)