private Operation createCloneOperation(String resourceType, ServiceDocument component, String projectLink) { if (component instanceof ResourceState) { String factoryLink = CompositeComponentRegistry .descriptionFactoryLinkByDescriptionLink(component.documentSelfLink); if (factoryLink == null) { throw new LocalizableValidationException( "Cannot clone unsupported type " + resourceType, "compute.clone.unsupported.type", resourceType); } ResourceState cloned = Utils.clone((ResourceState) component); if (cloned.customProperties == null) { cloned.customProperties = new HashMap<>(); } cloned.customProperties.put(CloneableResource.PARENT_RESOURCE_LINK_PROPERTY_NAME, cloned.documentSelfLink); cloned.documentSelfLink = null; Operation post = Operation.createPost(this, factoryLink) .setBody(cloned); if (projectLink != null && projectLink.isEmpty()) { post.addRequestHeader(OperationUtil.PROJECT_ADMIRAL_HEADER, projectLink); } return post; } throw new LocalizableValidationException("Cannot clone unsupported type " + resourceType, "compute.clone.unsupported.type", resourceType); }