olingo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chall...@apache.org
Subject [1/2] git commit: [OLINGO-327] make client supports shorter operation name in url (not protocol standard)
Date Tue, 24 Jun 2014 14:15:09 GMT
Repository: olingo-odata4
Updated Branches:
  refs/heads/master 4c820a26c -> 156ae7ef6


[OLINGO-327] make client supports shorter operation name in url (not protocol standard)


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4/commit/f40643f9
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4/tree/f40643f9
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4/diff/f40643f9

Branch: refs/heads/master
Commit: f40643f92ecb43b2a135fc413eba318801ae8744
Parents: 1e8ad44
Author: challenh <challenh@microsoft.com>
Authored: Tue Jun 24 12:52:27 2014 +0800
Committer: challenh <challenh@microsoft.com>
Committed: Tue Jun 24 12:52:27 2014 +0800

----------------------------------------------------------------------
 .../commons/OperationInvocationHandler.java     |  5 +++--
 .../olingo/client/api/CommonConfiguration.java  | 23 ++++++++++++++++++++
 .../client/core/AbstractConfiguration.java      | 12 ++++++++++
 3 files changed, 38 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f40643f9/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/OperationInvocationHandler.java
----------------------------------------------------------------------
diff --git a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/OperationInvocationHandler.java
b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/OperationInvocationHandler.java
index b561619..d68efb1 100644
--- a/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/OperationInvocationHandler.java
+++ b/ext/client-proxy/src/main/java/org/apache/olingo/ext/proxy/commons/OperationInvocationHandler.java
@@ -161,6 +161,7 @@ final class OperationInvocationHandler extends AbstractInvocationHandler
impleme
     if (boundOp == null) {
       boundOp = entity.getOperation(new FullQualifiedName(targetFQN.getNamespace(), operation.name()).toString());
     }
+    boolean useOperationFQN = this.getClient().getConfiguration().isUseUrlOperationFQN();
     if (boundOp == null) {
     	// json minimal/none metadata doesn't return operations for entity, so here try creating
it from Edm: 
     	EdmAction action = this.getClient().getEdm(null).getBoundAction(
@@ -170,7 +171,7 @@ final class OperationInvocationHandler extends AbstractInvocationHandler
impleme
     		boundOp.setMetadataAnchor(action.getFullQualifiedName().toString());
     		boundOp.setTitle(boundOp.getMetadataAnchor());
     		boundOp.setTarget(URI.create(entity.getEditLink().toString() + "/" 
-                  + action.getFullQualifiedName().toString()));
+                  + (useOperationFQN ? action.getFullQualifiedName().toString() : operation.name())));
     	}
     }
     if (boundOp == null) {
@@ -182,7 +183,7 @@ final class OperationInvocationHandler extends AbstractInvocationHandler
impleme
     		boundOp.setMetadataAnchor(func.getFullQualifiedName().toString());
     		boundOp.setTitle(boundOp.getMetadataAnchor());
     		boundOp.setTarget(URI.create(entity.getEditLink().toString() + "/" 
-                  + func.getFullQualifiedName().toString()));
+                  + (useOperationFQN ? func.getFullQualifiedName().toString() : operation.name())));
     	}
     }
     if (boundOp == null) {

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f40643f9/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonConfiguration.java
----------------------------------------------------------------------
diff --git a/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonConfiguration.java
b/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonConfiguration.java
index 46f12b3..7a25d8e 100644
--- a/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonConfiguration.java
+++ b/lib/client-api/src/main/java/org/apache/olingo/client/api/CommonConfiguration.java
@@ -216,6 +216,29 @@ public interface CommonConfiguration extends Serializable {
   boolean isAddressingDerivedTypes() ;
 
   /**
+   * Sets whether operation name in request URI should be fully qualified name, which is
required by OData V4 protocol,
+   * but some service may still choose to support shorter name.
+   * <br/>
+   * Example: http://host/service/Customers(2)/NS1.Model.IncreaseSalary VS 
+   * http://host/service/Customers(2)/IncreaseSalary
+   *
+   * @param value 'TRUE' to use this feature.
+   */  
+  void setUseUrlOperationFQN(final boolean value);
+  
+  /**
+   * Sets whether operation name in request URI should be fully qualified name, which is
required by OData V4 protocol,
+   * but some service may still choose to support shorter name.
+   * <br/>
+   * Example: http://host/service/Customers(2)/NS1.Model.IncreaseSalary VS 
+   * http://host/service/Customers(2)/IncreaseSalary
+   *
+   * @return whether whether operation name in request URI should be fully qualified name.
+   * segment.
+   */
+  boolean isUseUrlOperationFQN() ;
+
+  /**
    * Sets whether query URIs in request should contain fully qualified type name.
    * - OData Intermediate Conformance Level:
    * MUST support casting to a derived type according to [OData-URL] if derived types are
present in the model.

http://git-wip-us.apache.org/repos/asf/olingo-odata4/blob/f40643f9/lib/client-core/src/main/java/org/apache/olingo/client/core/AbstractConfiguration.java
----------------------------------------------------------------------
diff --git a/lib/client-core/src/main/java/org/apache/olingo/client/core/AbstractConfiguration.java
b/lib/client-core/src/main/java/org/apache/olingo/client/core/AbstractConfiguration.java
index 888452a..a314dd4 100644
--- a/lib/client-core/src/main/java/org/apache/olingo/client/core/AbstractConfiguration.java
+++ b/lib/client-core/src/main/java/org/apache/olingo/client/core/AbstractConfiguration.java
@@ -54,6 +54,8 @@ public abstract class AbstractConfiguration implements CommonConfiguration
{
   
   private static final String ADDRESS_DERIVED_TYPE = "addressDerivedType";
 
+  private static final String USE_OPERATION_FQN_IN_URL = "useOperationFqnInUrl";
+
   private static final String GZIP_COMPRESSION = "gzipCompression";
 
   private static final String CHUNKING = "chunking";
@@ -225,6 +227,16 @@ public abstract class AbstractConfiguration implements CommonConfiguration
{
   }
   
   @Override
+  public boolean isUseUrlOperationFQN() {
+    return (Boolean) getProperty(USE_OPERATION_FQN_IN_URL, true);
+  }
+
+  @Override
+  public void setUseUrlOperationFQN(final boolean value) {
+    setProperty(USE_OPERATION_FQN_IN_URL, value);
+  }
+  
+  @Override
   public ExecutorService getExecutor() {
     return executor;
   }


Mime
View raw message