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 */ 019package org.apache.isis.viewer.restfulobjects.applib.domainobjects; 020 021import java.io.InputStream; 022 023import javax.ws.rs.Consumes; 024import javax.ws.rs.DELETE; 025import javax.ws.rs.GET; 026import javax.ws.rs.POST; 027import javax.ws.rs.PUT; 028import javax.ws.rs.Path; 029import javax.ws.rs.PathParam; 030import javax.ws.rs.Produces; 031import javax.ws.rs.QueryParam; 032import javax.ws.rs.core.MediaType; 033import javax.ws.rs.core.Response; 034 035import org.apache.isis.viewer.restfulobjects.applib.RestfulMediaType; 036import org.jboss.resteasy.annotations.ClientResponseType; 037 038@Path("/objects") 039public interface DomainObjectResource { 040 041 @POST 042 @Path("/{domainType}") 043 @Consumes({ MediaType.WILDCARD }) 044 @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_OBJECT, RestfulMediaType.APPLICATION_JSON_ERROR }) 045 @ClientResponseType(entityType = String.class) 046 public Response persist(@PathParam("domainType") String domainType, final InputStream object); 047 048 // ////////////////////////////////////////////////////////// 049 // domain object 050 // ////////////////////////////////////////////////////////// 051 052 @GET 053 @Path("/{domainType}/{instanceId}") 054 @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_OBJECT, RestfulMediaType.APPLICATION_JSON_ERROR }) 055 @ClientResponseType(entityType = String.class) 056 public Response object(@PathParam("domainType") String domainType, @PathParam("instanceId") final String instanceId); 057 058 @PUT 059 @Path("/{domainType}/{instanceId}") 060 @Consumes({ MediaType.WILDCARD }) 061 @Produces({ RestfulMediaType.APPLICATION_JSON_OBJECT, RestfulMediaType.APPLICATION_JSON_ERROR }) 062 @ClientResponseType(entityType = String.class) 063 public Response object(@PathParam("domainType") String domainType, @PathParam("instanceId") final String instanceId, final InputStream arguments); 064 065 @DELETE 066 @Path("/{domainType}/{instanceId}") 067 public Response deleteMethodNotSupported(@PathParam("domainType") String domainType, @PathParam("instanceId") final String instanceId); 068 069 @POST 070 @Path("/{domainType}/{instanceId}") 071 public Response postMethodNotAllowed(@PathParam("domainType") String domainType, @PathParam("instanceId") final String instanceId); 072 073 074 // ////////////////////////////////////////////////////////// 075 // domain object property 076 // ////////////////////////////////////////////////////////// 077 078 @GET 079 @Path("/{domainType}/{instanceId}/properties/{propertyId}") 080 @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_OBJECT_PROPERTY, RestfulMediaType.APPLICATION_JSON_ERROR }) 081 @ClientResponseType(entityType = String.class) 082 public Response propertyDetails(@PathParam("domainType") String domainType, @PathParam("instanceId") final String instanceId, @PathParam("propertyId") final String propertyId); 083 084 @PUT 085 @Path("/{domainType}/{instanceId}/properties/{propertyId}") 086 @Consumes({ MediaType.WILDCARD }) 087 @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_ERROR }) 088 @ClientResponseType(entityType = String.class) 089 public Response modifyProperty(@PathParam("domainType") String domainType, @PathParam("instanceId") final String instanceId, @PathParam("propertyId") final String propertyId, final InputStream arguments); 090 091 @DELETE 092 @Path("/{domainType}/{instanceId}/properties/{propertyId}") 093 @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_ERROR }) 094 @ClientResponseType(entityType = String.class) 095 public Response clearProperty(@PathParam("domainType") String domainType, @PathParam("instanceId") final String instanceId, @PathParam("propertyId") final String propertyId); 096 097 @POST 098 @Path("/{domainType}/{instanceId}/properties/{propertyId}") 099 public Response postPropertyNotAllowed(@PathParam("domainType") String domainType, @PathParam("instanceId") final String instanceId, @PathParam("propertyId") final String propertyId); 100 101 102 // ////////////////////////////////////////////////////////// 103 // domain object collection 104 // ////////////////////////////////////////////////////////// 105 106 @GET 107 @Path("/{domainType}/{instanceId}/collections/{collectionId}") 108 @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_OBJECT_COLLECTION, RestfulMediaType.APPLICATION_JSON_ERROR }) 109 @ClientResponseType(entityType = String.class) 110 public Response accessCollection(@PathParam("domainType") String domainType, @PathParam("instanceId") final String instanceId, @PathParam("collectionId") final String collectionId); 111 112 @PUT 113 @Path("/{domainType}/{instanceId}/collections/{collectionId}") 114 @Consumes({ MediaType.WILDCARD }) 115 @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_ERROR }) 116 public Response addToSet(@PathParam("domainType") String domainType, @PathParam("instanceId") final String instanceId, @PathParam("collectionId") final String collectionId, final InputStream arguments); 117 118 @POST 119 @Path("/{domainType}/{instanceId}/collections/{collectionId}") 120 @Consumes({ MediaType.WILDCARD }) 121 @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_ERROR }) 122 @ClientResponseType(entityType = String.class) 123 public Response addToList(@PathParam("domainType") String domainType, @PathParam("instanceId") final String instanceId, @PathParam("collectionId") final String collectionId, final InputStream arguments); 124 125 @DELETE 126 @Path("/{domainType}/{instanceId}/collections/{collectionId}") 127 @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_ERROR }) 128 @ClientResponseType(entityType = String.class) 129 public Response removeFromCollection(@PathParam("domainType") String domainType, @PathParam("instanceId") final String instanceId, @PathParam("collectionId") final String collectionId); 130 131 // ////////////////////////////////////////////////////////// 132 // domain object action 133 // ////////////////////////////////////////////////////////// 134 135 @GET 136 @Path("/{domainType}/{instanceId}/actions/{actionId}") 137 @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_OBJECT_ACTION, RestfulMediaType.APPLICATION_JSON_ERROR }) 138 @ClientResponseType(entityType = String.class) 139 public Response actionPrompt(@PathParam("domainType") String domainType, @PathParam("instanceId") final String instanceId, @PathParam("actionId") final String actionId); 140 141 @DELETE 142 @Path("/{domainType}/{instanceId}/actions/{actionId}") 143 public Response deleteActionPromptNotAllowed(@PathParam("domainType") String domainType, @PathParam("instanceId") final String instanceId, @PathParam("actionId") final String actionId); 144 145 @PUT 146 @Path("/{domainType}/{instanceId}/actions/{actionId}") 147 public Response putActionPromptNotAllowed(@PathParam("domainType") String domainType, @PathParam("instanceId") final String instanceId, @PathParam("actionId") final String actionId); 148 149 @POST 150 @Path("/{domainType}/{instanceId}/actions/{actionId}") 151 public Response postActionPromptNotAllowed(@PathParam("domainType") String domainType, @PathParam("instanceId") final String instanceId, @PathParam("actionId") final String actionId); 152 153 // ////////////////////////////////////////////////////////// 154 // domain object action invoke 155 // ////////////////////////////////////////////////////////// 156 157 @GET 158 @Path("/{domainType}/{instanceId}/actions/{actionId}/invoke") 159 @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_ACTION_RESULT, RestfulMediaType.APPLICATION_JSON_ERROR }) 160 @ClientResponseType(entityType = String.class) 161 public Response invokeActionQueryOnly(@PathParam("domainType") String domainType, @PathParam("instanceId") final String instanceId, @PathParam("actionId") final String actionId, @QueryParam("x-isis-querystring") final String xIsisQueryString); 162 163 @PUT 164 @Path("/{domainType}/{instanceId}/actions/{actionId}/invoke") 165 @Consumes({ MediaType.WILDCARD }) 166 @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_ACTION_RESULT, RestfulMediaType.APPLICATION_JSON_ERROR }) 167 @ClientResponseType(entityType = String.class) 168 public Response invokeActionIdempotent(@PathParam("domainType") String domainType, @PathParam("instanceId") final String instanceId, @PathParam("actionId") final String actionId, final InputStream arguments); 169 170 @POST 171 @Path("/{domainType}/{instanceId}/actions/{actionId}/invoke") 172 @Consumes({ MediaType.WILDCARD }) 173 @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_ACTION_RESULT, RestfulMediaType.APPLICATION_JSON_ERROR }) 174 @ClientResponseType(entityType = String.class) 175 public Response invokeAction(@PathParam("domainType") String domainType, @PathParam("instanceId") final String instanceId, @PathParam("actionId") final String actionId, final InputStream arguments); 176 177 @DELETE 178 @Path("/{domainType}/{instanceId}/actions/{actionId}/invoke") 179 public Response deleteInvokeActionNotAllowed(@PathParam("domainType") String domainType, @PathParam("instanceId") final String instanceId, @PathParam("actionId") final String actionId); 180 181}