Package com.abiquo.model.transport

Examples of com.abiquo.model.transport.LinksDto


   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);
   }
View Full Code Here


            "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);
   }
View Full Code Here

   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);
   }
View Full Code Here

      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);
   }
View Full Code Here

      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);
   }
View Full Code Here

            "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");
      }
View Full Code Here

      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);
   }
View Full Code Here

            "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);
   }
View Full Code Here

   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);
   }
View Full Code Here

      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);
   }
View Full Code Here

TOP

Related Classes of com.abiquo.model.transport.LinksDto

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.