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

This commit is contained in:
challenh 2014-06-24 12:52:27 +08:00
parent 1e8ad44a00
commit f40643f92e
3 changed files with 38 additions and 2 deletions

View File

@ -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) {

View File

@ -215,6 +215,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:

View File

@ -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";
@ -224,6 +226,16 @@ public abstract class AbstractConfiguration implements CommonConfiguration {
setProperty(ADDRESS_DERIVED_TYPE, value);
}
@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;