JCLOUDS-785: Leave only Abiquo skeleton to start coding Abiquo 3 provider
Project: http://git-wip-us.apache.org/repos/asf/jclouds-labs/repo Commit: http://git-wip-us.apache.org/repos/asf/jclouds-labs/commit/1b689dc1 Tree: http://git-wip-us.apache.org/repos/asf/jclouds-labs/tree/1b689dc1 Diff: http://git-wip-us.apache.org/repos/asf/jclouds-labs/diff/1b689dc1 Branch: refs/heads/master Commit: 1b689dc17ff1cc78e981ca87e13094b47109d3fa Parents: 3bceb3f Author: Ignasi Barrera <[email protected]> Authored: Tue Nov 25 23:06:09 2014 +0100 Committer: Ignasi Barrera <[email protected]> Committed: Thu Nov 27 15:27:29 2014 +0100 ---------------------------------------------------------------------- abiquo/README.md | 10 - abiquo/pom.xml | 125 +- .../main/java/org/jclouds/abiquo/AbiquoApi.java | 99 +- .../org/jclouds/abiquo/AbiquoApiMetadata.java | 25 +- .../java/org/jclouds/abiquo/AbiquoContext.java | 72 - .../org/jclouds/abiquo/AbiquoFallbacks.java | 153 -- .../jclouds/abiquo/binders/AppendToPath.java | 48 - .../jclouds/abiquo/binders/BindLinkToPath.java | 41 - .../binders/BindLinkToPathAndAcceptHeader.java | 45 - .../abiquo/binders/BindRefsToPayload.java | 63 - .../org/jclouds/abiquo/binders/BindToPath.java | 134 -- .../abiquo/binders/BindToXMLPayloadAndPath.java | 75 - .../cloud/BindHardDiskRefsToPayload.java | 41 - .../binders/cloud/BindIpRefToPayload.java | 56 - .../binders/cloud/BindIpRefsToPayload.java | 63 - .../binders/cloud/BindMoveVolumeToPath.java | 44 - .../BindNetworkConfigurationRefToPayload.java | 68 - .../binders/cloud/BindNetworkRefToPayload.java | 73 - .../cloud/BindUnmanagedIpRefToPayload.java | 59 - .../BindVirtualDatacenterRefToPayload.java | 57 - .../binders/cloud/BindVolumeRefsToPayload.java | 41 - .../infrastructure/AppendMachineIdToPath.java | 44 - .../AppendRemoteServiceTypeToPath.java | 47 - .../BindSupportedDevicesLinkToPath.java | 35 - .../AbiquoComputeServiceContextModule.java | 77 - .../compute/functions/DatacenterToLocation.java | 51 - .../functions/VirtualDatacenterToLocation.java | 73 - .../VirtualMachineStateToNodeState.java | 50 - ...neTemplateInVirtualDatacenterToHardware.java | 90 -- .../VirtualMachineTemplateToImage.java | 86 -- .../functions/VirtualMachineToNodeMetadata.java | 134 -- .../compute/options/AbiquoTemplateOptions.java | 121 -- .../strategy/AbiquoComputeServiceAdapter.java | 335 ----- .../CreateGroupBeforeCreatingNodes.java | 112 -- .../FindCompatibleVirtualDatacenters.java | 32 - .../VirtualApplianceCachingTemplate.java | 145 -- ...irtualDatacentersForImageAndConversions.java | 74 - ...bleVirtualDatacentersForImageBaseFormat.java | 84 -- .../abiquo/config/AbiquoHttpApiModule.java | 80 - .../jclouds/abiquo/config/AbiquoProperties.java | 9 - .../abiquo/domain/DomainWithLimitsWrapper.java | 165 --- .../abiquo/domain/DomainWithTasksWrapper.java | 60 - .../jclouds/abiquo/domain/DomainWrapper.java | 279 ---- .../abiquo/domain/PaginatedCollection.java | 158 -- .../abiquo/domain/builder/LimitsBuilder.java | 94 -- .../jclouds/abiquo/domain/cloud/Conversion.java | 123 -- .../jclouds/abiquo/domain/cloud/HardDisk.java | 158 -- .../abiquo/domain/cloud/VirtualAppliance.java | 344 ----- .../abiquo/domain/cloud/VirtualDatacenter.java | 481 ------ .../abiquo/domain/cloud/VirtualMachine.java | 887 ------------ .../domain/cloud/VirtualMachineTemplate.java | 325 ----- ...rtualMachineTemplateInVirtualDatacenter.java | 44 - .../org/jclouds/abiquo/domain/cloud/Volume.java | 238 --- .../domain/cloud/options/ConversionOptions.java | 70 - .../cloud/options/VirtualApplianceOptions.java | 55 - .../cloud/options/VirtualDatacenterOptions.java | 70 - .../cloud/options/VirtualMachineOptions.java | 55 - .../options/VirtualMachineTemplateOptions.java | 101 -- .../domain/cloud/options/VolumeOptions.java | 55 - .../jclouds/abiquo/domain/config/Category.java | 163 --- .../jclouds/abiquo/domain/config/License.java | 107 -- .../jclouds/abiquo/domain/config/Privilege.java | 52 - .../abiquo/domain/config/SystemProperty.java | 73 - .../domain/config/options/IconOptions.java | 53 - .../domain/config/options/LicenseOptions.java | 63 - .../domain/config/options/PropertyOptions.java | 63 - .../abiquo/domain/enterprise/Enterprise.java | 645 --------- .../domain/enterprise/EnterpriseProperties.java | 78 - .../abiquo/domain/enterprise/Limits.java | 166 --- .../jclouds/abiquo/domain/enterprise/Role.java | 201 --- .../enterprise/TemplateDefinitionList.java | 208 --- .../abiquo/domain/enterprise/TemplateState.java | 65 - .../jclouds/abiquo/domain/enterprise/User.java | 417 ------ .../enterprise/options/EnterpriseOptions.java | 79 - .../domain/enterprise/options/UserOptions.java | 56 - .../org/jclouds/abiquo/domain/event/Event.java | 314 ---- .../domain/event/options/EventOptions.java | 164 --- .../domain/exception/AbiquoException.java | 120 -- .../domain/exception/BuilderException.java | 57 - .../domain/exception/WrapperException.java | 63 - .../domain/infrastructure/Datacenter.java | 794 ---------- .../abiquo/domain/infrastructure/Datastore.java | 82 -- .../abiquo/domain/infrastructure/Machine.java | 626 -------- .../domain/infrastructure/NetworkInterface.java | 72 - .../abiquo/domain/infrastructure/Rack.java | 336 ----- .../domain/infrastructure/RemoteService.java | 243 ---- .../domain/infrastructure/StorageDevice.java | 369 ----- .../infrastructure/StorageDeviceMetadata.java | 54 - .../domain/infrastructure/StoragePool.java | 248 ---- .../abiquo/domain/infrastructure/Tier.java | 130 -- .../options/DatacenterOptions.java | 52 - .../infrastructure/options/IpmiOptions.java | 56 - .../infrastructure/options/MachineOptions.java | 70 - .../options/StoragePoolOptions.java | 57 - .../abiquo/domain/network/AbstractPublicIp.java | 53 - .../abiquo/domain/network/ExternalIp.java | 72 - .../abiquo/domain/network/ExternalNetwork.java | 231 --- .../org/jclouds/abiquo/domain/network/Ip.java | 70 - .../jclouds/abiquo/domain/network/Network.java | 306 ---- .../domain/network/NetworkServiceType.java | 128 -- .../org/jclouds/abiquo/domain/network/Nic.java | 56 - .../abiquo/domain/network/PrivateIp.java | 71 - .../abiquo/domain/network/PrivateNetwork.java | 165 --- .../jclouds/abiquo/domain/network/PublicIp.java | 70 - .../abiquo/domain/network/PublicNetwork.java | 190 --- .../abiquo/domain/network/UnmanagedIp.java | 72 - .../abiquo/domain/network/UnmanagedNetwork.java | 233 --- .../domain/network/options/IpOptions.java | 55 - .../domain/network/options/NetworkOptions.java | 67 - .../abiquo/domain/options/FilterOptions.java | 108 -- .../jclouds/abiquo/domain/task/AsyncJob.java | 70 - .../jclouds/abiquo/domain/task/AsyncTask.java | 141 -- .../abiquo/domain/task/ConversionTask.java | 40 - .../abiquo/domain/task/VirtualMachineTask.java | 40 - .../domain/task/VirtualMachineTemplateTask.java | 40 - .../jclouds/abiquo/domain/util/LinkUtils.java | 55 - .../jclouds/abiquo/fallbacks/MovedVolume.java | 89 -- .../org/jclouds/abiquo/features/AdminApi.java | 180 --- .../org/jclouds/abiquo/features/CloudApi.java | 1253 ---------------- .../org/jclouds/abiquo/features/ConfigApi.java | 255 ---- .../jclouds/abiquo/features/EnterpriseApi.java | 616 -------- .../org/jclouds/abiquo/features/EventApi.java | 70 - .../abiquo/features/InfrastructureApi.java | 1367 ------------------ .../org/jclouds/abiquo/features/TaskApi.java | 77 - .../features/VirtualMachineTemplateApi.java | 258 ---- .../services/AdministrationService.java | 170 --- .../abiquo/features/services/CloudService.java | 81 -- .../abiquo/features/services/EventService.java | 39 - .../features/services/MonitoringService.java | 145 -- .../AppendApiVersionToAbiquoMimeType.java | 16 +- .../jclouds/abiquo/functions/ParseErrors.java | 38 - .../functions/ReturnTaskReferenceOrNull.java | 60 - .../abiquo/functions/auth/GetTokenFromApi.java | 40 +- .../functions/enterprise/ParseEnterpriseId.java | 40 - .../infrastructure/ParseDatacenterId.java | 40 - .../infrastructure/ParseMachineId.java | 40 - .../infrastructure/ParseRemoteServiceType.java | 41 - .../pagination/BasePaginationParser.java | 54 - .../functions/pagination/ParseEnterprises.java | 47 - .../functions/pagination/ParseEvents.java | 47 - .../functions/pagination/ParseExternalIps.java | 47 - .../functions/pagination/ParsePrivateIps.java | 47 - .../functions/pagination/ParsePublicIps.java | 47 - .../functions/pagination/ParseUnmanagedIps.java | 47 - .../abiquo/functions/pagination/ParseUsers.java | 154 -- .../ParseVirtualMachineTemplates.java | 49 - .../pagination/ParseVirtualMachines.java | 49 - .../functions/pagination/ParseVolumes.java | 48 - .../abiquo/handlers/AbiquoErrorHandler.java | 60 +- .../http/filters/AbiquoAuthentication.java | 2 +- .../filters/AppendApiVersionToMediaType.java | 3 +- .../abiquo/internal/AbiquoContextImpl.java | 89 -- .../internal/BaseAdministrationService.java | 231 --- .../abiquo/internal/BaseCloudService.java | 118 -- .../abiquo/internal/BaseEventService.java | 61 - .../abiquo/internal/BaseMonitoringService.java | 294 ---- .../abiquo/monitor/AsyncTaskMonitor.java | 73 - .../abiquo/monitor/ConversionMonitor.java | 73 - .../jclouds/abiquo/monitor/MonitorStatus.java | 31 - .../abiquo/monitor/VirtualApplianceMonitor.java | 121 -- .../abiquo/monitor/VirtualMachineMonitor.java | 169 --- .../abiquo/monitor/events/CompletedEvent.java | 27 - .../abiquo/monitor/events/FailedEvent.java | 27 - .../abiquo/monitor/events/MonitorEvent.java | 65 - .../abiquo/monitor/events/TimeoutEvent.java | 27 - .../functions/AsyncTaskStatusMonitor.java | 64 - .../functions/ConversionStatusMonitor.java | 62 - .../VirtualApplianceDeployMonitor.java | 65 - .../VirtualApplianceUndeployMonitor.java | 70 - .../functions/VirtualMachineDeployMonitor.java | 64 - .../functions/VirtualMachineStateMonitor.java | 61 - .../VirtualMachineUndeployMonitor.java | 73 - .../monitor/handlers/AbstractEventHandler.java | 52 - .../monitor/handlers/BlockingEventHandler.java | 145 -- .../monitor/internal/BaseAsyncTaskMonitor.java | 78 - .../monitor/internal/BaseConversionMonitor.java | 78 - .../internal/BaseVirtualApplianceMonitor.java | 101 -- .../internal/BaseVirtualMachineMonitor.java | 125 -- .../jclouds/abiquo/predicates/IpPredicates.java | 46 - .../abiquo/predicates/LinkPredicates.java | 64 - .../NetworkServiceTypePredicates.java | 35 - .../predicates/VirtualDatacenterPredicates.java | 78 - .../VirtualMachineTemplatePredicates.java | 45 - .../abiquo/reference/ValidationErrors.java | 31 - .../abiquo/reference/rest/ParentLinkName.java | 62 - .../abiquo/rest/annotations/EndpointLink.java | 35 - .../jclouds/abiquo/strategy/ListEntities.java | 26 - .../abiquo/strategy/ListRootEntities.java | 26 - .../abiquo/strategy/cloud/ListAttachedNics.java | 97 -- .../strategy/cloud/ListVirtualAppliances.java | 108 -- .../strategy/cloud/ListVirtualDatacenters.java | 122 -- .../enterprise/ListVirtualMachineTemplates.java | 110 -- .../strategy/infrastructure/ListMachines.java | 129 -- .../services/org.jclouds.apis.ApiMetadata | 1 - .../jclouds/abiquo/AbiquoApiMetadataTest.java | 12 +- .../java/org/jclouds/abiquo/AbiquoApiTest.java | 57 - .../jclouds/abiquo/AbiquoDelegateApiTest.java | 58 - .../abiquo/binders/AppendToPathTest.java | 51 - .../BindLinkToPathAndAcceptHeaderTest.java | 52 - .../abiquo/binders/BindLinkToPathTest.java | 46 - .../jclouds/abiquo/binders/BindToPathTest.java | 156 -- .../cloud/BindHardDiskRefsToPayloadTest.java | 77 - .../binders/cloud/BindIpRefToPayloadTest.java | 64 - .../binders/cloud/BindIpRefsToPayloadTest.java | 78 - .../binders/cloud/BindMoveVolumeToPathTest.java | 70 - ...indNetworkConfigurationRefToPayloadTest.java | 128 -- .../cloud/BindNetworkRefToPayloadTest.java | 61 - .../cloud/BindUnmanagedIpRefToPayloadTest.java | 63 - .../BindVirtualDatacenterRefToPayloadTest.java | 61 - .../cloud/BindVolumeRefsToPayloadTest.java | 77 - .../AppendMachineIdToPathTest.java | 56 - .../AppendRemoteServiceTypeToPathTest.java | 54 - .../BindSupportedDevicesLinkToPathTest.java | 84 -- .../compute/AbiquoComputeServiceLiveTest.java | 102 -- .../functions/DatacenterToLocationTest.java | 46 - .../VirtualDatacenterToLocationTest.java | 93 -- .../VirtualMachineStateToNodeStateTest.java | 43 - ...mplateInVirtualDatacenterToHardwareTest.java | 145 -- .../VirtualMachineTemplateToImageTest.java | 125 -- .../VirtualMachineToNodeMetadataTest.java | 218 --- .../options/AbiquoTemplateOptionsTest.java | 49 - .../abiquo/config/SchedulerModuleTest.java | 39 - .../abiquo/domain/AbiquoVersionLiveApiTest.java | 50 - .../jclouds/abiquo/domain/AdminResources.java | 194 --- .../jclouds/abiquo/domain/CloudResources.java | 455 ------ .../jclouds/abiquo/domain/ConfigResources.java | 155 -- .../org/jclouds/abiquo/domain/DomainUtils.java | 55 - .../abiquo/domain/EnterpriseResources.java | 316 ---- .../abiquo/domain/InfrastructureResources.java | 389 ----- .../jclouds/abiquo/domain/NetworkResources.java | 242 ---- .../abiquo/domain/TemplateResources.java | 169 --- .../abiquo/domain/admin/RoleLiveApiTest.java | 102 -- .../abiquo/domain/cloud/AccountLiveTest.java | 55 - .../domain/cloud/HardDiskLiveApiTest.java | 65 - .../cloud/VirtualApplianceLiveApiTest.java | 91 -- .../domain/cloud/VirtualApplianceLiveTest.java | 130 -- .../cloud/VirtualDatacenterLiveApiTest.java | 177 --- .../domain/cloud/VirtualMachineLiveApiTest.java | 137 -- .../domain/cloud/VirtualMachineLiveTest.java | 179 --- .../VirtualMachineNetworkingLiveApiTest.java | 223 --- .../cloud/VirtualMachineStorageLiveApiTest.java | 152 -- .../VirtualMachineTemplateLiveApiTest.java | 58 - .../abiquo/domain/cloud/VirtualMachineTest.java | 37 - .../abiquo/domain/cloud/VolumeLiveApiTest.java | 131 -- .../domain/config/CategoryLiveApiTest.java | 68 - .../domain/config/LicenseLiveApiTest.java | 44 - .../config/SystemPropertiesLiveApiTest.java | 44 - .../enterprise/EnterpriseLiveApiTest.java | 164 --- .../EnterprisePropertiesLiveApiTest.java | 47 - .../TemplateDefinitionListLiveApiTest.java | 75 - .../domain/enterprise/UserLiveApiTest.java | 105 -- .../abiquo/domain/event/EventLiveApiTest.java | 251 ---- .../infrastructure/DatacenterLiveApiTest.java | 76 - .../infrastructure/MachineLiveApiTest.java | 138 -- .../NetworkServiceTypeLiveApiTest.java | 64 - .../domain/infrastructure/RackLiveApiTest.java | 65 - .../RemoteServiceLiveApiTest.java | 116 -- .../StorageDeviceLiveApiTest.java | 66 - .../infrastructure/StoragePoolLiveApiTest.java | 85 -- .../domain/infrastructure/TierLiveApiTest.java | 67 - .../network/ExternalNetworkLiveApiTest.java | 160 -- .../network/GenericNetworkLiveApiTest.java | 79 - .../network/PrivateNetworkLiveApiTest.java | 146 -- .../network/PublicNetworkLiveApiTest.java | 150 -- .../network/UnmanagedNetworkLiveApiTest.java | 162 --- .../environment/CloudTestEnvironment.java | 221 --- .../InfrastructureTestEnvironment.java | 493 ------- .../abiquo/environment/TestEnvironment.java | 35 - .../AppendApiVersionToAbiquoMimeTypeTest.java | 60 - .../fallbacks/FalseIfNotAvailableTest.java | 105 -- .../abiquo/fallbacks/FalseOn5xxTest.java | 96 -- .../abiquo/fallbacks/MovedVolumeTest.java | 93 -- .../jclouds/abiquo/fallbacks/NullOn303Test.java | 94 -- ...agateAbiquoExceptionOnNotFoundOr4xxTest.java | 68 - .../jclouds/abiquo/features/AdminApiTest.java | 175 --- .../features/BaseAbiquoApiExpectTest.java | 89 -- .../abiquo/features/BaseAbiquoApiTest.java | 87 -- .../abiquo/features/CloudApiExpectTest.java | 590 -------- .../jclouds/abiquo/features/CloudApiTest.java | 1097 -------------- .../jclouds/abiquo/features/ConfigApiTest.java | 279 ---- .../features/EnterpriseApiExpectTest.java | 207 --- .../abiquo/features/EnterpriseApiTest.java | 603 -------- .../abiquo/features/EventApiExpectTest.java | 106 -- .../features/InfrastructureApiExpectTest.java | 424 ------ .../abiquo/features/InfrastructureApiTest.java | 1277 ---------------- .../jclouds/abiquo/features/TaskApiTest.java | 118 -- .../VirtualMachineTemplateApiExpectTest.java | 121 -- .../features/VirtualMachineTemplateApiTest.java | 208 --- .../ReturnTaskReferenceOrNullTest.java | 90 -- .../functions/auth/GetTokenFromApiTest.java | 14 +- .../enterprise/ParseEnterpriseIdTest.java | 56 - .../infrastructure/ParseDatacenterIdTest.java | 56 - .../infrastructure/ParseMachineIdTest.java | 56 - .../ParseRemoteServiceTypeTest.java | 47 - .../AppendApiVersionToMediaTypeTest.java | 122 +- .../abiquo/internal/AsyncMonitorTest.java | 533 ------- .../internal/BaseAbiquoApiLiveApiTest.java | 77 - .../abiquo/internal/BaseAbiquoLiveApiTest.java | 61 - .../internal/BaseAdministrationServiceTest.java | 38 - .../abiquo/internal/BaseCloudServiceTest.java | 37 - .../abiquo/internal/BaseEventServiceTest.java | 34 - .../abiquo/internal/BaseInjectionTest.java | 61 - .../internal/BaseMonitoringServiceTest.java | 90 -- .../functions/AsyncTaskStatusMonitorTest.java | 96 -- .../functions/ConversionStatusMonitorTest.java | 95 -- .../VirtualApplianceDeployMonitorTest.java | 99 -- .../VirtualApplianceUndeployMonitorTest.java | 100 -- .../VirtualMachineDeployMonitorTest.java | 97 -- .../VirtualMachineStateMonitorTest.java | 99 -- .../VirtualMachineUndeployMonitorTest.java | 98 -- .../handlers/BlockingEventHandlerTest.java | 107 -- .../internal/BaseAsyncTaskMonitorTest.java | 36 - .../BaseVirtualApplianceMonitorTest.java | 38 - .../internal/BaseVirtualMachineMonitorTest.java | 37 - .../abiquo/reference/AbiquoTestConstants.java | 29 - .../strategy/BaseAbiquoStrategyLiveApiTest.java | 28 - .../cloud/ListAttachedNicsLiveApiTest.java | 91 -- .../cloud/ListVirtualAppliancesLiveApiTest.java | 46 - .../ListVirtualDatacentersLiveApiTest.java | 62 - .../ListVirtualMachineTemplatesLiveApiTest.java | 46 - .../infrastructure/ListMachinesLiveApiTest.java | 46 - .../java/org/jclouds/abiquo/util/Assert.java | 76 - .../java/org/jclouds/abiquo/util/Config.java | 65 - abiquo/src/test/resources/api-live.properties | 41 - .../test/resources/filters/filters.properties | 47 - abiquo/src/test/resources/license/expired | 21 - abiquo/src/test/resources/logback-test.xml | 94 -- .../resources/payloads/all-vms-lastpage.xml | 31 - abiquo/src/test/resources/payloads/all-vms.xml | 31 - .../payloads/available-templates-lastpage.xml | 43 - .../payloads/available-templates-page.xml | 43 - .../resources/payloads/enterprises-lastpage.xml | 40 - .../resources/payloads/enterprises-page.xml | 40 - .../test/resources/payloads/events-lastpage.xml | 40 - .../src/test/resources/payloads/events-page.xml | 40 - .../resources/payloads/externalips-lastpage.xml | 27 - .../resources/payloads/externalips-page.xml | 27 - .../src/test/resources/payloads/nst-create.xml | 5 - abiquo/src/test/resources/payloads/nst-edit.xml | 7 - abiquo/src/test/resources/payloads/nst-list.xml | 15 - .../resources/payloads/privateips-lastpage.xml | 17 - .../test/resources/payloads/privateips-page.xml | 17 - .../payloads/publicips-available-lastpage.xml | 29 - .../payloads/publicips-available-page.xml | 29 - .../resources/payloads/publicips-lastpage.xml | 25 - .../test/resources/payloads/publicips-page.xml | 25 - .../payloads/publicips-purchased-lastpage.xml | 29 - .../payloads/publicips-purchased-page.xml | 29 - .../resources/payloads/templates-lastpage.xml | 35 - .../test/resources/payloads/templates-page.xml | 35 - .../payloads/unmanagedips-lastpage.xml | 29 - .../resources/payloads/unmanagedips-page.xml | 29 - .../test/resources/payloads/users-lastpage.xml | 24 - .../src/test/resources/payloads/users-page.xml | 39 - .../resources/payloads/vm-accepted-request.xml | 4 - .../src/test/resources/payloads/vm-snapshot.xml | 4 - .../test/resources/payloads/vms-lastpage.xml | 31 - abiquo/src/test/resources/payloads/vms-page.xml | 31 - .../resources/payloads/volumes-lastpage.xml | 18 - .../test/resources/payloads/volumes-page.xml | 18 - 360 files changed, 116 insertions(+), 42918 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/README.md ---------------------------------------------------------------------- diff --git a/abiquo/README.md b/abiquo/README.md deleted file mode 100644 index cdf6b84..0000000 --- a/abiquo/README.md +++ /dev/null @@ -1,10 +0,0 @@ -Jclouds Abiquo Provider -======================= - -This is the jclouds Abiquo provider. It enables compute features for the Abiquo cloud platform. - -Detailed information about the Abiquo REST API can be found in the -[Abiquo documentation page](http://community.abiquo.com). - -If you find any issue in the provider api, please submit it to the [Bug tracking system](http://jira.abiquo.com/browse/ABIQUOJC) and we will do our best to fix it. - http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/pom.xml ---------------------------------------------------------------------- diff --git a/abiquo/pom.xml b/abiquo/pom.xml index 5d07e09..3999eea 100644 --- a/abiquo/pom.xml +++ b/abiquo/pom.xml @@ -32,13 +32,11 @@ <packaging>bundle</packaging> <properties> - <abiquomodel.version>2.3.0</abiquomodel.version> - <abiquoam.version>2.2.0</abiquoam.version> <test.abiquo.endpoint>http://localhost/api</test.abiquo.endpoint> <test.abiquo.identity>FIXME</test.abiquo.identity> <test.abiquo.credential>FIXME</test.abiquo.credential> <test.abiquo.api-version /> - <test.abiquo.build-version /> + <test.abiquo.template /> <jclouds.osgi.export>org.jclouds.abiquo*;version="${project.version}"</jclouds.osgi.export> <jclouds.osgi.import> org.jclouds.labs*;version="${project.version}", @@ -58,60 +56,10 @@ <artifactId>jclouds-compute</artifactId> <version>${jclouds.version}</version> </dependency> - <!-- Abiquo --> <dependency> - <groupId>com.abiquo</groupId> - <artifactId>api-model-transport</artifactId> - <version>${abiquomodel.version}</version> - <exclusions> - <exclusion> - <groupId>javax.ws.rs</groupId> - <artifactId>jsr311-api</artifactId> - </exclusion> - <exclusion> - <groupId>org.uncommons</groupId> - <artifactId>reportng</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>com.abiquo</groupId> - <artifactId>am-model</artifactId> - <version>${abiquoam.version}</version> - <exclusions> - <exclusion> - <groupId>com.abiquo</groupId> - <artifactId>ovfmanager</artifactId> - </exclusion> - <exclusion> - <groupId>javax.ws.rs</groupId> - <artifactId>jsr311-api</artifactId> - </exclusion> - <exclusion> - <groupId>org.uncommons</groupId> - <artifactId>reportng</artifactId> - </exclusion> - </exclusions> - </dependency> - <!-- Required for class SyndLink (imported form RESTLink) : TODO remove this dependency --> - <dependency> - <groupId>org.apache.wink</groupId> - <artifactId>wink-common</artifactId> - <version>1.1-incubating</version> - <exclusions> - <exclusion> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-jdk14</artifactId> - </exclusion> - <exclusion> - <groupId>javax.ws.rs</groupId> - <artifactId>jsr311-api</artifactId> - </exclusion> - <exclusion> - <groupId>javax.xml.stream</groupId> - <artifactId>stax-api</artifactId> - </exclusion> - </exclusions> + <groupId>com.google.auto.value</groupId> + <artifactId>auto-value</artifactId> + <scope>provided</scope> </dependency> <!-- Test dependencies --> <dependency> @@ -152,29 +100,6 @@ </dependency> </dependencies> - <build> - <testResources> - <testResource> - <directory>src/test/resources</directory> - <filtering>true</filtering> - </testResource> - </testResources> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-surefire-plugin</artifactId> - <configuration> - <excludes> - <exclude>**/*IntegrationTest.java</exclude> - <exclude>**/*LiveTest.java</exclude> - <exclude>**/*LiveApiTest.java</exclude> - <exclude>**/*LiveUcsTest.java</exclude> - </excludes> - </configuration> - </plugin> - </plugins> - </build> - <profiles> <profile> <id>live</id> @@ -191,51 +116,13 @@ <goal>test</goal> </goals> <configuration> - <systemPropertyVariables> - <test.abiquo.identity>${test.abiquo.idenfity}</test.abiquo.identity> - <test.abiquo.credential>${test.abiquo.credential}</test.abiquo.credential> - <test.abiquo.api-version>${test.abiquo.api-version}</test.abiquo.api-version> - <test.abiquo.build-version>${test.abiquo.build-version}</test.abiquo.build-version> - </systemPropertyVariables> - </configuration> - </execution> - </executions> - </plugin> - </plugins> - </build> - </profile> - <profile> - <id>api</id> - <build> - <filters> - <filter>src/test/resources/filters/filters.properties</filter> - </filters> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-surefire-plugin</artifactId> - <executions> - <execution> - <id>integration</id> - <phase>integration-test</phase> - <goals> - <goal>test</goal> - </goals> - <configuration> - <!-- Infrastructure tests must not be executed in parallel. - They modify concurrently the same infrastructure resources. --> <threadCount>1</threadCount> - <excludes> - <exclude>none</exclude> - </excludes> - <includes> - <include>**/*LiveApiTest.java</include> - </includes> <systemPropertyVariables> + <test.abiquo.endpoint>${test.abiquo.endpoint}</test.abiquo.endpoint> <test.abiquo.identity>${test.abiquo.identity}</test.abiquo.identity> <test.abiquo.credential>${test.abiquo.credential}</test.abiquo.credential> <test.abiquo.api-version>${test.abiquo.api-version}</test.abiquo.api-version> - <test.abiquo.build-version>${test.abiquo.build-version}</test.abiquo.build-version> + <test.abiquo.template>${test.abiquo.template}</test.abiquo.template> </systemPropertyVariables> </configuration> </execution> http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/AbiquoApi.java ---------------------------------------------------------------------- diff --git a/abiquo/src/main/java/org/jclouds/abiquo/AbiquoApi.java b/abiquo/src/main/java/org/jclouds/abiquo/AbiquoApi.java index 76bee9c..ff64686 100644 --- a/abiquo/src/main/java/org/jclouds/abiquo/AbiquoApi.java +++ b/abiquo/src/main/java/org/jclouds/abiquo/AbiquoApi.java @@ -18,106 +18,9 @@ package org.jclouds.abiquo; import java.io.Closeable; -import javax.inject.Named; -import javax.ws.rs.GET; - -import org.jclouds.Fallbacks.NullOnNotFoundOr404; -import org.jclouds.abiquo.binders.BindLinkToPathAndAcceptHeader; -import org.jclouds.abiquo.features.AdminApi; -import org.jclouds.abiquo.features.CloudApi; -import org.jclouds.abiquo.features.ConfigApi; -import org.jclouds.abiquo.features.EnterpriseApi; -import org.jclouds.abiquo.features.EventApi; -import org.jclouds.abiquo.features.InfrastructureApi; -import org.jclouds.abiquo.features.TaskApi; -import org.jclouds.abiquo.features.VirtualMachineTemplateApi; -import org.jclouds.abiquo.http.filters.AbiquoAuthentication; -import org.jclouds.abiquo.http.filters.AppendApiVersionToMediaType; -import org.jclouds.http.HttpResponse; -import org.jclouds.rest.annotations.BinderParam; -import org.jclouds.rest.annotations.Delegate; -import org.jclouds.rest.annotations.Fallback; -import org.jclouds.rest.annotations.RequestFilters; - -import com.abiquo.model.rest.RESTLink; -import com.abiquo.model.transport.SingleResourceTransportDto; - /** - * Provides synchronous access to Abiquo. - * - * @see API: <a href="http://community.abiquo.com/display/ABI20/API+Reference"> - * http://community.abiquo.com/display/ABI20/API+Reference</a> + * Provides access to Abiquo. */ -@RequestFilters({ AbiquoAuthentication.class, AppendApiVersionToMediaType.class }) public interface AbiquoApi extends Closeable { - /** - * The version of the supported Abiquo API. - */ - String API_VERSION = SingleResourceTransportDto.API_VERSION; - - /** - * The supported build version of the Abiquo Api. - */ - String BUILD_VERSION = "7bbfe95-158721b"; - - /** - * Provides synchronous access to Admin features. - */ - @Delegate - AdminApi getAdminApi(); - - /** - * Provides synchronous access to Infrastructure features. - */ - @Delegate - InfrastructureApi getInfrastructureApi(); - - /** - * Provides synchronous access to Cloud features. - */ - @Delegate - CloudApi getCloudApi(); - - /** - * Provides synchronous access to Apps library features. - */ - @Delegate - VirtualMachineTemplateApi getVirtualMachineTemplateApi(); - - /** - * Provides synchronous access to Enterprise features. - */ - @Delegate - EnterpriseApi getEnterpriseApi(); - - /** - * Provides synchronous access to configuration features. - */ - @Delegate - ConfigApi getConfigApi(); - - /** - * Provides synchronous access to task asynchronous features. - */ - @Delegate - TaskApi getTaskApi(); - - /** - * Provides synchronous access to Event features. - */ - @Delegate - EventApi getEventApi(); - - /** - * Perform a GET request to the given link. - * - * @param link - * The link to get. - * @return The response. - */ - @Named("link:get") - @GET - @Fallback(NullOnNotFoundOr404.class) - HttpResponse get(@BinderParam(BindLinkToPathAndAcceptHeader.class) final RESTLink link); } http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/AbiquoApiMetadata.java ---------------------------------------------------------------------- diff --git a/abiquo/src/main/java/org/jclouds/abiquo/AbiquoApiMetadata.java b/abiquo/src/main/java/org/jclouds/abiquo/AbiquoApiMetadata.java index 7320e59..98e2d18 100644 --- a/abiquo/src/main/java/org/jclouds/abiquo/AbiquoApiMetadata.java +++ b/abiquo/src/main/java/org/jclouds/abiquo/AbiquoApiMetadata.java @@ -16,26 +16,24 @@ */ package org.jclouds.abiquo; -import static org.jclouds.Constants.PROPERTY_MAX_REDIRECTS; -import static org.jclouds.abiquo.config.AbiquoProperties.ASYNC_TASK_MONITOR_DELAY; import static org.jclouds.abiquo.config.AbiquoProperties.CREDENTIAL_TYPE; import java.net.URI; import java.util.Properties; -import org.jclouds.abiquo.compute.config.AbiquoComputeServiceContextModule; import org.jclouds.abiquo.config.AbiquoAuthenticationModule; import org.jclouds.abiquo.config.AbiquoHttpApiModule; -import org.jclouds.concurrent.config.ScheduledExecutorServiceModule; +import org.jclouds.apis.ApiMetadata; import org.jclouds.rest.internal.BaseHttpApiMetadata; -import com.google.common.base.CharMatcher; +import com.google.auto.service.AutoService; import com.google.common.collect.ImmutableSet; import com.google.inject.Module; /** * Implementation of {@link ApiMetadata} for Abiquo API. */ +@AutoService(ApiMetadata.class) public class AbiquoApiMetadata extends BaseHttpApiMetadata<AbiquoApi> { public AbiquoApiMetadata() { @@ -53,34 +51,26 @@ public class AbiquoApiMetadata extends BaseHttpApiMetadata<AbiquoApi> { public static Properties defaultProperties() { Properties properties = BaseHttpApiMetadata.defaultProperties(); - // By default redirects will be handled in the domain objects - properties.setProperty(PROPERTY_MAX_REDIRECTS, "0"); - // The default polling delay between AsyncTask monitor requests - properties.setProperty(ASYNC_TASK_MONITOR_DELAY, "5000"); // By default the provided credential is not a token properties.setProperty(CREDENTIAL_TYPE, "password"); return properties; } public static class Builder extends BaseHttpApiMetadata.Builder<AbiquoApi, Builder> { - private static final String DOCUMENTATION_ROOT = "http://community.abiquo.com/display/ABI" - + CharMatcher.DIGIT.retainFrom(AbiquoApi.API_VERSION); protected Builder() { id("abiquo") .name("Abiquo API") .identityName("API Username") .credentialName("API Password") - .documentation(URI.create(DOCUMENTATION_ROOT + "/API+Reference")) + .documentation(URI.create("http://wiki.abiquo.com/display/ABI32/Api+Reference")) .defaultEndpoint("http://localhost/api") - .version(AbiquoApi.API_VERSION) - .buildVersion(AbiquoApi.BUILD_VERSION) - .view(AbiquoContext.class) + .version("3.2") + // .view(ComputeServiceContext.class) .defaultProperties(AbiquoApiMetadata.defaultProperties()) .defaultModules( ImmutableSet.<Class<? extends Module>> of(AbiquoHttpApiModule.class, - AbiquoAuthenticationModule.class, AbiquoComputeServiceContextModule.class, - ScheduledExecutorServiceModule.class)); + AbiquoAuthenticationModule.class)); } @Override @@ -92,7 +82,6 @@ public class AbiquoApiMetadata extends BaseHttpApiMetadata<AbiquoApi> { protected Builder self() { return this; } - } } http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/AbiquoContext.java ---------------------------------------------------------------------- diff --git a/abiquo/src/main/java/org/jclouds/abiquo/AbiquoContext.java b/abiquo/src/main/java/org/jclouds/abiquo/AbiquoContext.java deleted file mode 100644 index 853a56a..0000000 --- a/abiquo/src/main/java/org/jclouds/abiquo/AbiquoContext.java +++ /dev/null @@ -1,72 +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.jclouds.abiquo; - -import org.jclouds.abiquo.features.services.AdministrationService; -import org.jclouds.abiquo.features.services.CloudService; -import org.jclouds.abiquo.features.services.EventService; -import org.jclouds.abiquo.features.services.MonitoringService; -import org.jclouds.abiquo.internal.AbiquoContextImpl; -import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.rest.ApiContext; - -import com.google.inject.ImplementedBy; - -/** - * Abiquo {@link ComputeServiceContext} implementation to expose high level - * Abiquo functionalities. - */ -@ImplementedBy(AbiquoContextImpl.class) -public interface AbiquoContext extends ComputeServiceContext { - /** - * Returns the Abiquo API context, providing direct access to the Abiquo Rest - * API. - * - * @return The Abiquo API context. - */ - ApiContext<AbiquoApi> getApiContext(); - - /** - * Returns the administration service. - * <p> - * This service provides an entry point to infrastructure administration - * tasks. - */ - AdministrationService getAdministrationService(); - - /** - * Returns the cloud service. - * <p> - * This service provides an entry point to cloud management tasks. - */ - CloudService getCloudService(); - - /** - * Returns the monitoring service. - * <p> - * This service provides an entry point to asynchronous task monitoring - * tasks. - */ - MonitoringService getMonitoringService(); - - /** - * Returns the event service. - * <p> - * This service provides an entry point to event management tasks. - */ - EventService getEventService(); -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/AbiquoFallbacks.java ---------------------------------------------------------------------- diff --git a/abiquo/src/main/java/org/jclouds/abiquo/AbiquoFallbacks.java b/abiquo/src/main/java/org/jclouds/abiquo/AbiquoFallbacks.java deleted file mode 100644 index c4abdea..0000000 --- a/abiquo/src/main/java/org/jclouds/abiquo/AbiquoFallbacks.java +++ /dev/null @@ -1,153 +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.jclouds.abiquo; - -import static com.google.common.base.Throwables.getCausalChain; -import static com.google.common.base.Throwables.propagate; -import static com.google.common.collect.Iterables.find; - -import javax.ws.rs.core.Response.Status; - -import org.jclouds.Fallback; -import org.jclouds.abiquo.domain.exception.AbiquoException; -import org.jclouds.http.HttpResponse; -import org.jclouds.http.HttpResponseException; -import org.jclouds.rest.ResourceNotFoundException; - -import com.google.common.base.Predicate; - -/** - * fallbacks common to abiquo - */ -public final class AbiquoFallbacks { - private AbiquoFallbacks() { - } - - /** - * Return an Abiquo Exception on not found errors. - */ - public static final class PropagateAbiquoExceptionOnNotFoundOr4xx implements Fallback<Object> { - @Override - public Object createOrPropagate(Throwable from) throws Exception { - Throwable exception = find(getCausalChain(from), isNotFoundAndHasAbiquoException(from), null); - throw propagate(exception == null ? from : exception.getCause()); - } - } - - /** - * Return <code>null</code> on 303 response codes when requesting a task. - */ - public static final class NullOn303 implements Fallback<Object> { - @Override - public Object createOrPropagate(Throwable from) throws Exception { - Throwable exception = find(getCausalChain(from), hasResponse(from), null); - - if (exception != null) { - HttpResponseException responseException = (HttpResponseException) exception; - HttpResponse response = responseException.getResponse(); - - if (response != null && response.getStatusCode() == Status.SEE_OTHER.getStatusCode()) { - return null; - } - } - - throw propagate(from); - } - - } - - /** - * Return false on service error exceptions. - */ - public static final class FalseOn5xx implements Fallback<Boolean> { - @Override - public Boolean createOrPropagate(Throwable from) throws Exception { - Throwable exception = find(getCausalChain(from), hasResponse(from), null); - - if (exception != null) { - HttpResponseException responseException = (HttpResponseException) exception; - HttpResponse response = responseException.getResponse(); - - if (response != null && response.getStatusCode() >= 500 && response.getStatusCode() < 600) { - return false; - } - } - - throw propagate(from); - } - - } - - /** - * Return false on service error exceptions. - */ - public static final class FalseIfNotAvailable implements Fallback<Boolean> { - @Override - public Boolean createOrPropagate(Throwable from) throws Exception { - Throwable exception = find(getCausalChain(from), isNotAvailableException(from), null); - - if (exception != null) { - if (exception instanceof HttpResponseException) { - HttpResponseException responseException = (HttpResponseException) exception; - HttpResponse response = responseException.getResponse(); - - if (response != null && response.getStatusCode() >= 500 && response.getStatusCode() < 600) { - return false; - } - } else { - // Will enter here when exception is a ResourceNotFoundException - return false; - } - } - - throw propagate(from); - } - - } - - private static Predicate<Throwable> isNotFoundAndHasAbiquoException(final Throwable exception) { - return new Predicate<Throwable>() { - @Override - public boolean apply(final Throwable input) { - return input instanceof ResourceNotFoundException && input.getCause() instanceof AbiquoException; - } - }; - } - - private static Predicate<Throwable> isNotAvailableException(final Throwable exception) { - return new Predicate<Throwable>() { - @Override - public boolean apply(final Throwable input) { - boolean notAvailable = input instanceof HttpResponseException - && ((HttpResponseException) input).getResponse() != null; - - notAvailable |= input instanceof ResourceNotFoundException; - - return notAvailable; - } - }; - } - - private static Predicate<Throwable> hasResponse(final Throwable exception) { - return new Predicate<Throwable>() { - @Override - public boolean apply(final Throwable input) { - return input instanceof HttpResponseException && ((HttpResponseException) input).getResponse() != null; - } - }; - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/binders/AppendToPath.java ---------------------------------------------------------------------- diff --git a/abiquo/src/main/java/org/jclouds/abiquo/binders/AppendToPath.java b/abiquo/src/main/java/org/jclouds/abiquo/binders/AppendToPath.java deleted file mode 100644 index 5b807b7..0000000 --- a/abiquo/src/main/java/org/jclouds/abiquo/binders/AppendToPath.java +++ /dev/null @@ -1,48 +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.jclouds.abiquo.binders; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.net.URI; - -import javax.inject.Singleton; - -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.Binder; - -/** - * Appends the parameter value to the end of the request URI. - */ -@Singleton -public class AppendToPath implements Binder { - @SuppressWarnings("unchecked") - @Override - public <R extends HttpRequest> R bindToRequest(final R request, final Object input) { - // Append the parameter to the request URI - String valueToAppend = getValue(request, checkNotNull(input, "input")); - URI path = URI.create(request.getEndpoint().toString() + "/" + valueToAppend); - return (R) request.toBuilder().endpoint(path).build(); - } - - /** - * Get the value that will be appended to the request URI. - */ - protected <R extends HttpRequest> String getValue(final R request, final Object input) { - return input.toString(); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/binders/BindLinkToPath.java ---------------------------------------------------------------------- diff --git a/abiquo/src/main/java/org/jclouds/abiquo/binders/BindLinkToPath.java b/abiquo/src/main/java/org/jclouds/abiquo/binders/BindLinkToPath.java deleted file mode 100644 index c36d6c1..0000000 --- a/abiquo/src/main/java/org/jclouds/abiquo/binders/BindLinkToPath.java +++ /dev/null @@ -1,41 +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.jclouds.abiquo.binders; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.inject.Singleton; - -import org.jclouds.rest.internal.GeneratedHttpRequest; - -import com.abiquo.model.rest.RESTLink; - -/** - * Binds the given link to the uri. - */ -@Singleton -public class BindLinkToPath extends BindToPath { - - @Override - protected String getNewEndpoint(final GeneratedHttpRequest gRequest, final Object input) { - checkArgument(checkNotNull(input, "input") instanceof RESTLink, "this binder is only valid for RESTLink objects"); - - return ((RESTLink) input).getHref(); - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/binders/BindLinkToPathAndAcceptHeader.java ---------------------------------------------------------------------- diff --git a/abiquo/src/main/java/org/jclouds/abiquo/binders/BindLinkToPathAndAcceptHeader.java b/abiquo/src/main/java/org/jclouds/abiquo/binders/BindLinkToPathAndAcceptHeader.java deleted file mode 100644 index c18e67f..0000000 --- a/abiquo/src/main/java/org/jclouds/abiquo/binders/BindLinkToPathAndAcceptHeader.java +++ /dev/null @@ -1,45 +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.jclouds.abiquo.binders; - -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.inject.Singleton; - -import org.jclouds.http.HttpRequest; - -import com.abiquo.model.rest.RESTLink; -import com.google.common.annotations.VisibleForTesting; -import com.google.common.net.HttpHeaders; - -/** - * Binds the given link to the uri and the Accept header. - */ -@Singleton -public class BindLinkToPathAndAcceptHeader extends BindLinkToPath { - @Override - public <R extends HttpRequest> R bindToRequest(final R request, final Object input) { - R updatedRequest = super.bindToRequest(request, input); - return addHeader(updatedRequest, HttpHeaders.ACCEPT, ((RESTLink) input).getType()); - } - - @SuppressWarnings("unchecked") - @VisibleForTesting - <R extends HttpRequest> R addHeader(final R request, final String header, final String value) { - return (R) request.toBuilder().replaceHeader(HttpHeaders.ACCEPT, checkNotNull(value, "value")).build(); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/binders/BindRefsToPayload.java ---------------------------------------------------------------------- diff --git a/abiquo/src/main/java/org/jclouds/abiquo/binders/BindRefsToPayload.java b/abiquo/src/main/java/org/jclouds/abiquo/binders/BindRefsToPayload.java deleted file mode 100644 index ccd74da..0000000 --- a/abiquo/src/main/java/org/jclouds/abiquo/binders/BindRefsToPayload.java +++ /dev/null @@ -1,63 +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.jclouds.abiquo.binders; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.inject.Inject; - -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.binders.BindToXMLPayload; -import org.jclouds.xml.XMLParser; - -import com.abiquo.model.rest.RESTLink; -import com.abiquo.model.transport.LinksDto; -import com.abiquo.model.transport.SingleResourceTransportDto; - -/** - * Bind multiple objects to the payload of the request as a list of links. - */ -public abstract class BindRefsToPayload extends BindToXMLPayload { - @Inject - public BindRefsToPayload(final XMLParser xmlParser) { - super(xmlParser); - } - - protected abstract String getRelToUse(final Object input); - - @Override - public <R extends HttpRequest> R bindToRequest(final R request, final Object input) { - checkArgument(checkNotNull(input, "input") instanceof SingleResourceTransportDto[], - "this binder is only valid for SingleResourceTransportDto arrays"); - - SingleResourceTransportDto[] dtos = (SingleResourceTransportDto[]) input; - LinksDto refs = new LinksDto(); - - for (SingleResourceTransportDto dto : dtos) { - RESTLink editLink = checkNotNull(dto.getEditLink(), "entity must have an edit link"); - - // Do not add repeated references - if (refs.searchLinkByHref(editLink.getHref()) == null) { - refs.addLink(new RESTLink(getRelToUse(input), editLink.getHref())); - } - } - - return super.bindToRequest(request, refs); - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/binders/BindToPath.java ---------------------------------------------------------------------- diff --git a/abiquo/src/main/java/org/jclouds/abiquo/binders/BindToPath.java b/abiquo/src/main/java/org/jclouds/abiquo/binders/BindToPath.java deleted file mode 100644 index 7611f8c..0000000 --- a/abiquo/src/main/java/org/jclouds/abiquo/binders/BindToPath.java +++ /dev/null @@ -1,134 +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.jclouds.abiquo.binders; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Preconditions.checkState; - -import java.lang.annotation.Annotation; -import java.net.URI; -import java.util.Arrays; - -import javax.inject.Singleton; - -import org.jclouds.abiquo.rest.annotations.EndpointLink; -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.Binder; -import org.jclouds.rest.binders.BindException; -import org.jclouds.rest.internal.GeneratedHttpRequest; - -import com.abiquo.model.rest.RESTLink; -import com.abiquo.model.transport.SingleResourceTransportDto; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; - -/** - * Binds the given object to the path.. - */ -@Singleton -public class BindToPath implements Binder { - @Override - public <R extends HttpRequest> R bindToRequest(final R request, final Object input) { - checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest, - "this binder is only valid for GeneratedHttpRequests"); - GeneratedHttpRequest gRequest = (GeneratedHttpRequest) request; - checkState(gRequest.getInvocation().getArgs() != null, "args should be initialized at this point"); - - // Update the request URI with the configured link URI - String newEndpoint = getNewEndpoint(gRequest, input); - return bindToPath(request, newEndpoint); - } - - /** - * Get the new endpoint to use. - * - * @param gRequest - * The request. - * @param input - * The input parameter. - * @return The new endpoint to use. - */ - protected String getNewEndpoint(final GeneratedHttpRequest gRequest, final Object input) { - SingleResourceTransportDto dto = checkValidInput(input); - return getLinkToUse(gRequest, dto).getHref(); - } - - /** - * Get the link to be used to build the request URI. - * - * @param request - * The current request. - * @param payload - * The object containing the link. - * @return The link to be used to build the request URI. - */ - static RESTLink getLinkToUse(final GeneratedHttpRequest request, final SingleResourceTransportDto payload) { - int argIndex = request.getInvocation().getArgs().indexOf(payload); - Annotation[] annotations = request.getInvocation().getInvokable().getParameters().get(argIndex).getAnnotations(); - - EndpointLink linkName = (EndpointLink) Iterables.find(Arrays.asList(annotations), - Predicates.instanceOf(EndpointLink.class), null); - - if (linkName == null) { - throw new BindException(request, "Expected a EndpointLink annotation but not found in the parameter"); - } - - return checkNotNull(payload.searchLink(linkName.value()), "No link was found in object with rel: " + linkName); - } - - /** - * Bind the given link to the request URI. - * - * @param request - * The request to modify. - * @param endpoint - * The endpoint to use as the request URI. - * @return The updated request. - */ - @SuppressWarnings("unchecked") - static <R extends HttpRequest> R bindToPath(final R request, final String endpoint) { - // Preserve current query parameters - String newEndpoint = endpoint + getParameterString(request); - - // Replace the URI with the edit link in the DTO - URI path = URI.create(newEndpoint); - return (R) request.toBuilder().endpoint(path).build(); - } - - protected static SingleResourceTransportDto checkValidInput(final Object input) { - checkArgument(checkNotNull(input, "input") instanceof SingleResourceTransportDto, - "this binder is only valid for SingleResourceTransportDto objects"); - - return (SingleResourceTransportDto) input; - } - - protected static <R extends HttpRequest> String getParameterString(final R request) { - String endpoint = request.getEndpoint().toString(); - - int query = endpoint.indexOf('?'); - - if (query == -1) { - // No parameters - return ""; - } else { - // Only request parameters - return endpoint.substring(query); - } - - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/binders/BindToXMLPayloadAndPath.java ---------------------------------------------------------------------- diff --git a/abiquo/src/main/java/org/jclouds/abiquo/binders/BindToXMLPayloadAndPath.java b/abiquo/src/main/java/org/jclouds/abiquo/binders/BindToXMLPayloadAndPath.java deleted file mode 100644 index 1b7c65e..0000000 --- a/abiquo/src/main/java/org/jclouds/abiquo/binders/BindToXMLPayloadAndPath.java +++ /dev/null @@ -1,75 +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.jclouds.abiquo.binders; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Preconditions.checkState; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.binders.BindToXMLPayload; -import org.jclouds.rest.internal.GeneratedHttpRequest; -import org.jclouds.xml.XMLParser; - -import com.abiquo.model.transport.SingleResourceTransportDto; - -/** - * Binds the given object to the payload and extracts the path parameters from - * the edit link. - * <p> - * This method should be used in {@link PUT} methods to automatically extract - * the path parameters from the edit link of the updated object. - */ -@Singleton -public class BindToXMLPayloadAndPath extends BindToXMLPayload { - @Inject - public BindToXMLPayloadAndPath(final XMLParser xmlParser) { - super(xmlParser); - } - - @Override - public <R extends HttpRequest> R bindToRequest(final R request, final Object payload) { - checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest, - "this binder is only valid for GeneratedHttpRequests"); - GeneratedHttpRequest gRequest = (GeneratedHttpRequest) request; - checkState(gRequest.getInvocation().getArgs() != null, "args should be initialized at this point"); - - // Update the request URI with the configured link URI - String newEndpoint = getNewEndpoint(gRequest, payload); - R updatedRequest = BindToPath.bindToPath(request, newEndpoint); - - // Add the payload - return super.bindToRequest(updatedRequest, payload); - } - - /** - * Get the new endpoint to use. - * - * @param gRequest - * The request. - * @param input - * The input parameter. - * @return The new endpoint to use. - */ - protected String getNewEndpoint(final GeneratedHttpRequest gRequest, final Object input) { - SingleResourceTransportDto dto = BindToPath.checkValidInput(input); - return BindToPath.getLinkToUse(gRequest, dto).getHref(); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindHardDiskRefsToPayload.java ---------------------------------------------------------------------- diff --git a/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindHardDiskRefsToPayload.java b/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindHardDiskRefsToPayload.java deleted file mode 100644 index 396606c..0000000 --- a/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindHardDiskRefsToPayload.java +++ /dev/null @@ -1,41 +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.jclouds.abiquo.binders.cloud; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.abiquo.binders.BindRefsToPayload; -import org.jclouds.xml.XMLParser; - -/** - * Bind multiple {@link DiskManagementDto} objects to the payload of the request - * as a list of links. - */ -@Singleton -public class BindHardDiskRefsToPayload extends BindRefsToPayload { - @Inject - public BindHardDiskRefsToPayload(final XMLParser xmlParser) { - super(xmlParser); - } - - @Override - protected String getRelToUse(final Object input) { - return "disk"; - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindIpRefToPayload.java ---------------------------------------------------------------------- diff --git a/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindIpRefToPayload.java b/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindIpRefToPayload.java deleted file mode 100644 index 9f0df3c..0000000 --- a/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindIpRefToPayload.java +++ /dev/null @@ -1,56 +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.jclouds.abiquo.binders.cloud; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.binders.BindToXMLPayload; -import org.jclouds.xml.XMLParser; - -import com.abiquo.model.rest.RESTLink; -import com.abiquo.model.transport.LinksDto; -import com.abiquo.server.core.infrastructure.network.AbstractIpDto; - -/** - * Bind the link reference to an {@link AbstractIpDto} object into the payload. - */ -@Singleton -public class BindIpRefToPayload extends BindToXMLPayload { - @Inject - public BindIpRefToPayload(final XMLParser xmlParser) { - super(xmlParser); - } - - @Override - public <R extends HttpRequest> R bindToRequest(final R request, final Object input) { - checkArgument(checkNotNull(input, "input") instanceof AbstractIpDto, - "this binder is only valid for AbstractIpDto objects"); - - AbstractIpDto ip = (AbstractIpDto) input; - RESTLink selfLink = checkNotNull(ip.searchLink("self"), "AbstractIpDto must have an self link"); - - LinksDto refs = new LinksDto(); - refs.addLink(new RESTLink(selfLink.getTitle(), selfLink.getHref())); - - return super.bindToRequest(request, refs); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindIpRefsToPayload.java ---------------------------------------------------------------------- diff --git a/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindIpRefsToPayload.java b/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindIpRefsToPayload.java deleted file mode 100644 index 4b106d6..0000000 --- a/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindIpRefsToPayload.java +++ /dev/null @@ -1,63 +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.jclouds.abiquo.binders.cloud; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.abiquo.domain.util.LinkUtils; -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.binders.BindToXMLPayload; -import org.jclouds.xml.XMLParser; - -import com.abiquo.model.rest.RESTLink; -import com.abiquo.model.transport.LinksDto; -import com.abiquo.server.core.infrastructure.network.AbstractIpDto; - -/** - * Bind the link reference to an {@link AbstractIpDto} object into the payload. - */ -@Singleton -public class BindIpRefsToPayload extends BindToXMLPayload { - @Inject - public BindIpRefsToPayload(final XMLParser xmlParser) { - super(xmlParser); - } - - @Override - public <R extends HttpRequest> R bindToRequest(final R request, final Object input) { - checkArgument(checkNotNull(input, "input") instanceof AbstractIpDto[], - "this binder is only valid for AbstractIpDto arrays"); - - AbstractIpDto[] ips = (AbstractIpDto[]) input; - LinksDto refs = new LinksDto(); - - for (AbstractIpDto ip : ips) { - RESTLink selfLink = checkNotNull(LinkUtils.getSelfLink(ip), "AbstractIpDto must have an edit or self link"); - if (refs.searchLinkByHref(selfLink.getHref()) == null) { - RESTLink ref = new RESTLink(selfLink.getTitle(), selfLink.getHref()); - ref.setType(selfLink.getType()); - refs.addLink(ref); - } - } - - return super.bindToRequest(request, refs); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindMoveVolumeToPath.java ---------------------------------------------------------------------- diff --git a/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindMoveVolumeToPath.java b/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindMoveVolumeToPath.java deleted file mode 100644 index 8cd5bc6..0000000 --- a/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindMoveVolumeToPath.java +++ /dev/null @@ -1,44 +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.jclouds.abiquo.binders.cloud; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - -import org.jclouds.abiquo.binders.BindToPath; -import org.jclouds.rest.internal.GeneratedHttpRequest; - -import com.abiquo.model.rest.RESTLink; -import com.abiquo.server.core.infrastructure.storage.VolumeManagementDto; - -/** - * Binds the move volume action to the request endpoint. - */ -public class BindMoveVolumeToPath extends BindToPath { - - @Override - protected String getNewEndpoint(final GeneratedHttpRequest gRequest, final Object input) { - checkArgument(checkNotNull(input, "input") instanceof VolumeManagementDto, - "this binder is only valid for VolumeManagementDto objects"); - - VolumeManagementDto volume = (VolumeManagementDto) input; - RESTLink editLink = checkNotNull(volume.getEditLink(), "VolumeManagementDto must have an edit link"); - - return editLink.getHref() + "/action/move"; - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindNetworkConfigurationRefToPayload.java ---------------------------------------------------------------------- diff --git a/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindNetworkConfigurationRefToPayload.java b/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindNetworkConfigurationRefToPayload.java deleted file mode 100644 index aa0e8ff..0000000 --- a/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindNetworkConfigurationRefToPayload.java +++ /dev/null @@ -1,68 +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.jclouds.abiquo.binders.cloud; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; -import static com.google.common.base.Preconditions.checkState; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.binders.BindToXMLPayload; -import org.jclouds.rest.internal.GeneratedHttpRequest; -import org.jclouds.xml.XMLParser; - -import com.abiquo.model.rest.RESTLink; -import com.abiquo.model.transport.LinksDto; -import com.abiquo.server.core.cloud.VirtualMachineDto; -import com.abiquo.server.core.infrastructure.network.VLANNetworkDto; -import com.google.common.base.Predicates; -import com.google.common.collect.Iterables; - -/** - * Bind multiple objects to the payload of the request as a list of links. - */ -@Singleton -public class BindNetworkConfigurationRefToPayload extends BindToXMLPayload { - @Inject - public BindNetworkConfigurationRefToPayload(final XMLParser xmlParser) { - super(xmlParser); - } - - @Override - public <R extends HttpRequest> R bindToRequest(final R request, final Object input) { - checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest, - "this binder is only valid for GeneratedHttpRequests"); - checkArgument(checkNotNull(input, "input") instanceof VLANNetworkDto, - "this binder is only valid for VLANNetworkDto"); - GeneratedHttpRequest gRequest = (GeneratedHttpRequest) request; - checkState(gRequest.getInvocation().getArgs() != null, "args should be initialized at this point"); - - VLANNetworkDto network = (VLANNetworkDto) input; - VirtualMachineDto vm = (VirtualMachineDto) Iterables.find(gRequest.getInvocation().getArgs(), - Predicates.instanceOf(VirtualMachineDto.class)); - - RESTLink configLink = checkNotNull(vm.searchLink("configurations"), "missing required link"); - - LinksDto dto = new LinksDto(); - dto.addLink(new RESTLink("network_configuration", configLink.getHref() + "/" + network.getId())); - - return super.bindToRequest(request, dto); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindNetworkRefToPayload.java ---------------------------------------------------------------------- diff --git a/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindNetworkRefToPayload.java b/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindNetworkRefToPayload.java deleted file mode 100644 index 0daaacc..0000000 --- a/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindNetworkRefToPayload.java +++ /dev/null @@ -1,73 +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.jclouds.abiquo.binders.cloud; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.binders.BindToXMLPayload; -import org.jclouds.xml.XMLParser; - -import com.abiquo.model.rest.RESTLink; -import com.abiquo.model.transport.LinksDto; -import com.abiquo.server.core.infrastructure.network.VLANNetworkDto; - -/** - * Bind the link reference to an {@link VLANNetworkDto} object into the payload. - */ -@Singleton -public class BindNetworkRefToPayload extends BindToXMLPayload { - @Inject - public BindNetworkRefToPayload(final XMLParser xmlParser) { - super(xmlParser); - } - - @Override - public <R extends HttpRequest> R bindToRequest(final R request, final Object input) { - checkArgument(checkNotNull(input, "input") instanceof VLANNetworkDto, - "this binder is only valid for VLANNetworkDto objects"); - - VLANNetworkDto network = (VLANNetworkDto) input; - RESTLink editLink = checkNotNull(network.getEditLink(), "VLANNetworkDto must have an edit link"); - - LinksDto refs = new LinksDto(); - switch (network.getType()) { - case INTERNAL: - refs.addLink(new RESTLink("internalnetwork", editLink.getHref())); - break; - case EXTERNAL: - refs.addLink(new RESTLink("externalnetwork", editLink.getHref())); - break; - case PUBLIC: - refs.addLink(new RESTLink("publicnetwork", editLink.getHref())); - break; - case UNMANAGED: - refs.addLink(new RESTLink("unmanagednetwork", editLink.getHref())); - break; - default: - // TODO: EXTERNAL_UNMANAGED network type - throw new IllegalArgumentException("Unsupported network type"); - } - - return super.bindToRequest(request, refs); - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindUnmanagedIpRefToPayload.java ---------------------------------------------------------------------- diff --git a/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindUnmanagedIpRefToPayload.java b/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindUnmanagedIpRefToPayload.java deleted file mode 100644 index ce9364f..0000000 --- a/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindUnmanagedIpRefToPayload.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.jclouds.abiquo.binders.cloud; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.binders.BindToXMLPayload; -import org.jclouds.xml.XMLParser; - -import com.abiquo.model.enumerator.NetworkType; -import com.abiquo.model.rest.RESTLink; -import com.abiquo.model.transport.LinksDto; -import com.abiquo.server.core.infrastructure.network.VLANNetworkDto; - -/** - * Bind the link reference to an {@link AbstractIpDto} object into the payload. - */ -@Singleton -public class BindUnmanagedIpRefToPayload extends BindToXMLPayload { - @Inject - public BindUnmanagedIpRefToPayload(final XMLParser xmlParser) { - super(xmlParser); - } - - @Override - public <R extends HttpRequest> R bindToRequest(final R request, final Object input) { - checkArgument(checkNotNull(input, "input") instanceof VLANNetworkDto, - "this binder is only valid for VLANNetworkDto objects"); - - VLANNetworkDto network = (VLANNetworkDto) input; - checkArgument(network.getType() == NetworkType.UNMANAGED, "this binder is only valid for UNMANAGED networks"); - - RESTLink ipsLink = checkNotNull(network.searchLink("ips"), "VLANNetworkDto must have an ips link"); - - LinksDto refs = new LinksDto(); - refs.addLink(new RESTLink("unmanagedip", ipsLink.getHref())); - - return super.bindToRequest(request, refs); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindVirtualDatacenterRefToPayload.java ---------------------------------------------------------------------- diff --git a/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindVirtualDatacenterRefToPayload.java b/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindVirtualDatacenterRefToPayload.java deleted file mode 100644 index d3ee835..0000000 --- a/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindVirtualDatacenterRefToPayload.java +++ /dev/null @@ -1,57 +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.jclouds.abiquo.binders.cloud; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.http.HttpRequest; -import org.jclouds.rest.binders.BindToXMLPayload; -import org.jclouds.xml.XMLParser; - -import com.abiquo.model.rest.RESTLink; -import com.abiquo.model.transport.LinksDto; -import com.abiquo.server.core.cloud.VirtualDatacenterDto; - -/** - * Bind multiple {@link VolumeManagementDto} objects to the payload of the - * request as a list of links. - */ -@Singleton -public class BindVirtualDatacenterRefToPayload extends BindToXMLPayload { - @Inject - public BindVirtualDatacenterRefToPayload(final XMLParser xmlParser) { - super(xmlParser); - } - - @Override - public <R extends HttpRequest> R bindToRequest(final R request, final Object input) { - checkArgument(checkNotNull(input, "input") instanceof VirtualDatacenterDto, - "this binder is only valid for VirtualDatacenterDto objects"); - - VirtualDatacenterDto vdc = (VirtualDatacenterDto) input; - RESTLink editLink = checkNotNull(vdc.getEditLink(), "VirtualDatacenterDto must have an edit link"); - LinksDto refs = new LinksDto(); - refs.addLink(new RESTLink("virtualdatacenter", editLink.getHref())); - - return super.bindToRequest(request, refs); - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/1b689dc1/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindVolumeRefsToPayload.java ---------------------------------------------------------------------- diff --git a/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindVolumeRefsToPayload.java b/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindVolumeRefsToPayload.java deleted file mode 100644 index 28c7c8b..0000000 --- a/abiquo/src/main/java/org/jclouds/abiquo/binders/cloud/BindVolumeRefsToPayload.java +++ /dev/null @@ -1,41 +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.jclouds.abiquo.binders.cloud; - -import javax.inject.Inject; -import javax.inject.Singleton; - -import org.jclouds.abiquo.binders.BindRefsToPayload; -import org.jclouds.xml.XMLParser; - -/** - * Bind multiple {@link VolumeManagementDto} objects to the payload of the - * request as a list of links. - */ -@Singleton -public class BindVolumeRefsToPayload extends BindRefsToPayload { - @Inject - public BindVolumeRefsToPayload(final XMLParser xmlParser) { - super(xmlParser); - } - - @Override - protected String getRelToUse(final Object input) { - return "volume"; - } - -}
