http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/17152920/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataError.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataError.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataError.java new file mode 100644 index 0000000..a910f08 --- /dev/null +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataError.java @@ -0,0 +1,132 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.olingo.commons.api.domain; + +import java.util.List; +import java.util.Map; + +/** + * OData error. + */ +public class ODataError { + + private String code; + private String message; + private String target; + private List<ODataErrorDetail> details; + private Map<String, String> innerError; + + /** + * The value for the code name/value pair is a language-independent string. Its value is a service-defined error code. + * This code serves as a sub-status for the HTTP error code specified in the response. MAY be null. + * @return the error code as a string + */ + public String getCode() { + return code; + } + + /** + * The value for the code name/value pair is a language-independent string. Its value is a service-defined error code. + * This code serves as a sub-status for the HTTP error code specified in the response. MAY be null. + * @param code + * @return this for method chaining + */ + public ODataError setCode(String code) { + this.code = code; + return this; + } + + /** + * The value for the message name/value pair MUST be a human-readable, language-dependent representation of the error. + * MUST not be null + * @return the message string + */ + public String getMessage() { + return message; + } + + /** + * The value for the message name/value pair MUST be a human-readable, language-dependent representation of the error. + * MUST not be null + * @param message + * @return this for method chaining + */ + public ODataError setMessage(String message) { + this.message = message; + return this; + } + + /** + * The value for the target name/value pair is the target of the particular error (for example, the name of the + * property in error). MAY be null. + * @return the target string + */ + public String getTarget() { + return target; + } + + /** + * The value for the target name/value pair is the target of the particular error (for example, the name of the + * property in error). MAY be null. + * @param target + * @return this for method chaining + */ + public ODataError setTarget(String target) { + this.target = target; + return this; + } + + /** + * Gets error details. + * + * @return ODataErrorDetail list. + */ + public List<ODataErrorDetail> getDetails() { + return details; + } + + /** + * Sets error details. + * + * @return this for method chaining. + */ + public ODataError setDetails(List<ODataErrorDetail> details) { + this.details = details; + return this; + } + + /** + * Gets server defined key-value pairs for debug environment only. + * + * @return a pair representing server defined object. MAY be null. + */ + public Map<String, String> getInnerError() { + return innerError; + } + + /** + * Sets server defined key-value pairs for debug environment only. + * + * @return this for method chaining. + */ + public ODataError setInnerError(Map<String, String> innerError) { + this.innerError = innerError; + return this; + } +}
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/17152920/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataErrorDetail.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataErrorDetail.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataErrorDetail.java new file mode 100644 index 0000000..573525d --- /dev/null +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataErrorDetail.java @@ -0,0 +1,73 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.olingo.commons.api.domain; + +/** + * OData detailsï¼ for example <tt>{ "error": {..., "details":[ + * {"code": "301","target": "$search" ,"message": "$search query option not supported"} + * ],...}}</tt>. + */ +public class ODataErrorDetail { + + private String code; + private String message; + private String target; + + /** + * Gets error code. + * + * @return error code. + */ + public String getCode() { + return code; + } + + public ODataErrorDetail setCode(final String code) { + this.code = code; + return this; + } + + /** + * Gets error message. + * + * @return error message. + */ + public String getMessage() { + return message; + } + + public ODataErrorDetail setMessage(final String message) { + this.message = message; + return this; + } + + /** + * Gets error target. + * + * @return error message. + */ + public String getTarget() { + return target; + } + + public ODataErrorDetail setTarget(final String target) { + this.target = target; + return this; + } +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/17152920/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataPropertyType.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataPropertyType.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataPropertyType.java new file mode 100644 index 0000000..e7b5b85 --- /dev/null +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/domain/ODataPropertyType.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.olingo.commons.api.domain; + +public enum ODataPropertyType { + + /** + * Primitive (including geospatial). + */ + PRIMITIVE, + /** + * Enum. + */ + ENUM, + /** + * Collection. + */ + COLLECTION, + /** + * Complex. + */ + COMPLEX, + /** + * Empty type (possibly, no type information could be retrieved). + */ + EMPTY + +} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/17152920/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmConstantAnnotationExpression.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmConstantAnnotationExpression.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmConstantAnnotationExpression.java index cc47fe6..0f0a34f 100644 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmConstantAnnotationExpression.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/edm/annotation/EdmConstantAnnotationExpression.java @@ -18,10 +18,10 @@ */ package org.apache.olingo.commons.api.edm.annotation; -import org.apache.olingo.commons.api.domain.ClientValue; +import org.apache.olingo.commons.api.data.Valuable; public interface EdmConstantAnnotationExpression extends EdmAnnotationExpression { - ClientValue getValue(); + Valuable getValue(); } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/17152920/lib/commons-api/src/main/java/org/apache/olingo/commons/api/serialization/ODataDeserializer.java ---------------------------------------------------------------------- diff --git a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/serialization/ODataDeserializer.java b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/serialization/ODataDeserializer.java index 38ad911..8e313b1 100755 --- a/lib/commons-api/src/main/java/org/apache/olingo/commons/api/serialization/ODataDeserializer.java +++ b/lib/commons-api/src/main/java/org/apache/olingo/commons/api/serialization/ODataDeserializer.java @@ -22,7 +22,7 @@ import org.apache.olingo.commons.api.data.Entity; import org.apache.olingo.commons.api.data.EntityCollection; import org.apache.olingo.commons.api.data.Property; import org.apache.olingo.commons.api.data.ResWrap; -import org.apache.olingo.commons.api.domain.ClientError; +import org.apache.olingo.commons.api.domain.ODataError; import java.io.InputStream; @@ -61,5 +61,5 @@ public interface ODataDeserializer { * @param input stream to be parsed and de-serialized. * @return parsed ODataError object represented by the given InputStream */ - ClientError toError(InputStream input) throws ODataDeserializerException; + ODataError toError(InputStream input) throws ODataDeserializerException; } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/17152920/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractClientEntitySet.java ---------------------------------------------------------------------- diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractClientEntitySet.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractClientEntitySet.java deleted file mode 100644 index d11b799..0000000 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/AbstractClientEntitySet.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.olingo.commons.core.domain; - -import org.apache.olingo.commons.api.domain.AbstractClientPayload; -import org.apache.olingo.commons.api.domain.ClientEntitySet; - -import java.net.URI; - -public abstract class AbstractClientEntitySet extends AbstractClientPayload implements ClientEntitySet { - - /** - * Link to the next page. - */ - private URI next; - - /** - * Number of ODataEntities contained in this entity set. - * <br/> - * If <tt>$inlinecount</tt> was requested, this value comes from there. - */ - private Integer count; - - /** - * Constructor. - */ - public AbstractClientEntitySet() { - super(null); - } - - /** - * Constructor. - * - * @param next next link. - */ - public AbstractClientEntitySet(final URI next) { - super(null); - this.next = next; - } - - @Override - public URI getNext() { - return next; - } - - @Override - public Integer getCount() { - return count; - } - - @Override - public void setCount(final int count) { - this.count = count; - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/17152920/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientAnnotationImpl.java ---------------------------------------------------------------------- diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientAnnotationImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientAnnotationImpl.java deleted file mode 100644 index b5fae89..0000000 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientAnnotationImpl.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.olingo.commons.core.domain; - -import org.apache.olingo.commons.api.domain.ClientAnnotation; -import org.apache.olingo.commons.api.domain.ClientCollectionValue; -import org.apache.olingo.commons.api.domain.ClientComplexValue; -import org.apache.olingo.commons.api.domain.ClientEnumValue; -import org.apache.olingo.commons.api.domain.ClientPrimitiveValue; -import org.apache.olingo.commons.api.domain.ClientValuable; -import org.apache.olingo.commons.api.domain.ClientValue; - -public class ClientAnnotationImpl implements ClientAnnotation { - - private final String term; - - private final ClientValuable valuable; - - public ClientAnnotationImpl(final String term, final ClientValue value) { - this.term = term; - valuable = new ClientValuableImpl(value); - } - - @Override - public String getTerm() { - return term; - } - - @Override - public ClientValue getValue() { - return valuable.getValue(); - } - - @Override - public boolean hasNullValue() { - return valuable.hasNullValue(); - } - - @Override - public boolean hasPrimitiveValue() { - return valuable.hasPrimitiveValue(); - } - - @Override - public ClientPrimitiveValue getPrimitiveValue() { - return valuable.getPrimitiveValue(); - } - - @Override - public boolean hasCollectionValue() { - return valuable.hasCollectionValue(); - } - - @Override - public ClientCollectionValue<ClientValue> getCollectionValue() { - return valuable.getCollectionValue(); - } - - @Override - public boolean hasComplexValue() { - return valuable.hasComplexValue(); - } - - @Override - public ClientComplexValue getComplexValue() { - return valuable.getComplexValue(); - } - - @Override - public boolean hasEnumValue() { - return valuable.hasEnumValue(); - } - - @Override - public ClientEnumValue getEnumValue() { - return valuable.getEnumValue(); - } - - @Override - public String toString() { - return "ODataPropertyImpl{" - + "term=" + term - + ",valuable=" + valuable - + '}'; - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/17152920/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientCollectionValueImpl.java ---------------------------------------------------------------------- diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientCollectionValueImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientCollectionValueImpl.java deleted file mode 100644 index e7b53ff..0000000 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientCollectionValueImpl.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.olingo.commons.core.domain; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; - -import org.apache.olingo.commons.api.domain.AbstractClientValue; -import org.apache.olingo.commons.api.domain.ClientCollectionValue; -import org.apache.olingo.commons.api.domain.ClientEnumValue; -import org.apache.olingo.commons.api.domain.ClientValue; - -public class ClientCollectionValueImpl<OV extends ClientValue> extends AbstractClientValue - implements ClientCollectionValue<OV>, ClientValue { - - /** - * Constructor. - * - * @param typeName type name. - */ - public ClientCollectionValueImpl(final String typeName) { - super(typeName == null || typeName.startsWith("Collection(") ? typeName : "Collection(" + typeName + ")"); - } - - @Override - public boolean isEnum() { - return false; - } - - @Override - public ClientEnumValue asEnum() { - return null; - } - - @Override - public boolean isComplex() { - return false; - } - - @Override - public Collection<Object> asJavaCollection() { - final List<Object> result = new ArrayList<Object>(); - for (ClientValue value : values) { - if (value.isPrimitive()) { - result.add(value.asPrimitive().toValue()); - } else if (value.isComplex()) { - result.add(value.asComplex().asJavaMap()); - } else if (value.isCollection()) { - result.add(value.asCollection().asJavaCollection()); - } else if (value.isEnum()) { - result.add(value.asEnum().toString()); - } - } - - return result; - } - - /** - * Values. - */ - protected final List<OV> values = new ArrayList<OV>(); - - /** - * Adds a value to the collection. - * - * @param value value to be added. - */ - @Override - @SuppressWarnings("unchecked") - public ClientCollectionValue<OV> add(final ClientValue value) { - values.add((OV) value); - return this; - } - - /** - * Value iterator. - * - * @return value iterator. - */ - @Override - public Iterator<OV> iterator() { - return values.iterator(); - } - - /** - * Gets collection size. - * - * @return collection size. - */ - @Override - public int size() { - return values.size(); - } - - /** - * Checks if collection is empty. - * - * @return 'TRUE' if empty; 'FALSE' otherwise. - */ - @Override - public boolean isEmpty() { - return values.isEmpty(); - } - - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/17152920/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientComplexValueImpl.java ---------------------------------------------------------------------- diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientComplexValueImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientComplexValueImpl.java deleted file mode 100644 index 3881c3a..0000000 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientComplexValueImpl.java +++ /dev/null @@ -1,204 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.olingo.commons.core.domain; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -import org.apache.olingo.commons.api.domain.AbstractClientValue; -import org.apache.olingo.commons.api.domain.ClientAnnotation; -import org.apache.olingo.commons.api.domain.ClientComplexValue; -import org.apache.olingo.commons.api.domain.ClientEnumValue; -import org.apache.olingo.commons.api.domain.ClientLink; -import org.apache.olingo.commons.api.domain.ClientProperty; - -public class ClientComplexValueImpl extends AbstractClientValue implements ClientComplexValue { - - /** - * Navigation links (might contain in-line entities or entity sets). - */ - private final List<ClientLink> navigationLinks = new ArrayList<ClientLink>(); - - /** - * Association links. - */ - private final List<ClientLink> associationLinks = new ArrayList<ClientLink>(); - - private final List<ClientAnnotation> annotations = new ArrayList<ClientAnnotation>(); - - /** - * Complex type fields. - */ - private final Map<String, ClientProperty> fields = new LinkedHashMap<String, ClientProperty>(); - - /** - * Constructor. - * - * @param typeName type name. - */ - public ClientComplexValueImpl(final String typeName) { - super(typeName); - } - - @Override - public boolean isEnum() { - return false; - } - - @Override - public ClientEnumValue asEnum() { - return null; - } - - @Override - public boolean isComplex() { - return true; - } - - @Override - public boolean addLink(final ClientLink link) { - boolean result = false; - - switch (link.getType()) { - case ASSOCIATION: - result = associationLinks.contains(link) ? false : associationLinks.add(link); - break; - - case ENTITY_NAVIGATION: - case ENTITY_SET_NAVIGATION: - result = navigationLinks.contains(link) ? false : navigationLinks.add(link); - break; - - case MEDIA_EDIT: - throw new IllegalArgumentException("Complex values cannot have media links!"); - - default: - } - - return result; - } - - @Override - public boolean removeLink(final ClientLink link) { - return associationLinks.remove(link) || navigationLinks.remove(link); - } - - private ClientLink getLink(final List<ClientLink> links, final String name) { - ClientLink result = null; - for (ClientLink link : links) { - if (name.equals(link.getName())) { - result = link; - break; - } - } - - return result; - } - - @Override - public ClientLink getNavigationLink(final String name) { - return getLink(navigationLinks, name); - } - - @Override - public List<ClientLink> getNavigationLinks() { - return navigationLinks; - } - - @Override - public ClientLink getAssociationLink(final String name) { - return getLink(associationLinks, name); - } - - @Override - public List<ClientLink> getAssociationLinks() { - return associationLinks; - } - - @Override - public Map<String, Object> asJavaMap() { - final Map<String, Object> result = new LinkedHashMap<String, Object>(); - for (Map.Entry<String, ClientProperty> entry : fields.entrySet()) { - Object value = null; - if (entry.getValue().hasPrimitiveValue()) { - value = entry.getValue().getPrimitiveValue().toValue(); - } else if (entry.getValue().hasComplexValue()) { - value = entry.getValue().getComplexValue().asJavaMap(); - } else if (entry.getValue().hasCollectionValue()) { - value = entry.getValue().getCollectionValue().asJavaCollection(); - } else if (entry.getValue().hasEnumValue()) { - value = entry.getValue().getEnumValue().toString(); - } - - result.put(entry.getKey(), value); - } - - return result; - } - - @Override - public List<ClientAnnotation> getAnnotations() { - return annotations; - } - - /** - * Adds field to the complex type. - * - * @param field field to be added. - */ - @Override - public ClientComplexValue add(final ClientProperty field) { - fields.put(field.getName(), field); - return this; - } - - /** - * Gets field. - * - * @param name name of the field to be retrieved. - * @return requested field. - */ - @Override - public ClientProperty get(final String name) { - return fields.get(name); - } - - /** - * Complex property fields iterator. - * - * @return fields iterator. - */ - @Override - public Iterator<ClientProperty> iterator() { - return fields.values().iterator(); - } - - /** - * Gets number of fields. - * - * @return number of fields. - */ - @Override - public int size() { - return fields.size(); - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/17152920/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientDeletedEntityImpl.java ---------------------------------------------------------------------- diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientDeletedEntityImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientDeletedEntityImpl.java deleted file mode 100644 index 9df7a18..0000000 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientDeletedEntityImpl.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.olingo.commons.core.domain; - -import org.apache.olingo.commons.api.domain.ClientDeletedEntity; -import org.apache.olingo.commons.api.domain.ClientItem; - -import java.net.URI; - -public class ClientDeletedEntityImpl extends ClientItem implements ClientDeletedEntity { - - private URI id; - - private Reason reason; - - public ClientDeletedEntityImpl() { - super(null); - } - - @Override - public URI getId() { - return id; - } - - public void setId(final URI id) { - this.id = id; - } - - @Override - public Reason getReason() { - return reason; - } - - public void setReason(final Reason reason) { - this.reason = reason; - } - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/17152920/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientDeltaImpl.java ---------------------------------------------------------------------- diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientDeltaImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientDeltaImpl.java deleted file mode 100644 index 1c1e521..0000000 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientDeltaImpl.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.olingo.commons.core.domain; - -import org.apache.olingo.commons.api.domain.ClientDeletedEntity; -import org.apache.olingo.commons.api.domain.ClientDelta; -import org.apache.olingo.commons.api.domain.ClientDeltaLink; - -import java.net.URI; -import java.util.ArrayList; -import java.util.List; - -public class ClientDeltaImpl extends ClientEntitySetImpl implements ClientDelta { - - private final List<ClientDeletedEntity> deletedEntities = new ArrayList<ClientDeletedEntity>(); - - private final List<ClientDeltaLink> addedLinks = new ArrayList<ClientDeltaLink>(); - - private final List<ClientDeltaLink> deletedLinks = new ArrayList<ClientDeltaLink>(); - - public ClientDeltaImpl() { - super(); - } - - public ClientDeltaImpl(final URI next) { - super(next); - } - - @Override - public List<ClientDeletedEntity> getDeletedEntities() { - return deletedEntities; - } - - @Override - public List<ClientDeltaLink> getAddedLinks() { - return addedLinks; - } - - @Override - public List<ClientDeltaLink> getDeletedLinks() { - return deletedLinks; - } - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/17152920/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientDeltaLinkImpl.java ---------------------------------------------------------------------- diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientDeltaLinkImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientDeltaLinkImpl.java deleted file mode 100644 index a21f7ae..0000000 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientDeltaLinkImpl.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.olingo.commons.core.domain; - -import org.apache.olingo.commons.api.domain.ClientAnnotation; -import org.apache.olingo.commons.api.domain.ClientDeltaLink; -import org.apache.olingo.commons.api.domain.ClientItem; - -import java.net.URI; -import java.util.ArrayList; -import java.util.List; - -public class ClientDeltaLinkImpl extends ClientItem implements ClientDeltaLink { - - private URI source; - - private String relationship; - - private URI target; - - private final List<ClientAnnotation> annotations = new ArrayList<ClientAnnotation>(); - - public ClientDeltaLinkImpl() { - super(null); - } - - @Override - public URI getSource() { - return source; - } - - @Override - public void setSource(final URI source) { - this.source = source; - } - - @Override - public String getRelationship() { - return relationship; - } - - @Override - public void setRelationship(final String relationship) { - this.relationship = relationship; - } - - @Override - public URI getTarget() { - return target; - } - - @Override - public void setTarget(final URI target) { - this.target = target; - } - - @Override - public List<ClientAnnotation> getAnnotations() { - return annotations; - } - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/17152920/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientEntityImpl.java ---------------------------------------------------------------------- diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientEntityImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientEntityImpl.java deleted file mode 100644 index 0c2ef29..0000000 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientEntityImpl.java +++ /dev/null @@ -1,298 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.olingo.commons.core.domain; - -import java.net.URI; -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.lang3.StringUtils; -import org.apache.olingo.commons.api.domain.AbstractClientPayload; -import org.apache.olingo.commons.api.domain.ClientAnnotation; -import org.apache.olingo.commons.api.domain.ClientEntity; -import org.apache.olingo.commons.api.domain.ClientLink; -import org.apache.olingo.commons.api.domain.ClientOperation; -import org.apache.olingo.commons.api.domain.ClientProperty; -import org.apache.olingo.commons.api.domain.ClientSingleton; -import org.apache.olingo.commons.api.edm.FullQualifiedName; - -public class ClientEntityImpl extends AbstractClientPayload implements ClientEntity, ClientSingleton { - - /** - * Entity id. - */ - private URI id; - /** - * ETag. - */ - private String eTag; - /** - * Media entity flag. - */ - private boolean mediaEntity = false; - /** - * In case of media entity, media content type. - */ - private String mediaContentType; - /** - * In case of media entity, media content source. - */ - private URI mediaContentSource; - /** - * Media ETag. - */ - private String mediaETag; - /** - * Edit link. - */ - private URI editLink; - - private final List<ClientProperty> properties = new ArrayList<ClientProperty>(); - - private final List<ClientAnnotation> annotations = new ArrayList<ClientAnnotation>(); - - private final FullQualifiedName typeName; - /** - * Navigation links (might contain in-line entities or entity sets). - */ - private final List<ClientLink> navigationLinks = new ArrayList<ClientLink>(); - /** - * Association links. - */ - private final List<ClientLink> associationLinks = new ArrayList<ClientLink>(); - /** - * Media edit links. - */ - private final List<ClientLink> mediaEditLinks = new ArrayList<ClientLink>(); - /** - * Operations (legacy, functions, actions). - */ - private final List<ClientOperation> operations = new ArrayList<ClientOperation>(); - - public ClientEntityImpl(final FullQualifiedName typeName) { - super(typeName == null ? null : typeName.toString()); - this.typeName = typeName; - } - - @Override - public FullQualifiedName getTypeName() { - return typeName; - } - - @Override - public String getETag() { - return eTag; - } - - @Override - public void setETag(final String eTag) { - this.eTag = eTag; - } - - @Override - public ClientOperation getOperation(final String title) { - ClientOperation result = null; - for (ClientOperation operation : operations) { - if (title.equals(operation.getTitle())) { - result = operation; - break; - } - } - - return result; - } - - /** - * Gets operations. - * - * @return operations. - */ - @Override - public List<ClientOperation> getOperations() { - return operations; - } - - - @Override - public ClientProperty getProperty(final String name) { - ClientProperty result = null; - - if (StringUtils.isNotBlank(name)) { - for (ClientProperty property : getProperties()) { - if (name.equals(property.getName())) { - result = property; - break; - } - } - } - - return result; - } - - @Override - public boolean addLink(final ClientLink link) { - boolean result = false; - - switch (link.getType()) { - case ASSOCIATION: - result = associationLinks.contains(link) ? false : associationLinks.add(link); - break; - - case ENTITY_NAVIGATION: - case ENTITY_SET_NAVIGATION: - result = navigationLinks.contains(link) ? false : navigationLinks.add(link); - break; - - case MEDIA_EDIT: - result = mediaEditLinks.contains(link) ? false : mediaEditLinks.add(link); - break; - - default: - } - - return result; - } - - @Override - public boolean removeLink(final ClientLink link) { - return associationLinks.remove(link) || navigationLinks.remove(link); - } - - private ClientLink getLink(final List<ClientLink> links, final String name) { - ClientLink result = null; - for (ClientLink link : links) { - if (name.equals(link.getName())) { - result = link; - break; - } - } - - return result; - } - - @Override - public ClientLink getNavigationLink(final String name) { - return getLink(navigationLinks, name); - } - - @Override - public List<ClientLink> getNavigationLinks() { - return navigationLinks; - } - - @Override - public ClientLink getAssociationLink(final String name) { - return getLink(associationLinks, name); - } - - @Override - public List<ClientLink> getAssociationLinks() { - return associationLinks; - } - - @Override - public ClientLink getMediaEditLink(final String name) { - return getLink(mediaEditLinks, name); - } - - @Override - public List<ClientLink> getMediaEditLinks() { - return mediaEditLinks; - } - - @Override - public URI getEditLink() { - return editLink; - } - - @Override - public void setEditLink(final URI editLink) { - this.editLink = editLink; - } - - @Override - public URI getLink() { - return super.getLink() == null ? getEditLink() : super.getLink(); - } - - @Override - public boolean isReadOnly() { - return super.getLink() != null; - } - - @Override - public boolean isMediaEntity() { - return mediaEntity; - } - - @Override - public void setMediaEntity(final boolean isMediaEntity) { - mediaEntity = isMediaEntity; - } - - @Override - public String getMediaContentType() { - return mediaContentType; - } - - @Override - public void setMediaContentType(final String mediaContentType) { - this.mediaContentType = mediaContentType; - } - - @Override - public URI getMediaContentSource() { - return mediaContentSource; - } - - @Override - public void setMediaContentSource(final URI mediaContentSource) { - this.mediaContentSource = mediaContentSource; - } - - @Override - public String getMediaETag() { - return mediaETag; - } - - @Override - public void setMediaETag(final String eTag) { - mediaETag = eTag; - } - - @Override - public URI getId() { - return id; - } - - @Override - public void setId(final URI id) { - this.id = id; - } - - @Override - public List<ClientProperty> getProperties() { - return properties; - } - - @Override - public List<ClientAnnotation> getAnnotations() { - return annotations; - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/17152920/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientEntitySetImpl.java ---------------------------------------------------------------------- diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientEntitySetImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientEntitySetImpl.java deleted file mode 100644 index 4e4d79b..0000000 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientEntitySetImpl.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.olingo.commons.core.domain; - -import org.apache.olingo.commons.api.domain.ClientAnnotation; -import org.apache.olingo.commons.api.domain.ClientEntity; -import org.apache.olingo.commons.api.domain.ClientEntitySet; - -import java.net.URI; -import java.util.ArrayList; -import java.util.List; - -public class ClientEntitySetImpl extends AbstractClientEntitySet implements ClientEntitySet { - - private URI deltaLink; - - private final List<ClientEntity> entities = new ArrayList<ClientEntity>(); - - private final List<ClientAnnotation> annotations = new ArrayList<ClientAnnotation>(); - - public ClientEntitySetImpl() { - super(); - } - - public ClientEntitySetImpl(final URI next) { - super(next); - } - - @Override - public List<ClientEntity> getEntities() { - return entities; - } - - @Override - public URI getDeltaLink() { - return deltaLink; - } - - @Override - public void setDeltaLink(final URI deltaLink) { - this.deltaLink = deltaLink; - } - - @Override - public List<ClientAnnotation> getAnnotations() { - return annotations; - } - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/17152920/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientEnumValueImpl.java ---------------------------------------------------------------------- diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientEnumValueImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientEnumValueImpl.java deleted file mode 100644 index 12634d4..0000000 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientEnumValueImpl.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.olingo.commons.core.domain; - -import org.apache.olingo.commons.api.domain.AbstractClientValue; -import org.apache.olingo.commons.api.domain.ClientEnumValue; - -public class ClientEnumValueImpl extends AbstractClientValue implements ClientEnumValue { - - private final String value; - - public ClientEnumValueImpl(final String typeName, final String value) { - super(typeName); - this.value = value; - } - - @Override - public String getValue() { - return value; - } - - @Override - public boolean isEnum() { - return true; - } - - @Override - public ClientEnumValue asEnum() { - return this; - } - - @Override - public boolean isComplex() { - return false; - } - - @Override - public String toString() { - return getTypeName() + "'" + getValue() + "'"; - - } - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/17152920/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientObjectFactoryImpl.java ---------------------------------------------------------------------- diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientObjectFactoryImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientObjectFactoryImpl.java deleted file mode 100644 index ed4692f..0000000 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientObjectFactoryImpl.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.olingo.commons.core.domain; - -import java.net.URI; - -import org.apache.olingo.commons.api.domain.ClientCollectionValue; -import org.apache.olingo.commons.api.domain.ClientComplexValue; -import org.apache.olingo.commons.api.domain.ClientDelta; -import org.apache.olingo.commons.api.domain.ClientEntity; -import org.apache.olingo.commons.api.domain.ClientEntitySet; -import org.apache.olingo.commons.api.domain.ClientEnumValue; -import org.apache.olingo.commons.api.domain.ClientInlineEntity; -import org.apache.olingo.commons.api.domain.ClientInlineEntitySet; -import org.apache.olingo.commons.api.domain.ClientLink; -import org.apache.olingo.commons.api.domain.ClientLinkType; -import org.apache.olingo.commons.api.domain.ClientObjectFactory; -import org.apache.olingo.commons.api.domain.ClientPrimitiveValue; -import org.apache.olingo.commons.api.domain.ClientProperty; -import org.apache.olingo.commons.api.domain.ClientSingleton; -import org.apache.olingo.commons.api.domain.ClientValue; -import org.apache.olingo.commons.api.edm.FullQualifiedName; - -public class ClientObjectFactoryImpl implements ClientObjectFactory { - - @Override - public ClientInlineEntitySet newDeepInsertEntitySet(final String name, final ClientEntitySet entitySet) { - return new ClientInlineEntitySet(null, ClientLinkType.ENTITY_SET_NAVIGATION, name, entitySet); - } - - @Override - public ClientInlineEntity newDeepInsertEntity(final String name, final ClientEntity entity) { - return new ClientInlineEntity(null, ClientLinkType.ENTITY_NAVIGATION, name, entity); - } - - @Override - public ClientEntitySet newEntitySet() { - return new ClientEntitySetImpl(); - } - - @Override - public ClientEntitySet newEntitySet(final URI next) { - return new ClientEntitySetImpl(next); - } - - @Override - public ClientEntity newEntity(final FullQualifiedName typeName) { - return new ClientEntityImpl(typeName); - } - - @Override - public ClientEntity newEntity(final FullQualifiedName typeName, final URI link) { - final ClientEntityImpl result = new ClientEntityImpl(typeName); - result.setLink(link); - return result; - } - - @Override - public ClientSingleton newSingleton(final FullQualifiedName typeName) { - return new ClientEntityImpl(typeName); - } - - @Override - public ClientLink newEntityNavigationLink(final String name, final URI link) { - return new ClientLink.Builder().setURI(link). - setType(ClientLinkType.ENTITY_NAVIGATION).setTitle(name).build(); - } - - @Override - public ClientLink newEntitySetNavigationLink(final String name, final URI link) { - return new ClientLink.Builder().setURI(link). - setType(ClientLinkType.ENTITY_SET_NAVIGATION).setTitle(name).build(); - } - - @Override - public ClientLink newAssociationLink(final String name, final URI link) { - return new ClientLink.Builder().setURI(link). - setType(ClientLinkType.ASSOCIATION).setTitle(name).build(); - } - - @Override - public ClientLink newMediaEditLink(final String name, final URI link) { - return new ClientLink.Builder().setURI(link). - setType(ClientLinkType.MEDIA_EDIT).setTitle(name).build(); - } - - @Override - public ClientPrimitiveValue.Builder newPrimitiveValueBuilder() { - return new ClientPrimitiveValueImpl.BuilderImpl(); - } - - @Override - public ClientEnumValue newEnumValue(final String typeName, final String value) { - return new ClientEnumValueImpl(typeName, value); - } - - @Override - public ClientComplexValue newComplexValue(final String typeName) { - return new ClientComplexValueImpl(typeName); - } - - @Override - public ClientCollectionValue<ClientValue> newCollectionValue(final String typeName) { - return new ClientCollectionValueImpl<ClientValue>(typeName); - } - - @Override - public ClientProperty newPrimitiveProperty(final String name, final ClientPrimitiveValue value) { - return new ClientPropertyImpl(name, value); - } - - @Override - public ClientProperty newComplexProperty(final String name, final ClientComplexValue value) { - - return new ClientPropertyImpl(name, value); - } - - @Override - public ClientProperty newCollectionProperty(final String name, - final ClientCollectionValue<? extends ClientValue> value) { - - return new ClientPropertyImpl(name, value); - } - - @Override - public ClientProperty newEnumProperty(final String name, final ClientEnumValue value) { - return new ClientPropertyImpl(name, value); - } - - @Override - public ClientDelta newDelta() { - return new ClientDeltaImpl(); - } - - @Override - public ClientDelta newDelta(final URI next) { - return new ClientDeltaImpl(next); - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/17152920/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientPrimitiveValueImpl.java ---------------------------------------------------------------------- diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientPrimitiveValueImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientPrimitiveValueImpl.java deleted file mode 100644 index 0f6ad2b..0000000 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientPrimitiveValueImpl.java +++ /dev/null @@ -1,222 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.olingo.commons.core.domain; - -import java.util.UUID; - -import org.apache.olingo.commons.api.Constants; -import org.apache.olingo.commons.api.domain.AbstractClientValue; -import org.apache.olingo.commons.api.domain.ClientEnumValue; -import org.apache.olingo.commons.api.domain.ClientPrimitiveValue; -import org.apache.olingo.commons.api.domain.ClientValue; -import org.apache.olingo.commons.api.edm.EdmPrimitiveType; -import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException; -import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; -import org.apache.olingo.commons.api.edm.EdmType; -import org.apache.olingo.commons.api.edm.constants.EdmTypeKind; -import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory; - -public class ClientPrimitiveValueImpl extends AbstractClientValue implements ClientValue, ClientPrimitiveValue { - - public static class BuilderImpl implements Builder { - - private final ClientPrimitiveValueImpl instance; - - public BuilderImpl() { - instance = new ClientPrimitiveValueImpl(); - } - - @Override - public BuilderImpl setType(final EdmType type) { - EdmPrimitiveTypeKind primitiveTypeKind = null; - if (type != null) { - if (type.getKind() != EdmTypeKind.PRIMITIVE) { - throw new IllegalArgumentException(String.format("Provided type %s is not primitive", type)); - } - primitiveTypeKind = EdmPrimitiveTypeKind.valueOf(type.getName()); - } - return setType(primitiveTypeKind); - } - - @Override - public BuilderImpl setType(final EdmPrimitiveTypeKind type) { - if (type == EdmPrimitiveTypeKind.Stream) { - throw new IllegalArgumentException(String.format( - "Cannot build a primitive value for %s", EdmPrimitiveTypeKind.Stream.toString())); - } - if (type == EdmPrimitiveTypeKind.Geography || type == EdmPrimitiveTypeKind.Geometry) { - throw new IllegalArgumentException( - type + "is not an instantiable type. " - + "An entity can declare a property to be of type Geometry. " - + "An instance of an entity MUST NOT have a value of type Geometry. " - + "Each value MUST be of some subtype."); - } - - instance.typeKind = type == null ? EdmPrimitiveTypeKind.String : type; - instance.type = EdmPrimitiveTypeFactory.getInstance(instance.typeKind); - - return this; - } - - @Override - public BuilderImpl setValue(final Object value) { - instance.value = value; - return this; - } - - @Override - public ClientPrimitiveValue build() { - if (instance.type == null) { - setType(EdmPrimitiveTypeKind.String); - } - return instance; - } - - @Override - public ClientPrimitiveValue buildBoolean(final Boolean value) { - return setType(EdmPrimitiveTypeKind.Boolean).setValue(value).build(); - } - - @Override - public ClientPrimitiveValue buildInt16(final Short value) { - return setType(EdmPrimitiveTypeKind.Int16).setValue(value).build(); - } - - @Override - public ClientPrimitiveValue buildInt32(final Integer value) { - return setType(EdmPrimitiveTypeKind.Int32).setValue(value).build(); - } - - @Override - public ClientPrimitiveValue buildInt64(final Long value) { - return setType(EdmPrimitiveTypeKind.Int64).setValue(value).build(); - } - - @Override - public ClientPrimitiveValue buildSingle(final Float value) { - return setType(EdmPrimitiveTypeKind.Single).setValue(value).build(); - } - - @Override - public ClientPrimitiveValue buildDouble(final Double value) { - return setType(EdmPrimitiveTypeKind.Double).setValue(value).build(); - } - - @Override - public ClientPrimitiveValue buildString(final String value) { - return setType(EdmPrimitiveTypeKind.String).setValue(value).build(); - } - - @Override - public ClientPrimitiveValue buildGuid(final UUID value) { - return setType(EdmPrimitiveTypeKind.Guid).setValue(value).build(); - } - - @Override - public ClientPrimitiveValue buildBinary(final byte[] value) { - return setType(EdmPrimitiveTypeKind.Binary).setValue(value).build(); - } - - } - - /** - * Type kind. - */ - private EdmPrimitiveTypeKind typeKind; - - /** - * Type. - */ - private EdmPrimitiveType type; - - /** - * Actual value. - */ - private Object value; - - protected ClientPrimitiveValueImpl() { - super(null); - } - - @Override - public String getTypeName() { - return typeKind.getFullQualifiedName().toString(); - } - - @Override - public EdmPrimitiveTypeKind getTypeKind() { - return typeKind; - } - - @Override - public EdmPrimitiveType getType() { - return type; - } - - @Override - public Object toValue() { - return value; - } - - @Override - public <T> T toCastValue(final Class<T> reference) throws EdmPrimitiveTypeException { - if (value == null) { - return null; - } else if (typeKind.isGeospatial()) { - return reference.cast(value); - } else { - // TODO: set facets - return type.valueOfString(type.valueToString(value, - null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null), - null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null, reference); - } - } - - @Override - public String toString() { - if (value == null) { - return ""; - } else if (typeKind.isGeospatial()) { - return value.toString(); - } else { - try { - // TODO: set facets - return type.valueToString(value, null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null); - } catch (EdmPrimitiveTypeException e) { - throw new IllegalArgumentException(e); - } - } - } - - @Override - public boolean isEnum() { - return false; - } - - @Override - public ClientEnumValue asEnum() { - return null; - } - - @Override - public boolean isComplex() { - return false; - } - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/17152920/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientPropertyImpl.java ---------------------------------------------------------------------- diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientPropertyImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientPropertyImpl.java deleted file mode 100644 index e53c94b..0000000 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientPropertyImpl.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.olingo.commons.core.domain; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; -import org.apache.olingo.commons.api.domain.ClientAnnotatable; -import org.apache.olingo.commons.api.domain.ClientAnnotation; -import org.apache.olingo.commons.api.domain.ClientCollectionValue; -import org.apache.olingo.commons.api.domain.ClientComplexValue; -import org.apache.olingo.commons.api.domain.ClientEnumValue; -import org.apache.olingo.commons.api.domain.ClientPrimitiveValue; -import org.apache.olingo.commons.api.domain.ClientProperty; -import org.apache.olingo.commons.api.domain.ClientValuable; -import org.apache.olingo.commons.api.domain.ClientValue; - -public class ClientPropertyImpl implements ClientProperty, ClientAnnotatable, ClientValuable { - - - private final List<ClientAnnotation> annotations = new ArrayList<ClientAnnotation>(); - private final String name; - private final ClientValue value; - private final ClientValuable valuable; - - public ClientPropertyImpl(final String name, final ClientValue value) { - this.name = name; - this.value = value; - this.valuable = new ClientValuableImpl(value); - } - - /** - * Returns property name. - * - * @return property name. - */ - @Override - public String getName() { - return name; - } - - /** - * Returns property value. - * - * @return property value. - */ - @Override - public ClientValue getValue() { - return value; - } - - /** - * Checks if has null value. - * - * @return 'TRUE' if has null value; 'FALSE' otherwise. - */ - @Override - public boolean hasNullValue() { - return value == null || value.isPrimitive() && value.asPrimitive().toValue() == null; - } - - /** - * Checks if has primitive value. - * - * @return 'TRUE' if has primitive value; 'FALSE' otherwise. - */ - @Override - public boolean hasPrimitiveValue() { - return !hasNullValue() && value.isPrimitive(); - } - - /** - * Gets primitive value. - * - * @return primitive value if exists; null otherwise. - */ - @Override - public ClientPrimitiveValue getPrimitiveValue() { - return hasPrimitiveValue() ? value.asPrimitive() : null; - } - - /** - * Checks if has complex value. - * - * @return 'TRUE' if has complex value; 'FALSE' otherwise. - */ - @Override - public boolean hasComplexValue() { - return !hasNullValue() && value.isComplex(); - } - - /** - * Checks if has collection value. - * - * @return 'TRUE' if has collection value; 'FALSE' otherwise. - */ - @Override - public boolean hasCollectionValue() { - return !hasNullValue() && value.isCollection(); - } - - @Override - public boolean equals(final Object obj) { - return EqualsBuilder.reflectionEquals(this, obj); - } - - @Override - public int hashCode() { - return HashCodeBuilder.reflectionHashCode(this); - } - - @Override - public boolean hasEnumValue() { - return valuable.hasEnumValue(); - } - - @Override - public ClientEnumValue getEnumValue() { - return valuable.getEnumValue(); - } - - @Override - public ClientComplexValue getComplexValue() { - return valuable.getComplexValue(); - } - - @Override - public ClientCollectionValue<ClientValue> getCollectionValue() { - return valuable.getCollectionValue(); - } - - @Override - public List<ClientAnnotation> getAnnotations() { - return annotations; - } - - @Override - public String toString() { - return "ODataPropertyImpl{" - + "name=" + getName() - + ",valuable=" + valuable - + ", annotations=" + annotations - + '}'; - } -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/17152920/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientValuableImpl.java ---------------------------------------------------------------------- diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientValuableImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientValuableImpl.java deleted file mode 100644 index 561d3df..0000000 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/domain/ClientValuableImpl.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.olingo.commons.core.domain; - -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; -import org.apache.commons.lang3.builder.ReflectionToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; -import org.apache.olingo.commons.api.domain.ClientCollectionValue; -import org.apache.olingo.commons.api.domain.ClientComplexValue; -import org.apache.olingo.commons.api.domain.ClientEnumValue; -import org.apache.olingo.commons.api.domain.ClientPrimitiveValue; -import org.apache.olingo.commons.api.domain.ClientValuable; -import org.apache.olingo.commons.api.domain.ClientValue; - -public class ClientValuableImpl implements ClientValuable { - - private final ClientValue value; - - public ClientValuableImpl(final ClientValue value) { - this.value = value; - } - - @Override - public ClientValue getValue() { - return value; - } - - @Override - public boolean hasNullValue() { - return value == null; - } - - @Override - public boolean hasPrimitiveValue() { - return !hasNullValue() && value.isPrimitive(); - } - - @Override - public ClientPrimitiveValue getPrimitiveValue() { - return hasPrimitiveValue() ? value.asPrimitive() : null; - } - - @Override - public boolean hasCollectionValue() { - return !hasNullValue() && value.isCollection(); - } - - @Override - public ClientCollectionValue<ClientValue> getCollectionValue() { - return hasCollectionValue() - ? getValue().<ClientValue> asCollection() - : null; - } - - @Override - public boolean hasComplexValue() { - return !hasNullValue() && value.isComplex(); - } - - @Override - public ClientComplexValue getComplexValue() { - return hasComplexValue() - ? getValue().asComplex() - : null; - } - - @Override - public boolean hasEnumValue() { - return !hasNullValue() && getValue().isEnum(); - } - - @Override - public ClientEnumValue getEnumValue() { - return hasEnumValue() - ? getValue().asEnum() - : null; - } - - @Override - public boolean equals(final Object obj) { - return EqualsBuilder.reflectionEquals(this, obj); - } - - @Override - public int hashCode() { - return HashCodeBuilder.reflectionHashCode(this); - } - - @Override - public String toString() { - return ReflectionToStringBuilder.toString(this, ToStringStyle.MULTI_LINE_STYLE); - } - -} http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/17152920/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmConstantAnnotationExpressionImpl.java ---------------------------------------------------------------------- diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmConstantAnnotationExpressionImpl.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmConstantAnnotationExpressionImpl.java index 7adeb3e..9763596 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmConstantAnnotationExpressionImpl.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/edm/annotation/EdmConstantAnnotationExpressionImpl.java @@ -23,42 +23,41 @@ import java.util.List; import org.apache.commons.lang3.StringUtils; import org.apache.olingo.commons.api.Constants; -import org.apache.olingo.commons.api.domain.ClientEnumValue; -import org.apache.olingo.commons.api.domain.ClientValue; +import org.apache.olingo.commons.api.data.Property; +import org.apache.olingo.commons.api.data.Valuable; +import org.apache.olingo.commons.api.data.ValueType; import org.apache.olingo.commons.api.edm.EdmPrimitiveType; import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException; import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.apache.olingo.commons.api.edm.annotation.EdmConstantAnnotationExpression; import org.apache.olingo.commons.api.edm.annotation.EdmDynamicAnnotationExpression; import org.apache.olingo.commons.api.edm.provider.annotation.ConstantAnnotationExpression; -import org.apache.olingo.commons.core.domain.ClientCollectionValueImpl; -import org.apache.olingo.commons.core.domain.ClientEnumValueImpl; -import org.apache.olingo.commons.core.domain.ClientPrimitiveValueImpl; import org.apache.olingo.commons.core.edm.primitivetype.EdmPrimitiveTypeFactory; public class EdmConstantAnnotationExpressionImpl implements EdmConstantAnnotationExpression { - private final ClientValue value; + private final Valuable value; + private final EdmPrimitiveType type; public EdmConstantAnnotationExpressionImpl(final ConstantAnnotationExpression constExprConstruct) { if (constExprConstruct.getType() == ConstantAnnotationExpression.Type.EnumMember) { - final List<ClientEnumValue> enumValues = new ArrayList<ClientEnumValue>(); + final List<Property> enumValues = new ArrayList<Property>(); String enumTypeName = null; for (String split : StringUtils.split(constExprConstruct.getValue(), ' ')) { final String[] enumSplit = StringUtils.split(split, '/'); enumTypeName = enumSplit[0]; - enumValues.add(new ClientEnumValueImpl(enumSplit[0], enumSplit[1])); + enumValues.add(new Property(enumSplit[0], enumSplit[1])); } if (enumValues.size() == 1) { value = enumValues.get(0); } else { - final ClientCollectionValueImpl<ClientEnumValue> collValue - = new ClientCollectionValueImpl<ClientEnumValue>(enumTypeName); - for (ClientValue enumValue : enumValues) { + final List<Property> collValue = new ArrayList<Property>(); + for (Property enumValue : enumValues) { collValue.add(enumValue); } - value = collValue; + value = new Property(enumTypeName, "name", ValueType.COLLECTION_ENUM, collValue); } + type = null; } else { EdmPrimitiveTypeKind kind; switch (constExprConstruct.getType()) { @@ -96,19 +95,30 @@ public class EdmConstantAnnotationExpressionImpl implements EdmConstantAnnotatio default: kind = EdmPrimitiveTypeKind.String; } - final ClientPrimitiveValueImpl.BuilderImpl primitiveValueBuilder = new ClientPrimitiveValueImpl.BuilderImpl(); - primitiveValueBuilder.setType(kind); +// final ClientPrimitiveValueImpl.BuilderImpl primitiveValueBuilder = new ClientPrimitiveValueImpl.BuilderImpl(); +// primitiveValueBuilder.setType(kind); +// try { +// final EdmPrimitiveType type = EdmPrimitiveTypeFactory.getInstance(kind); +// primitiveValueBuilder.setValue( +// type.valueOfString(constExprConstruct.getValue(), +// null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null, +// type.getDefaultType())); +// } catch (final EdmPrimitiveTypeException e) { +// throw new IllegalArgumentException(e); +// } +// +// value = primitiveValueBuilder.build(); + + type = EdmPrimitiveTypeFactory.getInstance(kind); try { - final EdmPrimitiveType primitiveType = EdmPrimitiveTypeFactory.getInstance(kind); - primitiveValueBuilder.setValue( - primitiveType.valueOfString(constExprConstruct.getValue(), + Object test = type.valueOfString(constExprConstruct.getValue(), null, null, Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null, - primitiveType.getDefaultType())); - } catch (final EdmPrimitiveTypeException e) { + type.getDefaultType()); + value = new Property(kind.getFullQualifiedName().getFullQualifiedNameAsString(), + "name", ValueType.PRIMITIVE, test); + } catch (EdmPrimitiveTypeException e) { throw new IllegalArgumentException(e); } - - value = primitiveValueBuilder.build(); } } @@ -133,8 +143,26 @@ public class EdmConstantAnnotationExpressionImpl implements EdmConstantAnnotatio } @Override - public ClientValue getValue() { + public Valuable getValue() { return value; } + public String toString() { + if (value == null) { + return ""; + } else if(value.isEnum()) { + return value.toString(); + } else if (value.isGeospatial()) { + return value.toString(); + } else { + // TODO: check after copied from ClientPrimitiveValueImpl + try { + return type.valueToString(value.getValue(), null, null, + Constants.DEFAULT_PRECISION, Constants.DEFAULT_SCALE, null); + } catch (EdmPrimitiveTypeException e) { + throw new IllegalArgumentException(e); + } + } + } + } http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/17152920/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomDeserializer.java ---------------------------------------------------------------------- diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomDeserializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomDeserializer.java index 460e367..6b4b72c 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomDeserializer.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomDeserializer.java @@ -46,13 +46,13 @@ import org.apache.olingo.commons.api.data.DeltaLink; import org.apache.olingo.commons.api.data.Entity; import org.apache.olingo.commons.api.data.EntityCollection; import org.apache.olingo.commons.api.data.Link; +import org.apache.olingo.commons.api.data.Operation; import org.apache.olingo.commons.api.data.Property; import org.apache.olingo.commons.api.data.ResWrap; import org.apache.olingo.commons.api.data.Valuable; import org.apache.olingo.commons.api.data.ValueType; -import org.apache.olingo.commons.api.domain.ClientError; -import org.apache.olingo.commons.api.domain.ClientOperation; -import org.apache.olingo.commons.api.domain.ClientPropertyType; +import org.apache.olingo.commons.api.domain.ODataError; +import org.apache.olingo.commons.api.domain.ODataPropertyType; import org.apache.olingo.commons.api.edm.EdmPrimitiveType; import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException; import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; @@ -214,7 +214,7 @@ public class AtomDeserializer extends AbstractAtomDealer implements ODataDeseria valuable.setValue(valueType, values); } - private ClientPropertyType guessPropertyType(final XMLEventReader reader, final EdmTypeInfo typeInfo) + private ODataPropertyType guessPropertyType(final XMLEventReader reader, final EdmTypeInfo typeInfo) throws XMLStreamException { XMLEvent child = null; @@ -227,24 +227,24 @@ public class AtomDeserializer extends AbstractAtomDealer implements ODataDeseria } } - final ClientPropertyType type; + final ODataPropertyType type; if (child == null) { - type = typeInfo == null || typeInfo.isPrimitiveType() ? ClientPropertyType.PRIMITIVE : ClientPropertyType.ENUM; + type = typeInfo == null || typeInfo.isPrimitiveType() ? ODataPropertyType.PRIMITIVE : ODataPropertyType.ENUM; } else { if (child.isStartElement()) { if (Constants.NS_GML.equals(child.asStartElement().getName().getNamespaceURI())) { - type = ClientPropertyType.PRIMITIVE; + type = ODataPropertyType.PRIMITIVE; } else if (elementQName.equals(child.asStartElement().getName())) { - type = ClientPropertyType.COLLECTION; + type = ODataPropertyType.COLLECTION; } else { - type = ClientPropertyType.COMPLEX; + type = ODataPropertyType.COMPLEX; } } else if (child.isCharacters()) { type = typeInfo == null || typeInfo.isPrimitiveType() - ? ClientPropertyType.PRIMITIVE - : ClientPropertyType.ENUM; + ? ODataPropertyType.PRIMITIVE + : ODataPropertyType.ENUM; } else { - type = ClientPropertyType.EMPTY; + type = ODataPropertyType.EMPTY; } } @@ -286,9 +286,9 @@ public class AtomDeserializer extends AbstractAtomDealer implements ODataDeseria valuable.setType(typeInfo.internal()); } - final ClientPropertyType propType = typeInfo == null ? guessPropertyType(reader, typeInfo) : - typeInfo.isCollection() ? ClientPropertyType.COLLECTION : - typeInfo.isPrimitiveType() ? ClientPropertyType.PRIMITIVE : ClientPropertyType.COMPLEX; + final ODataPropertyType propType = typeInfo == null ? guessPropertyType(reader, typeInfo) : + typeInfo.isCollection() ? ODataPropertyType.COLLECTION : + typeInfo.isPrimitiveType() ? ODataPropertyType.PRIMITIVE : ODataPropertyType.COMPLEX; if (nullAttr == null) { switch (propType) { @@ -316,10 +316,10 @@ public class AtomDeserializer extends AbstractAtomDealer implements ODataDeseria valuable.setValue(ValueType.PRIMITIVE, StringUtils.EMPTY); } } else { - valuable.setValue(propType == ClientPropertyType.PRIMITIVE ? ValueType.PRIMITIVE : - propType == ClientPropertyType.ENUM ? ValueType.ENUM : - propType == ClientPropertyType.COMPLEX ? ValueType.COMPLEX : - propType == ClientPropertyType.COLLECTION ? ValueType.COLLECTION_PRIMITIVE : ValueType.PRIMITIVE, + valuable.setValue(propType == ODataPropertyType.PRIMITIVE ? ValueType.PRIMITIVE : + propType == ODataPropertyType.ENUM ? ValueType.ENUM : + propType == ODataPropertyType.COMPLEX ? ValueType.COMPLEX : + propType == ODataPropertyType.COLLECTION ? ValueType.COLLECTION_PRIMITIVE : ValueType.PRIMITIVE, null); } } @@ -649,7 +649,7 @@ public class AtomDeserializer extends AbstractAtomDealer implements ODataDeseria entity.getMediaEditLinks().add(link); } } else if (actionQName.equals(event.asStartElement().getName())) { - final ClientOperation operation = new ClientOperation(); + final Operation operation = new Operation(); final Attribute metadata = event.asStartElement().getAttributeByName(QName.valueOf(Constants.ATTR_METADATA)); if (metadata != null) { @@ -800,8 +800,8 @@ public class AtomDeserializer extends AbstractAtomDealer implements ODataDeseria } } - private ClientError error(final XMLEventReader reader, final StartElement start) throws XMLStreamException { - final ClientError error = new ClientError(); + private ODataError error(final XMLEventReader reader, final StartElement start) throws XMLStreamException { + final ODataError error = new ODataError(); boolean setCode = false; boolean codeSet = false; @@ -851,7 +851,7 @@ public class AtomDeserializer extends AbstractAtomDealer implements ODataDeseria } @Override - public ClientError toError(final InputStream input) throws ODataDeserializerException { + public ODataError toError(final InputStream input) throws ODataDeserializerException { try { final XMLEventReader reader = getReader(input); final StartElement start = skipBeforeFirstStartElement(reader); http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/17152920/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomSerializer.java ---------------------------------------------------------------------- diff --git a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomSerializer.java b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomSerializer.java index 52a1bd3..2a3bb4a 100644 --- a/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomSerializer.java +++ b/lib/commons-core/src/main/java/org/apache/olingo/commons/core/serialization/AtomSerializer.java @@ -38,10 +38,10 @@ import org.apache.olingo.commons.api.data.ContextURL; import org.apache.olingo.commons.api.data.Entity; import org.apache.olingo.commons.api.data.EntityCollection; import org.apache.olingo.commons.api.data.Link; +import org.apache.olingo.commons.api.data.Operation; import org.apache.olingo.commons.api.data.Property; import org.apache.olingo.commons.api.data.ResWrap; import org.apache.olingo.commons.api.data.ValueType; -import org.apache.olingo.commons.api.domain.ClientOperation; import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeException; import org.apache.olingo.commons.api.edm.EdmPrimitiveTypeKind; import org.apache.olingo.commons.api.edm.geo.Geospatial; @@ -302,7 +302,7 @@ public class AtomSerializer extends AbstractAtomDealer implements ODataSerialize links(writer, entity.getMediaEditLinks()); if (serverMode) { - for (ClientOperation operation : entity.getOperations()) { + for (Operation operation : entity.getOperations()) { writer.writeStartElement(namespaceMetadata, Constants.ATOM_ELEM_ACTION); writer.writeAttribute(Constants.ATTR_METADATA, operation.getMetadataAnchor()); writer.writeAttribute(Constants.ATTR_TITLE, operation.getTitle());
