001/* 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; 036 037import org.jboss.resteasy.annotations.ClientResponseType; 038 039@Path("/services") 040public interface DomainServiceResource { 041 042 @GET 043 @Path("/") 044 @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_LIST, RestfulMediaType.APPLICATION_JSON_ERROR }) 045 @ClientResponseType(entityType = String.class) 046 public Response services(); 047 048 @DELETE 049 @Path("/") 050 public Response deleteServicesNotAllowed(); 051 052 @PUT 053 @Path("/") 054 public Response putServicesNotAllowed(); 055 056 @POST 057 @Path("/") 058 public Response postServicesNotAllowed(); 059 060 // ////////////////////////////////////////////////////////// 061 // domain service 062 // ////////////////////////////////////////////////////////// 063 064 @GET 065 @Path("/{serviceId}") 066 @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_OBJECT, RestfulMediaType.APPLICATION_JSON_ERROR }) 067 @ClientResponseType(entityType = String.class) 068 public Response service(@PathParam("serviceId") final String serviceId); 069 070 @DELETE 071 @Path("/{serviceId}") 072 public Response deleteServiceNotAllowed(@PathParam("serviceId") final String serviceId); 073 074 @PUT 075 @Path("/{serviceId}") 076 public Response putServiceNotAllowed(@PathParam("serviceId") final String serviceId); 077 078 @POST 079 @Path("/{serviceId}") 080 public Response postServiceNotAllowed(@PathParam("serviceId") final String serviceId); 081 082 083 // ////////////////////////////////////////////////////////// 084 // domain service action 085 // ////////////////////////////////////////////////////////// 086 087 @GET 088 @Path("/{serviceId}/actions/{actionId}") 089 @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_OBJECT_ACTION, RestfulMediaType.APPLICATION_JSON_ERROR }) 090 @ClientResponseType(entityType = String.class) 091 public Response actionPrompt(@PathParam("serviceId") final String serviceId, @PathParam("actionId") final String actionId); 092 093 @DELETE 094 @Path("/{serviceId}/actions/{actionId}") 095 public Response deleteActionPromptNotAllowed(@PathParam("serviceId") final String serviceId, @PathParam("actionId") final String actionId); 096 097 @PUT 098 @Path("/{serviceId}/actions/{actionId}") 099 public Response putActionPromptNotAllowed(@PathParam("serviceId") final String serviceId, @PathParam("actionId") final String actionId); 100 101 @POST 102 @Path("/{serviceId}/actions/{actionId}") 103 public Response postActionPromptNotAllowed(@PathParam("serviceId") final String serviceId, @PathParam("actionId") final String actionId); 104 105 // ////////////////////////////////////////////////////////// 106 // domain service action invoke 107 // ////////////////////////////////////////////////////////// 108 109 /** 110 * Because it isn't possible with the RestEasy client-side framework to specify a query string nor to pass arbitrary query params; instead 111 * we provide an additional syntax of passing an Isis-defined query param <tt>x-isis-querystring</tt>. 112 * 113 * <p> 114 * The content of this is taken to be the URL encoded map of arguments. 115 */ 116 @GET 117 @Path("/{serviceId}/actions/{actionId}/invoke") 118 @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_ACTION_RESULT, RestfulMediaType.APPLICATION_JSON_ERROR }) 119 @ClientResponseType(entityType = String.class) 120 public Response invokeActionQueryOnly(@PathParam("serviceId") final String serviceId, @PathParam("actionId") final String actionId, @QueryParam("x-isis-querystring") final String xIsisQueryString); 121 122 @PUT 123 @Path("/{serviceId}/actions/{actionId}/invoke") 124 @Consumes({ MediaType.APPLICATION_JSON }) 125 @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_ACTION_RESULT, RestfulMediaType.APPLICATION_JSON_ERROR }) 126 @ClientResponseType(entityType = String.class) 127 public Response invokeActionIdempotent(@PathParam("serviceId") final String serviceId, @PathParam("actionId") final String actionId, final InputStream arguments); 128 129 @POST 130 @Path("/{serviceId}/actions/{actionId}/invoke") 131 @Consumes({ MediaType.APPLICATION_JSON }) 132 @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_ACTION_RESULT, RestfulMediaType.APPLICATION_JSON_ERROR }) 133 @ClientResponseType(entityType = String.class) 134 public Response invokeAction(@PathParam("serviceId") final String serviceId, @PathParam("actionId") final String actionId, final InputStream arguments); 135 136 @DELETE 137 @Path("/{serviceId}/actions/{actionId}/invoke") 138 public Response deleteInvokeActionNotAllowed(@PathParam("serviceId") final String serviceId, @PathParam("actionId") final String actionId); 139}