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 // ////////////////////////////////////////////////////////// 049 // domain service 050 // ////////////////////////////////////////////////////////// 051 052 @GET 053 @Path("/{serviceId}") 054 @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_OBJECT, RestfulMediaType.APPLICATION_JSON_ERROR }) 055 @ClientResponseType(entityType = String.class) 056 public Response service(@PathParam("serviceId") final String serviceId); 057 058 // ////////////////////////////////////////////////////////// 059 // domain service property 060 // ////////////////////////////////////////////////////////// 061 062 @GET 063 @Path("/{serviceId}/properties/{propertyId}") 064 @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_OBJECT_PROPERTY, RestfulMediaType.APPLICATION_JSON_ERROR }) 065 @ClientResponseType(entityType = String.class) 066 public Response propertyDetails(@PathParam("serviceId") final String serviceId, @PathParam("propertyId") final String propertyId); 067 068 069 // ////////////////////////////////////////////////////////// 070 // domain service collection 071 // ////////////////////////////////////////////////////////// 072 073 @GET 074 @Path("/{serviceId}/collections/{collectionId}") 075 @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_OBJECT_COLLECTION, RestfulMediaType.APPLICATION_JSON_ERROR }) 076 @ClientResponseType(entityType = String.class) 077 public Response accessCollection(@PathParam("serviceId") final String serviceId, @PathParam("collectionId") final String collectionId); 078 079 080 // ////////////////////////////////////////////////////////// 081 // domain service action 082 // ////////////////////////////////////////////////////////// 083 084 @GET 085 @Path("/{serviceId}/actions/{actionId}") 086 @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_OBJECT_ACTION, RestfulMediaType.APPLICATION_JSON_ERROR }) 087 @ClientResponseType(entityType = String.class) 088 public Response actionPrompt(@PathParam("serviceId") final String serviceId, @PathParam("actionId") final String actionId); 089 090 // ////////////////////////////////////////////////////////// 091 // domain service action invoke 092 // ////////////////////////////////////////////////////////// 093 094 /** 095 * Because it isn't possible with the RestEasy client-side framework to specify a query string nor to pass arbitrary query params; instead 096 * we provide an additional syntax of passing an Isis-defined query param <tt>x-isis-querystring</tt>. 097 * 098 * <p> 099 * The content of this is taken to be the URL encoded map of arguments. 100 */ 101 @GET 102 @Path("/{serviceId}/actions/{actionId}/invoke") 103 @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_ACTION_RESULT, RestfulMediaType.APPLICATION_JSON_ERROR }) 104 @ClientResponseType(entityType = String.class) 105 public Response invokeActionQueryOnly(@PathParam("serviceId") final String serviceId, @PathParam("actionId") final String actionId, @QueryParam("x-isis-querystring") final String xIsisQueryString); 106 107 @PUT 108 @Path("/{serviceId}/actions/{actionId}/invoke") 109 @Consumes({ MediaType.APPLICATION_JSON }) 110 @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_ACTION_RESULT, RestfulMediaType.APPLICATION_JSON_ERROR }) 111 @ClientResponseType(entityType = String.class) 112 public Response invokeActionIdempotent(@PathParam("serviceId") final String serviceId, @PathParam("actionId") final String actionId, final InputStream arguments); 113 114 @POST 115 @Path("/{serviceId}/actions/{actionId}/invoke") 116 @Consumes({ MediaType.APPLICATION_JSON }) 117 @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_ACTION_RESULT, RestfulMediaType.APPLICATION_JSON_ERROR }) 118 @ClientResponseType(entityType = String.class) 119 public Response invokeAction(@PathParam("serviceId") final String serviceId, @PathParam("actionId") final String actionId, final InputStream arguments); 120}