You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@jclouds.apache.org by "Trevor Flanagan (JIRA)" <ji...@apache.org> on 2019/03/26 14:16:00 UTC

[jira] [Created] (JCLOUDS-1492) Dimension Data Feature API Predicates are not usable

Trevor Flanagan created JCLOUDS-1492:
----------------------------------------

             Summary: Dimension Data Feature API Predicates are not usable
                 Key: JCLOUDS-1492
                 URL: https://issues.apache.org/jira/browse/JCLOUDS-1492
             Project: jclouds
          Issue Type: Task
            Reporter: Trevor Flanagan


The predicates exposed in [https://github.com/apache/jclouds-labs/blob/master/dimensiondata/src/main/java/org/jclouds/dimensiondata/cloudcontrol/features/ServerApi.java#L183-L197] and other Feature API are not working as expected.

The issue is that where an interface is marked with {{@Delegate}} anything that exists inside is considered as something that will be invoked over HTTP. In the case of the Predicates these are not the case. The following error occurs when a call to {{api.getNetworkApi().networkDomainNormalPredicate().apply(networkDomainId);}} is made.
{code:java}
Exception in thread "main" java.lang.IllegalStateException: Optional.get() cannot be called on an absent value
at com.google.common.base.Absent.get(Absent.java:47)
at org.jclouds.rest.internal.RestAnnotationProcessor.apply(RestAnnotationProcessor.java:227)
at org.jclouds.rest.internal.RestAnnotationProcessor.apply(RestAnnotationProcessor.java:137)
at org.jclouds.rest.internal.InvokeHttpMethod.toCommand(InvokeHttpMethod.java:189)
at org.jclouds.rest.internal.InvokeHttpMethod.invoke(InvokeHttpMethod.java:85)
at org.jclouds.rest.internal.InvokeHttpMethod.apply(InvokeHttpMethod.java:74)
at org.jclouds.rest.internal.InvokeHttpMethod.apply(InvokeHttpMethod.java:45)
at org.jclouds.reflect.FunctionalReflection$FunctionalInvocationHandler.handleInvocation(FunctionalReflection.java:117)
at com.google.common.reflect.AbstractInvocationHandler.invoke(AbstractInvocationHandler.java:87)
at com.sun.proxy.$Proxy56.networkDomainNormalPredicate(Unknown Source)
at org.jclouds.examples.dimensiondata.cloudcontrol.DeployNetworkDomainVlanAndServer.deployNetworkDomain(DeployNetworkDomainVlanAndServer.java:148)
at org.jclouds.examples.dimensiondata.cloudcontrol.DeployNetworkDomainVlanAndServer.main(DeployNetworkDomainVlanAndServer.java:78){code}
The fix is to move the Predicates into {{org.jclouds.dimensiondata.cloudcontrol.DimensionDataCloudControlApi}} and remove them from the API classes.
{code:java}
public interface DimensionDataCloudControlApi extends Closeable {

   @Delegate
   AccountApi getAccountApi();

   @Delegate
   InfrastructureApi getInfrastructureApi();

   @Delegate
   ServerImageApi getServerImageApi();

   @Delegate
   NetworkApi getNetworkApi();

   @Delegate
   ServerApi getServerApi();

   @Delegate
   TagApi getTagApi();

   @Delegate
   CustomerImageApi getCustomerImageApi();

   @Provides
   @Named(VLAN_DELETED_PREDICATE)
   Predicate<String> vlanDeletedPredicate();

   @Provides
   @Named(NETWORK_DOMAIN_DELETED_PREDICATE)
   Predicate<String> networkDomainDeletedPredicate();

   @Provides
   @Named(NETWORK_DOMAIN_NORMAL_PREDICATE)
   Predicate<String> networkDomainNormalPredicate();

   @Provides
   @Named(VLAN_NORMAL_PREDICATE)
   Predicate<String> vlanNormalPredicate();

   @Provides
   @Named(SERVER_STOPPED_PREDICATE)
   Predicate<String> serverStoppedPredicate();

   @Provides
   @Named(SERVER_DELETED_PREDICATE)
   Predicate<String> serverDeletedPredicate();

   @Provides
   @Named(SERVER_STARTED_PREDICATE)
   Predicate<String> serverStartedPredicate();

   @Provides
   @Named(SERVER_NORMAL_PREDICATE)
   Predicate<String> serverNormalPredicate();

}
{code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)