You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by sk...@apache.org on 2014/06/30 16:58:17 UTC
[47/51] [abbrv] [partial] [OLINGO-328] code cleanup and checkstyle
issues
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/2ab4b2fd/fit/src/main/java/org/apache/olingo/fit/utils/Commons.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/utils/Commons.java b/fit/src/main/java/org/apache/olingo/fit/utils/Commons.java
index 16d984c..40d33f7 100644
--- a/fit/src/main/java/org/apache/olingo/fit/utils/Commons.java
+++ b/fit/src/main/java/org/apache/olingo/fit/utils/Commons.java
@@ -1,18 +1,18 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
+ * 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
- *
+ * 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
+ * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
@@ -60,14 +60,14 @@ public abstract class Commons {
protected static final Logger LOG = LoggerFactory.getLogger(Commons.class);
private static final EnumMap<ODataServiceVersion, Metadata> METADATA =
- new EnumMap<ODataServiceVersion, Metadata>(ODataServiceVersion.class);
+ new EnumMap<ODataServiceVersion, Metadata>(ODataServiceVersion.class);
protected static final Pattern MULTIKEY_PATTERN = Pattern.compile("(.*=.*,?)+");
protected static final Map<String, Integer> SEQUENCE = new HashMap<String, Integer>();
protected static final Map<String, Pair<String, EdmPrimitiveTypeKind>> MEDIA_CONTENT =
- new HashMap<String, Pair<String, EdmPrimitiveTypeKind>>();
+ new HashMap<String, Pair<String, EdmPrimitiveTypeKind>>();
static {
SEQUENCE.put("Customer", 1000);
@@ -89,12 +89,12 @@ public abstract class Commons {
SEQUENCE.put("People", 1000);
MEDIA_CONTENT.put("CustomerInfo",
- new ImmutablePair<String, EdmPrimitiveTypeKind>("CustomerInfoId", EdmPrimitiveTypeKind.Int32));
+ new ImmutablePair<String, EdmPrimitiveTypeKind>("CustomerInfoId", EdmPrimitiveTypeKind.Int32));
MEDIA_CONTENT.put("Car",
- new ImmutablePair<String, EdmPrimitiveTypeKind>("VIN", EdmPrimitiveTypeKind.Int32));
+ new ImmutablePair<String, EdmPrimitiveTypeKind>("VIN", EdmPrimitiveTypeKind.Int32));
MEDIA_CONTENT.put("Car/Photo", null);
MEDIA_CONTENT.put("Advertisements",
- new ImmutablePair<String, EdmPrimitiveTypeKind>("ID", EdmPrimitiveTypeKind.Guid));
+ new ImmutablePair<String, EdmPrimitiveTypeKind>("ID", EdmPrimitiveTypeKind.Guid));
}
public static Metadata getMetadata(final ODataServiceVersion version) {
@@ -119,7 +119,7 @@ public abstract class Commons {
public static String getEntityBasePath(final String entitySetName, final String entityKey) {
// expected singleton in case of null key
return entitySetName + File.separatorChar
- + (StringUtils.isNotBlank(entityKey) ? getEntityKey(entityKey) + File.separatorChar : "");
+ + (StringUtils.isNotBlank(entityKey) ? getEntityKey(entityKey) + File.separatorChar : "");
}
public static String getLinksURI(final String entitySetName, final String entityId, final String linkName)
@@ -134,12 +134,12 @@ public abstract class Commons {
}
public static String getLinksPath(
- final ODataServiceVersion version, final String basePath, final String linkName, final Accept accept)
- throws IOException {
+ final ODataServiceVersion version, final String basePath, final String linkName, final Accept accept)
+ throws IOException {
try {
return FSManager.instance(version)
- .getAbsolutePath(basePath + Constants.get(version, ConstantKey.LINKS_FILE_PATH)
- + File.separatorChar + linkName, accept);
+ .getAbsolutePath(basePath + Constants.get(version, ConstantKey.LINKS_FILE_PATH)
+ + File.separatorChar + linkName, accept);
} catch (Exception e) {
throw new IOException(e);
}
@@ -163,7 +163,7 @@ public abstract class Commons {
}
public static InputStream getLinksAsATOM(final ODataServiceVersion version,
- final Map.Entry<String, Collection<String>> link) throws IOException {
+ final Map.Entry<String, Collection<String>> link) throws IOException {
final StringBuilder builder = new StringBuilder();
builder.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
@@ -185,13 +185,13 @@ public abstract class Commons {
}
public static InputStream getLinksAsJSON(final ODataServiceVersion version,
- final String entitySetName, final Map.Entry<String, Collection<String>> link)
- throws IOException {
+ final String entitySetName, final Map.Entry<String, Collection<String>> link)
+ throws IOException {
final ObjectNode links = new ObjectNode(JsonNodeFactory.instance);
links.put(
- Constants.get(version, ConstantKey.JSON_ODATAMETADATA_NAME),
- Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX) + entitySetName + "/$links/" + link.getKey());
+ Constants.get(version, ConstantKey.JSON_ODATAMETADATA_NAME),
+ Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX) + entitySetName + "/$links/" + link.getKey());
final ArrayNode uris = new ArrayNode(JsonNodeFactory.instance);
@@ -222,9 +222,9 @@ public abstract class Commons {
IOUtils.closeQuietly(is);
final ObjectMapper mapper = new ObjectMapper(
- new JsonFactory().configure(JsonParser.Feature.ALLOW_NUMERIC_LEADING_ZEROS, true));
+ new JsonFactory().configure(JsonParser.Feature.ALLOW_NUMERIC_LEADING_ZEROS, true));
final JsonNode node =
- changeFormat((ObjectNode) mapper.readTree(new ByteArrayInputStream(bos.toByteArray())), version, target);
+ changeFormat((ObjectNode) mapper.readTree(new ByteArrayInputStream(bos.toByteArray())), version, target);
return IOUtils.toInputStream(node.toString(), Constants.ENCODING);
} catch (Exception e) {
@@ -239,40 +239,40 @@ public abstract class Commons {
public static JsonNode changeFormat(final ObjectNode node, final ODataServiceVersion version, final Accept target) {
final List<String> toBeRemoved = new ArrayList<String>();
switch (target) {
- case JSON_NOMETA:
- // nometa + minimal
- toBeRemoved.add(Constants.get(version, ConstantKey.JSON_ODATAMETADATA_NAME));
-
- case JSON:
- // minimal
- toBeRemoved.add(Constants.get(version, ConstantKey.JSON_EDITLINK_NAME));
- toBeRemoved.add(Constants.get(version, ConstantKey.JSON_ID_NAME));
- toBeRemoved.add(Constants.get(version, ConstantKey.JSON_TYPE_NAME));
-
- final Iterator<Map.Entry<String, JsonNode>> fields = node.fields();
- while (fields.hasNext()) {
- final Map.Entry<String, JsonNode> field = fields.next();
- if (field.getKey().endsWith(Constants.get(version, ConstantKey.JSON_MEDIA_SUFFIX))
- || field.getKey().endsWith(Constants.get(version, ConstantKey.JSON_NAVIGATION_SUFFIX))
- || field.getKey().endsWith(Constants.get(version, ConstantKey.JSON_TYPE_SUFFIX))) {
- toBeRemoved.add(field.getKey());
- } else if (field.getValue().isObject()) {
- changeFormat((ObjectNode) field.getValue(), version, target);
- } else if (field.getValue().isArray()) {
- for (final Iterator<JsonNode> subItor = field.getValue().elements(); subItor.hasNext();) {
- final JsonNode subNode = subItor.next();
- if (subNode.isObject()) {
- changeFormat((ObjectNode) subNode, version, target);
- }
+ case JSON_NOMETA:
+ // nometa + minimal
+ toBeRemoved.add(Constants.get(version, ConstantKey.JSON_ODATAMETADATA_NAME));
+
+ case JSON:
+ // minimal
+ toBeRemoved.add(Constants.get(version, ConstantKey.JSON_EDITLINK_NAME));
+ toBeRemoved.add(Constants.get(version, ConstantKey.JSON_ID_NAME));
+ toBeRemoved.add(Constants.get(version, ConstantKey.JSON_TYPE_NAME));
+
+ final Iterator<Map.Entry<String, JsonNode>> fields = node.fields();
+ while (fields.hasNext()) {
+ final Map.Entry<String, JsonNode> field = fields.next();
+ if (field.getKey().endsWith(Constants.get(version, ConstantKey.JSON_MEDIA_SUFFIX))
+ || field.getKey().endsWith(Constants.get(version, ConstantKey.JSON_NAVIGATION_SUFFIX))
+ || field.getKey().endsWith(Constants.get(version, ConstantKey.JSON_TYPE_SUFFIX))) {
+ toBeRemoved.add(field.getKey());
+ } else if (field.getValue().isObject()) {
+ changeFormat((ObjectNode) field.getValue(), version, target);
+ } else if (field.getValue().isArray()) {
+ for (final Iterator<JsonNode> subItor = field.getValue().elements(); subItor.hasNext();) {
+ final JsonNode subNode = subItor.next();
+ if (subNode.isObject()) {
+ changeFormat((ObjectNode) subNode, version, target);
}
}
}
- case JSON_FULLMETA:
- //ignore: no changes
- break;
+ }
+ case JSON_FULLMETA:
+ // ignore: no changes
+ break;
- default:
- throw new UnsupportedOperationException(target.name());
+ default:
+ throw new UnsupportedOperationException(target.name());
}
node.remove(toBeRemoved);
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/2ab4b2fd/fit/src/main/java/org/apache/olingo/fit/utils/ConstantKey.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/utils/ConstantKey.java b/fit/src/main/java/org/apache/olingo/fit/utils/ConstantKey.java
index 7ff1bd4..9b9a20d 100644
--- a/fit/src/main/java/org/apache/olingo/fit/utils/ConstantKey.java
+++ b/fit/src/main/java/org/apache/olingo/fit/utils/ConstantKey.java
@@ -1,18 +1,18 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
+ * 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
- *
+ * 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
+ * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/2ab4b2fd/fit/src/main/java/org/apache/olingo/fit/utils/Constants.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/utils/Constants.java b/fit/src/main/java/org/apache/olingo/fit/utils/Constants.java
index ad060ba..b697881 100644
--- a/fit/src/main/java/org/apache/olingo/fit/utils/Constants.java
+++ b/fit/src/main/java/org/apache/olingo/fit/utils/Constants.java
@@ -1,18 +1,18 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
+ * 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
- *
+ * 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
+ * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
@@ -23,6 +23,7 @@ import java.nio.charset.CharsetDecoder;
import java.nio.charset.CodingErrorAction;
import java.util.EnumMap;
import java.util.Map;
+
import org.apache.olingo.commons.api.edm.constants.ODataServiceVersion;
public class Constants {
@@ -34,7 +35,7 @@ public class Constants {
/**
* CR/LF.
*/
- public static final byte[] CRLF = {13, 10};
+ public static final byte[] CRLF = { 13, 10 };
public static final Charset ENCODING = Charset.forName("UTF-8");
@@ -59,8 +60,8 @@ public class Constants {
v4constants.put(ConstantKey.ATOM_LINK_REL, "http://docs.oasis-open.org/odata/ns/related/");
v4constants.put(ConstantKey.ODATA_SERVICE_VERSION, "OData-Version");
v4constants.put(ConstantKey.DEFAULT_SERVICE_URL, "http://localhost:9080/stub/StaticService/V40/Static.svc/");
- v4constants.put(ConstantKey.ODATA_METADATA_PREFIX,
- "http://localhost:9080/stub/StaticService/V40/Static.svc/$metadata#");
+ v4constants.put(ConstantKey.ODATA_METADATA_PREFIX,
+ "http://localhost:9080/stub/StaticService/V40/Static.svc/$metadata#");
v4constants.put(ConstantKey.ODATA_METADATA_ENTITY_SUFFIX, "/$entity");
// -----------------------------
@@ -71,7 +72,7 @@ public class Constants {
constants.put(ConstantKey.DEFAULT_SERVICE_URL, "http://localhost:9080/stub/StaticService/V30/Static.svc/");
constants.put(ConstantKey.ODATA_COUNT_NAME, "odata.count");
constants.put(ConstantKey.ODATA_METADATA_PREFIX,
- "http://localhost:9080/stub/StaticService/V30/Static.svc/$metadata#");
+ "http://localhost:9080/stub/StaticService/V30/Static.svc/$metadata#");
constants.put(ConstantKey.ODATA_METADATA_ENTITY_SUFFIX, "/@Element");
constants.put(ConstantKey.ATOM_DEF_TYPE, "Edm.String");
constants.put(ConstantKey.ATOM_PROPERTY_PREFIX, "d:");
@@ -124,6 +125,6 @@ public class Constants {
public static String get(final ODataServiceVersion version, final ConstantKey key) {
return (version == null || version.compareTo(ODataServiceVersion.V30) <= 0 || !v4constants.containsKey(key)
- ? constants : v4constants).get(key);
+ ? constants : v4constants).get(key);
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/2ab4b2fd/fit/src/main/java/org/apache/olingo/fit/utils/FSManager.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/utils/FSManager.java b/fit/src/main/java/org/apache/olingo/fit/utils/FSManager.java
index 2b63501..805db47 100644
--- a/fit/src/main/java/org/apache/olingo/fit/utils/FSManager.java
+++ b/fit/src/main/java/org/apache/olingo/fit/utils/FSManager.java
@@ -1,18 +1,18 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
+ * 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
- *
+ * 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
+ * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/2ab4b2fd/fit/src/main/java/org/apache/olingo/fit/utils/InjectableSerializerProvider.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/utils/InjectableSerializerProvider.java b/fit/src/main/java/org/apache/olingo/fit/utils/InjectableSerializerProvider.java
index 69b3bb1..a8587c5 100644
--- a/fit/src/main/java/org/apache/olingo/fit/utils/InjectableSerializerProvider.java
+++ b/fit/src/main/java/org/apache/olingo/fit/utils/InjectableSerializerProvider.java
@@ -1,18 +1,18 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
+ * 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
- *
+ * 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
+ * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
@@ -28,14 +28,14 @@ public class InjectableSerializerProvider extends DefaultSerializerProvider {
private static final long serialVersionUID = 3432260063063739646L;
public InjectableSerializerProvider(
- final SerializerProvider src, final SerializationConfig config, final SerializerFactory factory) {
+ final SerializerProvider src, final SerializationConfig config, final SerializerFactory factory) {
super(src, config, factory);
}
@Override
public InjectableSerializerProvider createInstance(
- final SerializationConfig config, final SerializerFactory factory) {
+ final SerializationConfig config, final SerializerFactory factory) {
return this;
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/2ab4b2fd/fit/src/main/java/org/apache/olingo/fit/utils/JSONUtilities.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/utils/JSONUtilities.java b/fit/src/main/java/org/apache/olingo/fit/utils/JSONUtilities.java
index fcfa552..7580ce7 100644
--- a/fit/src/main/java/org/apache/olingo/fit/utils/JSONUtilities.java
+++ b/fit/src/main/java/org/apache/olingo/fit/utils/JSONUtilities.java
@@ -1,18 +1,18 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
+ * 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
- *
+ * 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
+ * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
@@ -56,13 +56,13 @@ public class JSONUtilities extends AbstractUtilities {
mapper = new ObjectMapper().setSerializationInclusion(JsonInclude.Include.NON_NULL);
mapper.setInjectableValues(new InjectableValues.Std()
- .addValue(Boolean.class, Boolean.TRUE)
- .addValue(ODataServiceVersion.class, version));
+ .addValue(Boolean.class, Boolean.TRUE)
+ .addValue(ODataServiceVersion.class, version));
mapper.setSerializerProvider(new InjectableSerializerProvider(mapper.getSerializerProvider(),
- mapper.getSerializationConfig()
+ mapper.getSerializationConfig()
.withAttribute(ODataServiceVersion.class, version)
.withAttribute(Boolean.class, Boolean.TRUE),
- mapper.getSerializerFactory()));
+ mapper.getSerializerFactory()));
}
@Override
@@ -72,22 +72,22 @@ public class JSONUtilities extends AbstractUtilities {
@Override
protected InputStream addLinks(
- final String entitySetName, final String entitykey, final InputStream is, final Set<String> links)
- throws IOException {
+ final String entitySetName, final String entitykey, final InputStream is, final Set<String> links)
+ throws IOException {
final ObjectNode srcNode = (ObjectNode) mapper.readTree(is);
IOUtils.closeQuietly(is);
for (String link : links) {
srcNode.set(link + Constants.get(version, ConstantKey.JSON_NAVIGATION_SUFFIX),
- new TextNode(Commons.getLinksURI(entitySetName, entitykey, link)));
+ new TextNode(Commons.getLinksURI(entitySetName, entitykey, link)));
}
return IOUtils.toInputStream(srcNode.toString(), Constants.ENCODING);
}
@Override
- protected Set<String> retrieveAllLinkNames(InputStream is) throws IOException {
+ protected Set<String> retrieveAllLinkNames(final InputStream is) throws IOException {
final ObjectNode srcNode = (ObjectNode) mapper.readTree(is);
IOUtils.closeQuietly(is);
@@ -99,9 +99,9 @@ public class JSONUtilities extends AbstractUtilities {
final String field = fieldIter.next();
if (field.endsWith(Constants.get(version, ConstantKey.JSON_NAVIGATION_BIND_SUFFIX))
- || field.endsWith(Constants.get(version, ConstantKey.JSON_NAVIGATION_SUFFIX))
- || field.endsWith(Constants.get(version, ConstantKey.JSON_MEDIA_SUFFIX))
- || field.endsWith(Constants.get(version, ConstantKey.JSON_EDITLINK_NAME))) {
+ || field.endsWith(Constants.get(version, ConstantKey.JSON_NAVIGATION_SUFFIX))
+ || field.endsWith(Constants.get(version, ConstantKey.JSON_MEDIA_SUFFIX))
+ || field.endsWith(Constants.get(version, ConstantKey.JSON_EDITLINK_NAME))) {
if (field.indexOf('@') > 0) {
links.add(field.substring(0, field.indexOf('@')));
} else {
@@ -115,7 +115,7 @@ public class JSONUtilities extends AbstractUtilities {
@Override
protected NavigationLinks retrieveNavigationInfo(final String entitySetName, final InputStream is)
- throws IOException {
+ throws IOException {
final ObjectNode srcNode = (ObjectNode) mapper.readTree(is);
IOUtils.closeQuietly(is);
@@ -152,8 +152,8 @@ public class JSONUtilities extends AbstractUtilities {
@Override
protected InputStream normalizeLinks(
- final String entitySetName, final String entityKey, final InputStream is, final NavigationLinks links)
- throws IOException {
+ final String entitySetName, final String entityKey, final InputStream is, final NavigationLinks links)
+ throws IOException {
final ObjectNode srcNode = (ObjectNode) mapper.readTree(is);
@@ -162,16 +162,16 @@ public class JSONUtilities extends AbstractUtilities {
// normalize link
srcNode.remove(linkTitle + Constants.get(version, ConstantKey.JSON_NAVIGATION_BIND_SUFFIX));
srcNode.set(
- linkTitle + Constants.get(version, ConstantKey.JSON_NAVIGATION_SUFFIX),
- new TextNode(String.format("%s(%s)/%s", entitySetName, entityKey, linkTitle)));
+ linkTitle + Constants.get(version, ConstantKey.JSON_NAVIGATION_SUFFIX),
+ new TextNode(String.format("%s(%s)/%s", entitySetName, entityKey, linkTitle)));
}
for (String linkTitle : links.getInlineNames()) {
// normalize link if exist; declare a new one if missing
srcNode.remove(linkTitle + Constants.get(version, ConstantKey.JSON_NAVIGATION_BIND_SUFFIX));
srcNode.set(
- linkTitle + Constants.get(version, ConstantKey.JSON_NAVIGATION_SUFFIX),
- new TextNode(String.format("%s(%s)/%s", entitySetName, entityKey, linkTitle)));
+ linkTitle + Constants.get(version, ConstantKey.JSON_NAVIGATION_SUFFIX),
+ new TextNode(String.format("%s(%s)/%s", entitySetName, entityKey, linkTitle)));
// remove inline
srcNode.remove(linkTitle);
@@ -182,8 +182,8 @@ public class JSONUtilities extends AbstractUtilities {
}
srcNode.set(
- Constants.get(version, ConstantKey.JSON_EDITLINK_NAME), new TextNode(
- Constants.get(version, ConstantKey.DEFAULT_SERVICE_URL) + entitySetName + "(" + entityKey + ")"));
+ Constants.get(version, ConstantKey.JSON_EDITLINK_NAME), new TextNode(
+ Constants.get(version, ConstantKey.DEFAULT_SERVICE_URL) + entitySetName + "(" + entityKey + ")"));
return IOUtils.toInputStream(srcNode.toString(), Constants.ENCODING);
}
@@ -258,8 +258,8 @@ public class JSONUtilities extends AbstractUtilities {
@Override
public InputStream readEntities(
- final List<String> links, final String linkName, final String next, final boolean forceFeed)
- throws IOException {
+ final List<String> links, final String linkName, final String next, final boolean forceFeed)
+ throws IOException {
if (links.isEmpty()) {
throw new NotFoundException();
@@ -277,7 +277,7 @@ public class JSONUtilities extends AbstractUtilities {
try {
final Map.Entry<String, String> uriMap = Commons.parseEntityURI(link);
final Map.Entry<String, InputStream> entity =
- readEntity(uriMap.getKey(), uriMap.getValue(), Accept.JSON_FULLMETA);
+ readEntity(uriMap.getKey(), uriMap.getValue(), Accept.JSON_FULLMETA);
if (bos.size() > 1) {
bos.write(",".getBytes());
@@ -295,7 +295,7 @@ public class JSONUtilities extends AbstractUtilities {
}
node.set(Constants.get(version, ConstantKey.JSON_VALUE_NAME),
- mapper.readTree(new ByteArrayInputStream(bos.toByteArray())));
+ mapper.readTree(new ByteArrayInputStream(bos.toByteArray())));
if (StringUtils.isNotBlank(next)) {
node.set(Constants.get(version, ConstantKey.JSON_NEXTLINK_NAME), new TextNode(next));
@@ -306,8 +306,8 @@ public class JSONUtilities extends AbstractUtilities {
@Override
protected InputStream replaceLink(
- final InputStream toBeChanged, final String linkName, final InputStream replacement)
- throws IOException {
+ final InputStream toBeChanged, final String linkName, final InputStream replacement)
+ throws IOException {
final ObjectNode toBeChangedNode = (ObjectNode) mapper.readTree(toBeChanged);
final ObjectNode replacementNode = (ObjectNode) mapper.readTree(replacement);
@@ -343,7 +343,7 @@ public class JSONUtilities extends AbstractUtilities {
@Override
public Map.Entry<String, List<String>> extractLinkURIs(
- final String entitySetName, final String entityId, final String linkName) throws Exception {
+ final String entitySetName, final String entityId, final String linkName) throws Exception {
final LinkInfo links = readLinks(entitySetName, entityId, linkName, Accept.JSON_FULLMETA);
return extractLinkURIs(links.getLinks());
}
@@ -376,7 +376,7 @@ public class JSONUtilities extends AbstractUtilities {
@Override
public InputStream addEditLink(
- final InputStream content, final String title, final String href) throws IOException {
+ final InputStream content, final String title, final String href) throws IOException {
final ObjectNode srcNode = (ObjectNode) mapper.readTree(content);
IOUtils.closeQuietly(content);
@@ -387,7 +387,7 @@ public class JSONUtilities extends AbstractUtilities {
@Override
public InputStream addOperation(final InputStream content, final String name, final String metaAnchor,
- final String href) throws IOException {
+ final String href) throws IOException {
final ObjectNode srcNode = (ObjectNode) mapper.readTree(content);
IOUtils.closeQuietly(content);
@@ -402,8 +402,8 @@ public class JSONUtilities extends AbstractUtilities {
@Override
public InputStream replaceProperty(
- final InputStream src, final InputStream replacement, final List<String> path, final boolean justValue)
- throws IOException {
+ final InputStream src, final InputStream replacement, final List<String> path, final boolean justValue)
+ throws IOException {
final ObjectNode srcNode = (ObjectNode) mapper.readTree(src);
IOUtils.closeQuietly(src);
@@ -427,8 +427,8 @@ public class JSONUtilities extends AbstractUtilities {
}
}
- ((ObjectNode) node).set(path.get(path.size() - 1), replacementNode);
-
+ ((ObjectNode) node).set(path.get(path.size() - 1), replacementNode);
+
return IOUtils.toInputStream(srcNode.toString(), Constants.ENCODING);
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/2ab4b2fd/fit/src/main/java/org/apache/olingo/fit/utils/LinkInfo.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/utils/LinkInfo.java b/fit/src/main/java/org/apache/olingo/fit/utils/LinkInfo.java
index c922e3b..1f8abf4 100644
--- a/fit/src/main/java/org/apache/olingo/fit/utils/LinkInfo.java
+++ b/fit/src/main/java/org/apache/olingo/fit/utils/LinkInfo.java
@@ -1,18 +1,18 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
+ * 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
- *
+ * 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
+ * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
@@ -36,7 +36,7 @@ public class LinkInfo {
return feed;
}
- public void setFeed(boolean feed) {
+ public void setFeed(final boolean feed) {
this.feed = feed;
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/2ab4b2fd/fit/src/main/java/org/apache/olingo/fit/utils/MetadataLinkInfo.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/utils/MetadataLinkInfo.java b/fit/src/main/java/org/apache/olingo/fit/utils/MetadataLinkInfo.java
index f18b8b8..c30a8f3 100644
--- a/fit/src/main/java/org/apache/olingo/fit/utils/MetadataLinkInfo.java
+++ b/fit/src/main/java/org/apache/olingo/fit/utils/MetadataLinkInfo.java
@@ -1,18 +1,18 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
+ * 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
- *
+ * 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
+ * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
@@ -22,6 +22,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
+
import javax.ws.rs.NotFoundException;
public class MetadataLinkInfo {
@@ -47,7 +48,7 @@ public class MetadataLinkInfo {
}
public void addLink(
- final String entitySetName, final String linkName, final String targetName, final boolean isFeed) {
+ final String entitySetName, final String linkName, final String targetName, final boolean isFeed) {
final EntitySet entitySet;
if (entitySets.containsKey(entitySetName)) {
entitySet = entitySets.get(entitySetName);
@@ -111,14 +112,6 @@ public class MetadataLinkInfo {
links.add(new NavigationLink(linkName, targetName, isFeed));
}
- public String getName() {
- return name;
- }
-
- public void setName(final String name) {
- this.name = name;
- }
-
public Set<NavigationLink> getLinks() {
return links;
}
@@ -141,19 +134,11 @@ public class MetadataLinkInfo {
}
}
- public void setLinks(final Set<NavigationLink> links) {
- this.links = links;
- }
-
- public EntitySet(boolean singleton) {
- this.singleton = singleton;
- }
-
public boolean isSingleton() {
return singleton;
}
- public void setSingleton(boolean singleton) {
+ public void setSingleton(final boolean singleton) {
this.singleton = singleton;
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/2ab4b2fd/fit/src/main/java/org/apache/olingo/fit/utils/NavigationLinks.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/utils/NavigationLinks.java b/fit/src/main/java/org/apache/olingo/fit/utils/NavigationLinks.java
index 1c50e37..e2d948a 100644
--- a/fit/src/main/java/org/apache/olingo/fit/utils/NavigationLinks.java
+++ b/fit/src/main/java/org/apache/olingo/fit/utils/NavigationLinks.java
@@ -1,18 +1,18 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
+ * 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
- *
+ * 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
+ * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
@@ -25,6 +25,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
+
import org.apache.commons.io.IOUtils;
public class NavigationLinks {
@@ -34,7 +35,7 @@ public class NavigationLinks {
private final Map<String, List<String>> links = new HashMap<String, List<String>>();
public NavigationLinks addInlines(final String name, final InputStream inline) {
- return addInlines(name, Collections.<InputStream>singletonList(inline));
+ return addInlines(name, Collections.<InputStream> singletonList(inline));
}
public NavigationLinks addInlines(final String name, final List<InputStream> inline) {
@@ -52,7 +53,7 @@ public class NavigationLinks {
}
public NavigationLinks addLinks(final String name, final String uri) {
- return addLinks(name, Collections.<String>singletonList(uri));
+ return addLinks(name, Collections.<String> singletonList(uri));
}
public NavigationLinks addLinks(final String name, final List<String> uris) {
@@ -70,19 +71,19 @@ public class NavigationLinks {
}
public Set<String> getInlineNames() {
- return Collections.<String>unmodifiableSet(inlines.keySet());
+ return Collections.<String> unmodifiableSet(inlines.keySet());
}
public Set<String> getLinkNames() {
- return Collections.<String>unmodifiableSet(links.keySet());
+ return Collections.<String> unmodifiableSet(links.keySet());
}
public List<InputStream> getInlines(final String name) {
- return Collections.<InputStream>unmodifiableList(inlines.get(name));
+ return Collections.<InputStream> unmodifiableList(inlines.get(name));
}
public List<String> getLinks(final String name) {
- return Collections.<String>unmodifiableList(links.get(name));
+ return Collections.<String> unmodifiableList(links.get(name));
}
public Iterable<Map.Entry<String, List<InputStream>>> getInlines() {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/2ab4b2fd/fit/src/main/java/org/apache/olingo/fit/utils/ResolvingReferencesInterceptor.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/utils/ResolvingReferencesInterceptor.java b/fit/src/main/java/org/apache/olingo/fit/utils/ResolvingReferencesInterceptor.java
index 4adac8a..794e449 100644
--- a/fit/src/main/java/org/apache/olingo/fit/utils/ResolvingReferencesInterceptor.java
+++ b/fit/src/main/java/org/apache/olingo/fit/utils/ResolvingReferencesInterceptor.java
@@ -1,18 +1,18 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
+ * 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
- *
+ * 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
+ * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
@@ -21,6 +21,7 @@ package org.apache.olingo.fit.utils;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URLDecoder;
+
import org.apache.commons.lang3.StringUtils;
import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.message.Message;
@@ -40,7 +41,7 @@ public class ResolvingReferencesInterceptor extends AbstractPhaseInterceptor<Mes
try {
if (path.endsWith("$entity") && StringUtils.isNotBlank(query)
- && URLDecoder.decode(query, "UTF-8").contains("$id=")) {
+ && URLDecoder.decode(query, "UTF-8").contains("$id=")) {
final String id = URLDecoder.decode(query, "UTF-8");
final String newURL = id.substring(id.indexOf("$id=") + 4);
@@ -51,7 +52,6 @@ public class ResolvingReferencesInterceptor extends AbstractPhaseInterceptor<Mes
message.put(Message.PATH_INFO, uri.getPath());
}
- } catch (UnsupportedEncodingException ignore) {
- }
+ } catch (UnsupportedEncodingException ignore) {}
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/2ab4b2fd/fit/src/main/java/org/apache/olingo/fit/utils/XHTTPMethodInterceptor.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/utils/XHTTPMethodInterceptor.java b/fit/src/main/java/org/apache/olingo/fit/utils/XHTTPMethodInterceptor.java
index bbcc489..238e155 100644
--- a/fit/src/main/java/org/apache/olingo/fit/utils/XHTTPMethodInterceptor.java
+++ b/fit/src/main/java/org/apache/olingo/fit/utils/XHTTPMethodInterceptor.java
@@ -1,18 +1,18 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
+ * 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
- *
+ * 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
+ * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
@@ -20,6 +20,7 @@ package org.apache.olingo.fit.utils;
import java.util.List;
import java.util.Map;
+
import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.message.Message;
import org.apache.cxf.phase.AbstractPhaseInterceptor;
@@ -38,7 +39,7 @@ public class XHTTPMethodInterceptor extends AbstractPhaseInterceptor<Message> {
if (headers.containsKey(Constants.get(ConstantKey.XHTTP_HEADER_NAME))) {
message.put(Message.HTTP_REQUEST_METHOD, headers.get(Constants.get(ConstantKey.XHTTP_HEADER_NAME))
- .iterator().next());
+ .iterator().next());
}
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/2ab4b2fd/fit/src/main/java/org/apache/olingo/fit/utils/XMLElement.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/utils/XMLElement.java b/fit/src/main/java/org/apache/olingo/fit/utils/XMLElement.java
index c8a0ee8..1bc1b4e 100644
--- a/fit/src/main/java/org/apache/olingo/fit/utils/XMLElement.java
+++ b/fit/src/main/java/org/apache/olingo/fit/utils/XMLElement.java
@@ -1,18 +1,18 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
+ * 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
- *
+ * 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
+ * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
@@ -52,7 +52,7 @@ public class XMLElement {
return start;
}
- public void setStart(StartElement start) {
+ public void setStart(final StartElement start) {
this.start = start;
}
@@ -60,7 +60,7 @@ public class XMLElement {
return end;
}
- public void setEnd(EndElement end) {
+ public void setEnd(final EndElement end) {
this.end = end;
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/2ab4b2fd/fit/src/main/java/org/apache/olingo/fit/utils/XMLEventReaderWrapper.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/utils/XMLEventReaderWrapper.java b/fit/src/main/java/org/apache/olingo/fit/utils/XMLEventReaderWrapper.java
index 1774f0c..b3de7ee 100644
--- a/fit/src/main/java/org/apache/olingo/fit/utils/XMLEventReaderWrapper.java
+++ b/fit/src/main/java/org/apache/olingo/fit/utils/XMLEventReaderWrapper.java
@@ -1,18 +1,18 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
+ * 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
- *
+ * 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
+ * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
@@ -50,23 +50,23 @@ public class XMLEventReaderWrapper implements XMLEventReader {
throws IOException, XMLStreamException {
final StringBuilder startBuilder = new StringBuilder();
startBuilder.append("<").append(CONTENT).
- append(" xmlns:m").append("=\"").append(Constants.get(version, ConstantKey.METADATA_NS)).append("\"").
- append(" xmlns:d").append("=\"").append(Constants.get(version, ConstantKey.DATASERVICES_NS)).append("\"").
- append(" xmlns:georss").append("=\"").append(Constants.get(version, ConstantKey.GEORSS_NS)).append("\"").
- append(" xmlns:gml").append("=\"").append(Constants.get(version, ConstantKey.GML_NS)).append("\"").
- append(">");
+ append(" xmlns:m").append("=\"").append(Constants.get(version, ConstantKey.METADATA_NS)).append("\"").
+ append(" xmlns:d").append("=\"").append(Constants.get(version, ConstantKey.DATASERVICES_NS)).append("\"").
+ append(" xmlns:georss").append("=\"").append(Constants.get(version, ConstantKey.GEORSS_NS)).append("\"").
+ append(" xmlns:gml").append("=\"").append(Constants.get(version, ConstantKey.GML_NS)).append("\"").
+ append(">");
CONTENT_STAG = startBuilder.toString();
final XMLInputFactory factory = XMLInputFactory.newInstance();
final InputStreamReader reader = new InputStreamReader(
- new ByteArrayInputStream((CONTENT_STAG
+ new ByteArrayInputStream((CONTENT_STAG
+ IOUtils.toString(stream, ENCODING).replaceAll("^<\\?xml.*\\?>", "")
+ XMLEventReaderWrapper.CONTENT_ETAG).getBytes(ENCODING)),
- Constants.DECODER);
+ Constants.DECODER);
- this.wrapped = factory.createXMLEventReader(reader);
+ wrapped = factory.createXMLEventReader(reader);
init();
}
@@ -76,11 +76,11 @@ public class XMLEventReaderWrapper implements XMLEventReader {
try {
do {
- this.nextGivenEvent = this.wrapped.nextEvent();
+ nextGivenEvent = wrapped.nextEvent();
- } while (this.nextGivenEvent.isStartDocument()
- || (this.nextGivenEvent.isStartElement()
- && CONTENT.equals(this.nextGivenEvent.asStartElement().getName().getLocalPart())));
+ } while (nextGivenEvent.isStartDocument()
+ || (nextGivenEvent.isStartElement()
+ && CONTENT.equals(nextGivenEvent.asStartElement().getName().getLocalPart())));
} catch (Exception ignore) {
// ignore
@@ -148,7 +148,7 @@ public class XMLEventReaderWrapper implements XMLEventReader {
private boolean isValidEvent(final XMLEvent event) {
// discard content end element tag ...
return event != null
- && (!event.isEndElement()
- || !CONTENT.equals(event.asEndElement().getName().getLocalPart()));
+ && (!event.isEndElement()
+ || !CONTENT.equals(event.asEndElement().getName().getLocalPart()));
}
}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/2ab4b2fd/fit/src/main/java/org/apache/olingo/fit/utils/XMLUtilities.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/utils/XMLUtilities.java b/fit/src/main/java/org/apache/olingo/fit/utils/XMLUtilities.java
index f5ba1c1..7745d3f 100644
--- a/fit/src/main/java/org/apache/olingo/fit/utils/XMLUtilities.java
+++ b/fit/src/main/java/org/apache/olingo/fit/utils/XMLUtilities.java
@@ -1,18 +1,18 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
+ * 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
- *
+ * 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
+ * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
@@ -37,6 +37,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
+
import javax.ws.rs.NotFoundException;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLEventFactory;
@@ -49,6 +50,7 @@ import javax.xml.stream.XMLStreamException;
import javax.xml.stream.events.Attribute;
import javax.xml.stream.events.StartElement;
import javax.xml.stream.events.XMLEvent;
+
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.vfs2.FileObject;
@@ -99,11 +101,11 @@ public class XMLUtilities extends AbstractUtilities {
}
private void skipElement(
- final StartElement start,
- final XMLEventReader reader,
- final XMLEventWriter writer,
- final boolean excludeStart)
- throws Exception {
+ final StartElement start,
+ final XMLEventReader reader,
+ final XMLEventWriter writer,
+ final boolean excludeStart)
+ throws Exception {
if (!excludeStart) {
writeEvent(start, writer);
@@ -131,8 +133,8 @@ public class XMLUtilities extends AbstractUtilities {
*/
@Override
protected InputStream addLinks(
- final String entitySetName, final String entitykey, final InputStream is, final Set<String> links)
- throws Exception {
+ final String entitySetName, final String entitykey, final InputStream is, final Set<String> links)
+ throws Exception {
// -----------------------------------------
// 0. Build reader and writer
@@ -144,7 +146,7 @@ public class XMLUtilities extends AbstractUtilities {
final XMLEventWriter writer = getEventWriter(bos);
// -----------------------------------------
final Map.Entry<Integer, XMLElement> entry =
- extractElement(reader, writer, Collections.singletonList("entry"), 0, 1, 1);
+ extractElement(reader, writer, Collections.singletonList("entry"), 0, 1, 1);
writer.add(entry.getValue().getStart());
@@ -155,16 +157,16 @@ public class XMLUtilities extends AbstractUtilities {
final Set<Attribute> attributes = new HashSet<Attribute>();
attributes.add(eventFactory.createAttribute(new QName("title"), link));
attributes.add(eventFactory.createAttribute(new QName("href"),
- Commons.getLinksURI(entitySetName, entitykey, link)));
+ Commons.getLinksURI(entitySetName, entitykey, link)));
attributes.add(eventFactory.createAttribute(new QName("rel"),
- Constants.get(version, ConstantKey.ATOM_LINK_REL) + link));
+ Constants.get(version, ConstantKey.ATOM_LINK_REL) + link));
attributes.add(eventFactory.createAttribute(new QName("type"),
- navigationProperties.get(link).isEntitySet()
+ navigationProperties.get(link).isEntitySet()
? Constants.get(version, ConstantKey.ATOM_LINK_FEED)
: Constants.get(version, ConstantKey.ATOM_LINK_ENTRY)));
writer.add(eventFactory.createStartElement(
- new QName(Constants.get(version, ConstantKey.LINK)), attributes.iterator(), null));
+ new QName(Constants.get(version, ConstantKey.LINK)), attributes.iterator(), null));
writer.add(eventFactory.createEndElement(new QName(Constants.get(version, ConstantKey.LINK)), null));
}
@@ -195,8 +197,8 @@ public class XMLUtilities extends AbstractUtilities {
while (true) {
final Map.Entry<Integer, XMLElement> linkInfo =
- extractElement(reader, null,
- Collections.<String>singletonList(Constants.get(version, ConstantKey.LINK)), startDepth, 2, 2);
+ extractElement(reader, null,
+ Collections.<String> singletonList(Constants.get(version, ConstantKey.LINK)), startDepth, 2, 2);
startDepth = linkInfo.getKey();
@@ -217,8 +219,8 @@ public class XMLUtilities extends AbstractUtilities {
*/
@Override
protected NavigationLinks retrieveNavigationInfo(
- final String entitySetName, final InputStream is)
- throws Exception {
+ final String entitySetName, final InputStream is)
+ throws Exception {
final NavigationLinks links = new NavigationLinks();
@@ -234,8 +236,8 @@ public class XMLUtilities extends AbstractUtilities {
while (true) {
// a. search for link with type attribute equals to "application/atom+xml;type=entry/feed"
final Map.Entry<Integer, XMLElement> linkInfo = extractElement(
- reader, null, Collections.<String>singletonList(Constants.get(version, ConstantKey.LINK)),
- filter, true, startDepth, 2, 2);
+ reader, null, Collections.<String> singletonList(Constants.get(version, ConstantKey.LINK)),
+ filter, true, startDepth, 2, 2);
final XMLElement link = linkInfo.getValue();
startDepth = linkInfo.getKey();
@@ -246,15 +248,15 @@ public class XMLUtilities extends AbstractUtilities {
try {
final XMLElement inlineElement =
- extractElement(link.getContentReader(version), null,
- Collections.<String>singletonList(Constants.get(version, ConstantKey.INLINE)), 0, -1, -1).
+ extractElement(link.getContentReader(version), null,
+ Collections.<String> singletonList(Constants.get(version, ConstantKey.INLINE)), 0, -1, -1).
getValue();
final XMLEventReader inlineReader = inlineElement.getContentReader(version);
try {
while (true) {
final XMLElement entry =
- extractElement(inlineReader, null, Collections.<String>singletonList("entry"), 0, -1, -1).
+ extractElement(inlineReader, null, Collections.<String> singletonList("entry"), 0, -1, -1).
getValue();
links.addInlines(title, entry.toStream());
}
@@ -284,8 +286,8 @@ public class XMLUtilities extends AbstractUtilities {
*/
@Override
protected InputStream normalizeLinks(
- final String entitySetName, final String entityKey, final InputStream is, final NavigationLinks links)
- throws Exception {
+ final String entitySetName, final String entityKey, final InputStream is, final NavigationLinks links)
+ throws Exception {
// -----------------------------------------
// 0. Build reader and writer
@@ -315,9 +317,9 @@ public class XMLUtilities extends AbstractUtilities {
while (true) {
// a. search for link with type attribute equals to "application/atom+xml;type=entry/feed"
linkInfo = extractElement(
- reader, writer,
- Collections.<String>singletonList(Constants.get(version, ConstantKey.LINK)), filter, true,
- linkInfo == null ? 0 : linkInfo.getKey(), 2, 2);
+ reader, writer,
+ Collections.<String> singletonList(Constants.get(version, ConstantKey.LINK)), filter, true,
+ linkInfo == null ? 0 : linkInfo.getKey(), 2, 2);
final XMLElement link = linkInfo.getValue();
final String title = link.getStart().getAttributeByName(new QName("title")).getValue();
@@ -326,13 +328,13 @@ public class XMLUtilities extends AbstractUtilities {
added.add(title);
final String normalizedLink = String.format(
- "<link href=\"%s(%s)/%s\" rel=\"%s\" title=\"%s\" type=\"%s\"/>",
- entitySetName,
- entityKey,
- title,
- link.getStart().getAttributeByName(new QName("rel")).getValue(),
- title,
- link.getStart().getAttributeByName(new QName("type")).getValue());
+ "<link href=\"%s(%s)/%s\" rel=\"%s\" title=\"%s\" type=\"%s\"/>",
+ entitySetName,
+ entityKey,
+ title,
+ link.getStart().getAttributeByName(new QName("rel")).getValue(),
+ title,
+ link.getStart().getAttributeByName(new QName("type")).getValue());
addAtomElement(IOUtils.toInputStream(normalizedLink, Constants.ENCODING), writer);
}
@@ -349,26 +351,26 @@ public class XMLUtilities extends AbstractUtilities {
// 2. Add edit link if missing
// -----------------------------------------
final InputStream content = addEditLink(
- new ByteArrayInputStream(tmpBos.toByteArray()),
- entitySetName,
- Constants.get(version, ConstantKey.DEFAULT_SERVICE_URL) + entitySetName + "(" + entityKey + ")");
+ new ByteArrayInputStream(tmpBos.toByteArray()),
+ entitySetName,
+ Constants.get(version, ConstantKey.DEFAULT_SERVICE_URL) + entitySetName + "(" + entityKey + ")");
// -----------------------------------------
// -----------------------------------------
// 3. Add content element if missing
// -----------------------------------------
return addAtomContent(
- content,
- entitySetName,
- Constants.get(version, ConstantKey.DEFAULT_SERVICE_URL) + entitySetName + "(" + entityKey + ")");
+ content,
+ entitySetName,
+ Constants.get(version, ConstantKey.DEFAULT_SERVICE_URL) + entitySetName + "(" + entityKey + ")");
// -----------------------------------------
}
public XMLElement getXmlElement(
- final StartElement start,
- final XMLEventReader reader)
- throws Exception {
+ final StartElement start,
+ final XMLEventReader reader)
+ throws Exception {
final XMLElement res = new XMLElement();
res.setStart(start);
@@ -404,9 +406,9 @@ public class XMLUtilities extends AbstractUtilities {
}
private void addAtomElement(
- final InputStream content,
- final XMLEventWriter writer)
- throws Exception {
+ final InputStream content,
+ final XMLEventWriter writer)
+ throws Exception {
final XMLEventReader reader = getEventReader(content);
final XMLEventFactory eventFactory = XMLEventFactory.newInstance();
@@ -419,8 +421,8 @@ public class XMLUtilities extends AbstractUtilities {
final XMLEvent event = reader.nextEvent();
if (event.getEventType() != XMLStreamConstants.START_DOCUMENT
- && event.getEventType() != XMLStreamConstants.END_DOCUMENT
- && event.getEventType() != XMLStreamConstants.COMMENT) {
+ && event.getEventType() != XMLStreamConstants.END_DOCUMENT
+ && event.getEventType() != XMLStreamConstants.COMMENT) {
writer.add(event);
}
}
@@ -433,8 +435,8 @@ public class XMLUtilities extends AbstractUtilities {
@Override
public InputStream addEditLink(
- final InputStream content, final String title, final String href)
- throws Exception {
+ final InputStream content, final String title, final String href)
+ throws Exception {
final ByteArrayOutputStream copy = new ByteArrayOutputStream();
IOUtils.copy(content, copy);
@@ -449,8 +451,8 @@ public class XMLUtilities extends AbstractUtilities {
try {
// check edit link existence
- extractElement(reader, writer, Collections.<String>singletonList(Constants.get(version, ConstantKey.LINK)),
- Collections.<Map.Entry<String, String>>singletonList(
+ extractElement(reader, writer, Collections.<String> singletonList(Constants.get(version, ConstantKey.LINK)),
+ Collections.<Map.Entry<String, String>> singletonList(
new AbstractMap.SimpleEntry<String, String>("rel", "edit")), false, 0, -1, -1);
addAtomElement(IOUtils.toInputStream(editLinkElement, Constants.ENCODING), writer);
@@ -464,7 +466,7 @@ public class XMLUtilities extends AbstractUtilities {
writer = getEventWriter(bos);
final XMLElement entryElement =
- extractElement(reader, writer, Collections.<String>singletonList("entry"), 0, 1, 1).getValue();
+ extractElement(reader, writer, Collections.<String> singletonList("entry"), 0, 1, 1).getValue();
writer.add(entryElement.getStart());
@@ -486,22 +488,22 @@ public class XMLUtilities extends AbstractUtilities {
@Override
public InputStream addOperation(final InputStream content, final String name, final String metaAnchor,
- final String href) throws Exception {
+ final String href) throws Exception {
final ByteArrayOutputStream copy = new ByteArrayOutputStream();
IOUtils.copy(content, copy);
IOUtils.closeQuietly(content);
final String action = String.format("<m:action metadata=\"%s%s\" title=\"%s\" target=\"%s\"/>",
- Constants.get(version, ConstantKey.DEFAULT_SERVICE_URL), metaAnchor, name, href);
+ Constants.get(version, ConstantKey.DEFAULT_SERVICE_URL), metaAnchor, name, href);
final String newContent = new String(copy.toByteArray(), "UTF-8").replaceAll("\\<content ", action + "\\<content ");
return IOUtils.toInputStream(newContent, "UTF-8");
}
private InputStream addAtomContent(
- final InputStream content, final String title, final String href)
- throws Exception {
+ final InputStream content, final String title, final String href)
+ throws Exception {
final ByteArrayOutputStream copy = new ByteArrayOutputStream();
IOUtils.copy(content, copy);
@@ -516,7 +518,7 @@ public class XMLUtilities extends AbstractUtilities {
try {
// check edit link existence
XMLElement contentElement =
- extractElement(reader, writer, Collections.<String>singletonList("content"), 0, 2, 2).getValue();
+ extractElement(reader, writer, Collections.<String> singletonList("content"), 0, 2, 2).getValue();
writer.add(contentElement.getStart());
writer.add(contentElement.getContentReader(version));
writer.add(contentElement.getEnd());
@@ -530,33 +532,33 @@ public class XMLUtilities extends AbstractUtilities {
if (isMediaContent(title)) {
final XMLElement entryElement =
- extractElement(reader, writer, Collections.<String>singletonList("entry"), 0, 1, 1).getValue();
+ extractElement(reader, writer, Collections.<String> singletonList("entry"), 0, 1, 1).getValue();
writer.add(entryElement.getStart());
writer.add(entryElement.getContentReader(version));
addAtomElement(
- IOUtils.toInputStream(String.format("<content type=\"*/*\" src=\"%s/$value\" />", href)),
- writer);
+ IOUtils.toInputStream(String.format("<content type=\"*/*\" src=\"%s/$value\" />", href)),
+ writer);
writer.add(entryElement.getEnd());
} else {
try {
final XMLElement entryElement =
- extractElement(reader, writer, Collections.<String>singletonList(
+ extractElement(reader, writer, Collections.<String> singletonList(
Constants.get(version, ConstantKey.PROPERTIES)), 0, 2, 3).getValue();
addAtomElement(
- IOUtils.toInputStream("<content type=\"application/xml\">"),
- writer);
+ IOUtils.toInputStream("<content type=\"application/xml\">"),
+ writer);
writer.add(entryElement.getStart());
writer.add(entryElement.getContentReader(version));
writer.add(entryElement.getEnd());
addAtomElement(
- IOUtils.toInputStream("</content>"),
- writer);
+ IOUtils.toInputStream("</content>"),
+ writer);
} catch (Exception nf) {
reader.close();
reader = getEventReader(new ByteArrayInputStream(copy.toByteArray()));
@@ -565,13 +567,13 @@ public class XMLUtilities extends AbstractUtilities {
writer = getEventWriter(bos);
final XMLElement entryElement =
- extractElement(reader, writer, Collections.<String>singletonList("entry"), 0, 1, 1).getValue();
+ extractElement(reader, writer, Collections.<String> singletonList("entry"), 0, 1, 1).getValue();
writer.add(entryElement.getStart());
writer.add(entryElement.getContentReader(version));
addAtomElement(
- IOUtils.toInputStream("<content type=\"application/xml\"/>"),
- writer);
+ IOUtils.toInputStream("<content type=\"application/xml\"/>"),
+ writer);
writer.add(entryElement.getEnd());
}
@@ -591,9 +593,10 @@ public class XMLUtilities extends AbstractUtilities {
public int countAllElements(final String entitySetName) throws Exception {
final String basePath = entitySetName + File.separatorChar;
int count = countFeedElements(fsManager.readFile(basePath + Constants.get(version, ConstantKey.FEED), Accept.XML),
- "entry");
+ "entry");
- final String skipTokenDirPath = fsManager.getAbsolutePath(basePath + Constants.get(version, ConstantKey.SKIP_TOKEN),
+ final String skipTokenDirPath =
+ fsManager.getAbsolutePath(basePath + Constants.get(version, ConstantKey.SKIP_TOKEN),
null);
try {
@@ -602,7 +605,7 @@ public class XMLUtilities extends AbstractUtilities {
for (FileObject file : files) {
count += countFeedElements(fsManager.readFile(
- basePath + Constants.get(version, ConstantKey.SKIP_TOKEN) + File.separatorChar
+ basePath + Constants.get(version, ConstantKey.SKIP_TOKEN) + File.separatorChar
+ file.getName().getBaseName(), null), "entry");
}
} catch (FileSystemException fse) {
@@ -621,7 +624,7 @@ public class XMLUtilities extends AbstractUtilities {
final XMLEvent event = reader.nextEvent();
if (event.getEventType() == XMLStreamConstants.START_ELEMENT
- && elementName.equals(event.asStartElement().getName().getLocalPart())) {
+ && elementName.equals(event.asStartElement().getName().getLocalPart())) {
count++;
}
}
@@ -631,18 +634,18 @@ public class XMLUtilities extends AbstractUtilities {
}
public Map.Entry<Integer, XMLElement> extractElement(
- final XMLEventReader reader, final XMLEventWriter writer, final List<String> path,
- final int startPathPos, final int minPathPos, final int maxPathPos)
- throws Exception {
+ final XMLEventReader reader, final XMLEventWriter writer, final List<String> path,
+ final int startPathPos, final int minPathPos, final int maxPathPos)
+ throws Exception {
return extractElement(reader, writer, path, null, false, startPathPos, minPathPos, maxPathPos);
}
public Map.Entry<Integer, XMLElement> extractElement(
- final XMLEventReader reader, final XMLEventWriter writer, final List<String> path,
- final Collection<Map.Entry<String, String>> filter,
- final boolean filterInOr,
- final int startPathPos, final int minPathPos, final int maxPathPos)
- throws Exception {
+ final XMLEventReader reader, final XMLEventWriter writer, final List<String> path,
+ final Collection<Map.Entry<String, String>> filter,
+ final boolean filterInOr,
+ final int startPathPos, final int minPathPos, final int maxPathPos)
+ throws Exception {
StartElement start = null;
int searchFor = 0;
@@ -652,9 +655,9 @@ public class XMLUtilities extends AbstractUtilities {
String current = null;
// set defaults
- final List<String> pathElementNames = path == null ? Collections.<String>emptyList() : path;
+ final List<String> pathElementNames = path == null ? Collections.<String> emptyList() : path;
final Collection<Map.Entry<String, String>> filterAttrs =
- filter == null ? Collections.<Map.Entry<String, String>>emptySet() : filter;
+ filter == null ? Collections.<Map.Entry<String, String>> emptySet() : filter;
while (reader.hasNext() && start == null) {
final XMLEvent event = reader.nextEvent();
@@ -664,7 +667,7 @@ public class XMLUtilities extends AbstractUtilities {
if (current != null || ((minPathPos < 0 || minPathPos <= depth) && (maxPathPos < 0 || depth <= maxPathPos))) {
if (pathElementNames.isEmpty()
- || pathElementNames.get(searchFor).trim().equals(event.asStartElement().getName().getLocalPart())) {
+ || pathElementNames.get(searchFor).trim().equals(event.asStartElement().getName().getLocalPart())) {
if (searchFor < pathElementNames.size() - 1) {
// path exploring not completed
@@ -736,7 +739,7 @@ public class XMLUtilities extends AbstractUtilities {
try {
final XMLElement feedElement =
- extractElement(reader, writer, Collections.<String>singletonList("feed"), 0, 1, 1).getValue();
+ extractElement(reader, writer, Collections.<String> singletonList("feed"), 0, 1, 1).getValue();
writer.add(feedElement.getStart());
addAtomElement(IOUtils.toInputStream(String.format("<m:count>%d</m:count>", count), Constants.ENCODING), writer);
@@ -776,22 +779,22 @@ public class XMLUtilities extends AbstractUtilities {
while (reader.hasNext()) {
final XMLEvent event = reader.nextEvent();
if (event.getEventType() == XMLStreamConstants.START_ELEMENT
- && Constants.get(version, ConstantKey.LINK).equals(event.asStartElement().getName().getLocalPart())
- && !fieldToBeSaved.contains(
+ && Constants.get(version, ConstantKey.LINK).equals(event.asStartElement().getName().getLocalPart())
+ && !fieldToBeSaved.contains(
event.asStartElement().getAttributeByName(new QName("title")).getValue())
- && !"edit".equals(event.asStartElement().getAttributeByName(new QName("rel")).getValue())) {
+ && !"edit".equals(event.asStartElement().getAttributeByName(new QName("rel")).getValue())) {
writeCurrent = false;
} else if (event.getEventType() == XMLStreamConstants.END_ELEMENT
- && Constants.get(version, ConstantKey.LINK).equals(event.asEndElement().getName().getLocalPart())) {
+ && Constants.get(version, ConstantKey.LINK).equals(event.asEndElement().getName().getLocalPart())) {
writeNext = true;
} else if (event.getEventType() == XMLStreamConstants.START_ELEMENT
- && (Constants.get(version, ConstantKey.PROPERTIES)).equals(
+ && (Constants.get(version, ConstantKey.PROPERTIES)).equals(
event.asStartElement().getName().getLocalPart())) {
writeCurrent = true;
writeNext = false;
inProperties = true;
} else if (event.getEventType() == XMLStreamConstants.END_ELEMENT
- && (Constants.get(version, ConstantKey.PROPERTIES)).equals(
+ && (Constants.get(version, ConstantKey.PROPERTIES)).equals(
event.asEndElement().getName().getLocalPart())) {
writeCurrent = true;
} else if (inProperties) {
@@ -807,8 +810,8 @@ public class XMLUtilities extends AbstractUtilities {
}
} else if (event.getEventType() == XMLStreamConstants.END_ELEMENT
- && StringUtils.isNotBlank(currentName)
- && (Constants.get(version, ConstantKey.ATOM_PROPERTY_PREFIX) + currentName.trim()).equals(
+ && StringUtils.isNotBlank(currentName)
+ && (Constants.get(version, ConstantKey.ATOM_PROPERTY_PREFIX) + currentName.trim()).equals(
event.asEndElement().getName().getLocalPart())) {
writeNext = false;
currentName = null;
@@ -833,15 +836,15 @@ public class XMLUtilities extends AbstractUtilities {
// Do not raise any exception in order to support FC properties as well
// if (!found.isEmpty()) {
- // throw new Exception(String.format("Could not find a properties '%s'", found));
+ // throw new Exception(String.format("Could not find a properties '%s'", found));
// }
return new ByteArrayInputStream(bos.toByteArray());
}
@Override
public InputStream readEntities(
- final List<String> links, final String linkName, final String next, final boolean forceFeed)
- throws Exception {
+ final List<String> links, final String linkName, final String next, final boolean forceFeed)
+ throws Exception {
if (links.isEmpty()) {
throw new NotFoundException();
@@ -858,13 +861,14 @@ public class XMLUtilities extends AbstractUtilities {
// build a feed
writer.write(("<feed xml:base=\"" + Constants.get(version, ConstantKey.DEFAULT_SERVICE_URL) + "\" "
- + "xmlns=\"http://www.w3.org/2005/Atom\" "
- + "xmlns:d=\"http://schemas.microsoft.com/ado/2007/08/dataservices\" "
- + "xmlns:m=\"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\">")
- .toCharArray());
+ + "xmlns=\"http://www.w3.org/2005/Atom\" "
+ + "xmlns:d=\"http://schemas.microsoft.com/ado/2007/08/dataservices\" "
+ + "xmlns:m=\"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\">")
+ .toCharArray());
- writer.write(("<id>" + Constants.get(version, ConstantKey.DEFAULT_SERVICE_URL) + "entityset(entityid)/" + linkName
- + "</id>").toCharArray());
+ writer.write(("<id>" + Constants.get(version, ConstantKey.DEFAULT_SERVICE_URL) + "entityset(entityid)/"
+ + linkName
+ + "</id>").toCharArray());
writer.write(("<title type=\"text\">" + linkName + "</title>").toCharArray());
writer.write("<updated>2014-03-03T13:40:49Z</updated>".toCharArray());
@@ -876,10 +880,10 @@ public class XMLUtilities extends AbstractUtilities {
final Map.Entry<String, String> uri = Commons.parseEntityURI(link);
final XMLElement entry =
- extractElement(
+ extractElement(
getEventReader(readEntity(uri.getKey(), uri.getValue(), Accept.ATOM).getValue()),
null,
- Collections.<String>singletonList("entry"),
+ Collections.<String> singletonList("entry"),
0, 1, 1).getValue();
IOUtils.copy(entry.toStream(), writer, encoding);
@@ -916,8 +920,8 @@ public class XMLUtilities extends AbstractUtilities {
XMLEventReader reader = getEventReader(new ByteArrayInputStream(bos.toByteArray()));
final Map.Entry<Integer, XMLElement> propertyElement =
- extractElement(reader, null,
- Collections.<String>singletonList(Constants.get(version, ConstantKey.PROPERTIES)), 0, 2, 3);
+ extractElement(reader, null,
+ Collections.<String> singletonList(Constants.get(version, ConstantKey.PROPERTIES)), 0, 2, 3);
reader.close();
reader = propertyElement.getValue().getContentReader(version);
@@ -940,12 +944,12 @@ public class XMLUtilities extends AbstractUtilities {
int pos = 0;
while (true) {
final Map.Entry<Integer, XMLElement> linkElement =
- extractElement(reader, null,
- Collections.<String>singletonList(Constants.get(version, ConstantKey.LINK)), pos, 2, 2);
+ extractElement(reader, null,
+ Collections.<String> singletonList(Constants.get(version, ConstantKey.LINK)), pos, 2, 2);
res.put("[Constants.get(version, ConstantKey.LINK)]"
- + linkElement.getValue().getStart().getAttributeByName(new QName("title")).getValue(),
- linkElement.getValue().toStream());
+ + linkElement.getValue().getStart().getAttributeByName(new QName("title")).getValue(),
+ linkElement.getValue().toStream());
pos = linkElement.getKey();
}
@@ -958,8 +962,8 @@ public class XMLUtilities extends AbstractUtilities {
@Override
protected InputStream replaceLink(
- final InputStream toBeChanged, final String linkName, final InputStream replacement)
- throws Exception {
+ final InputStream toBeChanged, final String linkName, final InputStream replacement)
+ throws Exception {
final XMLEventReader reader = getEventReader(toBeChanged);
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
@@ -970,10 +974,10 @@ public class XMLUtilities extends AbstractUtilities {
try {
final XMLElement linkElement =
- extractElement(reader, writer,
- Collections.<String>singletonList(Constants.get(version, ConstantKey.LINK)),
- Collections.<Map.Entry<String, String>>singletonList(
- new SimpleEntry<String, String>("title", linkName)), false, 0, -1, -1).getValue();
+ extractElement(reader, writer,
+ Collections.<String> singletonList(Constants.get(version, ConstantKey.LINK)),
+ Collections.<Map.Entry<String, String>> singletonList(
+ new SimpleEntry<String, String>("title", linkName)), false, 0, -1, -1).getValue();
writer.add(linkElement.getStart());
// ------------------------------------------
@@ -1003,8 +1007,8 @@ public class XMLUtilities extends AbstractUtilities {
@Override
public Map.Entry<String, List<String>> extractLinkURIs(
- final String entitySetName, final String entityId, final String linkName)
- throws Exception {
+ final String entitySetName, final String entityId, final String linkName)
+ throws Exception {
final LinkInfo links = readLinks(entitySetName, entityId, linkName, Accept.XML);
return extractLinkURIs(links.getLinks());
@@ -1012,7 +1016,7 @@ public class XMLUtilities extends AbstractUtilities {
@Override
public Map.Entry<String, List<String>> extractLinkURIs(final InputStream is)
- throws Exception {
+ throws Exception {
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
IOUtils.copy(is, bos);
IOUtils.closeQuietly(is);
@@ -1021,8 +1025,8 @@ public class XMLUtilities extends AbstractUtilities {
final List<String> links = new ArrayList<String>();
try {
while (true) {
- links.add(IOUtils.toString(extractElement(reader, null, Collections.<String>singletonList("uri"), 0, -1, -1).
- getValue().getContent()));
+ links.add(IOUtils.toString(extractElement(reader, null, Collections.<String> singletonList("uri"), 0, -1, -1).
+ getValue().getContent()));
}
} catch (Exception ignore) {
// End document reached ...
@@ -1033,8 +1037,8 @@ public class XMLUtilities extends AbstractUtilities {
reader = getEventReader(new ByteArrayInputStream(bos.toByteArray()));
try {
- next = IOUtils.toString(extractElement(reader, null, Collections.<String>singletonList("next"), 0, -1, -1).
- getValue().getContent());
+ next = IOUtils.toString(extractElement(reader, null, Collections.<String> singletonList("next"), 0, -1, -1).
+ getValue().getContent());
} catch (Exception ignore) {
// next link is not mandatory
next = null;
@@ -1046,8 +1050,8 @@ public class XMLUtilities extends AbstractUtilities {
@Override
public InputStream replaceProperty(
- final InputStream src, final InputStream replacement, final List<String> path, final boolean justValue)
- throws Exception {
+ final InputStream src, final InputStream replacement, final List<String> path, final boolean justValue)
+ throws Exception {
final List<String> pathElements = new ArrayList<String>();
@@ -1104,7 +1108,7 @@ public class XMLUtilities extends AbstractUtilities {
final XMLEventWriter writer = getEventWriter(bos);
final XMLEventReader changesReader = new XMLEventReaderWrapper(IOUtils.toInputStream(
- String.format("<%s m:null=\"true\" />", path.get(path.size() - 1)), Constants.ENCODING), version);
+ String.format("<%s m:null=\"true\" />", path.get(path.size() - 1)), Constants.ENCODING), version);
writer.add(changesReader);
changesReader.close();
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/2ab4b2fd/fit/src/test/java/org/apache/olingo/fit/AbstractBaseTestITCase.java
----------------------------------------------------------------------
diff --git a/fit/src/test/java/org/apache/olingo/fit/AbstractBaseTestITCase.java b/fit/src/test/java/org/apache/olingo/fit/AbstractBaseTestITCase.java
index f54b5b8..a5a0b93 100644
--- a/fit/src/test/java/org/apache/olingo/fit/AbstractBaseTestITCase.java
+++ b/fit/src/test/java/org/apache/olingo/fit/AbstractBaseTestITCase.java
@@ -1,18 +1,18 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
+ * 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
- *
+ * 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
+ * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/