Issue 695: Deleted AnonymousResource now name is optional.

This commit is contained in:
Jason King 2011-12-20 11:18:06 +00:00
parent db310519ae
commit 5dc2f65636
9 changed files with 44 additions and 141 deletions

View File

@ -22,7 +22,7 @@ import com.jamesmurty.utils.XMLBuilder;
import org.jclouds.http.HttpRequest;
import org.jclouds.rest.Binder;
import org.jclouds.rest.binders.BindToStringPayload;
import org.jclouds.tmrk.enterprisecloud.domain.internal.AnonymousResource;
import org.jclouds.tmrk.enterprisecloud.domain.NamedResource;
import org.jclouds.tmrk.enterprisecloud.domain.layout.LayoutRequest;
import org.jclouds.tmrk.enterprisecloud.domain.network.LinuxCustomization;
import org.jclouds.tmrk.enterprisecloud.domain.network.NetworkAdapterSetting;
@ -76,7 +76,7 @@ public class BindCreateVirtualMachineKeyToXmlPayload implements Binder {
final String description = vmData.getDescription();
final LayoutRequest layout = vmData.getLayout();
final String poweredOn = Boolean.toString(vmData.isPoweredOn());
final AnonymousResource template = vmData.getTemplate();
final NamedResource template = vmData.getTemplate();
XMLBuilder builder = XMLBuilder.create("CreateVirtualMachine").a("name",name)
.e("ProcessorCount").t(processorCount).up()

View File

@ -1,95 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.tmrk.enterprisecloud.domain.internal;
import java.net.URI;
import java.util.Map;
/**
* A Resource with no name.
* @author Jason King
*
*/
public class AnonymousResource extends BaseResource<AnonymousResource> {
@SuppressWarnings("unchecked")
public static Builder builder() {
return new Builder();
}
/**
* {@inheritDoc}
*/
@Override
public Builder toBuilder() {
return new Builder().fromBaseResource(this);
}
public static class Builder extends BaseResource.Builder<AnonymousResource> {
/**
* {@inheritDoc}
*/
@Override
public AnonymousResource build() {
return new AnonymousResource(href, type);
}
/**
* {@inheritDoc}
*/
@Override
public Builder fromBaseResource(BaseResource<AnonymousResource> in) {
return Builder.class.cast(super.fromBaseResource(in));
}
/**
* {@inheritDoc}
*/
@Override
public Builder href(URI href) {
return Builder.class.cast(super.href(href));
}
/**
* {@inheritDoc}
*/
@Override
public Builder type(String type) {
return Builder.class.cast(super.type(type));
}
/**
* {@inheritDoc}
*/
@Override
public Builder fromAttributes(Map<String, String> in) {
return Builder.class.cast(super.fromAttributes(in));
}
}
private AnonymousResource(URI href, String type) {
super(href, type);
}
protected AnonymousResource() {
//For JAXB
}
}

View File

@ -19,7 +19,7 @@
package org.jclouds.tmrk.enterprisecloud.domain.layout;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.tmrk.enterprisecloud.domain.internal.AnonymousResource;
import org.jclouds.tmrk.enterprisecloud.domain.NamedResource;
import javax.xml.bind.annotation.XmlElement;
@ -61,15 +61,15 @@ public class LayoutRequest {
}
public static class Builder {
private AnonymousResource row;
private AnonymousResource group;
private NamedResource row;
private NamedResource group;
private String newRow;
private String newGroup;
/**
* @see LayoutRequest#getRow
*/
public Builder row(AnonymousResource row) {
public Builder row(NamedResource row) {
this.row = row;
return this;
}
@ -77,7 +77,7 @@ public class LayoutRequest {
/**
* @see LayoutRequest#getGroup
*/
public Builder group(AnonymousResource group) {
public Builder group(NamedResource group) {
this.group = group;
return this;
}
@ -108,10 +108,10 @@ public class LayoutRequest {
}
@XmlElement(name = "Row", required = false)
private AnonymousResource row;
private NamedResource row;
@XmlElement(name = "Group", required = false)
private AnonymousResource group;
private NamedResource group;
@XmlElement(name = "NewRow", required = false)
private String newRow;
@ -120,7 +120,7 @@ public class LayoutRequest {
private String newGroup;
private LayoutRequest(@Nullable AnonymousResource row, @Nullable AnonymousResource group, @Nullable String newRow, @Nullable String newGroup) {
private LayoutRequest(@Nullable NamedResource row, @Nullable NamedResource group, @Nullable String newRow, @Nullable String newGroup) {
this.row = row;
this.group = group;
this.newRow = newRow;
@ -131,11 +131,11 @@ public class LayoutRequest {
//For JAXB
}
public AnonymousResource getRow() {
public NamedResource getRow() {
return row;
}
public AnonymousResource getGroup() {
public NamedResource getGroup() {
return group;
}

View File

@ -19,7 +19,7 @@
package org.jclouds.tmrk.enterprisecloud.domain.network;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.tmrk.enterprisecloud.domain.internal.AnonymousResource;
import org.jclouds.tmrk.enterprisecloud.domain.NamedResource;
import javax.xml.bind.annotation.XmlElement;
@ -41,7 +41,7 @@ public class LinuxCustomization {
public static class Builder {
private NetworkSettings networkSettings = NetworkSettings.builder().build();
private AnonymousResource sshKey;
private NamedResource sshKey;
/**
* @see org.jclouds.tmrk.enterprisecloud.domain.network.LinuxCustomization#getNetworkSettings
@ -54,7 +54,7 @@ public class LinuxCustomization {
/**
* @see org.jclouds.tmrk.enterprisecloud.domain.network.LinuxCustomization#getSshKey
*/
public Builder sshKey(AnonymousResource sshKey) {
public Builder sshKey(NamedResource sshKey) {
this.sshKey = sshKey;
return this;
}
@ -72,9 +72,9 @@ public class LinuxCustomization {
private NetworkSettings networkSettings;
@XmlElement(name = "SshKey", required = false)
private AnonymousResource sshKey;
private NamedResource sshKey;
public LinuxCustomization(@Nullable NetworkSettings networkSettings, @Nullable AnonymousResource sshKey) {
public LinuxCustomization(@Nullable NetworkSettings networkSettings, @Nullable NamedResource sshKey) {
this.networkSettings = networkSettings;
this.sshKey = sshKey;
}
@ -87,7 +87,7 @@ public class LinuxCustomization {
return networkSettings;
}
public AnonymousResource getSshKey() {
public NamedResource getSshKey() {
return sshKey;
}

View File

@ -19,7 +19,7 @@
package org.jclouds.tmrk.enterprisecloud.domain.resource;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.tmrk.enterprisecloud.domain.internal.AnonymousResource;
import org.jclouds.tmrk.enterprisecloud.domain.NamedResource;
import javax.xml.bind.annotation.XmlElement;
@ -40,13 +40,13 @@ public class ComputePoolPerformanceStatistic {
}
public static class Builder {
private AnonymousResource cpu;
private AnonymousResource memory;
private NamedResource cpu;
private NamedResource memory;
/**
* @see org.jclouds.tmrk.enterprisecloud.domain.resource.ComputePoolPerformanceStatistic#getCpu
*/
public Builder cpu(AnonymousResource cpu) {
public Builder cpu(NamedResource cpu) {
this.cpu = cpu;
return this;
}
@ -54,7 +54,7 @@ public class ComputePoolPerformanceStatistic {
/**
* @see org.jclouds.tmrk.enterprisecloud.domain.resource.ComputePoolPerformanceStatistic#getMemory
*/
public Builder memory(AnonymousResource memory) {
public Builder memory(NamedResource memory) {
this.memory = memory;
return this;
}
@ -69,12 +69,12 @@ public class ComputePoolPerformanceStatistic {
}
@XmlElement(name = "Cpu", required = false)
private AnonymousResource cpu;
private NamedResource cpu;
@XmlElement(name = "Memory", required = false)
private AnonymousResource memory;
private NamedResource memory;
private ComputePoolPerformanceStatistic(@Nullable AnonymousResource cpu, @Nullable AnonymousResource memory) {
private ComputePoolPerformanceStatistic(@Nullable NamedResource cpu, @Nullable NamedResource memory) {
this.cpu = cpu;
this.memory = memory;
}
@ -83,11 +83,11 @@ public class ComputePoolPerformanceStatistic {
//For JAXB
}
public AnonymousResource getCpu() {
public NamedResource getCpu() {
return cpu;
}
public AnonymousResource getMemory() {
public NamedResource getMemory() {
return memory;
}

View File

@ -19,9 +19,9 @@
package org.jclouds.tmrk.enterprisecloud.domain.vm;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.tmrk.enterprisecloud.domain.internal.AnonymousResource;
import org.jclouds.tmrk.enterprisecloud.domain.layout.LayoutRequest;
import org.jclouds.tmrk.enterprisecloud.domain.NamedResource;
import org.jclouds.tmrk.enterprisecloud.domain.internal.ResourceCapacity;
import org.jclouds.tmrk.enterprisecloud.domain.layout.LayoutRequest;
import org.jclouds.tmrk.enterprisecloud.domain.network.LinuxCustomization;
import org.jclouds.tmrk.enterprisecloud.domain.network.WindowsCustomization;
@ -57,7 +57,7 @@ public class CreateVirtualMachine extends CreateVirtualMachineRequest {
private LinuxCustomization linuxCustomization;
private WindowsCustomization windowsCustomization;
private boolean poweredOn;
private AnonymousResource template;
private NamedResource template;
/**
* @see CreateVirtualMachine#getLinuxCustomization
@ -87,7 +87,7 @@ public class CreateVirtualMachine extends CreateVirtualMachineRequest {
/**
* @see CreateVirtualMachine#getTemplate
*/
public Builder template(AnonymousResource template) {
public Builder template(NamedResource template) {
this.template = template;
return this;
}
@ -164,13 +164,13 @@ public class CreateVirtualMachine extends CreateVirtualMachineRequest {
private boolean poweredOn;
@XmlElement(name = "Template", required = false)
private AnonymousResource template;
private NamedResource template;
private CreateVirtualMachine(String name, int processorCount, ResourceCapacity memory,
@Nullable String description, @Nullable LayoutRequest layout, @Nullable Set<String> tags,
@Nullable LinuxCustomization linuxCustomization, @Nullable WindowsCustomization windowsCustomization,
boolean poweredOn, @Nullable AnonymousResource template) {
boolean poweredOn, @Nullable NamedResource template) {
super(name,processorCount,memory,description,layout,tags);
this.linuxCustomization = linuxCustomization;
this.windowsCustomization = windowsCustomization;
@ -194,7 +194,7 @@ public class CreateVirtualMachine extends CreateVirtualMachineRequest {
return poweredOn;
}
public AnonymousResource getTemplate() {
public NamedResource getTemplate() {
return template;
}

View File

@ -24,7 +24,6 @@ import com.google.inject.Guice;
import com.google.inject.Injector;
import org.jclouds.http.HttpRequest;
import org.jclouds.tmrk.enterprisecloud.domain.NamedResource;
import org.jclouds.tmrk.enterprisecloud.domain.internal.AnonymousResource;
import org.jclouds.tmrk.enterprisecloud.domain.internal.ResourceCapacity;
import org.jclouds.tmrk.enterprisecloud.domain.layout.LayoutRequest;
import org.jclouds.tmrk.enterprisecloud.domain.network.LinuxCustomization;
@ -84,11 +83,11 @@ public class BindCreateVirtualMachineKeyToXmlPayloadTest {
.processorCount(2)
.memory(ResourceCapacity.builder().value(1024).unit("MB").build());
AnonymousResource group = AnonymousResource.builder().href(URI.create("/cloudapi/ecloud/layoutgroups/308")).type("application/vnd.tmrk.cloud.layoutGroup").build();
NamedResource group = NamedResource.builder().href(URI.create("/cloudapi/ecloud/layoutgroups/308")).type("application/vnd.tmrk.cloud.layoutGroup").build();
builder.layout(LayoutRequest.builder().group(group).build());
builder.description("This is my first VM");
builder.tags(ImmutableSet.of("Web"));
AnonymousResource sshKey = AnonymousResource.builder().href(URI.create("/cloudapi/ecloud/admin/sshkeys/77")).type("application/vnd.tmrk.cloud.admin.sshKey").build();
NamedResource sshKey = NamedResource.builder().href(URI.create("/cloudapi/ecloud/admin/sshkeys/77")).type("application/vnd.tmrk.cloud.admin.sshKey").build();
NamedResource network = NamedResource.builder()
.href(URI.create("/cloudapi/ecloud/networks/3936"))
@ -111,7 +110,7 @@ public class BindCreateVirtualMachineKeyToXmlPayloadTest {
.build();
builder.linuxCustomization(linuxCustomization);
AnonymousResource template = AnonymousResource.builder().href(URI.create("/cloudapi/ecloud/templates/6/computepools/89")).type("application/vnd.tmrk.cloud.template").build();
NamedResource template = NamedResource.builder().href(URI.create("/cloudapi/ecloud/templates/6/computepools/89")).type("application/vnd.tmrk.cloud.template").build();
builder.template(template);
binder.bindToRequest(request, builder.build());
assertEquals(request.getPayload().getRawContent(), expected.replaceAll("'","\""));

View File

@ -22,7 +22,6 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import org.jclouds.tmrk.enterprisecloud.domain.NamedResource;
import org.jclouds.tmrk.enterprisecloud.domain.hardware.HardwareConfiguration;
import org.jclouds.tmrk.enterprisecloud.domain.internal.AnonymousResource;
import org.jclouds.tmrk.enterprisecloud.domain.internal.ResourceCapacity;
import org.jclouds.tmrk.enterprisecloud.domain.layout.LayoutRequest;
import org.jclouds.tmrk.enterprisecloud.domain.network.*;
@ -112,11 +111,11 @@ public class VirtualMachineClientLiveTest extends BaseTerremarkEnterpriseCloudCl
.processorCount(2)
.memory(ResourceCapacity.builder().value(1024).unit("MB").build());
AnonymousResource group = AnonymousResource.builder().href(URI.create("/cloudapi/ecloud/layoutgroups/308")).type("application/vnd.tmrk.cloud.layoutGroup").build();
NamedResource group = NamedResource.builder().href(URI.create("/cloudapi/ecloud/layoutgroups/308")).type("application/vnd.tmrk.cloud.layoutGroup").build();
builder.layout(LayoutRequest.builder().group(group).build());
builder.description("This is my first VM");
builder.tags(ImmutableSet.of("Web"));
AnonymousResource sshKey = AnonymousResource.builder().href(URI.create("/cloudapi/ecloud/admin/sshkeys/77")).type("application/vnd.tmrk.cloud.admin.sshKey").build();
NamedResource sshKey = NamedResource.builder().href(URI.create("/cloudapi/ecloud/admin/sshkeys/77")).type("application/vnd.tmrk.cloud.admin.sshKey").build();
NamedResource network = NamedResource.builder()
.href(URI.create("/cloudapi/ecloud/networks/3933"))
@ -142,7 +141,7 @@ public class VirtualMachineClientLiveTest extends BaseTerremarkEnterpriseCloudCl
.build();
builder.linuxCustomization(linuxCustomization);
AnonymousResource template = AnonymousResource.builder().href(URI.create("/cloudapi/ecloud/templates/6/computepools/89")).type("application/vnd.tmrk.cloud.template").build();
NamedResource template = NamedResource.builder().href(URI.create("/cloudapi/ecloud/templates/6/computepools/89")).type("application/vnd.tmrk.cloud.template").build();
builder.template(template);
VirtualMachine vm = client.createVirtualMachineFromTemplate(URI.create("/cloudapi/ecloud/virtualMachines/computePools/89/action/createVirtualMachine"), builder.build());

View File

@ -35,7 +35,7 @@ import org.jclouds.rest.BaseRestClientTest;
import org.jclouds.rest.RestContextSpec;
import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.jclouds.tmrk.enterprisecloud.domain.Link;
import org.jclouds.tmrk.enterprisecloud.domain.internal.AnonymousResource;
import org.jclouds.tmrk.enterprisecloud.domain.NamedResource;
import org.jclouds.tmrk.enterprisecloud.domain.resource.ComputePoolPerformanceStatistics;
import org.jclouds.tmrk.enterprisecloud.features.ResourceAsyncClient;
import org.testng.annotations.BeforeClass;
@ -102,8 +102,8 @@ public class ComputePoolPerformanceStatisticsJAXBParsingTest extends BaseRestCli
assertEquals(stats.getDaily().getMemory(), createResource("memory", "daily"));
}
private AnonymousResource createResource(String type, String period) {
return AnonymousResource.builder().href(URI.create("/cloudapi/ecloud/computepools/89/usage/"+type+"/performancestatistics/"+period))
private NamedResource createResource(String type, String period) {
return NamedResource.builder().href(URI.create("/cloudapi/ecloud/computepools/89/usage/"+type+"/performancestatistics/"+period))
.type("application/vnd.tmrk.cloud.performanceStatistics")
.build();
}