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 // ////////////////////////////////////////////////////////// 066 // domain object property 067 // ////////////////////////////////////////////////////////// 068 069 @GET 070 @Path("/{domainType}/{instanceId}/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("domainType") String domainType, @PathParam("instanceId") final String instanceId, @PathParam("propertyId") final String propertyId); 074 075 @PUT 076 @Path("/{domainType}/{instanceId}/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("domainType") String domainType, @PathParam("instanceId") final String instanceId, @PathParam("propertyId") final String propertyId, final InputStream arguments); 081 082 @DELETE 083 @Path("/{domainType}/{instanceId}/properties/{propertyId}") 084 @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_ERROR }) 085 @ClientResponseType(entityType = String.class) 086 public Response clearProperty(@PathParam("domainType") String domainType, @PathParam("instanceId") final String instanceId, @PathParam("propertyId") final String propertyId); 087 088 // ////////////////////////////////////////////////////////// 089 // domain object collection 090 // ////////////////////////////////////////////////////////// 091 092 @GET 093 @Path("/{domainType}/{instanceId}/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("domainType") String domainType, @PathParam("instanceId") final String instanceId, @PathParam("collectionId") final String collectionId); 097 098 @PUT 099 @Path("/{domainType}/{instanceId}/collections/{collectionId}") 100 @Consumes({ MediaType.WILDCARD }) 101 @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_ERROR }) 102 public Response addToSet(@PathParam("domainType") String domainType, @PathParam("instanceId") final String instanceId, @PathParam("collectionId") final String collectionId, final InputStream arguments); 103 104 @POST 105 @Path("/{domainType}/{instanceId}/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("domainType") String domainType, @PathParam("instanceId") final String instanceId, @PathParam("collectionId") final String collectionId, final InputStream arguments); 110 111 @DELETE 112 @Path("/{domainType}/{instanceId}/collections/{collectionId}") 113 @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_ERROR }) 114 @ClientResponseType(entityType = String.class) 115 public Response removeFromCollection(@PathParam("domainType") String domainType, @PathParam("instanceId") final String instanceId, @PathParam("collectionId") final String collectionId); 116 117 // ////////////////////////////////////////////////////////// 118 // domain object action 119 // ////////////////////////////////////////////////////////// 120 121 @GET 122 @Path("/{domainType}/{instanceId}/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("domainType") String domainType, @PathParam("instanceId") final String instanceId, @PathParam("actionId") final String actionId); 126 127 // ////////////////////////////////////////////////////////// 128 // domain object action invoke 129 // ////////////////////////////////////////////////////////// 130 131 @GET 132 @Path("/{domainType}/{instanceId}/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("domainType") String domainType, @PathParam("instanceId") final String instanceId, @PathParam("actionId") final String actionId, @QueryParam("x-isis-querystring") final String xIsisQueryString); 136 137 @PUT 138 @Path("/{domainType}/{instanceId}/actions/{actionId}/invoke") 139 @Consumes({ MediaType.WILDCARD }) 140 @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_ACTION_RESULT, RestfulMediaType.APPLICATION_JSON_ERROR }) 141 @ClientResponseType(entityType = String.class) 142 public Response invokeActionIdempotent(@PathParam("domainType") String domainType, @PathParam("instanceId") final String instanceId, @PathParam("actionId") final String actionId, final InputStream arguments); 143 144 @POST 145 @Path("/{domainType}/{instanceId}/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("domainType") String domainType, @PathParam("instanceId") final String instanceId, @PathParam("actionId") final String actionId, final InputStream arguments); 150 151}