You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by ch...@apache.org on 2013/09/20 15:33:53 UTC
[31/59] [abbrv] Cleanup of core
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/a030e42b/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/consumer/JsonServiceDocumentConsumer.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/consumer/JsonServiceDocumentConsumer.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/consumer/JsonServiceDocumentConsumer.java
index 8873a89..7c31a16 100644
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/consumer/JsonServiceDocumentConsumer.java
+++ b/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/consumer/JsonServiceDocumentConsumer.java
@@ -1,20 +1,20 @@
/*******************************************************************************
* 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
+ * 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
+ * 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.
+ * 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.
******************************************************************************/
package org.apache.olingo.odata2.core.ep.consumer;
@@ -39,7 +39,7 @@ import com.google.gson.stream.JsonReader;
/**
* Reads the OData service document (JSON).
- *
+ *
*/
public class JsonServiceDocumentConsumer {
private static final String DEFAULT_CHARSET = "UTF-8";
@@ -63,11 +63,14 @@ public class JsonServiceDocumentConsumer {
reader.peek();
reader.close();
} catch (final IOException e) {
- throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass().getSimpleName()), e);
+ throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
+ .getSimpleName()), e);
} catch (final IllegalStateException e) {
- throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass().getSimpleName()), e);
+ throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
+ .getSimpleName()), e);
} catch (final EdmException e) {
- throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass().getSimpleName()), e);
+ throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
+ .getSimpleName()), e);
}
return new ServiceDocumentImpl().setEntitySetsInfo(entitySets);
}
@@ -104,13 +107,15 @@ public class JsonServiceDocumentConsumer {
private JsonReader createJsonReader(final InputStream in) throws EntityProviderException {
if (in == null) {
- throw new EntityProviderException(EntityProviderException.INVALID_STATE.addContent(("Got not supported NULL object as content to de-serialize.")));
+ throw new EntityProviderException(EntityProviderException.INVALID_STATE
+ .addContent(("Got not supported NULL object as content to de-serialize.")));
}
InputStreamReader isReader;
try {
isReader = new InputStreamReader(in, DEFAULT_CHARSET);
} catch (final UnsupportedEncodingException e) {
- throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass().getSimpleName()), e);
+ throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
+ .getSimpleName()), e);
}
return new JsonReader(isReader);
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/a030e42b/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/consumer/XmlEntityConsumer.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/consumer/XmlEntityConsumer.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/consumer/XmlEntityConsumer.java
index d065d4d..6559b9d 100644
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/consumer/XmlEntityConsumer.java
+++ b/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/consumer/XmlEntityConsumer.java
@@ -1,20 +1,20 @@
/*******************************************************************************
* 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
+ * 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
+ * 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.
+ * 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.
******************************************************************************/
package org.apache.olingo.odata2.core.ep.consumer;
@@ -40,7 +40,7 @@ import org.apache.olingo.odata2.core.ep.aggregator.EntityInfoAggregator;
/**
* Xml entity (content type dependent) consumer for reading input (from <code>content</code>).
*
- *
+ *
*/
public class XmlEntityConsumer {
@@ -51,7 +51,8 @@ public class XmlEntityConsumer {
super();
}
- public ODataFeed readFeed(final EdmEntitySet entitySet, final InputStream content, final EntityProviderReadProperties properties) throws EntityProviderException {
+ public ODataFeed readFeed(final EdmEntitySet entitySet, final InputStream content,
+ final EntityProviderReadProperties properties) throws EntityProviderException {
XMLStreamReader reader = null;
EntityProviderException cachedException = null;
@@ -65,7 +66,9 @@ public class XmlEntityConsumer {
cachedException = e;
throw cachedException;
} catch (XMLStreamException e) {
- cachedException = new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass().getSimpleName()), e);
+ cachedException =
+ new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
+ .getSimpleName()), e);
throw cachedException;
} finally {// NOPMD (suppress DoNotThrowExceptionInFinally)
if (reader != null) {
@@ -75,14 +78,16 @@ public class XmlEntityConsumer {
if (cachedException != null) {
throw cachedException;
} else {
- throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass().getSimpleName()), e);
+ throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
+ .getSimpleName()), e);
}
}
}
}
}
- public ODataEntry readEntry(final EdmEntitySet entitySet, final InputStream content, final EntityProviderReadProperties properties) throws EntityProviderException {
+ public ODataEntry readEntry(final EdmEntitySet entitySet, final InputStream content,
+ final EntityProviderReadProperties properties) throws EntityProviderException {
XMLStreamReader reader = null;
EntityProviderException cachedException = null;
@@ -95,7 +100,9 @@ public class XmlEntityConsumer {
cachedException = e;
throw cachedException;
} catch (XMLStreamException e) {
- cachedException = new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass().getSimpleName()), e);
+ cachedException =
+ new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
+ .getSimpleName()), e);
throw cachedException;
} finally {// NOPMD (suppress DoNotThrowExceptionInFinally)
if (reader != null) {
@@ -105,24 +112,29 @@ public class XmlEntityConsumer {
if (cachedException != null) {
throw cachedException;
} else {
- throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass().getSimpleName()), e);
+ throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
+ .getSimpleName()), e);
}
}
}
}
}
- public Map<String, Object> readProperty(final EdmProperty edmProperty, final InputStream content, final EntityProviderReadProperties properties) throws EntityProviderException {
+ public Map<String, Object> readProperty(final EdmProperty edmProperty, final InputStream content,
+ final EntityProviderReadProperties properties) throws EntityProviderException {
XMLStreamReader reader = null;
EntityProviderException cachedException = null;
XmlPropertyConsumer xec = new XmlPropertyConsumer();
try {
reader = createStaxReader(content);
- Map<String, Object> result = xec.readProperty(reader, edmProperty, properties.getMergeSemantic(), properties.getTypeMappings());
+ Map<String, Object> result =
+ xec.readProperty(reader, edmProperty, properties.getMergeSemantic(), properties.getTypeMappings());
return result;
} catch (XMLStreamException e) {
- cachedException = new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass().getSimpleName()), e);
+ cachedException =
+ new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
+ .getSimpleName()), e);
throw cachedException;
} finally {// NOPMD (suppress DoNotThrowExceptionInFinally)
if (reader != null) {
@@ -132,18 +144,21 @@ public class XmlEntityConsumer {
if (cachedException != null) {
throw cachedException;
} else {
- throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass().getSimpleName()), e);
+ throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
+ .getSimpleName()), e);
}
}
}
}
}
- public Object readPropertyValue(final EdmProperty edmProperty, final InputStream content) throws EntityProviderException {
+ public Object readPropertyValue(final EdmProperty edmProperty, final InputStream content)
+ throws EntityProviderException {
return readPropertyValue(edmProperty, content, null);
}
- public Object readPropertyValue(final EdmProperty edmProperty, final InputStream content, final Class<?> typeMapping) throws EntityProviderException {
+ public Object readPropertyValue(final EdmProperty edmProperty, final InputStream content, final Class<?> typeMapping)
+ throws EntityProviderException {
try {
final Map<String, Object> result;
EntityProviderReadPropertiesBuilder propertiesBuilder = EntityProviderReadProperties.init().mergeSemantic(false);
@@ -156,7 +171,8 @@ public class XmlEntityConsumer {
}
return result.get(edmProperty.getName());
} catch (EdmException e) {
- throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass().getSimpleName()), e);
+ throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
+ .getSimpleName()), e);
}
}
@@ -169,7 +185,9 @@ public class XmlEntityConsumer {
reader = createStaxReader(content);
return xlc.readLink(reader, entitySet);
} catch (XMLStreamException e) {
- cachedException = new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass().getSimpleName()), e);
+ cachedException =
+ new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
+ .getSimpleName()), e);
throw cachedException;
} finally {// NOPMD (suppress DoNotThrowExceptionInFinally)
if (reader != null) {
@@ -179,7 +197,8 @@ public class XmlEntityConsumer {
if (cachedException != null) {
throw cachedException;
} else {
- throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass().getSimpleName()), e);
+ throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
+ .getSimpleName()), e);
}
}
}
@@ -195,7 +214,9 @@ public class XmlEntityConsumer {
reader = createStaxReader(content);
return xlc.readLinks(reader, entitySet);
} catch (XMLStreamException e) {
- cachedException = new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass().getSimpleName()), e);
+ cachedException =
+ new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
+ .getSimpleName()), e);
throw cachedException;
} finally {// NOPMD (suppress DoNotThrowExceptionInFinally)
if (reader != null) {
@@ -205,7 +226,8 @@ public class XmlEntityConsumer {
if (cachedException != null) {
throw cachedException;
} else {
- throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass().getSimpleName()), e);
+ throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
+ .getSimpleName()), e);
}
}
}
@@ -224,10 +246,12 @@ public class XmlEntityConsumer {
if (content instanceof InputStream) {
XMLStreamReader streamReader = factory.createXMLStreamReader((InputStream) content, DEFAULT_CHARSET);
- // verify charset encoding set in content is supported (if not set UTF-8 is used as defined in 'http://www.w3.org/TR/2008/REC-xml-20081126/')
+ // verify charset encoding set in content is supported (if not set UTF-8 is used as defined in
+ // 'http://www.w3.org/TR/2008/REC-xml-20081126/')
String characterEncodingInContent = streamReader.getCharacterEncodingScheme();
if (characterEncodingInContent != null && !DEFAULT_CHARSET.equalsIgnoreCase(characterEncodingInContent)) {
- throw new EntityProviderException(EntityProviderException.UNSUPPORTED_CHARACTER_ENCODING.addContent(characterEncodingInContent));
+ throw new EntityProviderException(EntityProviderException.UNSUPPORTED_CHARACTER_ENCODING
+ .addContent(characterEncodingInContent));
}
return streamReader;
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/a030e42b/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/consumer/XmlEntryConsumer.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/consumer/XmlEntryConsumer.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/consumer/XmlEntryConsumer.java
index 4d2775e..47d4eef 100644
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/consumer/XmlEntryConsumer.java
+++ b/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/consumer/XmlEntryConsumer.java
@@ -1,20 +1,20 @@
/*******************************************************************************
* 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
+ * 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
+ * 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.
+ * 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.
******************************************************************************/
package org.apache.olingo.odata2.core.ep.consumer;
@@ -59,9 +59,10 @@ import org.apache.olingo.odata2.core.uri.ExpandSelectTreeNodeImpl;
/**
* Atom/XML format reader/consumer for entries.
*
- * {@link XmlEntryConsumer} instance can be reused for several {@link #readEntry(XMLStreamReader, EntityInfoAggregator, EntityProviderReadProperties)} calls
+ * {@link XmlEntryConsumer} instance can be reused for several
+ * {@link #readEntry(XMLStreamReader, EntityInfoAggregator, EntityProviderReadProperties)} calls
* but be aware that the instance and their <code>readEntry*</code> methods are <b>NOT THREAD SAFE</b>.
- *
+ *
*/
public class XmlEntryConsumer {
@@ -73,7 +74,8 @@ public class XmlEntryConsumer {
private EntityTypeMapping typeMappings;
private String currentHandledStartTagName;
- public ODataEntry readEntry(final XMLStreamReader reader, final EntityInfoAggregator eia, final EntityProviderReadProperties readProperties) throws EntityProviderException {
+ public ODataEntry readEntry(final XMLStreamReader reader, final EntityInfoAggregator eia,
+ final EntityProviderReadProperties readProperties) throws EntityProviderException {
try {
initialize(readProperties);
@@ -86,9 +88,11 @@ public class XmlEntryConsumer {
return readEntryResult;
} catch (XMLStreamException e) {
- throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass().getSimpleName()), e);
+ throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
+ .getSimpleName()), e);
} catch (EdmException e) {
- throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass().getSimpleName()), e);
+ throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
+ .getSimpleName()), e);
}
}
@@ -113,7 +117,8 @@ public class XmlEntryConsumer {
typeMappings = EntityTypeMapping.create(readProperties.getTypeMappings());
}
- private void handleStartedTag(final XMLStreamReader reader, final EntityInfoAggregator eia, final EntityProviderReadProperties readProperties)
+ private void handleStartedTag(final XMLStreamReader reader, final EntityInfoAggregator eia,
+ final EntityProviderReadProperties readProperties)
throws EntityProviderException, XMLStreamException, EdmException {
currentHandledStartTagName = reader.getLocalName();
@@ -135,7 +140,8 @@ public class XmlEntryConsumer {
}
}
- private void readCustomElement(final XMLStreamReader reader, final String tagName, final EntityInfoAggregator eia) throws EdmException, EntityProviderException, XMLStreamException {
+ private void readCustomElement(final XMLStreamReader reader, final String tagName, final EntityInfoAggregator eia)
+ throws EdmException, EntityProviderException, XMLStreamException {
EntityPropertyInfo targetPathInfo = eia.getTargetPathInfo(tagName);
NamespaceContext nsctx = reader.getNamespaceContext();
@@ -212,7 +218,9 @@ public class XmlEntryConsumer {
* @throws XMLStreamException
* @throws EdmException
*/
- private void readLink(final XMLStreamReader reader, final EntityInfoAggregator eia, final EntityProviderReadProperties readProperties) throws EntityProviderException, XMLStreamException, EdmException {
+ private void readLink(final XMLStreamReader reader, final EntityInfoAggregator eia,
+ final EntityProviderReadProperties readProperties) throws EntityProviderException, XMLStreamException,
+ EdmException {
reader.require(XMLStreamConstants.START_ELEMENT, Edm.NAMESPACE_ATOM_2005, FormatXml.ATOM_LINK);
final String rel = reader.getAttributeValue(null, FormatXml.ATOM_REL);
@@ -255,14 +263,16 @@ public class XmlEntryConsumer {
* @throws EntityProviderException
* @throws EdmException
*/
- private void readInlineContent(final XMLStreamReader reader, final EntityInfoAggregator eia, final EntityProviderReadProperties readProperties,
+ private void readInlineContent(final XMLStreamReader reader, final EntityInfoAggregator eia,
+ final EntityProviderReadProperties readProperties,
final String atomLinkType, final String atomLinkRel)
throws XMLStreamException, EntityProviderException, EdmException {
//
String navigationPropertyName = atomLinkRel.substring(Edm.NAMESPACE_REL_2007_08.length());
- EdmNavigationProperty navigationProperty = (EdmNavigationProperty) eia.getEntityType().getProperty(navigationPropertyName);
+ EdmNavigationProperty navigationProperty =
+ (EdmNavigationProperty) eia.getEntityType().getProperty(navigationPropertyName);
EdmEntitySet entitySet = eia.getEntitySet().getRelatedEntitySet(navigationProperty);
EntityInfoAggregator inlineEia = EntityInfoAggregator.create(entitySet);
@@ -273,9 +283,11 @@ public class XmlEntryConsumer {
List<ODataEntry> inlineEntries = new ArrayList<ODataEntry>();
- while (!(reader.isEndElement() && Edm.NAMESPACE_M_2007_08.equals(reader.getNamespaceURI()) && FormatXml.M_INLINE.equals(reader.getLocalName()))) {
+ while (!(reader.isEndElement() && Edm.NAMESPACE_M_2007_08.equals(reader.getNamespaceURI()) && FormatXml.M_INLINE
+ .equals(reader.getLocalName()))) {
- if (reader.isStartElement() && Edm.NAMESPACE_ATOM_2005.equals(reader.getNamespaceURI()) && FormatXml.ATOM_ENTRY.equals(reader.getLocalName())) {
+ if (reader.isStartElement() && Edm.NAMESPACE_ATOM_2005.equals(reader.getNamespaceURI())
+ && FormatXml.ATOM_ENTRY.equals(reader.getLocalName())) {
XmlEntryConsumer xec = new XmlEntryConsumer();
ODataEntry inlineEntry = xec.readEntry(reader, inlineEia, inlineProperties);
inlineEntries.add(inlineEntry);
@@ -298,10 +310,12 @@ public class XmlEntryConsumer {
* @param navigationProperty
* @param isFeed
* @param inlineEntries
- * @throws EntityProviderException
+ * @throws EntityProviderException
*/
- private void updateReadProperties(final EntityProviderReadProperties readProperties, final String navigationPropertyName,
- final EdmNavigationProperty navigationProperty, final boolean isFeed, final List<ODataEntry> inlineEntries) throws EntityProviderException {
+ private void updateReadProperties(final EntityProviderReadProperties readProperties,
+ final String navigationPropertyName,
+ final EdmNavigationProperty navigationProperty, final boolean isFeed, final List<ODataEntry> inlineEntries)
+ throws EntityProviderException {
Object entry = extractODataEntity(isFeed, inlineEntries);
OnReadInlineContent callback = readProperties.getCallback();
if (callback == null) {
@@ -313,13 +327,15 @@ public class XmlEntryConsumer {
}
/**
- * Updates the expand select tree ({@link #expandSelectTree}) for this {@link ReadEntryResult} ({@link #readEntryResult}).
+ * Updates the expand select tree ({@link #expandSelectTree}) for this {@link ReadEntryResult} (
+ * {@link #readEntryResult}).
*
* @param navigationPropertyName
* @param inlineEntries
- * @throws EntityProviderException
+ * @throws EntityProviderException
*/
- private void updateExpandSelectTree(final String navigationPropertyName, final List<ODataEntry> inlineEntries) throws EntityProviderException {
+ private void updateExpandSelectTree(final String navigationPropertyName, final List<ODataEntry> inlineEntries)
+ throws EntityProviderException {
expandSelectTree.setExpanded();
ExpandSelectTreeNodeImpl subNode = getExpandSelectTreeNode(inlineEntries);
expandSelectTree.putLink(navigationPropertyName, subNode);
@@ -330,10 +346,12 @@ public class XmlEntryConsumer {
* {@link ExpandSelectTreeNodeImpl}.
*
* @param inlineEntries entries which are checked for existing {@link ExpandSelectTreeNodeImpl}
- * @return {@link ExpandSelectTreeNodeImpl} from the <code>inlineEntries</code> or if none exists create a new {@link ExpandSelectTreeNodeImpl}.
+ * @return {@link ExpandSelectTreeNodeImpl} from the <code>inlineEntries</code> or if none exists create a new
+ * {@link ExpandSelectTreeNodeImpl}.
* @throws EntityProviderException if an unsupported {@link ExpandSelectTreeNode} implementation was found.
*/
- private ExpandSelectTreeNodeImpl getExpandSelectTreeNode(final List<ODataEntry> inlineEntries) throws EntityProviderException {
+ private ExpandSelectTreeNodeImpl getExpandSelectTreeNode(final List<ODataEntry> inlineEntries)
+ throws EntityProviderException {
if (inlineEntries.isEmpty()) {
return new ExpandSelectTreeNodeImpl();
} else {
@@ -348,7 +366,7 @@ public class XmlEntryConsumer {
}
/**
- * Get a list of {@link ODataEntry}, an empty list, a single {@link ODataEntry} or <code>NULL</code> based on
+ * Get a list of {@link ODataEntry}, an empty list, a single {@link ODataEntry} or <code>NULL</code> based on
* <code>isFeed</code> value and <code>inlineEntries</code> content.
*
* @param isFeed
@@ -357,7 +375,7 @@ public class XmlEntryConsumer {
*/
private Object extractODataEntity(final boolean isFeed, final List<ODataEntry> inlineEntries) {
if (isFeed) {
- //TODO: fill metadata correctly with inline count and inline next link. Both are currently ignored.
+ // TODO: fill metadata correctly with inline count and inline next link. Both are currently ignored.
return new ODataFeedImpl(inlineEntries, new FeedMetadataImpl());
} else if (!inlineEntries.isEmpty()) {
return inlineEntries.get(0);
@@ -375,7 +393,8 @@ public class XmlEntryConsumer {
* @param entry
* @throws EntityProviderException
*/
- private void doCallback(final EntityProviderReadProperties readProperties, final EdmNavigationProperty navigationProperty,
+ private void doCallback(final EntityProviderReadProperties readProperties,
+ final EdmNavigationProperty navigationProperty,
final OnReadInlineContent callback, final boolean isFeed, final Object content) throws EntityProviderException {
try {
@@ -387,20 +406,23 @@ public class XmlEntryConsumer {
callback.handleReadEntry(callbackInfo);
}
} catch (ODataApplicationException e) {
- throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass().getSimpleName()), e);
+ throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
+ .getSimpleName()), e);
}
}
/**
- * Create {@link EntityProviderReadProperties} which can be used for reading of inline properties/entrys of navigation links within
+ * Create {@link EntityProviderReadProperties} which can be used for reading of inline properties/entrys of navigation
+ * links within
* this current read entry.
*
* @param readProperties
* @param navigationProperty
* @return
- * @throws EntityProviderException
+ * @throws EntityProviderException
*/
- private EntityProviderReadProperties createInlineProperties(final EntityProviderReadProperties readProperties, final EdmNavigationProperty navigationProperty) throws EntityProviderException {
+ private EntityProviderReadProperties createInlineProperties(final EntityProviderReadProperties readProperties,
+ final EdmNavigationProperty navigationProperty) throws EntityProviderException {
final OnReadInlineContent callback = readProperties.getCallback();
EntityProviderReadProperties currentReadProperties = EntityProviderReadProperties.initFrom(readProperties).build();
@@ -410,7 +432,8 @@ public class XmlEntryConsumer {
try {
return callback.receiveReadProperties(currentReadProperties, navigationProperty);
} catch (ODataApplicationException e) {
- throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass().getSimpleName()), e);
+ throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
+ .getSimpleName()), e);
}
}
}
@@ -419,30 +442,34 @@ public class XmlEntryConsumer {
* <p>
* Inline content was found and {@link XMLStreamReader} already points to <code><m:inline> tag</code>.
* <br/>
- * <b>ATTENTION</b>: If {@link XMLStreamReader} does not point to the <code><m:inline> tag</code> an exception is thrown.
+ * <b>ATTENTION</b>: If {@link XMLStreamReader} does not point to the <code><m:inline> tag</code> an exception is
+ * thrown.
* </p>
* <p>
* Check whether it is an inline <code>Feed</code> or <code>Entry</code> and validate that...
* <ul>
* <li>...{@link FormatXml#M_INLINE} tag is correctly set.</li>
* <li>...based on {@link EdmMultiplicity} of {@link EdmNavigationProperty} all tags are correctly set.</li>
- * <li>...{@link FormatXml#ATOM_TYPE} tag is correctly set and according to {@link FormatXml#ATOM_ENTRY} or {@link FormatXml#ATOM_FEED} to following tags are available.</li>
+ * <li>...{@link FormatXml#ATOM_TYPE} tag is correctly set and according to {@link FormatXml#ATOM_ENTRY} or
+ * {@link FormatXml#ATOM_FEED} to following tags are available.</li>
* </ul>
*
* For the case that one of above validations fail an {@link EntityProviderException} is thrown.
- * If validation was successful <code>true</code> is returned for <code>Feed</code> and <code>false</code> for <code>Entry</code>
+ * If validation was successful <code>true</code> is returned for <code>Feed</code> and <code>false</code> for
+ * <code>Entry</code>
* multiplicity.
* </p>
*
* @param reader xml content reader which already points to <code><m:inline> tag</code>
- * @param eia all necessary information about the entity
+ * @param eia all necessary information about the entity
* @param type the atom type attribute value of the <code>link</code> tag
* @param navigationPropertyName the navigation property name of the entity
* @return <code>true</code> for <code>Feed</code> and <code>false</code> for <code>Entry</code>
* @throws EntityProviderException is thrown if at least one validation fails.
* @throws EdmException if edm access fails
*/
- private boolean isInlineFeedValidated(final XMLStreamReader reader, final EntityInfoAggregator eia, final String type, final String navigationPropertyName) throws EntityProviderException, EdmException {
+ private boolean isInlineFeedValidated(final XMLStreamReader reader, final EntityInfoAggregator eia,
+ final String type, final String navigationPropertyName) throws EntityProviderException, EdmException {
boolean isFeed = false;
try {
reader.require(XMLStreamConstants.START_ELEMENT, Edm.NAMESPACE_M_2007_08, FormatXml.M_INLINE);
@@ -452,7 +479,8 @@ public class XmlEntryConsumer {
throw new EntityProviderException(EntityProviderException.INVALID_INLINE_CONTENT.addContent("xml data"));
}
- EdmNavigationProperty navigationProperty = (EdmNavigationProperty) eia.getEntityType().getProperty(navigationPropertyName);
+ EdmNavigationProperty navigationProperty =
+ (EdmNavigationProperty) eia.getEntityType().getProperty(navigationPropertyName);
EdmMultiplicity navigationMultiplicity = navigationProperty.getMultiplicity();
switch (navigationMultiplicity) {
@@ -471,7 +499,8 @@ public class XmlEntryConsumer {
return isFeed;
}
- private void validateEntryTags(final XMLStreamReader reader, final ContentType cType) throws XMLStreamException, EntityProviderException {
+ private void validateEntryTags(final XMLStreamReader reader, final ContentType cType) throws XMLStreamException,
+ EntityProviderException {
if (FormatXml.ATOM_ENTRY.equals(cType.getParameters().get(FormatXml.ATOM_TYPE))) {
int next = reader.nextTag();
if (XMLStreamConstants.START_ELEMENT == next) {
@@ -484,7 +513,8 @@ public class XmlEntryConsumer {
}
}
- private void validateFeedTags(final XMLStreamReader reader, final ContentType cType) throws XMLStreamException, EntityProviderException {
+ private void validateFeedTags(final XMLStreamReader reader, final ContentType cType) throws XMLStreamException,
+ EntityProviderException {
if (FormatXml.ATOM_FEED.equals(cType.getParameters().get(FormatXml.ATOM_TYPE))) {
int next = reader.nextTag();
if (XMLStreamConstants.START_ELEMENT == next) {
@@ -497,7 +527,8 @@ public class XmlEntryConsumer {
}
}
- private void readContent(final XMLStreamReader reader, final EntityInfoAggregator eia) throws EntityProviderException, XMLStreamException, EdmException {
+ private void readContent(final XMLStreamReader reader, final EntityInfoAggregator eia)
+ throws EntityProviderException, XMLStreamException, EdmException {
reader.require(XMLStreamConstants.START_ELEMENT, Edm.NAMESPACE_ATOM_2005, FormatXml.ATOM_CONTENT);
final String contentType = reader.getAttributeValue(null, FormatXml.ATOM_TYPE);
@@ -511,7 +542,8 @@ public class XmlEntryConsumer {
reader.require(XMLStreamConstants.END_ELEMENT, Edm.NAMESPACE_ATOM_2005, FormatXml.ATOM_CONTENT);
} else {
throw new EntityProviderException(EntityProviderException.INVALID_STATE
- .addContent("Expected closing 'content' or starting 'properties' but found '" + reader.getLocalName() + "'."));
+ .addContent("Expected closing 'content' or starting 'properties' but found '"
+ + reader.getLocalName() + "'."));
}
mediaMetadata.setContentType(contentType);
@@ -528,7 +560,8 @@ public class XmlEntryConsumer {
reader.require(XMLStreamConstants.END_ELEMENT, Edm.NAMESPACE_ATOM_2005, FormatXml.ATOM_ID);
}
- private void readProperties(final XMLStreamReader reader, final EntityInfoAggregator entitySet) throws XMLStreamException, EdmException, EntityProviderException {
+ private void readProperties(final XMLStreamReader reader, final EntityInfoAggregator entitySet)
+ throws XMLStreamException, EdmException, EntityProviderException {
// validate namespace
reader.require(XMLStreamConstants.START_ELEMENT, Edm.NAMESPACE_M_2007_08, FormatXml.M_PROPERTIES);
if (entitySet.getEntityType().hasStream()) {
@@ -561,7 +594,8 @@ public class XmlEntryConsumer {
} else if (reader.isEndElement()) {
if (reader.getLocalName().equals(closeTag)) {
closeTag = null;
- } else if (Edm.NAMESPACE_M_2007_08.equals(reader.getNamespaceURI()) && FormatXml.M_PROPERTIES.equals(reader.getLocalName())) {
+ } else if (Edm.NAMESPACE_M_2007_08.equals(reader.getNamespaceURI())
+ && FormatXml.M_PROPERTIES.equals(reader.getLocalName())) {
run = false;
}
}
@@ -571,28 +605,33 @@ public class XmlEntryConsumer {
/**
* Check if the {@link #currentHandledStartTagName} is the same as the <code>expectedTagName</code>.
- * If tag name is not as expected or if {@link #currentHandledStartTagName} is not set an {@link EntityProviderException} is thrown.
+ * If tag name is not as expected or if {@link #currentHandledStartTagName} is not set an
+ * {@link EntityProviderException} is thrown.
*
* @param expectedTagName expected name for {@link #currentHandledStartTagName}
- * @throws EntityProviderException if tag name is not as expected or if {@link #currentHandledStartTagName} is <code>NULL</code>.
+ * @throws EntityProviderException if tag name is not as expected or if {@link #currentHandledStartTagName} is
+ * <code>NULL</code>.
*/
private void checkCurrentHandledStartTag(final String expectedTagName) throws EntityProviderException {
if (currentHandledStartTagName == null) {
- throw new EntityProviderException(EntityProviderException.INVALID_STATE.addContent("No current handled start tag name set."));
+ throw new EntityProviderException(EntityProviderException.INVALID_STATE
+ .addContent("No current handled start tag name set."));
} else if (!currentHandledStartTagName.equals(expectedTagName)) {
- throw new EntityProviderException(EntityProviderException.INVALID_PARENT_TAG.addContent(expectedTagName).addContent(currentHandledStartTagName));
+ throw new EntityProviderException(EntityProviderException.INVALID_PARENT_TAG.addContent(expectedTagName)
+ .addContent(currentHandledStartTagName));
}
}
/**
- * Checks if property of currently read tag in {@link XMLStreamReader} is defined in
+ * Checks if property of currently read tag in {@link XMLStreamReader} is defined in
* <code>edm properties namespace</code> {@value Edm#NAMESPACE_D_2007_08}.
*
* If no namespace uri definition is found for namespace prefix of property (<code>tag</code>) an exception is thrown.
*
* @param reader {@link XMLStreamReader} with position at to checked tag
* @return <code>true</code> if property is in <code>edm properties namespace</code>, otherwise <code>false</code>.
- * @throws EntityProviderException If no namespace uri definition is found for namespace prefix of property (<code>tag</code>).
+ * @throws EntityProviderException If no namespace uri definition is found for namespace prefix of property
+ * (<code>tag</code>).
*/
private boolean isEdmNamespaceProperty(final XMLStreamReader reader) throws EntityProviderException {
final String nsUri = reader.getNamespaceURI();
@@ -614,7 +653,8 @@ public class XmlEntryConsumer {
* @return valid {@link EntityPropertyInfo} (which is never <code>NULL</code>).
* @throws EntityProviderException
*/
- private EntityPropertyInfo getValidatedPropertyInfo(final EntityInfoAggregator entitySet, final String name) throws EntityProviderException {
+ private EntityPropertyInfo getValidatedPropertyInfo(final EntityInfoAggregator entitySet, final String name)
+ throws EntityProviderException {
EntityPropertyInfo info = entitySet.getPropertyInfo(name);
if (info == null) {
throw new EntityProviderException(EntityProviderException.INVALID_PROPERTY.addContent(name));
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/a030e42b/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/consumer/XmlFeedConsumer.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/consumer/XmlFeedConsumer.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/consumer/XmlFeedConsumer.java
index b0e2f80..d0df839 100644
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/consumer/XmlFeedConsumer.java
+++ b/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/consumer/XmlFeedConsumer.java
@@ -1,20 +1,20 @@
/*******************************************************************************
* 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
+ * 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
+ * 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.
+ * 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.
******************************************************************************/
package org.apache.olingo.odata2.core.ep.consumer;
@@ -40,10 +40,11 @@ import org.apache.olingo.odata2.core.ep.util.FormatXml;
/**
* Atom/XML format reader/consumer for feeds.
*
- * {@link XmlFeedConsumer} instance use {@link XmlEntryConsumer#readEntry(XMLStreamReader, EntityInfoAggregator, EntityProviderReadProperties)}
- * for read/consume of several entries.
+ * {@link XmlFeedConsumer} instance use
+ * {@link XmlEntryConsumer#readEntry(XMLStreamReader, EntityInfoAggregator, EntityProviderReadProperties)} for
+ * read/consume of several entries.
+ *
*
- *
*/
public class XmlFeedConsumer {
@@ -55,7 +56,8 @@ public class XmlFeedConsumer {
* @return {@link ODataFeed} object
* @throws EntityProviderException
*/
- public ODataFeed readFeed(final XMLStreamReader reader, final EntityInfoAggregator eia, final EntityProviderReadProperties readProperties) throws EntityProviderException {
+ public ODataFeed readFeed(final XMLStreamReader reader, final EntityInfoAggregator eia,
+ final EntityProviderReadProperties readProperties) throws EntityProviderException {
try {
// read xml tag
reader.require(XMLStreamConstants.START_DOCUMENT, null, null);
@@ -72,21 +74,25 @@ public class XmlFeedConsumer {
// read feed data (metadata and entries)
return readFeedData(reader, eia, entryReadProperties);
} catch (XMLStreamException e) {
- throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass().getSimpleName()), e);
+ throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
+ .getSimpleName()), e);
}
}
/**
- * Read all feed specific data (like <code>inline count</code> and <code>next link</code>) as well as all feed entries (<code>entry</code>).
+ * Read all feed specific data (like <code>inline count</code> and <code>next link</code>) as well as all feed entries
+ * (<code>entry</code>).
*
* @param reader xml stream reader with xml content to be read
* @param eia entity infos for validation and mapping
* @param entryReadProperties properties which are used for read of feed.
- * @return all feed specific data (like <code>inline count</code> and <code>next link</code>) as well as all feed entries (<code>entry</code>).
+ * @return all feed specific data (like <code>inline count</code> and <code>next link</code>) as well as all feed
+ * entries (<code>entry</code>).
* @throws XMLStreamException if malformed xml is read in stream
* @throws EntityProviderException if xml contains invalid data (based on odata specification and edm definition)
*/
- private ODataFeed readFeedData(final XMLStreamReader reader, final EntityInfoAggregator eia, final EntityProviderReadProperties entryReadProperties) throws XMLStreamException, EntityProviderException {
+ private ODataFeed readFeedData(final XMLStreamReader reader, final EntityInfoAggregator eia,
+ final EntityProviderReadProperties entryReadProperties) throws XMLStreamException, EntityProviderException {
FeedMetadataImpl metadata = new FeedMetadataImpl();
XmlEntryConsumer xec = new XmlEntryConsumer();
List<ODataEntry> results = new ArrayList<ODataEntry>();
@@ -106,7 +112,8 @@ public class XmlFeedConsumer {
if (inlineCountNumber >= 0) {
metadata.setInlineCount(inlineCountNumber);
} else {
- throw new EntityProviderException(EntityProviderException.INLINECOUNT_INVALID.addContent(inlineCountNumber));
+ throw new EntityProviderException(EntityProviderException.INLINECOUNT_INVALID
+ .addContent(inlineCountNumber));
}
} catch (NumberFormatException e) {
throw new EntityProviderException(EntityProviderException.INLINECOUNT_INVALID.addContent(""), e);
@@ -166,10 +173,11 @@ public class XmlFeedConsumer {
/**
*
- * @param foundPrefix2NamespaceUri
+ * @param foundPrefix2NamespaceUri
* @throws EntityProviderException
*/
- private void checkAllMandatoryNamespacesAvailable(final Map<String, String> foundPrefix2NamespaceUri) throws EntityProviderException {
+ private void checkAllMandatoryNamespacesAvailable(final Map<String, String> foundPrefix2NamespaceUri)
+ throws EntityProviderException {
if (!foundPrefix2NamespaceUri.containsValue(Edm.NAMESPACE_D_2007_08)) {
throw new EntityProviderException(EntityProviderException.INVALID_NAMESPACE.addContent(Edm.NAMESPACE_D_2007_08));
} else if (!foundPrefix2NamespaceUri.containsValue(Edm.NAMESPACE_M_2007_08)) {
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/a030e42b/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/consumer/XmlLinkConsumer.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/consumer/XmlLinkConsumer.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/consumer/XmlLinkConsumer.java
index 72c69ef..9536c62 100644
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/consumer/XmlLinkConsumer.java
+++ b/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/consumer/XmlLinkConsumer.java
@@ -1,20 +1,20 @@
/*******************************************************************************
* 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
+ * 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
+ * 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.
+ * 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.
******************************************************************************/
package org.apache.olingo.odata2.core.ep.consumer;
@@ -47,7 +47,8 @@ public class XmlLinkConsumer {
reader.next();
return readLink(reader);
} catch (final XMLStreamException e) {
- throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass().getSimpleName()), e);
+ throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
+ .getSimpleName()), e);
}
}
@@ -55,7 +56,8 @@ public class XmlLinkConsumer {
return readTag(reader, Edm.NAMESPACE_D_2007_08, FormatXml.D_URI);
}
- private String readTag(final XMLStreamReader reader, final String namespaceURI, final String localName) throws XMLStreamException {
+ private String readTag(final XMLStreamReader reader, final String namespaceURI, final String localName)
+ throws XMLStreamException {
reader.require(XMLStreamConstants.START_ELEMENT, namespaceURI, localName);
reader.next();
@@ -69,22 +71,21 @@ public class XmlLinkConsumer {
}
/**
- * Reads multiple links with format
- * <pre>
- * {@code
+ * Reads multiple links with format
+ * <pre> {@code
* <links>
* <uri>http://somelink</uri>
* <uri>http://anotherLink</uri>
* <uri>http://somelink/yetAnotherLink</uri>
* </links>
- * }
- * </pre>
+ * } </pre>
* @param reader
* @param entitySet
* @return list of string based links
* @throws EntityProviderException
*/
- public List<String> readLinks(final XMLStreamReader reader, final EdmEntitySet entitySet) throws EntityProviderException {
+ public List<String> readLinks(final XMLStreamReader reader, final EdmEntitySet entitySet)
+ throws EntityProviderException {
try {
List<String> links = new ArrayList<String>();
@@ -106,7 +107,8 @@ public class XmlLinkConsumer {
return links;
} catch (final XMLStreamException e) {
- throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass().getSimpleName()), e);
+ throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
+ .getSimpleName()), e);
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/a030e42b/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/consumer/XmlMetadataConsumer.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/consumer/XmlMetadataConsumer.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/consumer/XmlMetadataConsumer.java
index 2bd649c..8ecd4d4 100644
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/consumer/XmlMetadataConsumer.java
+++ b/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/consumer/XmlMetadataConsumer.java
@@ -1,20 +1,20 @@
/*******************************************************************************
* 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
+ * 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
+ * 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.
+ * 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.
******************************************************************************/
package org.apache.olingo.odata2.core.ep.consumer;
@@ -113,7 +113,8 @@ public class XmlMetadataConsumer {
reader.close();
return dataServices;
} catch (XMLStreamException e) {
- throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass().getSimpleName()), e);
+ throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
+ .getSimpleName()), e);
}
}
@@ -206,7 +207,8 @@ public class XmlMetadataConsumer {
container.setName(reader.getAttributeValue(null, XmlMetadataConstants.EDM_NAME));
if (reader.getAttributeValue(Edm.NAMESPACE_M_2007_08, XmlMetadataConstants.EDM_CONTAINER_IS_DEFAULT) != null) {
- container.setDefaultEntityContainer("true".equalsIgnoreCase(reader.getAttributeValue(Edm.NAMESPACE_M_2007_08, "IsDefaultEntityContainer")));
+ container.setDefaultEntityContainer("true".equalsIgnoreCase(reader.getAttributeValue(Edm.NAMESPACE_M_2007_08,
+ "IsDefaultEntityContainer")));
}
container.setExtendz(reader.getAttributeValue(null, XmlMetadataConstants.EDM_CONTAINER_EXTENDZ));
container.setAnnotationAttributes(readAnnotationAttribute(reader));
@@ -229,7 +231,8 @@ public class XmlMetadataConsumer {
}
}
}
- container.setEntitySets(entitySets).setAssociationSets(associationSets).setFunctionImports(functionImports).setAnnotationElements(annotationElements);
+ container.setEntitySets(entitySets).setAssociationSets(associationSets).setFunctionImports(functionImports)
+ .setAnnotationElements(annotationElements);
containerMap.put(new FullQualifiedName(currentNamespace, container.getName()), container);
return container;
@@ -243,7 +246,8 @@ public class XmlMetadataConsumer {
List<AnnotationElement> annotationElements = new ArrayList<AnnotationElement>();
function.setName(reader.getAttributeValue(null, XmlMetadataConstants.EDM_NAME));
- function.setHttpMethod(reader.getAttributeValue(Edm.NAMESPACE_M_2007_08, XmlMetadataConstants.EDM_FUNCTION_IMPORT_HTTP_METHOD));
+ function.setHttpMethod(reader.getAttributeValue(Edm.NAMESPACE_M_2007_08,
+ XmlMetadataConstants.EDM_FUNCTION_IMPORT_HTTP_METHOD));
function.setEntitySet(reader.getAttributeValue(null, XmlMetadataConstants.EDM_ENTITY_SET));
ReturnType returnType = new ReturnType();
String returnTypeString = reader.getAttributeValue(null, XmlMetadataConstants.EDM_FUNCTION_IMPORT_RETURN);
@@ -319,7 +323,9 @@ public class XmlMetadataConsumer {
.addContent(XmlMetadataConstants.EDM_ASSOCIATION).addContent(XmlMetadataConstants.EDM_ASSOCIATION_SET));
}
associationSet.setAnnotationAttributes(readAnnotationAttribute(reader));
- while (reader.hasNext() && !(reader.isEndElement() && edmNamespace.equals(reader.getNamespaceURI()) && XmlMetadataConstants.EDM_ASSOCIATION_SET.equals(reader.getLocalName()))) {
+ while (reader.hasNext()
+ && !(reader.isEndElement() && edmNamespace.equals(reader.getNamespaceURI())
+ && XmlMetadataConstants.EDM_ASSOCIATION_SET.equals(reader.getLocalName()))) {
reader.next();
if (reader.isStartElement()) {
extractNamespaces(reader);
@@ -335,7 +341,8 @@ public class XmlMetadataConsumer {
}
}
if (ends.size() != 2) {
- throw new EntityProviderException(EntityProviderException.ILLEGAL_ARGUMENT.addContent("Count of AssociationSet ends should be 2"));
+ throw new EntityProviderException(EntityProviderException.ILLEGAL_ARGUMENT
+ .addContent("Count of AssociationSet ends should be 2"));
} else {
associationSet.setEnd1(ends.get(0)).setEnd2(ends.get(1));
}
@@ -395,15 +402,18 @@ public class XmlMetadataConsumer {
}
}
if (associationEnds.size() < 2 && associationEnds.size() > 2) {
- throw new EntityProviderException(EntityProviderException.ILLEGAL_ARGUMENT.addContent("Count of association ends should be 2"));
+ throw new EntityProviderException(EntityProviderException.ILLEGAL_ARGUMENT
+ .addContent("Count of association ends should be 2"));
}
- association.setEnd1(associationEnds.get(0)).setEnd2(associationEnds.get(1)).setAnnotationElements(annotationElements);
+ association.setEnd1(associationEnds.get(0)).setEnd2(associationEnds.get(1)).setAnnotationElements(
+ annotationElements);
associationsMap.put(new FullQualifiedName(currentNamespace, association.getName()), association);
return association;
}
- private ReferentialConstraint readReferentialConstraint(final XMLStreamReader reader) throws XMLStreamException, EntityProviderException {
+ private ReferentialConstraint readReferentialConstraint(final XMLStreamReader reader) throws XMLStreamException,
+ EntityProviderException {
reader.require(XMLStreamConstants.START_ELEMENT, edmNamespace, XmlMetadataConstants.EDM_ASSOCIATION_CONSTRAINT);
ReferentialConstraint refConstraint = new ReferentialConstraint();
List<AnnotationElement> annotationElements = new ArrayList<AnnotationElement>();
@@ -416,10 +426,12 @@ public class XmlMetadataConsumer {
extractNamespaces(reader);
currentHandledStartTagName = reader.getLocalName();
if (XmlMetadataConstants.EDM_ASSOCIATION_PRINCIPAL.equals(currentHandledStartTagName)) {
- reader.require(XMLStreamConstants.START_ELEMENT, edmNamespace, XmlMetadataConstants.EDM_ASSOCIATION_PRINCIPAL);
+ reader
+ .require(XMLStreamConstants.START_ELEMENT, edmNamespace, XmlMetadataConstants.EDM_ASSOCIATION_PRINCIPAL);
refConstraint.setPrincipal(readReferentialConstraintRole(reader));
} else if (XmlMetadataConstants.EDM_ASSOCIATION_DEPENDENT.equals(currentHandledStartTagName)) {
- reader.require(XMLStreamConstants.START_ELEMENT, edmNamespace, XmlMetadataConstants.EDM_ASSOCIATION_DEPENDENT);
+ reader
+ .require(XMLStreamConstants.START_ELEMENT, edmNamespace, XmlMetadataConstants.EDM_ASSOCIATION_DEPENDENT);
refConstraint.setDependent(readReferentialConstraintRole(reader));
} else {
annotationElements.add(readAnnotationElement(reader));
@@ -430,7 +442,8 @@ public class XmlMetadataConsumer {
return refConstraint;
}
- private ReferentialConstraintRole readReferentialConstraintRole(final XMLStreamReader reader) throws EntityProviderException, XMLStreamException {
+ private ReferentialConstraintRole readReferentialConstraintRole(final XMLStreamReader reader)
+ throws EntityProviderException, XMLStreamException {
ReferentialConstraintRole rcRole = new ReferentialConstraintRole();
rcRole.setRole(reader.getAttributeValue(null, XmlMetadataConstants.EDM_ROLE));
List<PropertyRef> propertyRefs = new ArrayList<PropertyRef>();
@@ -466,7 +479,8 @@ public class XmlMetadataConsumer {
complexType.setBaseType(extractFQName(baseType));
}
if (reader.getAttributeValue(null, XmlMetadataConstants.EDM_TYPE_ABSTRACT) != null) {
- complexType.setAbstract("true".equalsIgnoreCase(reader.getAttributeValue(null, XmlMetadataConstants.EDM_TYPE_ABSTRACT)));
+ complexType.setAbstract("true".equalsIgnoreCase(reader.getAttributeValue(null,
+ XmlMetadataConstants.EDM_TYPE_ABSTRACT)));
}
complexType.setAnnotationAttributes(readAnnotationAttribute(reader));
while (reader.hasNext()
@@ -509,7 +523,8 @@ public class XmlMetadataConsumer {
}
if (reader.getAttributeValue(null, XmlMetadataConstants.EDM_TYPE_ABSTRACT) != null) {
- entityType.setAbstract("true".equalsIgnoreCase(reader.getAttributeValue(null, XmlMetadataConstants.EDM_TYPE_ABSTRACT)));
+ entityType.setAbstract("true".equalsIgnoreCase(reader.getAttributeValue(null,
+ XmlMetadataConstants.EDM_TYPE_ABSTRACT)));
}
String baseType = reader.getAttributeValue(null, XmlMetadataConstants.EDM_BASE_TYPE);
if (baseType != null) {
@@ -535,7 +550,8 @@ public class XmlMetadataConsumer {
extractNamespaces(reader);
}
}
- entityType.setKey(key).setProperties(properties).setNavigationProperties(navProperties).setAnnotationElements(annotationElements);
+ entityType.setKey(key).setProperties(properties).setNavigationProperties(navProperties).setAnnotationElements(
+ annotationElements);
if (entityType.getName() != null) {
FullQualifiedName fqName = new FullQualifiedName(currentNamespace, entityType.getName());
entityTypesMap.put(fqName, entityType);
@@ -565,7 +581,8 @@ public class XmlMetadataConsumer {
}
}
}
- return new Key().setKeys(keys).setAnnotationElements(annotationElements).setAnnotationAttributes(annotationAttributes);
+ return new Key().setKeys(keys).setAnnotationElements(annotationElements).setAnnotationAttributes(
+ annotationAttributes);
}
private PropertyRef readPropertyRef(final XMLStreamReader reader) throws XMLStreamException, EntityProviderException {
@@ -585,7 +602,8 @@ public class XmlMetadataConsumer {
return propertyRef.setAnnotationElements(annotationElements);
}
- private NavigationProperty readNavigationProperty(final XMLStreamReader reader) throws XMLStreamException, EntityProviderException {
+ private NavigationProperty readNavigationProperty(final XMLStreamReader reader) throws XMLStreamException,
+ EntityProviderException {
reader.require(XMLStreamConstants.START_ELEMENT, edmNamespace, XmlMetadataConstants.EDM_NAVIGATION_PROPERTY);
NavigationProperty navProperty = new NavigationProperty();
@@ -598,7 +616,8 @@ public class XmlMetadataConsumer {
} else {
throw new EntityProviderException(EntityProviderException.MISSING_ATTRIBUTE
- .addContent(XmlMetadataConstants.EDM_NAVIGATION_RELATIONSHIP).addContent(XmlMetadataConstants.EDM_NAVIGATION_PROPERTY));
+ .addContent(XmlMetadataConstants.EDM_NAVIGATION_RELATIONSHIP).addContent(
+ XmlMetadataConstants.EDM_NAVIGATION_PROPERTY));
}
navProperty.setFromRole(reader.getAttributeValue(null, XmlMetadataConstants.EDM_NAVIGATION_FROM_ROLE));
@@ -649,14 +668,16 @@ public class XmlMetadataConsumer {
return property;
}
- private Property readComplexProperty(final XMLStreamReader reader, final FullQualifiedName fqName) throws XMLStreamException {
+ private Property readComplexProperty(final XMLStreamReader reader, final FullQualifiedName fqName)
+ throws XMLStreamException {
ComplexProperty property = new ComplexProperty();
property.setName(reader.getAttributeValue(null, XmlMetadataConstants.EDM_NAME));
property.setType(fqName);
return property;
}
- private Property readSimpleProperty(final XMLStreamReader reader, final FullQualifiedName fqName) throws XMLStreamException {
+ private Property readSimpleProperty(final XMLStreamReader reader, final FullQualifiedName fqName)
+ throws XMLStreamException {
SimpleProperty property = new SimpleProperty();
property.setName(reader.getAttributeValue(null, XmlMetadataConstants.EDM_NAME));
property.setType(EdmSimpleTypeKind.valueOf(fqName.getName()));
@@ -738,13 +759,15 @@ public class XmlMetadataConsumer {
}
- private AssociationEnd readAssociationEnd(final XMLStreamReader reader) throws EntityProviderException, XMLStreamException {
+ private AssociationEnd readAssociationEnd(final XMLStreamReader reader) throws EntityProviderException,
+ XMLStreamException {
reader.require(XMLStreamConstants.START_ELEMENT, edmNamespace, XmlMetadataConstants.EDM_ASSOCIATION_END);
AssociationEnd associationEnd = new AssociationEnd();
List<AnnotationElement> annotationElements = new ArrayList<AnnotationElement>();
associationEnd.setRole(reader.getAttributeValue(null, XmlMetadataConstants.EDM_ROLE));
- associationEnd.setMultiplicity(EdmMultiplicity.fromLiteral(reader.getAttributeValue(null, XmlMetadataConstants.EDM_ASSOCIATION_MULTIPLICITY)));
+ associationEnd.setMultiplicity(EdmMultiplicity.fromLiteral(reader.getAttributeValue(null,
+ XmlMetadataConstants.EDM_ASSOCIATION_MULTIPLICITY)));
String type = reader.getAttributeValue(null, XmlMetadataConstants.EDM_TYPE);
if (type == null) {
throw new EntityProviderException(EntityProviderException.MISSING_ATTRIBUTE
@@ -761,7 +784,8 @@ public class XmlMetadataConsumer {
if (XmlMetadataConstants.EDM_ASSOCIATION_ONDELETE.equals(currentHandledStartTagName)) {
OnDelete onDelete = new OnDelete();
for (int i = 0; i < EdmAction.values().length; i++) {
- if (EdmAction.values()[i].name().equalsIgnoreCase(reader.getAttributeValue(null, XmlMetadataConstants.EDM_ONDELETE_ACTION))) {
+ if (EdmAction.values()[i].name().equalsIgnoreCase(
+ reader.getAttributeValue(null, XmlMetadataConstants.EDM_ONDELETE_ACTION))) {
onDelete.setAction(EdmAction.values()[i]);
}
}
@@ -820,7 +844,8 @@ public class XmlMetadataConsumer {
&& !mandatoryNamespaces.containsValue(attributeNamespace)
&& !edmNamespaces.contains(attributeNamespace)) {
annotationAttributes.add(new AnnotationAttribute().setName(reader.getAttributeLocalName(i)).
- setPrefix(reader.getAttributePrefix(i)).setNamespace(attributeNamespace).setText(reader.getAttributeValue(i)));
+ setPrefix(reader.getAttributePrefix(i)).setNamespace(attributeNamespace).setText(
+ reader.getAttributeValue(i)));
}
}
if (annotationAttributes.isEmpty()) {
@@ -835,7 +860,8 @@ public class XmlMetadataConsumer {
private void checkMandatoryNamespacesAvailable() throws EntityProviderException {
if (!xmlNamespaceMap.containsValue(Edm.NAMESPACE_EDMX_2007_06)) {
- throw new EntityProviderException(EntityProviderException.INVALID_NAMESPACE.addContent(Edm.NAMESPACE_EDMX_2007_06));
+ throw new EntityProviderException(EntityProviderException.INVALID_NAMESPACE
+ .addContent(Edm.NAMESPACE_EDMX_2007_06));
} else if (!xmlNamespaceMap.containsValue(Edm.NAMESPACE_M_2007_08)) {
throw new EntityProviderException(EntityProviderException.INVALID_NAMESPACE.addContent(Edm.NAMESPACE_M_2007_08));
}
@@ -843,7 +869,8 @@ public class XmlMetadataConsumer {
private void checkEdmNamespace() throws EntityProviderException {
if (!edmNamespaces.contains(edmNamespace)) {
- throw new EntityProviderException(EntityProviderException.INVALID_NAMESPACE.addContent(XmlMetadataConstants.EDM_SCHEMA));
+ throw new EntityProviderException(EntityProviderException.INVALID_NAMESPACE
+ .addContent(XmlMetadataConstants.EDM_SCHEMA));
}
}
@@ -864,13 +891,15 @@ public class XmlMetadataConsumer {
// Looking for the last dot
String[] names = name.split("\\" + Edm.DELIMITER + "(?=[^\\" + Edm.DELIMITER + "]+$)");
if (names.length != 2) {
- throw new EntityProviderException(EntityProviderException.ILLEGAL_ARGUMENT.addContent("Attribute should specify a namespace qualified name or an alias qualified name"));
+ throw new EntityProviderException(EntityProviderException.ILLEGAL_ARGUMENT
+ .addContent("Attribute should specify a namespace qualified name or an alias qualified name"));
} else {
return new FullQualifiedName(names[0], names[1]);
}
}
- private FullQualifiedName validateEntityTypeWithAlias(final FullQualifiedName aliasName) throws EntityProviderException {
+ private FullQualifiedName validateEntityTypeWithAlias(final FullQualifiedName aliasName)
+ throws EntityProviderException {
String namespace = aliasNamespaceMap.get(aliasName.getNamespace());
FullQualifiedName fqName = new FullQualifiedName(namespace, aliasName.getName());
if (!entityTypesMap.containsKey(fqName)) {
@@ -893,20 +922,24 @@ public class XmlMetadataConsumer {
baseEntityType = entityTypesMap.get(baseTypeFQName);
}
if (baseEntityType.getKey() == null) {
- throw new EntityProviderException(EntityProviderException.ILLEGAL_ARGUMENT.addContent("Missing key for EntityType " + baseEntityType.getName()));
+ throw new EntityProviderException(EntityProviderException.ILLEGAL_ARGUMENT
+ .addContent("Missing key for EntityType " + baseEntityType.getName()));
}
} else if (entityType.getKey() == null) {
- throw new EntityProviderException(EntityProviderException.ILLEGAL_ARGUMENT.addContent("Missing key for EntityType " + entityType.getName()));
+ throw new EntityProviderException(EntityProviderException.ILLEGAL_ARGUMENT
+ .addContent("Missing key for EntityType " + entityType.getName()));
}
}
}
}
- private FullQualifiedName validateComplexTypeWithAlias(final FullQualifiedName aliasName) throws EntityProviderException {
+ private FullQualifiedName validateComplexTypeWithAlias(final FullQualifiedName aliasName)
+ throws EntityProviderException {
String namespace = aliasNamespaceMap.get(aliasName.getNamespace());
FullQualifiedName fqName = new FullQualifiedName(namespace, aliasName.getName());
if (!complexTypesMap.containsKey(fqName)) {
- throw new EntityProviderException(EntityProviderException.ILLEGAL_ARGUMENT.addContent("Invalid BaseType").addContent(fqName));
+ throw new EntityProviderException(EntityProviderException.ILLEGAL_ARGUMENT.addContent("Invalid BaseType")
+ .addContent(fqName));
}
return fqName;
}
@@ -929,9 +962,12 @@ public class XmlMetadataConsumer {
for (NavigationProperty navProperty : navProperties) {
if (associationsMap.containsKey(navProperty.getRelationship())) {
Association assoc = associationsMap.get(navProperty.getRelationship());
- if (!(assoc.getEnd1().getRole().equals(navProperty.getFromRole()) ^ assoc.getEnd1().getRole().equals(navProperty.getToRole())
- && (assoc.getEnd2().getRole().equals(navProperty.getFromRole()) ^ assoc.getEnd2().getRole().equals(navProperty.getToRole())))) {
- throw new EntityProviderException(EntityProviderException.ILLEGAL_ARGUMENT.addContent("Invalid end of association"));
+ if (!(assoc.getEnd1().getRole().equals(navProperty.getFromRole())
+ ^ assoc.getEnd1().getRole().equals(navProperty.getToRole())
+ && (assoc.getEnd2().getRole().equals(navProperty.getFromRole()) ^ assoc.getEnd2().getRole().equals(
+ navProperty.getToRole())))) {
+ throw new EntityProviderException(EntityProviderException.ILLEGAL_ARGUMENT
+ .addContent("Invalid end of association"));
}
if (!entityTypesMap.containsKey(assoc.getEnd1().getType())) {
validateEntityTypeWithAlias(assoc.getEnd1().getType());
@@ -964,18 +1000,22 @@ public class XmlMetadataConsumer {
}
}
if (!(end1 && end2)) {
- throw new EntityProviderException(EntityProviderException.ILLEGAL_ARGUMENT.addContent("Invalid AssociationSet"));
+ throw new EntityProviderException(EntityProviderException.ILLEGAL_ARGUMENT
+ .addContent("Invalid AssociationSet"));
}
} else {
- throw new EntityProviderException(EntityProviderException.ILLEGAL_ARGUMENT.addContent("Invalid AssociationSet"));
+ throw new EntityProviderException(EntityProviderException.ILLEGAL_ARGUMENT
+ .addContent("Invalid AssociationSet"));
}
}
}
}
- private void validateAssociationEnd(final AssociationSetEnd end, final Association association) throws EntityProviderException {
- if (!(association.getEnd1().getRole().equals(end.getRole()) ^ association.getEnd2().getRole().equals(end.getRole()))) {
+ private void validateAssociationEnd(final AssociationSetEnd end, final Association association)
+ throws EntityProviderException {
+ if (!(association.getEnd1().getRole().equals(end.getRole()) ^
+ association.getEnd2().getRole().equals(end.getRole()))) {
throw new EntityProviderException(EntityProviderException.COMMON.addContent("Invalid Association"));
}
}
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/a030e42b/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/consumer/XmlPropertyConsumer.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/consumer/XmlPropertyConsumer.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/consumer/XmlPropertyConsumer.java
index 0ce8f1e..28cacef 100644
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/consumer/XmlPropertyConsumer.java
+++ b/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/consumer/XmlPropertyConsumer.java
@@ -1,20 +1,20 @@
/*******************************************************************************
* 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
+ * 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
+ * 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.
+ * 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.
******************************************************************************/
package org.apache.olingo.odata2.core.ep.consumer;
@@ -47,11 +47,14 @@ public class XmlPropertyConsumer {
protected static final String TRUE = "true";
protected static final String FALSE = "false";
- public Map<String, Object> readProperty(final XMLStreamReader reader, final EdmProperty property, final boolean merge) throws EntityProviderException {
+ public Map<String, Object>
+ readProperty(final XMLStreamReader reader, final EdmProperty property, final boolean merge)
+ throws EntityProviderException {
return readProperty(reader, property, merge, null);
}
- public Map<String, Object> readProperty(final XMLStreamReader reader, final EdmProperty property, final boolean merge, final Map<String, Object> typeMappings) throws EntityProviderException {
+ public Map<String, Object> readProperty(final XMLStreamReader reader, final EdmProperty property,
+ final boolean merge, final Map<String, Object> typeMappings) throws EntityProviderException {
EntityPropertyInfo eia = EntityInfoAggregator.create(property);
try {
@@ -67,9 +70,11 @@ public class XmlPropertyConsumer {
result.put(eia.getName(), value);
return result;
} catch (XMLStreamException e) {
- throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass().getSimpleName()), e);
+ throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
+ .getSimpleName()), e);
} catch (EdmException e) {
- throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass().getSimpleName()), e);
+ throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
+ .getSimpleName()), e);
}
}
@@ -85,7 +90,8 @@ public class XmlPropertyConsumer {
mergeComplexWithDefaultValues((Map<String, Object>) value, (EntityComplexPropertyInfo) epi);
}
- private void mergeComplexWithDefaultValues(final Map<String, Object> complexValue, final EntityComplexPropertyInfo ecpi) {
+ private void mergeComplexWithDefaultValues(final Map<String, Object> complexValue,
+ final EntityComplexPropertyInfo ecpi) {
for (EntityPropertyInfo info : ecpi.getPropertyInfos()) {
Object obj = complexValue.get(info.getName());
if (obj == null) {
@@ -103,7 +109,8 @@ public class XmlPropertyConsumer {
}
}
- protected Object readStartedElement(final XMLStreamReader reader, final EntityPropertyInfo propertyInfo, final EntityTypeMapping typeMappings) throws EntityProviderException, EdmException {
+ protected Object readStartedElement(final XMLStreamReader reader, final EntityPropertyInfo propertyInfo,
+ final EntityTypeMapping typeMappings) throws EntityProviderException, EdmException {
final String name = propertyInfo.getName();
Object result = null;
@@ -123,9 +130,11 @@ public class XmlPropertyConsumer {
} else if (propertyInfo.isComplex()) {
final String typeAttribute = reader.getAttributeValue(Edm.NAMESPACE_M_2007_08, FormatXml.M_TYPE);
if (typeAttribute != null) {
- final String expectedTypeAttributeValue = propertyInfo.getType().getNamespace() + Edm.DELIMITER + propertyInfo.getType().getName();
+ final String expectedTypeAttributeValue =
+ propertyInfo.getType().getNamespace() + Edm.DELIMITER + propertyInfo.getType().getName();
if (!expectedTypeAttributeValue.equals(typeAttribute)) {
- throw new EntityProviderException(EntityProviderException.INVALID_COMPLEX_TYPE.addContent(expectedTypeAttributeValue).addContent(typeAttribute));
+ throw new EntityProviderException(EntityProviderException.INVALID_COMPLEX_TYPE.addContent(
+ expectedTypeAttributeValue).addContent(typeAttribute));
}
}
@@ -133,7 +142,8 @@ public class XmlPropertyConsumer {
Map<String, Object> name2Value = new HashMap<String, Object>();
while (reader.hasNext() && !reader.isEndElement()) {
final String childName = reader.getLocalName();
- final EntityPropertyInfo childProperty = ((EntityComplexPropertyInfo) propertyInfo).getPropertyInfo(childName);
+ final EntityPropertyInfo childProperty =
+ ((EntityComplexPropertyInfo) propertyInfo).getPropertyInfo(childName);
if (childProperty == null) {
throw new EntityProviderException(EntityProviderException.INVALID_PROPERTY.addContent(childName));
}
@@ -149,11 +159,13 @@ public class XmlPropertyConsumer {
return result;
} catch (XMLStreamException e) {
- throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass().getSimpleName()), e);
+ throw new EntityProviderException(EntityProviderException.EXCEPTION_OCCURRED.addContent(e.getClass()
+ .getSimpleName()), e);
}
}
- private Object convert(final EntityPropertyInfo property, final String value, final Class<?> typeMapping) throws EdmSimpleTypeException {
+ private Object convert(final EntityPropertyInfo property, final String value, final Class<?> typeMapping)
+ throws EdmSimpleTypeException {
final EdmSimpleType type = (EdmSimpleType) property.getType();
return type.valueOfString(value, EdmLiteralKind.DEFAULT, property.getFacets(),
typeMapping == null ? type.getDefaultType() : typeMapping);
http://git-wip-us.apache.org/repos/asf/incubator-olingo-odata2/blob/a030e42b/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/entry/EntryMetadataImpl.java
----------------------------------------------------------------------
diff --git a/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/entry/EntryMetadataImpl.java b/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/entry/EntryMetadataImpl.java
index b1cb159..a7d1054 100644
--- a/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/entry/EntryMetadataImpl.java
+++ b/odata-core/src/main/java/org/apache/olingo/odata2/core/ep/entry/EntryMetadataImpl.java
@@ -1,20 +1,20 @@
/*******************************************************************************
* 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
+ * 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
+ * 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.
+ * 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.
******************************************************************************/
package org.apache.olingo.odata2.core.ep.entry;
@@ -83,6 +83,7 @@ public class EntryMetadataImpl implements EntryMetadata {
@Override
public String toString() {
- return "EntryMetadataImpl [id=" + id + ", etag=" + etag + ", uri=" + uri + ", associationUris=" + associationUris + "]";
+ return "EntryMetadataImpl [id=" + id + ", etag=" + etag + ", uri=" + uri + ", associationUris=" + associationUris
+ + "]";
}
}