Merge "Inherit from oparent"
[vfc/nfvo/wfengine.git] / winery / org.eclipse.winery.repository / src / main / java / org / eclipse / winery / repository / resources / admin / AbstractAdminResource.java
1 /*******************************************************************************
2  * Copyright (c) 2012-2013 University of Stuttgart.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * and the Apache License 2.0 which both accompany this distribution,
6  * and are available at http://www.eclipse.org/legal/epl-v10.html
7  * and http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Contributors:
10  *     Oliver Kopp - initial API and implementation
11  *******************************************************************************/
12 package org.eclipse.winery.repository.resources.admin;
13
14 import javax.ws.rs.DELETE;
15 import javax.ws.rs.core.Response;
16
17 import org.apache.commons.configuration.Configuration;
18 import org.eclipse.winery.repository.backend.BackendUtils;
19 import org.eclipse.winery.repository.backend.Repository;
20 import org.eclipse.winery.repository.datatypes.ids.admin.AdminId;
21
22 /**
23  * Instance of one admin resource
24  * 
25  * Offers a configuration object to store data
26  */
27 public abstract class AbstractAdminResource {
28         
29         protected final AdminId id;
30         protected Configuration configuration;
31         
32         
33         /**
34          * @param id the id of the element rendered by this resource
35          */
36         public AbstractAdminResource(AdminId id) {
37                 this.id = id;
38                 this.configuration = Repository.INSTANCE.getConfiguration(id);
39         }
40         
41         @DELETE
42         public Response onDelete() {
43                 return BackendUtils.delete(this.id);
44         }
45 }