001 /*s
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements. See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership. The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License. You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied. See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 */
019 package org.apache.isis.viewer.restfulobjects.domainobjects;
020
021 import java.io.InputStream;
022
023 import javax.ws.rs.Consumes;
024 import javax.ws.rs.DELETE;
025 import javax.ws.rs.GET;
026 import javax.ws.rs.POST;
027 import javax.ws.rs.PUT;
028 import javax.ws.rs.Path;
029 import javax.ws.rs.PathParam;
030 import javax.ws.rs.Produces;
031 import javax.ws.rs.core.MediaType;
032 import javax.ws.rs.core.Response;
033
034 import org.jboss.resteasy.annotations.ClientResponseType;
035
036 import org.apache.isis.viewer.restfulobjects.applib.RestfulMediaType;
037
038 @Path("/objects")
039 public interface DomainObjectResource {
040
041 @POST
042 @Path("/")
043 @Consumes({ MediaType.WILDCARD })
044 @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_DOMAIN_OBJECT, RestfulMediaType.APPLICATION_JSON_ERROR })
045 @ClientResponseType(entityType = String.class)
046 public Response persist(final InputStream object);
047
048 // //////////////////////////////////////////////////////////
049 // domain object
050 // //////////////////////////////////////////////////////////
051
052 @GET
053 @Path("/{oid}")
054 @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_DOMAIN_OBJECT, RestfulMediaType.APPLICATION_JSON_ERROR })
055 @ClientResponseType(entityType = String.class)
056 public Response object(@PathParam("oid") final String oidStr);
057
058 @PUT
059 @Path("/{oid}")
060 @Consumes({ MediaType.WILDCARD })
061 @Produces({ RestfulMediaType.APPLICATION_JSON_DOMAIN_OBJECT, RestfulMediaType.APPLICATION_JSON_ERROR })
062 @ClientResponseType(entityType = String.class)
063 public Response object(@PathParam("oid") final String oidStr, final InputStream arguments);
064
065 // //////////////////////////////////////////////////////////
066 // domain object property
067 // //////////////////////////////////////////////////////////
068
069 @GET
070 @Path("/{oid}/properties/{propertyId}")
071 @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_OBJECT_PROPERTY, RestfulMediaType.APPLICATION_JSON_ERROR })
072 @ClientResponseType(entityType = String.class)
073 public Response propertyDetails(@PathParam("oid") final String oidStr, @PathParam("propertyId") final String propertyId);
074
075 @PUT
076 @Path("/{oid}/properties/{propertyId}")
077 @Consumes({ MediaType.WILDCARD })
078 @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_ERROR })
079 @ClientResponseType(entityType = String.class)
080 public Response modifyProperty(@PathParam("oid") final String oidStr, @PathParam("propertyId") final String propertyId, final InputStream arguments);
081
082 @DELETE
083 @Path("/{oid}/properties/{propertyId}")
084 @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_ERROR })
085 @ClientResponseType(entityType = String.class)
086 public Response clearProperty(@PathParam("oid") final String oidStr, @PathParam("propertyId") final String propertyId);
087
088 // //////////////////////////////////////////////////////////
089 // domain object collection
090 // //////////////////////////////////////////////////////////
091
092 @GET
093 @Path("/{oid}/collections/{collectionId}")
094 @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_OBJECT_COLLECTION, RestfulMediaType.APPLICATION_JSON_ERROR })
095 @ClientResponseType(entityType = String.class)
096 public Response accessCollection(@PathParam("oid") final String oidStr, @PathParam("collectionId") final String collectionId);
097
098 @PUT
099 @Path("/{oid}/collections/{collectionId}")
100 @Consumes({ MediaType.WILDCARD })
101 @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_ERROR })
102 public Response addToSet(@PathParam("oid") final String oidStr, @PathParam("collectionId") final String collectionId, final InputStream arguments);
103
104 @POST
105 @Path("/{oid}/collections/{collectionId}")
106 @Consumes({ MediaType.WILDCARD })
107 @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_ERROR })
108 @ClientResponseType(entityType = String.class)
109 public Response addToList(@PathParam("oid") final String oidStr, @PathParam("collectionId") final String collectionId, final InputStream arguments);
110
111 @DELETE
112 @Path("/{oid}/collections/{collectionId}")
113 @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_ERROR })
114 @ClientResponseType(entityType = String.class)
115 public Response removeFromCollection(@PathParam("oid") final String oidStr, @PathParam("collectionId") final String collectionId);
116
117 // //////////////////////////////////////////////////////////
118 // domain object action
119 // //////////////////////////////////////////////////////////
120
121 @GET
122 @Path("/{oid}/actions/{actionId}")
123 @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_OBJECT_ACTION, RestfulMediaType.APPLICATION_JSON_ERROR })
124 @ClientResponseType(entityType = String.class)
125 public Response actionPrompt(@PathParam("oid") final String oidStr, @PathParam("actionId") final String actionId);
126
127 // //////////////////////////////////////////////////////////
128 // domain object action invoke
129 // //////////////////////////////////////////////////////////
130
131 @GET
132 @Path("/{oid}/actions/{actionId}/invoke")
133 @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_ACTION_RESULT, RestfulMediaType.APPLICATION_JSON_ERROR })
134 @ClientResponseType(entityType = String.class)
135 public Response invokeActionQueryOnly(@PathParam("oid") final String oidStr, @PathParam("actionId") final String actionId);
136
137 @PUT
138 @Path("/{oid}/actions/{actionId}/invoke")
139 @Consumes({ MediaType.WILDCARD })
140 @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_ACTION_RESULT, RestfulMediaType.APPLICATION_JSON_SCALAR_VALUE, RestfulMediaType.APPLICATION_JSON_ERROR })
141 @ClientResponseType(entityType = String.class)
142 public Response invokeActionIdempotent(@PathParam("oid") final String oidStr, @PathParam("actionId") final String actionId, final InputStream arguments);
143
144 @POST
145 @Path("/{oid}/actions/{actionId}/invoke")
146 @Consumes({ MediaType.WILDCARD })
147 @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_ACTION_RESULT, RestfulMediaType.APPLICATION_JSON_ERROR })
148 @ClientResponseType(entityType = String.class)
149 public Response invokeAction(@PathParam("oid") final String oidStr, @PathParam("actionId") final String actionId, final InputStream arguments);
150
151 }