public Request<ImportVolumeRequest> marshall(ImportVolumeRequest importVolumeRequest) { if (importVolumeRequest == null) { throw new AmazonClientException("Invalid argument passed to marshall(...)"); } Request<ImportVolumeRequest> request = new DefaultRequest<ImportVolumeRequest>(importVolumeRequest, "AmazonEC2"); request.addParameter("Action", "ImportVolume"); request.addParameter("Version", "2013-07-15"); if (importVolumeRequest.getAvailabilityZone() != null) { request.addParameter( "AvailabilityZone", StringUtils.fromString(importVolumeRequest.getAvailabilityZone())); } DiskImageDetail diskImageDetailImage = importVolumeRequest.getImage(); if (diskImageDetailImage != null) { if (diskImageDetailImage.getFormat() != null) { request.addParameter( "Image.Format", StringUtils.fromString(diskImageDetailImage.getFormat())); } if (diskImageDetailImage.getBytes() != null) { request.addParameter("Image.Bytes", StringUtils.fromLong(diskImageDetailImage.getBytes())); } if (diskImageDetailImage.getImportManifestUrl() != null) { request.addParameter( "Image.ImportManifestUrl", StringUtils.fromString(diskImageDetailImage.getImportManifestUrl())); } } if (importVolumeRequest.getDescription() != null) { request.addParameter( "Description", StringUtils.fromString(importVolumeRequest.getDescription())); } VolumeDetail volumeDetailVolume = importVolumeRequest.getVolume(); if (volumeDetailVolume != null) { if (volumeDetailVolume.getSize() != null) { request.addParameter("Volume.Size", StringUtils.fromLong(volumeDetailVolume.getSize())); } } return request; }
public VolumeDetail unmarshall(StaxUnmarshallerContext context) throws Exception { VolumeDetail volumeDetail = new VolumeDetail(); int originalDepth = context.getCurrentDepth(); int targetDepth = originalDepth + 1; if (context.isStartOfDocument()) targetDepth += 1; while (true) { XMLEvent xmlEvent = context.nextEvent(); if (xmlEvent.isEndDocument()) return volumeDetail; if (xmlEvent.isAttribute() || xmlEvent.isStartElement()) { if (context.testExpression("size", targetDepth)) { volumeDetail.setSize(LongStaxUnmarshaller.getInstance().unmarshall(context)); continue; } } else if (xmlEvent.isEndElement()) { if (context.getCurrentDepth() < originalDepth) { return volumeDetail; } } } }