Sharad Mishra has uploaded a new change for review. Change subject: restapi: WIP: Created restapi interface for backup. ......................................................................
restapi: WIP: Created restapi interface for backup. This is not fully functional/populated code. The idea is to get it out there to see if its going in the right direction. Change-Id: I29f8d40130386e7eb5fe533d3c59dbc8c5ec33ac Signed-off-by: Sharad Mishra <snmis...@linux.vnet.ibm.com> --- A backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/BackupResource.java A backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendBackupResource.java 2 files changed, 102 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/19/14219/1 diff --git a/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/BackupResource.java b/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/BackupResource.java new file mode 100644 index 0000000..281ee9f --- /dev/null +++ b/backend/manager/modules/restapi/interface/definition/src/main/java/org/ovirt/engine/api/resource/BackupResource.java @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2010 Red Hat, Inc. +* +* Licensed 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.ovirt.engine.api.resource; + +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; + +import org.ovirt.engine.api.model.Backup; + + +@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON, MediaType.APPLICATION_X_YAML}) +public interface BackupResource extends AsynchronouslyCreatedResource { + + @GET + @Formatted + public Backup get(); + +} diff --git a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendBackupResource.java b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendBackupResource.java new file mode 100644 index 0000000..de0bf5f --- /dev/null +++ b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendBackupResource.java @@ -0,0 +1,70 @@ +package org.ovirt.engine.api.restapi.resource; + +import javax.ws.rs.core.Response; + +import org.ovirt.engine.api.model.Action; +import org.ovirt.engine.api.model.Backup; +import org.ovirt.engine.api.resource.ActionResource; +import org.ovirt.engine.api.resource.CreationResource; +import org.ovirt.engine.api.resource.BackupResource; +import org.ovirt.engine.core.common.action.VdcActionType; +import org.ovirt.engine.core.compat.Guid; + +import static org.ovirt.engine.api.restapi.resource.BackendBackupsResource.SUB_COLLECTIONS; + +public class BackendBackupResource extends AbstractBackendActionableResource<Backup, org.ovirt.engine.core.common.businessentities.Backup> implements BackupResource { + + protected Guid parentId; + protected BackendBackupsResource collection; + + public BackendBackupResource(String id, Guid parentId, BackendBackupsResource collection) { + super(id, Backup.class, org.ovirt.engine.core.common.businessentities.Backup.class, SUB_COLLECTIONS); + this.parentId = parentId; + this.collection = collection; + } + + @Override + public Backup get() { + org.ovirt.engine.core.common.businessentities.Backup entity = getBackup(); + Backup backup = map(entity, null); + backup = addLinks(backup); + backup = collection.addVmConfiguration(entity, backup); + return backup; + } + + protected org.ovirt.engine.core.common.businessentities.Backup getBackup() { + org.ovirt.engine.core.common.businessentities.Backup entity = collection.getBackupById(guid); + if (entity==null) { + notFound(); + } + return entity; + } + + @Override + public CreationResource getCreationSubresource(String ids) { + return inject(new BackendCreationResource(ids)); + } + + @Override + public ActionResource getActionSubresource(String action, String ids) { + return inject(new BackendActionResource(action, ids)); + } + + @Override + protected Backup addParents(Backup backup) { + return collection.addParents(backup); + } + + BackendBackupsResource getCollection() { + return collection; + } + + public void setCollectionResource(BackendBackupsResource collection) { + this.collection = collection; + } + + @Override + protected Backup doPopulate(Backup model, org.ovirt.engine.core.common.businessentities.Backup entity) { + return model; + } +} -- To view, visit http://gerrit.ovirt.org/14219 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I29f8d40130386e7eb5fe533d3c59dbc8c5ec33ac Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Sharad Mishra <snmis...@linux.vnet.ibm.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches