You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by il...@apache.org on 2014/07/16 10:14:22 UTC
[10/12] [OLINGO-362] OAuth2 supporting abstract class provided +
concrete CXF-based IT
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c541d925/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java b/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java
index dbbb110..999ec1d 100644
--- a/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java
+++ b/fit/src/main/java/org/apache/olingo/fit/AbstractServices.java
@@ -125,22 +125,28 @@ public abstract class AbstractServices {
private static final Pattern REF_PATTERN = Pattern.compile("([$]\\d+)");
protected static final String BOUNDARY = "batch_243234_25424_ef_892u748";
+
protected static final String MULTIPART_MIXED = "multipart/mixed";
- // ContentType.MULTIPART_MIXED.toContentTypeString();
+
protected static final String APPLICATION_OCTET_STREAM = "application/octet-stream";
protected final ODataServiceVersion version;
+
protected final Metadata metadata;
protected final ODataDeserializer atomDeserializer;
+
protected final ODataDeserializer jsonDeserializer;
+
protected final ODataSerializer atomSerializer;
+
protected final ODataSerializer jsonSerializer;
protected final XMLUtilities xml;
+
protected final JSONUtilities json;
- public AbstractServices(final ODataServiceVersion version, final Metadata metadata) throws Exception {
+ public AbstractServices(final ODataServiceVersion version, final Metadata metadata) throws IOException {
this.version = version;
this.metadata = metadata;
@@ -155,7 +161,7 @@ public abstract class AbstractServices {
/**
* Provide sample services.
- *
+ *
* @param accept Accept header.
* @return OData services.
*/
@@ -169,9 +175,9 @@ public abstract class AbstractServices {
}
return xml.createResponse(
- null,
- FSManager.instance(version).readFile(Constants.get(version, ConstantKey.SERVICES), acceptType),
- null, acceptType);
+ null,
+ FSManager.instance(version).readFile(Constants.get(version, ConstantKey.SERVICES), acceptType),
+ null, acceptType);
} catch (Exception e) {
return xml.createFaultResponse(accept, e);
}
@@ -179,7 +185,7 @@ public abstract class AbstractServices {
/**
* Provide sample getMetadata().
- *
+ *
* @return getMetadata().
*/
@GET
@@ -202,13 +208,13 @@ public abstract class AbstractServices {
@Consumes(MULTIPART_MIXED)
@Produces(APPLICATION_OCTET_STREAM + ";boundary=" + BOUNDARY)
public Response batch(
- @HeaderParam("Authorization") @DefaultValue(StringUtils.EMPTY) final String authorization,
- @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer,
- final @Multipart MultipartBody attachment) {
+ @HeaderParam("Authorization") @DefaultValue(StringUtils.EMPTY) final String authorization,
+ @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer,
+ final @Multipart MultipartBody attachment) {
try {
final boolean continueOnError = prefer.contains("odata.continue-on-error");
return xml.createBatchResponse(
- exploreMultipart(attachment.getAllAttachments(), BOUNDARY, continueOnError));
+ exploreMultipart(attachment.getAllAttachments(), BOUNDARY, continueOnError));
} catch (IOException e) {
return xml.createFaultResponse(Accept.XML.toString(version), e);
}
@@ -258,9 +264,8 @@ public abstract class AbstractServices {
}
// ----------------------------------------------
-
protected Response bodyPartRequest(final MimeBodyPart body) throws Exception {
- return bodyPartRequest(body, Collections.<String, String> emptyMap());
+ return bodyPartRequest(body, Collections.<String, String>emptyMap());
}
protected Response bodyPartRequest(final MimeBodyPart body, final Map<String, String> references) throws Exception {
@@ -269,7 +274,7 @@ public abstract class AbstractServices {
Header header = en.nextElement();
final String request =
- header.getName() + (StringUtils.isNotBlank(header.getValue()) ? ":" + header.getValue() : "");
+ header.getName() + (StringUtils.isNotBlank(header.getValue()) ? ":" + header.getValue() : "");
final Matcher matcher = REQUEST_PATTERN.matcher(request);
final Matcher matcherRef = BATCH_REQUEST_REF_PATTERN.matcher(request);
@@ -323,15 +328,16 @@ public abstract class AbstractServices {
}
}
- client.close();
+ // When updating to CXF 3.0.1, uncomment the following line, see CXF-5865
+ //client.close();
}
return res;
}
protected abstract InputStream exploreMultipart(
- final List<Attachment> attachments, final String boundary, final boolean continueOnError)
- throws IOException;
+ final List<Attachment> attachments, final String boundary, final boolean continueOnError)
+ throws IOException;
protected void addItemIntro(final ByteArrayOutputStream bos) throws IOException {
addItemIntro(bos, null);
@@ -352,7 +358,7 @@ public abstract class AbstractServices {
}
protected void addChangesetItemIntro(
- final ByteArrayOutputStream bos, final String contentId, final String cboundary) throws IOException {
+ final ByteArrayOutputStream bos, final String contentId, final String cboundary) throws IOException {
bos.write(("--" + cboundary).getBytes());
bos.write(Constants.CRLF);
bos.write(("Content-ID: " + contentId).getBytes());
@@ -361,12 +367,14 @@ public abstract class AbstractServices {
}
protected void addSingleBatchResponse(
- final Response response, final ByteArrayOutputStream bos) throws IOException {
+ final Response response, final ByteArrayOutputStream bos) throws IOException {
+
addSingleBatchResponse(response, null, bos);
}
protected void addSingleBatchResponse(
- final Response response, final String contentId, final ByteArrayOutputStream bos) throws IOException {
+ final Response response, final String contentId, final ByteArrayOutputStream bos) throws IOException {
+
bos.write("HTTP/1.1 ".getBytes());
bos.write(String.valueOf(response.getStatusInfo().getStatusCode()).getBytes());
bos.write(" ".getBytes());
@@ -403,45 +411,47 @@ public abstract class AbstractServices {
}
protected void addErrorBatchResponse(final Exception e, final ByteArrayOutputStream bos)
- throws IOException {
+ throws IOException {
+
addErrorBatchResponse(e, null, bos);
}
protected void addErrorBatchResponse(final Exception e, final String contentId, final ByteArrayOutputStream bos)
- throws IOException {
+ throws IOException {
+
addSingleBatchResponse(xml.createFaultResponse(Accept.XML.toString(version), e), contentId, bos);
}
@MERGE
@Path("/{entitySetName}({entityId})")
- @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON })
- @Consumes({ MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON })
+ @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON})
+ @Consumes({MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON})
public Response mergeEntity(
- @Context final UriInfo uriInfo,
- @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
- @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType,
- @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer,
- @HeaderParam("If-Match") @DefaultValue(StringUtils.EMPTY) final String ifMatch,
- @PathParam("entitySetName") final String entitySetName,
- @PathParam("entityId") final String entityId,
- final String changes) {
+ @Context final UriInfo uriInfo,
+ @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+ @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType,
+ @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer,
+ @HeaderParam("If-Match") @DefaultValue(StringUtils.EMPTY) final String ifMatch,
+ @PathParam("entitySetName") final String entitySetName,
+ @PathParam("entityId") final String entityId,
+ final String changes) {
return patchEntity(uriInfo, accept, contentType, prefer, ifMatch, entitySetName, entityId, changes);
}
@PATCH
@Path("/{entitySetName}({entityId})")
- @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON })
- @Consumes({ MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON })
+ @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON})
+ @Consumes({MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON})
public Response patchEntity(
- @Context final UriInfo uriInfo,
- @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
- @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType,
- @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer,
- @HeaderParam("If-Match") @DefaultValue(StringUtils.EMPTY) final String ifMatch,
- @PathParam("entitySetName") final String entitySetName,
- @PathParam("entityId") final String entityId,
- final String changes) {
+ @Context final UriInfo uriInfo,
+ @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+ @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType,
+ @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer,
+ @HeaderParam("If-Match") @DefaultValue(StringUtils.EMPTY) final String ifMatch,
+ @PathParam("entitySetName") final String entitySetName,
+ @PathParam("entityId") final String entityId,
+ final String changes) {
try {
final Accept acceptType = Accept.parse(accept, version);
@@ -465,7 +475,7 @@ public abstract class AbstractServices {
throw new UnsupportedMediaTypeException("Unsupported media type");
} else if (contentTypeValue == Accept.ATOM) {
entryChanges = atomDeserializer.toEntity(
- IOUtils.toInputStream(changes, Constants.ENCODING)).getPayload();
+ IOUtils.toInputStream(changes, Constants.ENCODING)).getPayload();
} else {
final ResWrap<Entity> jcont = jsonDeserializer.toEntity(IOUtils.toInputStream(changes, Constants.ENCODING));
entryChanges = jcont.getPayload();
@@ -493,7 +503,7 @@ public abstract class AbstractServices {
writer.close();
final InputStream res = xml.addOrReplaceEntity(
- entityId, entitySetName, new ByteArrayInputStream(content.toByteArray()), container.getPayload());
+ entityId, entitySetName, new ByteArrayInputStream(content.toByteArray()), container.getPayload());
final ResWrap<Entity> cres = atomDeserializer.toEntity(res);
@@ -501,25 +511,25 @@ public abstract class AbstractServices {
final String path = Commons.getEntityBasePath(entitySetName, entityId);
FSManager.instance(version).putInMemory(
- cres, path + File.separatorChar + Constants.get(version, ConstantKey.ENTITY));
+ cres, path + File.separatorChar + Constants.get(version, ConstantKey.ENTITY));
final Response response;
if ("return-content".equalsIgnoreCase(prefer)) {
response = xml.createResponse(
- uriInfo.getRequestUri().toASCIIString(),
- xml.readEntity(entitySetName, entityId, acceptType).getValue(),
- null, acceptType, Response.Status.OK);
+ uriInfo.getRequestUri().toASCIIString(),
+ xml.readEntity(entitySetName, entityId, acceptType).getValue(),
+ null, acceptType, Response.Status.OK);
} else {
res.close();
response = xml.createResponse(
- uriInfo.getRequestUri().toASCIIString(),
- null,
- null,
- acceptType, Response.Status.NO_CONTENT);
+ uriInfo.getRequestUri().toASCIIString(),
+ null,
+ null,
+ acceptType, Response.Status.NO_CONTENT);
}
if (StringUtils.isNotBlank(prefer)) {
- response.getHeaders().put("Preference-Applied", Collections.<Object> singletonList(prefer));
+ response.getHeaders().put("Preference-Applied", Collections.<Object>singletonList(prefer));
}
return response;
@@ -530,16 +540,16 @@ public abstract class AbstractServices {
@PUT
@Path("/{entitySetName}({entityId})")
- @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON })
- @Consumes({ MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON })
+ @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON})
+ @Consumes({MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON})
public Response replaceEntity(
- @Context final UriInfo uriInfo,
- @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
- @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType,
- @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer,
- @PathParam("entitySetName") final String entitySetName,
- @PathParam("entityId") final String entityId,
- final String entity) {
+ @Context final UriInfo uriInfo,
+ @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+ @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType,
+ @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer,
+ @PathParam("entitySetName") final String entitySetName,
+ @PathParam("entityId") final String entityId,
+ final String entity) {
try {
final Accept acceptType = Accept.parse(accept, version);
@@ -549,8 +559,8 @@ public abstract class AbstractServices {
}
final InputStream res = getUtilities(acceptType).addOrReplaceEntity(entityId, entitySetName,
- IOUtils.toInputStream(entity, Constants.ENCODING),
- xml.readEntity(acceptType, IOUtils.toInputStream(entity, Constants.ENCODING)));
+ IOUtils.toInputStream(entity, Constants.ENCODING),
+ xml.readEntity(acceptType, IOUtils.toInputStream(entity, Constants.ENCODING)));
final ResWrap<Entity> cres;
if (acceptType == Accept.ATOM) {
@@ -561,28 +571,28 @@ public abstract class AbstractServices {
final String path = Commons.getEntityBasePath(entitySetName, entityId);
FSManager.instance(version).putInMemory(
- cres, path + File.separatorChar + Constants.get(version, ConstantKey.ENTITY));
+ cres, path + File.separatorChar + Constants.get(version, ConstantKey.ENTITY));
final Response response;
if ("return-content".equalsIgnoreCase(prefer)) {
response = xml.createResponse(
- uriInfo.getRequestUri().toASCIIString(),
- xml.readEntity(entitySetName, entityId, acceptType).getValue(),
- null,
- acceptType,
- Response.Status.OK);
+ uriInfo.getRequestUri().toASCIIString(),
+ xml.readEntity(entitySetName, entityId, acceptType).getValue(),
+ null,
+ acceptType,
+ Response.Status.OK);
} else {
res.close();
response = xml.createResponse(
- uriInfo.getRequestUri().toASCIIString(),
- null,
- null,
- acceptType,
- Response.Status.NO_CONTENT);
+ uriInfo.getRequestUri().toASCIIString(),
+ null,
+ null,
+ acceptType,
+ Response.Status.NO_CONTENT);
}
if (StringUtils.isNotBlank(prefer)) {
- response.getHeaders().put("Preference-Applied", Collections.<Object> singletonList(prefer));
+ response.getHeaders().put("Preference-Applied", Collections.<Object>singletonList(prefer));
}
return response;
@@ -593,15 +603,15 @@ public abstract class AbstractServices {
@POST
@Path("/{entitySetName}")
- @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON })
- @Consumes({ MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_OCTET_STREAM })
+ @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON})
+ @Consumes({MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_OCTET_STREAM})
public Response postNewEntity(
- @Context final UriInfo uriInfo,
- @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
- @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType,
- @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer,
- @PathParam("entitySetName") final String entitySetName,
- final String entity) {
+ @Context final UriInfo uriInfo,
+ @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+ @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType,
+ @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer,
+ @PathParam("entitySetName") final String entitySetName,
+ final String entity) {
try {
final Accept acceptType = Accept.parse(accept, version);
@@ -630,8 +640,11 @@ public abstract class AbstractServices {
prop.setName(id.getKey());
prop.setType(id.getValue().toString());
prop.setValue(ValueType.PRIMITIVE,
- id.getValue() == EdmPrimitiveTypeKind.Int32 ? Integer.parseInt(entityKey) :
- id.getValue() == EdmPrimitiveTypeKind.Guid ? UUID.fromString(entityKey) : entityKey);
+ id.getValue() == EdmPrimitiveTypeKind.Int32
+ ? Integer.parseInt(entityKey)
+ : id.getValue() == EdmPrimitiveTypeKind.Guid
+ ? UUID.fromString(entityKey)
+ : entityKey);
entry.getProperties().add(prop);
}
@@ -666,13 +679,13 @@ public abstract class AbstractServices {
writer.close();
final InputStream serialization =
- xml.addOrReplaceEntity(entityKey, entitySetName, new ByteArrayInputStream(content.toByteArray()), entry);
+ xml.addOrReplaceEntity(entityKey, entitySetName, new ByteArrayInputStream(content.toByteArray()), entry);
ResWrap<Entity> result = atomDeserializer.toEntity(serialization);
result = new ResWrap<Entity>(
- URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX)
- + entitySetName + Constants.get(version, ConstantKey.ODATA_METADATA_ENTITY_SUFFIX)),
- null, result.getPayload());
+ URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX)
+ + entitySetName + Constants.get(version, ConstantKey.ODATA_METADATA_ENTITY_SUFFIX)),
+ null, result.getPayload());
final String path = Commons.getEntityBasePath(entitySetName, entityKey);
FSManager.instance(version).putInMemory(result, path + Constants.get(version, ConstantKey.ENTITY));
@@ -682,22 +695,22 @@ public abstract class AbstractServices {
final Response response;
if ("return-no-content".equalsIgnoreCase(prefer)) {
response = xml.createResponse(
- location,
- null,
- null,
- acceptType,
- Response.Status.NO_CONTENT);
+ location,
+ null,
+ null,
+ acceptType,
+ Response.Status.NO_CONTENT);
} else {
response = xml.createResponse(
- location,
- xml.writeEntity(acceptType, result),
- null,
- acceptType,
- Response.Status.CREATED);
+ location,
+ xml.writeEntity(acceptType, result),
+ null,
+ acceptType,
+ Response.Status.CREATED);
}
if (StringUtils.isNotBlank(prefer)) {
- response.getHeaders().put("Preference-Applied", Collections.<Object> singletonList(prefer));
+ response.getHeaders().put("Preference-Applied", Collections.<Object>singletonList(prefer));
}
return response;
@@ -710,10 +723,10 @@ public abstract class AbstractServices {
@POST
@Path("/Person({entityId})/{type:.*}/Sack")
public Response actionSack(
- @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
- @PathParam("entityId") final String entityId,
- @PathParam("type") final String type,
- @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
+ @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+ @PathParam("entityId") final String entityId,
+ @PathParam("type") final String type,
+ @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
final Map.Entry<Accept, AbstractUtilities> utils = getUtilities(accept, format);
@@ -732,8 +745,8 @@ public abstract class AbstractServices {
final FSManager fsManager = FSManager.instance(version);
fsManager.putInMemory(xml.writeEntity(Accept.ATOM, container),
- fsManager.getAbsolutePath(Commons.getEntityBasePath("Person", entityId) + Constants.get(version,
- ConstantKey.ENTITY), Accept.ATOM));
+ fsManager.getAbsolutePath(Commons.getEntityBasePath("Person", entityId) + Constants.get(version,
+ ConstantKey.ENTITY), Accept.ATOM));
return utils.getValue().createResponse(null, null, null, utils.getKey(), Response.Status.NO_CONTENT);
} catch (Exception e) {
@@ -744,10 +757,10 @@ public abstract class AbstractServices {
@POST
@Path("/Person/{type:.*}/IncreaseSalaries")
public Response actionIncreaseSalaries(
- @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
- @PathParam("type") final String type,
- @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
- final String body) {
+ @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+ @PathParam("type") final String type,
+ @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
+ final String body) {
final String name = "Person";
try {
@@ -763,12 +776,12 @@ public abstract class AbstractServices {
final int n = tree.get("n").asInt();
final StringBuilder path = new StringBuilder(name).
- append(File.separatorChar).append(type).
- append(File.separatorChar);
+ append(File.separatorChar).append(type).
+ append(File.separatorChar);
path.append(metadata.getEntitySet(name).isSingleton()
- ? Constants.get(version, ConstantKey.ENTITY)
- : Constants.get(version, ConstantKey.FEED));
+ ? Constants.get(version, ConstantKey.ENTITY)
+ : Constants.get(version, ConstantKey.FEED));
final InputStream feed = FSManager.instance(version).readFile(path.toString(), acceptType);
@@ -778,20 +791,20 @@ public abstract class AbstractServices {
String newContent = new String(copy.toByteArray(), "UTF-8");
final Pattern salary = Pattern.compile(acceptType == Accept.ATOM
- ? "\\<d:Salary m:type=\"Edm.Int32\"\\>(-?\\d+)\\</d:Salary\\>"
- : "\"Salary\":(-?\\d+),");
+ ? "\\<d:Salary m:type=\"Edm.Int32\"\\>(-?\\d+)\\</d:Salary\\>"
+ : "\"Salary\":(-?\\d+),");
final Matcher salaryMatcher = salary.matcher(newContent);
while (salaryMatcher.find()) {
final Long newSalary = Long.valueOf(salaryMatcher.group(1)) + n;
newContent = newContent.
- replaceAll("\"Salary\":" + salaryMatcher.group(1) + ",",
- "\"Salary\":" + newSalary + ",").
- replaceAll("\\<d:Salary m:type=\"Edm.Int32\"\\>" + salaryMatcher.group(1) + "</d:Salary\\>",
- "<d:Salary m:type=\"Edm.Int32\">" + newSalary + "</d:Salary>");
+ replaceAll("\"Salary\":" + salaryMatcher.group(1) + ",",
+ "\"Salary\":" + newSalary + ",").
+ replaceAll("\\<d:Salary m:type=\"Edm.Int32\"\\>" + salaryMatcher.group(1) + "</d:Salary\\>",
+ "<d:Salary m:type=\"Edm.Int32\">" + newSalary + "</d:Salary>");
}
FSManager.instance(version).putInMemory(IOUtils.toInputStream(newContent, Constants.ENCODING),
- FSManager.instance(version).getAbsolutePath(path.toString(), acceptType));
+ FSManager.instance(version).getAbsolutePath(path.toString(), acceptType));
return xml.createResponse(null, null, null, acceptType, Response.Status.NO_CONTENT);
} catch (Exception e) {
@@ -802,10 +815,10 @@ public abstract class AbstractServices {
@POST
@Path("/Product({entityId})/ChangeProductDimensions")
public Response actionChangeProductDimensions(
- @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
- @PathParam("entityId") final String entityId,
- @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
- final String argument) {
+ @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+ @PathParam("entityId") final String entityId,
+ @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
+ final String argument) {
final Map.Entry<Accept, AbstractUtilities> utils = getUtilities(accept, format);
@@ -826,8 +839,8 @@ public abstract class AbstractServices {
final FSManager fsManager = FSManager.instance(version);
fsManager.putInMemory(xml.writeEntity(Accept.ATOM, container),
- fsManager.getAbsolutePath(Commons.getEntityBasePath("Product", entityId) + Constants.get(version,
- ConstantKey.ENTITY), Accept.ATOM));
+ fsManager.getAbsolutePath(Commons.getEntityBasePath("Product", entityId) + Constants.get(version,
+ ConstantKey.ENTITY), Accept.ATOM));
return utils.getValue().createResponse(null, null, null, utils.getKey(), Response.Status.NO_CONTENT);
} catch (Exception e) {
@@ -838,10 +851,10 @@ public abstract class AbstractServices {
@POST
@Path("/ComputerDetail({entityId})/ResetComputerDetailsSpecifications")
public Response actionResetComputerDetailsSpecifications(
- @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
- @PathParam("entityId") final String entityId,
- @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
- final String argument) {
+ @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+ @PathParam("entityId") final String entityId,
+ @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
+ final String argument) {
final Map.Entry<Accept, AbstractUtilities> utils = getUtilities(accept, format);
@@ -864,8 +877,8 @@ public abstract class AbstractServices {
final FSManager fsManager = FSManager.instance(version);
fsManager.putInMemory(xml.writeEntity(Accept.ATOM, container),
- fsManager.getAbsolutePath(Commons.getEntityBasePath("ComputerDetail", entityId) + Constants.get(version,
- ConstantKey.ENTITY), Accept.ATOM));
+ fsManager.getAbsolutePath(Commons.getEntityBasePath("ComputerDetail", entityId) + Constants.get(version,
+ ConstantKey.ENTITY), Accept.ATOM));
return utils.getValue().createResponse(null, null, null, utils.getKey(), Response.Status.NO_CONTENT);
} catch (Exception e) {
@@ -875,7 +888,7 @@ public abstract class AbstractServices {
/**
* Retrieve entities from the given entity set and the given type.
- *
+ *
* @param accept Accept header.
* @param name entity set.
* @param type entity type.
@@ -884,9 +897,9 @@ public abstract class AbstractServices {
@GET
@Path("/{name}/{type:.*}")
public Response getEntitySet(
- @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
- @PathParam("name") final String name,
- @PathParam("type") final String type) {
+ @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+ @PathParam("name") final String name,
+ @PathParam("type") final String type) {
try {
final Accept acceptType = Accept.parse(accept, version);
@@ -896,12 +909,12 @@ public abstract class AbstractServices {
final String basePath = name + File.separatorChar;
final StringBuilder path = new StringBuilder(name).
- append(File.separatorChar).append(type).
- append(File.separatorChar);
+ append(File.separatorChar).append(type).
+ append(File.separatorChar);
path.append(metadata.getEntitySet(name).isSingleton()
- ? Constants.get(version, ConstantKey.ENTITY)
- : Constants.get(version, ConstantKey.FEED));
+ ? Constants.get(version, ConstantKey.ENTITY)
+ : Constants.get(version, ConstantKey.FEED));
final InputStream feed = FSManager.instance(version).readFile(path.toString(), acceptType);
return xml.createResponse(null, feed, Commons.getETag(basePath, version), acceptType);
@@ -912,7 +925,7 @@ public abstract class AbstractServices {
/**
* Retrieve entity set or function execution sample.
- *
+ *
* @param accept Accept header.
* @param name entity set or function name.
* @param format format query option.
@@ -925,16 +938,16 @@ public abstract class AbstractServices {
@GET
@Path("/{name}")
public Response getEntitySet(
- @Context final UriInfo uriInfo,
- @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
- @PathParam("name") final String name,
- @QueryParam("$top") @DefaultValue(StringUtils.EMPTY) final String top,
- @QueryParam("$skip") @DefaultValue(StringUtils.EMPTY) final String skip,
- @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
- @QueryParam("$inlinecount") @DefaultValue(StringUtils.EMPTY) final String count,
- @QueryParam("$filter") @DefaultValue(StringUtils.EMPTY) final String filter,
- @QueryParam("$orderby") @DefaultValue(StringUtils.EMPTY) final String orderby,
- @QueryParam("$skiptoken") @DefaultValue(StringUtils.EMPTY) final String skiptoken) {
+ @Context final UriInfo uriInfo,
+ @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+ @PathParam("name") final String name,
+ @QueryParam("$top") @DefaultValue(StringUtils.EMPTY) final String top,
+ @QueryParam("$skip") @DefaultValue(StringUtils.EMPTY) final String skip,
+ @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
+ @QueryParam("$inlinecount") @DefaultValue(StringUtils.EMPTY) final String count,
+ @QueryParam("$filter") @DefaultValue(StringUtils.EMPTY) final String filter,
+ @QueryParam("$orderby") @DefaultValue(StringUtils.EMPTY) final String orderby,
+ @QueryParam("$skiptoken") @DefaultValue(StringUtils.EMPTY) final String skiptoken) {
try {
final Accept acceptType;
@@ -962,19 +975,19 @@ public abstract class AbstractServices {
if (StringUtils.isNotBlank(orderby)) {
builder.append(Constants.get(version, ConstantKey.ORDERBY)).append(File.separatorChar).
- append(orderby).append(File.separatorChar);
+ append(orderby).append(File.separatorChar);
}
if (StringUtils.isNotBlank(filter)) {
builder.append(Constants.get(version, ConstantKey.FILTER)).append(File.separatorChar).
- append(filter.replaceAll("/", "."));
+ append(filter.replaceAll("/", "."));
} else if (StringUtils.isNotBlank(skiptoken)) {
builder.append(Constants.get(version, ConstantKey.SKIP_TOKEN)).append(File.separatorChar).
- append(skiptoken);
+ append(skiptoken);
} else {
builder.append(metadata.getEntitySet(name).isSingleton()
- ? Constants.get(version, ConstantKey.ENTITY)
- : Constants.get(version, ConstantKey.FEED));
+ ? Constants.get(version, ConstantKey.ENTITY)
+ : Constants.get(version, ConstantKey.FEED));
}
final InputStream feed = FSManager.instance(version).readFile(builder.toString(), Accept.ATOM);
@@ -1012,10 +1025,10 @@ public abstract class AbstractServices {
writer.close();
return xml.createResponse(
- location,
- new ByteArrayInputStream(content.toByteArray()),
- Commons.getETag(basePath, version),
- acceptType);
+ location,
+ new ByteArrayInputStream(content.toByteArray()),
+ Commons.getETag(basePath, version),
+ acceptType);
}
} catch (Exception e) {
return xml.createFaultResponse(accept, e);
@@ -1027,29 +1040,29 @@ public abstract class AbstractServices {
@GET
@Path("/Person({entityId})")
public Response getPerson(
- @Context final UriInfo uriInfo,
- @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
- @PathParam("entityId") final String entityId,
- @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
+ @Context final UriInfo uriInfo,
+ @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+ @PathParam("entityId") final String entityId,
+ @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
final Map.Entry<Accept, AbstractUtilities> utils = getUtilities(accept, format);
final Response internal = getEntityInternal(uriInfo.getRequestUri().toASCIIString(),
- accept, "Person", entityId, format, null, null, false);
+ accept, "Person", entityId, format, null, null, false);
if (internal.getStatus() == 200) {
InputStream entity = (InputStream) internal.getEntity();
try {
if (utils.getKey() == Accept.JSON_FULLMETA || utils.getKey() == Accept.ATOM) {
entity = utils.getValue().addOperation(entity, "Sack", "#DefaultContainer.Sack",
- uriInfo.getAbsolutePath().toASCIIString()
+ uriInfo.getAbsolutePath().toASCIIString()
+ "/Microsoft.Test.OData.Services.AstoriaDefaultService.SpecialEmployee/Sack");
}
return utils.getValue().createResponse(
- uriInfo.getRequestUri().toASCIIString(),
- entity,
- internal.getHeaderString("ETag"),
- utils.getKey());
+ uriInfo.getRequestUri().toASCIIString(),
+ entity,
+ internal.getHeaderString("ETag"),
+ utils.getKey());
} catch (Exception e) {
LOG.error("Error retrieving entity", e);
return xml.createFaultResponse(accept, e);
@@ -1062,29 +1075,29 @@ public abstract class AbstractServices {
@GET
@Path("/Product({entityId})")
public Response getProduct(
- @Context final UriInfo uriInfo,
- @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
- @PathParam("entityId") final String entityId,
- @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
+ @Context final UriInfo uriInfo,
+ @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+ @PathParam("entityId") final String entityId,
+ @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
final Map.Entry<Accept, AbstractUtilities> utils = getUtilities(accept, format);
final Response internal = getEntityInternal(uriInfo.getRequestUri().toASCIIString(),
- accept, "Product", entityId, format, null, null, false);
+ accept, "Product", entityId, format, null, null, false);
if (internal.getStatus() == 200) {
InputStream entity = (InputStream) internal.getEntity();
try {
if (utils.getKey() == Accept.JSON_FULLMETA || utils.getKey() == Accept.ATOM) {
entity = utils.getValue().addOperation(entity,
- "ChangeProductDimensions", "#DefaultContainer.ChangeProductDimensions",
- uriInfo.getAbsolutePath().toASCIIString() + "/ChangeProductDimensions");
+ "ChangeProductDimensions", "#DefaultContainer.ChangeProductDimensions",
+ uriInfo.getAbsolutePath().toASCIIString() + "/ChangeProductDimensions");
}
return utils.getValue().createResponse(
- uriInfo.getRequestUri().toASCIIString(),
- entity,
- internal.getHeaderString("ETag"),
- utils.getKey());
+ uriInfo.getRequestUri().toASCIIString(),
+ entity,
+ internal.getHeaderString("ETag"),
+ utils.getKey());
} catch (Exception e) {
LOG.error("Error retrieving entity", e);
return xml.createFaultResponse(accept, e);
@@ -1097,29 +1110,29 @@ public abstract class AbstractServices {
@GET
@Path("/ComputerDetail({entityId})")
public Response getComputerDetail(
- @Context final UriInfo uriInfo,
- @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
- @PathParam("entityId") final String entityId,
- @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
+ @Context final UriInfo uriInfo,
+ @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+ @PathParam("entityId") final String entityId,
+ @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
final Map.Entry<Accept, AbstractUtilities> utils = getUtilities(accept, format);
final Response internal = getEntityInternal(uriInfo.getRequestUri().toASCIIString(),
- accept, "ComputerDetail", entityId, format, null, null, false);
+ accept, "ComputerDetail", entityId, format, null, null, false);
if (internal.getStatus() == 200) {
InputStream entity = (InputStream) internal.getEntity();
try {
if (utils.getKey() == Accept.JSON_FULLMETA || utils.getKey() == Accept.ATOM) {
entity = utils.getValue().addOperation(entity,
- "ResetComputerDetailsSpecifications", "#DefaultContainer.ResetComputerDetailsSpecifications",
- uriInfo.getAbsolutePath().toASCIIString() + "/ResetComputerDetailsSpecifications");
+ "ResetComputerDetailsSpecifications", "#DefaultContainer.ResetComputerDetailsSpecifications",
+ uriInfo.getAbsolutePath().toASCIIString() + "/ResetComputerDetailsSpecifications");
}
return utils.getValue().createResponse(
- uriInfo.getRequestUri().toASCIIString(),
- entity,
- internal.getHeaderString("ETag"),
- utils.getKey());
+ uriInfo.getRequestUri().toASCIIString(),
+ entity,
+ internal.getHeaderString("ETag"),
+ utils.getKey());
} catch (Exception e) {
LOG.error("Error retrieving entity", e);
return xml.createFaultResponse(accept, e);
@@ -1131,7 +1144,7 @@ public abstract class AbstractServices {
/**
* Retrieve entity sample.
- *
+ *
* @param accept Accept header.
* @param entitySetName Entity set name.
* @param entityId entity id.
@@ -1143,27 +1156,27 @@ public abstract class AbstractServices {
@GET
@Path("/{entitySetName}({entityId})")
public Response getEntity(
- @Context final UriInfo uriInfo,
- @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
- @PathParam("entitySetName") final String entitySetName,
- @PathParam("entityId") final String entityId,
- @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
- @QueryParam("$expand") @DefaultValue(StringUtils.EMPTY) final String expand,
- @QueryParam("$select") @DefaultValue(StringUtils.EMPTY) final String select) {
+ @Context final UriInfo uriInfo,
+ @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+ @PathParam("entitySetName") final String entitySetName,
+ @PathParam("entityId") final String entityId,
+ @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
+ @QueryParam("$expand") @DefaultValue(StringUtils.EMPTY) final String expand,
+ @QueryParam("$select") @DefaultValue(StringUtils.EMPTY) final String select) {
return getEntityInternal(
- uriInfo.getRequestUri().toASCIIString(), accept, entitySetName, entityId, format, expand, select, false);
+ uriInfo.getRequestUri().toASCIIString(), accept, entitySetName, entityId, format, expand, select, false);
}
protected Response getEntityInternal(
- final String location,
- final String accept,
- final String entitySetName,
- final String entityId,
- final String format,
- String expand,
- final String select,
- final boolean keyAsSegment) {
+ final String location,
+ final String accept,
+ final String entitySetName,
+ final String entityId,
+ final String format,
+ String expand,
+ final String select,
+ final boolean keyAsSegment) {
try {
final Map.Entry<Accept, AbstractUtilities> utils = getUtilities(accept, format);
@@ -1173,15 +1186,15 @@ public abstract class AbstractServices {
}
final Map.Entry<String, InputStream> entityInfo =
- utils.getValue().readEntity(entitySetName, entityId, Accept.ATOM);
+ utils.getValue().readEntity(entitySetName, entityId, Accept.ATOM);
final InputStream entity = entityInfo.getValue();
ResWrap<Entity> container = atomDeserializer.toEntity(entity);
if (container.getContextURL() == null) {
container = new ResWrap<Entity>(URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX)
- + entitySetName + Constants.get(version, ConstantKey.ODATA_METADATA_ENTITY_SUFFIX)),
- container.getMetadataETag(), container.getPayload());
+ + entitySetName + Constants.get(version, ConstantKey.ODATA_METADATA_ENTITY_SUFFIX)),
+ container.getMetadataETag(), container.getPayload());
}
final Entity entry = container.getPayload();
@@ -1234,12 +1247,12 @@ public abstract class AbstractServices {
if (link.getType().equals(Constants.get(version, ConstantKey.ATOM_LINK_ENTRY))) {
// inline entry
final Entity inline = atomDeserializer.toEntity(
- xml.expandEntity(entitySetName, entityId, link.getTitle())).getPayload();
+ xml.expandEntity(entitySetName, entityId, link.getTitle())).getPayload();
rep.setInlineEntity(inline);
} else if (link.getType().equals(Constants.get(version, ConstantKey.ATOM_LINK_FEED))) {
// inline feed
final EntitySet inline = atomDeserializer.toEntitySet(
- xml.expandEntity(entitySetName, entityId, link.getTitle())).getPayload();
+ xml.expandEntity(entitySetName, entityId, link.getTitle())).getPayload();
rep.setInlineEntitySet(inline);
}
replace.put(link, rep);
@@ -1253,10 +1266,10 @@ public abstract class AbstractServices {
}
return xml.createResponse(
- location,
- xml.writeEntity(utils.getKey(), container),
- Commons.getETag(entityInfo.getKey(), version),
- utils.getKey());
+ location,
+ xml.writeEntity(utils.getKey(), container),
+ Commons.getETag(entityInfo.getKey(), version),
+ utils.getKey());
} catch (Exception e) {
LOG.error("Error retrieving entity", e);
return xml.createFaultResponse(accept, e);
@@ -1266,10 +1279,10 @@ public abstract class AbstractServices {
@GET
@Path("/{entitySetName}({entityId})/$value")
public Response getMediaEntity(
- @Context final UriInfo uriInfo,
- @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
- @PathParam("entitySetName") final String entitySetName,
- @PathParam("entityId") final String entityId) {
+ @Context final UriInfo uriInfo,
+ @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+ @PathParam("entitySetName") final String entitySetName,
+ @PathParam("entityId") final String entityId) {
try {
if (!accept.contains("*/*") && !accept.contains("application/octet-stream")) {
@@ -1279,10 +1292,10 @@ public abstract class AbstractServices {
final AbstractUtilities utils = getUtilities(null);
final Map.Entry<String, InputStream> entityInfo = utils.readMediaEntity(entitySetName, entityId);
return utils.createResponse(
- uriInfo.getRequestUri().toASCIIString(),
- entityInfo.getValue(),
- Commons.getETag(entityInfo.getKey(), version),
- null);
+ uriInfo.getRequestUri().toASCIIString(),
+ entityInfo.getValue(),
+ Commons.getETag(entityInfo.getKey(), version),
+ null);
} catch (Exception e) {
LOG.error("Error retrieving entity", e);
@@ -1293,8 +1306,8 @@ public abstract class AbstractServices {
@DELETE
@Path("/{entitySetName}({entityId})")
public Response removeEntity(
- @PathParam("entitySetName") final String entitySetName,
- @PathParam("entityId") final String entityId) {
+ @PathParam("entitySetName") final String entitySetName,
+ @PathParam("entityId") final String entityId) {
try {
final String basePath = entitySetName + File.separatorChar + Commons.getEntityKey(entityId);
@@ -1308,16 +1321,16 @@ public abstract class AbstractServices {
}
private Response replaceProperty(
- final String location,
- final String accept,
- final String contentType,
- final String prefer,
- final String entitySetName,
- final String entityId,
- final String path,
- final String format,
- final String changes,
- final boolean justValue) {
+ final String location,
+ final String accept,
+ final String contentType,
+ final String prefer,
+ final String entitySetName,
+ final String entityId,
+ final String path,
+ final String format,
+ final String changes,
+ final boolean justValue) {
// if the given path is not about any link then search for property
LOG.info("Retrieve property {}", path);
@@ -1327,7 +1340,7 @@ public abstract class AbstractServices {
final String basePath = Commons.getEntityBasePath(entitySetName, entityId);
final ResWrap<Entity> container = xml.readContainerEntity(Accept.ATOM,
- fsManager.readFile(basePath + Constants.get(version, ConstantKey.ENTITY), Accept.ATOM));
+ fsManager.readFile(basePath + Constants.get(version, ConstantKey.ENTITY), Accept.ATOM));
final Entity entry = container.getPayload();
@@ -1354,14 +1367,14 @@ public abstract class AbstractServices {
toBeReplaced.setValue(ValueType.PRIMITIVE, changes);
} else {
final Property pchanges = xml.readProperty(
- Accept.parse(contentType, version),
- IOUtils.toInputStream(changes, Constants.ENCODING));
+ Accept.parse(contentType, version),
+ IOUtils.toInputStream(changes, Constants.ENCODING));
toBeReplaced.setValue(pchanges.getValueType(), pchanges.getValue());
}
fsManager.putInMemory(xml.writeEntity(Accept.ATOM, container),
- fsManager.getAbsolutePath(basePath + Constants.get(version, ConstantKey.ENTITY), Accept.ATOM));
+ fsManager.getAbsolutePath(basePath + Constants.get(version, ConstantKey.ENTITY), Accept.ATOM));
final Response response;
if ("return-content".equalsIgnoreCase(prefer)) {
@@ -1378,7 +1391,7 @@ public abstract class AbstractServices {
}
if (StringUtils.isNotBlank(prefer)) {
- response.getHeaders().put("Preference-Applied", Collections.<Object> singletonList(prefer));
+ response.getHeaders().put("Preference-Applied", Collections.<Object>singletonList(prefer));
}
return response;
@@ -1388,12 +1401,12 @@ public abstract class AbstractServices {
}
private Response deletePropertyValue(
- final String accept,
- final String prefer,
- final String entitySetName,
- final String entityId,
- final String path,
- final String format) {
+ final String accept,
+ final String prefer,
+ final String entitySetName,
+ final String entityId,
+ final String path,
+ final String format) {
try {
Accept acceptType = null;
if (StringUtils.isNotBlank(format)) {
@@ -1408,10 +1421,10 @@ public abstract class AbstractServices {
final AbstractUtilities utils = getUtilities(acceptType);
final InputStream changed = utils.deleteProperty(
- entitySetName,
- entityId,
- Arrays.asList(path.split("/")),
- acceptType);
+ entitySetName,
+ entityId,
+ Arrays.asList(path.split("/")),
+ acceptType);
final Response response;
if ("return-content".equalsIgnoreCase(prefer)) {
@@ -1422,7 +1435,7 @@ public abstract class AbstractServices {
}
if (StringUtils.isNotBlank(prefer)) {
- response.getHeaders().put("Preference-Applied", Collections.<Object> singletonList(prefer));
+ response.getHeaders().put("Preference-Applied", Collections.<Object>singletonList(prefer));
}
return response;
@@ -1434,7 +1447,7 @@ public abstract class AbstractServices {
/**
* Replace property value.
- *
+ *
* @param accept
* @param entitySetName
* @param entityId
@@ -1446,23 +1459,23 @@ public abstract class AbstractServices {
@PUT
@Path("/{entitySetName}({entityId})/{path:.*}/$value")
public Response replacePropertyValue(
- @Context final UriInfo uriInfo,
- @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
- @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType,
- @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer,
- @PathParam("entitySetName") final String entitySetName,
- @PathParam("entityId") final String entityId,
- @PathParam("path") final String path,
- @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
- final String changes) {
+ @Context final UriInfo uriInfo,
+ @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+ @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType,
+ @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer,
+ @PathParam("entitySetName") final String entitySetName,
+ @PathParam("entityId") final String entityId,
+ @PathParam("path") final String path,
+ @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
+ final String changes) {
return replaceProperty(uriInfo.getRequestUri().toASCIIString(),
- accept, contentType, prefer, entitySetName, entityId, path, format, changes, true);
+ accept, contentType, prefer, entitySetName, entityId, path, format, changes, true);
}
/**
* Replace property.
- *
+ *
* @param accept
* @param entitySetName
* @param entityId
@@ -1474,23 +1487,23 @@ public abstract class AbstractServices {
@MERGE
@Path("/{entitySetName}({entityId})/{path:.*}")
public Response mergeProperty(
- @Context final UriInfo uriInfo,
- @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
- @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType,
- @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer,
- @PathParam("entitySetName") final String entitySetName,
- @PathParam("entityId") final String entityId,
- @PathParam("path") final String path,
- @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
- final String changes) {
+ @Context final UriInfo uriInfo,
+ @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+ @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType,
+ @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer,
+ @PathParam("entitySetName") final String entitySetName,
+ @PathParam("entityId") final String entityId,
+ @PathParam("path") final String path,
+ @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
+ final String changes) {
return replaceProperty(uriInfo.getRequestUri().toASCIIString(),
- accept, contentType, prefer, entitySetName, entityId, path, format, changes, false);
+ accept, contentType, prefer, entitySetName, entityId, path, format, changes, false);
}
/**
* Replace property.
- *
+ *
* @param accept
* @param entitySetName
* @param entityId
@@ -1502,37 +1515,37 @@ public abstract class AbstractServices {
@PATCH
@Path("/{entitySetName}({entityId})/{path:.*}")
public Response patchProperty(
- @Context final UriInfo uriInfo,
- @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
- @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType,
- @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer,
- @PathParam("entitySetName") final String entitySetName,
- @PathParam("entityId") final String entityId,
- @PathParam("path") final String path,
- @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
- final String changes) {
+ @Context final UriInfo uriInfo,
+ @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+ @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType,
+ @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer,
+ @PathParam("entitySetName") final String entitySetName,
+ @PathParam("entityId") final String entityId,
+ @PathParam("path") final String path,
+ @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
+ final String changes) {
return replaceProperty(uriInfo.getRequestUri().toASCIIString(),
- accept, contentType, prefer, entitySetName, entityId, path, format, changes, false);
+ accept, contentType, prefer, entitySetName, entityId, path, format, changes, false);
}
@PUT
- @Produces({ MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON })
- @Consumes({ MediaType.WILDCARD, MediaType.APPLICATION_OCTET_STREAM })
+ @Produces({MediaType.APPLICATION_ATOM_XML, MediaType.APPLICATION_JSON})
+ @Consumes({MediaType.WILDCARD, MediaType.APPLICATION_OCTET_STREAM})
@Path("/{entitySetName}({entityId})/$value")
public Response replaceMediaEntity(
- @Context final UriInfo uriInfo,
- @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer,
- @PathParam("entitySetName") final String entitySetName,
- @PathParam("entityId") final String entityId,
- @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
- final String value) {
+ @Context final UriInfo uriInfo,
+ @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer,
+ @PathParam("entitySetName") final String entitySetName,
+ @PathParam("entityId") final String entityId,
+ @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
+ final String value) {
try {
final AbstractUtilities utils = getUtilities(null);
final InputStream res = utils.putMediaInMemory(
- entitySetName, entityId, IOUtils.toInputStream(value, Constants.ENCODING));
+ entitySetName, entityId, IOUtils.toInputStream(value, Constants.ENCODING));
final String location = uriInfo.getRequestUri().toASCIIString().replace("/$value", "");
@@ -1545,7 +1558,7 @@ public abstract class AbstractServices {
}
if (StringUtils.isNotBlank(prefer)) {
- response.getHeaders().put("Preference-Applied", Collections.<Object> singletonList(prefer));
+ response.getHeaders().put("Preference-Applied", Collections.<Object>singletonList(prefer));
}
return response;
@@ -1558,7 +1571,7 @@ public abstract class AbstractServices {
/**
* Replace property.
- *
+ *
* @param accept
* @param entitySetName
* @param entityId
@@ -1570,36 +1583,36 @@ public abstract class AbstractServices {
@PUT
@Path("/{entitySetName}({entityId})/{path:.*}")
public Response replaceProperty(
- @Context final UriInfo uriInfo,
- @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
- @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType,
- @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer,
- @PathParam("entitySetName") final String entitySetName,
- @PathParam("entityId") final String entityId,
- @PathParam("path") final String path,
- @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
- final String changes) {
+ @Context final UriInfo uriInfo,
+ @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+ @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType,
+ @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer,
+ @PathParam("entitySetName") final String entitySetName,
+ @PathParam("entityId") final String entityId,
+ @PathParam("path") final String path,
+ @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
+ final String changes) {
if (xml.isMediaContent(entitySetName + "/" + path)) {
return replaceMediaProperty(prefer, entitySetName, entityId, path, changes);
} else {
return replaceProperty(uriInfo.getRequestUri().toASCIIString(),
- accept, contentType, prefer, entitySetName, entityId, path, format, changes, false);
+ accept, contentType, prefer, entitySetName, entityId, path, format, changes, false);
}
}
private Response replaceMediaProperty(
- final String prefer,
- final String entitySetName,
- final String entityId,
- final String path,
- final String value) {
+ final String prefer,
+ final String entitySetName,
+ final String entityId,
+ final String path,
+ final String value) {
try {
final AbstractUtilities utils = getUtilities(null);
InputStream res = utils.putMediaInMemory(
- entitySetName, entityId, path, IOUtils.toInputStream(value, Constants.ENCODING));
+ entitySetName, entityId, path, IOUtils.toInputStream(value, Constants.ENCODING));
final Response response;
if ("return-content".equalsIgnoreCase(prefer)) {
@@ -1610,7 +1623,7 @@ public abstract class AbstractServices {
}
if (StringUtils.isNotBlank(prefer)) {
- response.getHeaders().put("Preference-Applied", Collections.<Object> singletonList(prefer));
+ response.getHeaders().put("Preference-Applied", Collections.<Object>singletonList(prefer));
}
return response;
@@ -1622,7 +1635,7 @@ public abstract class AbstractServices {
/**
* Nullify property value.
- *
+ *
* @param accept
* @param entitySetName
* @param entityId
@@ -1633,18 +1646,18 @@ public abstract class AbstractServices {
@DELETE
@Path("/{entitySetName}({entityId})/{path:.*}/$value")
public Response deleteProperty(
- @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
- @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer,
- @PathParam("entitySetName") final String entitySetName,
- @PathParam("entityId") final String entityId,
- @PathParam("path") final String path,
- @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
+ @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+ @HeaderParam("Prefer") @DefaultValue(StringUtils.EMPTY) final String prefer,
+ @PathParam("entitySetName") final String entitySetName,
+ @PathParam("entityId") final String entityId,
+ @PathParam("path") final String path,
+ @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
return deletePropertyValue(accept, prefer, entitySetName, entityId, path, format);
}
/**
* Retrieve property sample.
- *
+ *
* @param accept Accept header.
* @param entitySetName Entity set name.
* @param entityId entity id.
@@ -1655,11 +1668,11 @@ public abstract class AbstractServices {
@GET
@Path("/{entitySetName}({entityId})/{path:.*}/$value")
public Response getPathValue(
- @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
- @PathParam("entitySetName") final String entitySetName,
- @PathParam("entityId") final String entityId,
- @PathParam("path") final String path,
- @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
+ @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+ @PathParam("entitySetName") final String entitySetName,
+ @PathParam("entityId") final String entityId,
+ @PathParam("path") final String path,
+ @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
try {
Accept acceptType = null;
@@ -1677,7 +1690,7 @@ public abstract class AbstractServices {
/**
* Retrieve property sample.
- *
+ *
* @param accept Accept header.
* @param entitySetName Entity set name.
* @param entityId entity id.
@@ -1688,11 +1701,11 @@ public abstract class AbstractServices {
@GET
@Path("/{entitySetName}({entityId})/{path:.*}")
public Response getPath(
- @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
- @PathParam("entitySetName") final String entitySetName,
- @PathParam("entityId") final String entityId,
- @PathParam("path") final String path,
- @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
+ @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+ @PathParam("entitySetName") final String entitySetName,
+ @PathParam("entityId") final String entityId,
+ @PathParam("path") final String path,
+ @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
// default utilities
final AbstractUtilities utils = xml;
@@ -1716,9 +1729,9 @@ public abstract class AbstractServices {
final ByteArrayOutputStream content = new ByteArrayOutputStream();
final OutputStreamWriter writer = new OutputStreamWriter(content, Constants.ENCODING);
- final ResWrap<?> container = linkInfo.isFeed() ?
- atomDeserializer.toEntitySet(stream) :
- atomDeserializer.toEntity(stream);
+ final ResWrap<?> container = linkInfo.isFeed()
+ ? atomDeserializer.toEntitySet(stream)
+ : atomDeserializer.toEntity(stream);
if (acceptType == Accept.ATOM) {
atomSerializer.write(writer, container);
} else {
@@ -1730,10 +1743,10 @@ public abstract class AbstractServices {
final String basePath = Commons.getEntityBasePath(entitySetName, entityId);
return xml.createResponse(
- null,
- new ByteArrayInputStream(content.toByteArray()),
- Commons.getETag(basePath, version),
- acceptType);
+ null,
+ new ByteArrayInputStream(content.toByteArray()),
+ Commons.getETag(basePath, version),
+ acceptType);
} catch (NotFoundException e) {
// if the given path is not about any link then search for property
@@ -1746,9 +1759,9 @@ public abstract class AbstractServices {
}
private Response navigateStreamedEntity(
- final String entitySetName,
- final String entityId,
- final String path) throws Exception {
+ final String entitySetName,
+ final String entityId,
+ final String path) throws Exception {
final AbstractUtilities utils = getUtilities(null);
final Map.Entry<String, InputStream> entityInfo = utils.readMediaEntity(entitySetName, entityId, path);
@@ -1756,11 +1769,11 @@ public abstract class AbstractServices {
}
private Response navigateProperty(
- final Accept acceptType,
- final String entitySetName,
- final String entityId,
- final String path,
- final boolean searchForValue) throws Exception {
+ final Accept acceptType,
+ final String entitySetName,
+ final String entityId,
+ final String path,
+ final boolean searchForValue) throws Exception {
if ((searchForValue && acceptType != null && acceptType != Accept.TEXT) || acceptType == Accept.ATOM) {
throw new UnsupportedMediaTypeException("Unsupported media type " + acceptType);
@@ -1792,29 +1805,29 @@ public abstract class AbstractServices {
}
final ResWrap<Property> container = new ResWrap<Property>(
- URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX)
- + (version.compareTo(ODataServiceVersion.V40) >= 0 ?
- entitySetName + "(" + entityId + ")/" + path : property.getType())),
- entryContainer.getMetadataETag(),
- property);
+ URI.create(Constants.get(version, ConstantKey.ODATA_METADATA_PREFIX)
+ + (version.compareTo(ODataServiceVersion.V40) >= 0
+ ? entitySetName + "(" + entityId + ")/" + path : property.getType())),
+ entryContainer.getMetadataETag(),
+ property);
return xml.createResponse(null,
- searchForValue ?
- IOUtils.toInputStream(
- container.getPayload().isNull() ? StringUtils.EMPTY : stringValue(container.getPayload()),
- Constants.ENCODING) :
- utils.writeProperty(acceptType, container),
- Commons.getETag(Commons.getEntityBasePath(entitySetName, entityId), version),
- acceptType);
+ searchForValue
+ ? IOUtils.toInputStream(
+ container.getPayload().isNull() ? StringUtils.EMPTY : stringValue(container.getPayload()),
+ Constants.ENCODING)
+ : utils.writeProperty(acceptType, container),
+ Commons.getETag(Commons.getEntityBasePath(entitySetName, entityId), version),
+ acceptType);
}
private String stringValue(final Property property) {
EdmPrimitiveTypeKind kind = EdmPrimitiveTypeKind.valueOfFQN(version, property.getType());
try {
return EdmPrimitiveTypeFactory.getInstance(kind)
- .valueToString(property.asPrimitive(), null, null,
- org.apache.olingo.commons.api.Constants.DEFAULT_PRECISION,
- org.apache.olingo.commons.api.Constants.DEFAULT_SCALE, null);
+ .valueToString(property.asPrimitive(), null, null,
+ org.apache.olingo.commons.api.Constants.DEFAULT_PRECISION,
+ org.apache.olingo.commons.api.Constants.DEFAULT_SCALE, null);
} catch (final EdmPrimitiveTypeException e) {
return property.asPrimitive().toString();
}
@@ -1822,7 +1835,7 @@ public abstract class AbstractServices {
/**
* Count sample.
- *
+ *
* @param accept Accept header.
* @param entitySetName entity set name.
* @return count.
@@ -1830,8 +1843,8 @@ public abstract class AbstractServices {
@GET
@Path("/{entitySetName}/$count")
public Response count(
- @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
- @PathParam("entitySetName") final String entitySetName) {
+ @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+ @PathParam("entitySetName") final String entitySetName) {
try {
final Accept acceptType = Accept.parse(accept, version, Accept.TEXT);
@@ -1892,8 +1905,8 @@ public abstract class AbstractServices {
alink.getAnnotations().addAll(property.getAnnotations());
alink.setType(navProperties.get(property.getName()).isEntitySet()
- ? Constants.get(version, ConstantKey.ATOM_LINK_FEED)
- : Constants.get(version, ConstantKey.ATOM_LINK_ENTRY));
+ ? Constants.get(version, ConstantKey.ATOM_LINK_FEED)
+ : Constants.get(version, ConstantKey.ATOM_LINK_ENTRY));
alink.setRel(Constants.get(version, ConstantKey.ATOM_LINK_REL) + property.getName());
@@ -1910,8 +1923,8 @@ public abstract class AbstractServices {
for (Object value : property.asCollection()) {
Entity inlineEntity = new EntityImpl();
inlineEntity.setType(navProperties.get(property.getName()).getType());
- for (Property prop : (value instanceof LinkedComplexValue ?
- ((LinkedComplexValue) value).getValue() : ((Valuable) value).asComplex())) {
+ for (Property prop : (value instanceof LinkedComplexValue
+ ? ((LinkedComplexValue) value).getValue() : ((Valuable) value).asComplex())) {
inlineEntity.getProperties().add(prop);
}
inline.getEntities().add(inlineEntity);
@@ -1949,8 +1962,8 @@ public abstract class AbstractServices {
final LinkImpl link = new LinkImpl();
link.setTitle(property.getKey());
link.setType(property.getValue().isEntitySet()
- ? Constants.get(version, ConstantKey.ATOM_LINK_FEED)
- : Constants.get(version, ConstantKey.ATOM_LINK_ENTRY));
+ ? Constants.get(version, ConstantKey.ATOM_LINK_FEED)
+ : Constants.get(version, ConstantKey.ATOM_LINK_ENTRY));
link.setRel(Constants.get(version, ConstantKey.ATOM_LINK_REL) + property.getKey());
link.setHref(entitySetName + "(" + entityKey + ")/" + property.getKey());
entry.getNavigationLinks().add(link);
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c541d925/fit/src/main/java/org/apache/olingo/fit/UnsupportedMediaTypeException.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/UnsupportedMediaTypeException.java b/fit/src/main/java/org/apache/olingo/fit/UnsupportedMediaTypeException.java
index 7b76cd8..30a9bca 100644
--- a/fit/src/main/java/org/apache/olingo/fit/UnsupportedMediaTypeException.java
+++ b/fit/src/main/java/org/apache/olingo/fit/UnsupportedMediaTypeException.java
@@ -23,15 +23,15 @@ public class UnsupportedMediaTypeException extends RuntimeException {
private static final long serialVersionUID = 9076398602010056960L;
/**
- * Creates a new instance of
- * <code>UnsupportedMediaTypeException</code> without detail message.
+ * Creates a new instance of <code>UnsupportedMediaTypeException</code> without detail message.
*/
- public UnsupportedMediaTypeException() {}
+ public UnsupportedMediaTypeException() {
+ super();
+ }
/**
- * Constructs an instance of
- * <code>UnsupportedMediaTypeException</code> with the specified detail message.
- *
+ * Constructs an instance of <code>UnsupportedMediaTypeException</code> with the specified detail message.
+ *
* @param msg the detail message.
*/
public UnsupportedMediaTypeException(final String msg) {
http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/c541d925/fit/src/main/java/org/apache/olingo/fit/V3ActionOverloading.java
----------------------------------------------------------------------
diff --git a/fit/src/main/java/org/apache/olingo/fit/V3ActionOverloading.java b/fit/src/main/java/org/apache/olingo/fit/V3ActionOverloading.java
index 9dd3130..0132a00 100644
--- a/fit/src/main/java/org/apache/olingo/fit/V3ActionOverloading.java
+++ b/fit/src/main/java/org/apache/olingo/fit/V3ActionOverloading.java
@@ -20,6 +20,7 @@ package org.apache.olingo.fit;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
+import java.io.IOException;
import java.io.InputStream;
import java.util.Map;
@@ -52,16 +53,16 @@ import org.springframework.stereotype.Service;
@Path("/V30/ActionOverloading.svc")
public class V3ActionOverloading extends V3Services {
- public V3ActionOverloading() throws Exception {
+ public V3ActionOverloading() throws IOException {
super(new Metadata(FSManager.instance(ODataServiceVersion.V30).readRes(
- "actionOverloading" + StringUtils.capitalize(Constants.get(ODataServiceVersion.V30, ConstantKey.METADATA)),
- Accept.XML), ODataServiceVersion.V30));
+ "actionOverloading" + StringUtils.capitalize(Constants.get(ODataServiceVersion.V30, ConstantKey.METADATA)),
+ Accept.XML), ODataServiceVersion.V30));
}
private Response replaceServiceName(final Response response) {
try {
final String content = IOUtils.toString((InputStream) response.getEntity(), Constants.ENCODING).
- replaceAll("Static\\.svc", "ActionOverloading.svc");
+ replaceAll("Static\\.svc", "ActionOverloading.svc");
final Response.ResponseBuilder builder = Response.status(response.getStatus());
for (String headerName : response.getHeaders().keySet()) {
@@ -90,15 +91,15 @@ public class V3ActionOverloading extends V3Services {
@Override
public Response getMetadata() {
return super.getMetadata("actionOverloading"
- + StringUtils.capitalize(Constants.get(ODataServiceVersion.V30, ConstantKey.METADATA)));
+ + StringUtils.capitalize(Constants.get(ODataServiceVersion.V30, ConstantKey.METADATA)));
}
@POST
@Path("/RetrieveProduct")
public Response unboundRetrieveProduct(
- @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
- @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
- @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType) {
+ @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+ @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
+ @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType) {
final Accept acceptType;
if (StringUtils.isNotBlank(format)) {
@@ -112,7 +113,7 @@ public class V3ActionOverloading extends V3Services {
try {
final InputStream result = FSManager.instance(ODataServiceVersion.V30).
- readFile("actionOverloadingRetrieveProduct", acceptType);
+ readFile("actionOverloadingRetrieveProduct", acceptType);
return replaceServiceName(xml.createResponse(result, null, acceptType));
} catch (Exception e) {
return replaceServiceName(xml.createFaultResponse(accept, e));
@@ -123,10 +124,10 @@ public class V3ActionOverloading extends V3Services {
@Path("/Product({entityId})")
@Override
public Response getProduct(
- @Context final UriInfo uriInfo,
- @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
- @PathParam("entityId") final String entityId,
- @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
+ @Context final UriInfo uriInfo,
+ @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+ @PathParam("entityId") final String entityId,
+ @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
final Map.Entry<Accept, AbstractUtilities> utils = super.getUtilities(accept, format);
@@ -140,12 +141,12 @@ public class V3ActionOverloading extends V3Services {
try {
if (utils.getKey() == Accept.JSON_FULLMETA || utils.getKey() == Accept.ATOM) {
entity = utils.getValue().addOperation(entity, "RetrieveProduct", "#DefaultContainer.RetrieveProduct",
- uriInfo.getAbsolutePath().toASCIIString()
+ uriInfo.getAbsolutePath().toASCIIString()
+ "/RetrieveProduct");
}
return replaceServiceName(utils.getValue().createResponse(
- entity, Commons.getETag(entityInfo.getKey(), ODataServiceVersion.V30), utils.getKey()));
+ entity, Commons.getETag(entityInfo.getKey(), ODataServiceVersion.V30), utils.getKey()));
} catch (Exception e) {
LOG.error("Error retrieving entity", e);
return replaceServiceName(xml.createFaultResponse(accept, e));
@@ -155,9 +156,9 @@ public class V3ActionOverloading extends V3Services {
@POST
@Path("/Product({entityId})/RetrieveProduct")
public Response productBoundRetrieveProduct(
- @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
- @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
- @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType) {
+ @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+ @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
+ @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType) {
return unboundRetrieveProduct(accept, format, contentType);
}
@@ -165,11 +166,11 @@ public class V3ActionOverloading extends V3Services {
@GET
@Path("/OrderLine(OrderId={orderId},ProductId={productId})")
public Response getOrderLine(
- @Context final UriInfo uriInfo,
- @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
- @PathParam("orderId") final String orderId,
- @PathParam("productId") final String productId,
- @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
+ @Context final UriInfo uriInfo,
+ @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+ @PathParam("orderId") final String orderId,
+ @PathParam("productId") final String productId,
+ @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format) {
final Map.Entry<Accept, AbstractUtilities> utils = super.getUtilities(accept, format);
@@ -178,18 +179,18 @@ public class V3ActionOverloading extends V3Services {
}
final Map.Entry<String, InputStream> entityInfo = utils.getValue().
- readEntity("OrderLine", orderId + " " + productId, utils.getKey());
+ readEntity("OrderLine", orderId + " " + productId, utils.getKey());
InputStream entity = entityInfo.getValue();
try {
if (utils.getKey() == Accept.JSON_FULLMETA || utils.getKey() == Accept.ATOM) {
entity = utils.getValue().addOperation(entity, "RetrieveProduct", "#DefaultContainer.RetrieveProduct",
- uriInfo.getAbsolutePath().toASCIIString()
+ uriInfo.getAbsolutePath().toASCIIString()
+ "/RetrieveProduct");
}
return replaceServiceName(utils.getValue().createResponse(
- entity, Commons.getETag(entityInfo.getKey(), ODataServiceVersion.V30), utils.getKey()));
+ entity, Commons.getETag(entityInfo.getKey(), ODataServiceVersion.V30), utils.getKey()));
} catch (Exception e) {
LOG.error("Error retrieving entity", e);
return replaceServiceName(xml.createFaultResponse(accept, e));
@@ -199,9 +200,9 @@ public class V3ActionOverloading extends V3Services {
@POST
@Path("/OrderLine(OrderId={orderId},ProductId={productId})/RetrieveProduct")
public Response orderLineBoundRetrieveProduct(
- @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
- @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
- @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType) {
+ @HeaderParam("Accept") @DefaultValue(StringUtils.EMPTY) final String accept,
+ @QueryParam("$format") @DefaultValue(StringUtils.EMPTY) final String format,
+ @HeaderParam("Content-Type") @DefaultValue(StringUtils.EMPTY) final String contentType) {
return unboundRetrieveProduct(accept, format, contentType);
}