20
20
import io .swagger .annotations .ApiParam ;
21
21
import io .swagger .annotations .ApiResponse ;
22
22
import io .swagger .annotations .ApiResponses ;
23
- import org .commonjava .indy .bind .jaxrs .IndyDeployment ;
24
23
import org .commonjava .indy .bind .jaxrs .util .REST ;
25
24
import org .commonjava .maven .galley .event .EventMetadata ;
26
25
import org .slf4j .Logger ;
42
41
import javax .ws .rs .core .UriInfo ;
43
42
44
43
import static org .commonjava .indy .IndyContentConstants .CHECK_CACHE_ONLY ;
44
+ import static org .commonjava .indy .content .DownloadManager .ROOT_PATH ;
45
45
import static org .commonjava .indy .model .core .GenericPackageTypeDescriptor .GENERIC_CONTENT_REST_BASE_PATH ;
46
46
import static org .commonjava .indy .model .core .GenericPackageTypeDescriptor .GENERIC_PKG_KEY ;
47
- import static org .commonjava .indy .pkg .maven .model .MavenPackageTypeDescriptor .MAVEN_PKG_KEY ;
48
47
49
- @ Api ( value = "Maven Content Access and Storage" ,
50
- description = "Handles retrieval and management of Maven artifact content. This is the main point of access for Maven/Gradle users." )
48
+ @ Api ( value = "generic-http Content Access and Storage" )
51
49
@ Path ( "/api/content/generic-http/{type: (hosted|group|remote)}/{name}" )
52
50
@ ApplicationScoped
53
51
@ REST
54
52
public class GenericContentAccessResource
55
- implements PackageContentAccessResource
53
+ implements PackageContentAccessResource
56
54
{
57
55
58
56
private final Logger logger = LoggerFactory .getLogger ( getClass () );
@@ -71,13 +69,13 @@ public GenericContentAccessResource( final ContentAccessHandler handler )
71
69
72
70
@ Override
73
71
@ ApiOperation ( "Store content under the given artifact store (type/name) and path." )
74
- @ ApiResponses ( { @ ApiResponse ( code = 201 , message = "Content was stored successfully" ), @ ApiResponse ( code = 400 ,
75
- message = "No appropriate storage location was found in the specified store (this store, or a member if a group is specified) ." ) } )
72
+ @ ApiResponses ( { @ ApiResponse ( code = 201 , message = "Content was stored successfully" ),
73
+ @ ApiResponse ( code = 400 , message = "No appropriate storage location found in the specified store." ) } )
76
74
@ PUT
77
75
@ Path ( "/{path: (.+)?}" )
78
76
public Response doCreate (
79
- final @ ApiParam ( allowableValues = "hosted,group,remote" , required = true ) @ PathParam ( "type" )
80
- String type , final @ ApiParam ( required = true ) @ PathParam ( "name" ) String name ,
77
+ final @ ApiParam ( allowableValues = "hosted,group,remote" , required = true ) @ PathParam ( "type" ) String type ,
78
+ final @ ApiParam ( required = true ) @ PathParam ( "name" ) String name ,
81
79
final @ PathParam ( "path" ) String path , final @ Context UriInfo uriInfo ,
82
80
final @ Context HttpServletRequest request )
83
81
{
@@ -89,10 +87,21 @@ public Response doCreate(
89
87
.build ( GENERIC_PKG_KEY , type , name ) );
90
88
}
91
89
90
+ @ ApiOperation ( "Store '/' in the given artifact store by handling the '/' as special filepath" )
91
+ @ PUT
92
+ @ Path ( "/" )
93
+ public Response doCreate (
94
+ final @ ApiParam ( allowableValues = "hosted,group,remote" , required = true ) @ PathParam ( "type" ) String type ,
95
+ final @ ApiParam ( required = true ) @ PathParam ( "name" ) String name , final @ Context UriInfo uriInfo ,
96
+ final @ Context HttpServletRequest request )
97
+ {
98
+ return doCreate ( type , name , ROOT_PATH , uriInfo , request );
99
+ }
100
+
92
101
@ Override
93
102
@ ApiOperation ( "Delete content under the given store (type/name) and path." )
94
103
@ ApiResponses ( { @ ApiResponse ( code = 404 , message = "Content is not available" ),
95
- @ ApiResponse ( code = 204 , message = "Content was deleted successfully" ) } )
104
+ @ ApiResponse ( code = 204 , message = "Content was deleted successfully" ) } )
96
105
@ DELETE
97
106
@ Path ( "/{path: (.*)}" )
98
107
public Response doDelete (
@@ -105,55 +114,60 @@ public Response doDelete(
105
114
}
106
115
107
116
@ Override
108
- @ ApiOperation ( "Store content under the given store (type/name) and path." )
109
- @ ApiResponses ( { @ ApiResponse ( code = 404 , message = "Content is not available" ), @ ApiResponse ( code = 200 ,
110
- message = "Header metadata for content (or rendered listing when path ends with '/index.html' or '/' " ), } )
117
+ @ ApiOperation ( "Check content under the given store and path." )
118
+ @ ApiResponses ( { @ ApiResponse ( code = 404 , message = "Content is not available" ),
119
+ @ ApiResponse ( code = 200 , message = "Get header metadata for content" ), } )
111
120
@ HEAD
112
121
@ Path ( "/{path: (.*)}" )
113
122
public Response doHead (
114
- final @ ApiParam ( allowableValues = "hosted,group,remote" , required = true ) @ PathParam ( "type" )
115
- String type , final @ ApiParam ( required = true ) @ PathParam ( "name" ) String name ,
116
- final @ PathParam ( "path" ) String path , @ QueryParam ( CHECK_CACHE_ONLY ) final Boolean cacheOnly ,
123
+ final @ ApiParam ( allowableValues = "hosted,group,remote" , required = true ) @ PathParam ( "type" ) String type ,
124
+ final @ ApiParam ( required = true ) @ PathParam ( "name" ) String name ,
125
+ final @ PathParam ( "path" ) String path , final @ QueryParam ( CHECK_CACHE_ONLY ) Boolean cacheOnly ,
117
126
@ Context final UriInfo uriInfo , @ Context final HttpServletRequest request )
118
127
{
119
128
final String baseUri = uriInfo .getBaseUriBuilder ().path ( GENERIC_CONTENT_REST_BASE_PATH ).build ().toString ();
120
- return handler .doHead ( GENERIC_PKG_KEY , type , name , path , cacheOnly , baseUri , request ,
121
- new EventMetadata () );
129
+ return handler .doHead ( GENERIC_PKG_KEY , type , name , path , cacheOnly , baseUri , request , new EventMetadata (),
130
+ null , false );
131
+ }
132
+
133
+ @ ApiOperation ( "Check '/' in the given artifact store by handling the '/' as special filepath" )
134
+ @ HEAD
135
+ @ Path ( "/" )
136
+ public Response doHead (
137
+ final @ ApiParam ( allowableValues = "hosted,group,remote" , required = true ) @ PathParam ( "type" ) String type ,
138
+ final @ ApiParam ( required = true ) @ PathParam ( "name" ) String name ,
139
+ final @ QueryParam ( CHECK_CACHE_ONLY ) Boolean cacheOnly , @ Context final UriInfo uriInfo ,
140
+ @ Context final HttpServletRequest request )
141
+ {
142
+ return doHead ( type , name , ROOT_PATH , cacheOnly , uriInfo , request );
122
143
}
123
144
124
145
@ Override
125
146
@ ApiOperation ( "Retrieve Maven artifact content under the given artifact store (type/name) and path." )
126
147
@ ApiResponses ( { @ ApiResponse ( code = 404 , message = "Content is not available" ),
127
- @ ApiResponse ( code = 200 , response = String .class ,
128
- message = "Rendered content listing (when path ends with '/index.html' or '/')" ),
129
- @ ApiResponse ( code = 200 , response = StreamingOutput .class , message = "Content stream" ), } )
148
+ @ ApiResponse ( code = 200 , response = StreamingOutput .class , message = "Content stream" ), } )
130
149
@ GET
131
150
@ Path ( "/{path: (.*)}" )
132
151
public Response doGet (
133
- final @ ApiParam ( allowableValues = "hosted,group,remote" , required = true ) @ PathParam ( "type" )
134
- String type , final @ ApiParam ( required = true ) @ PathParam ( "name" ) String name ,
152
+ final @ ApiParam ( allowableValues = "hosted,group,remote" , required = true ) @ PathParam ( "type" ) String type ,
153
+ final @ ApiParam ( required = true ) @ PathParam ( "name" ) String name ,
135
154
final @ PathParam ( "path" ) String path , @ Context final UriInfo uriInfo ,
136
155
@ Context final HttpServletRequest request )
137
156
{
138
157
final String baseUri = uriInfo .getBaseUriBuilder ().path ( GENERIC_CONTENT_REST_BASE_PATH ).build ().toString ();
139
-
140
- return handler .doGet ( GENERIC_PKG_KEY , type , name , path , baseUri , request , new EventMetadata () );
158
+ return handler .doGet ( GENERIC_PKG_KEY , type , name , path , baseUri , request , new EventMetadata (), null , false );
141
159
}
142
160
143
161
@ Override
144
- @ ApiOperation ( "Retrieve root listing under the given artifact store (type/name)." )
145
- @ ApiResponses ( { @ ApiResponse ( code = 200 , response = String .class , message = "Rendered root content listing" ),
146
- @ ApiResponse ( code = 200 , response = StreamingOutput .class , message = "Content stream" ), } )
162
+ @ ApiOperation ( "Retrieve '/' in the given artifact store by handling the '/' as special filepath" )
147
163
@ GET
148
164
@ Path ( "/" )
149
165
public Response doGet (
150
- final @ ApiParam ( allowableValues = "hosted,group,remote" , required = true ) @ PathParam ( "type" )
151
- String type , final @ ApiParam ( required = true ) @ PathParam ( "name" ) String name ,
152
- @ Context final UriInfo uriInfo , @ Context final HttpServletRequest request )
166
+ final @ ApiParam ( allowableValues = "hosted,group,remote" , required = true ) @ PathParam ( "type" ) String type ,
167
+ final @ ApiParam ( required = true ) @ PathParam ( "name" ) String name , @ Context final UriInfo uriInfo ,
168
+ @ Context final HttpServletRequest request )
153
169
{
154
- final String baseUri = uriInfo .getBaseUriBuilder ().path ( GENERIC_CONTENT_REST_BASE_PATH ).build ().toString ();
155
-
156
- return handler .doGet ( GENERIC_PKG_KEY , type , name , "" , baseUri , request , new EventMetadata () );
170
+ return doGet ( type , name , ROOT_PATH , uriInfo , request );
157
171
}
158
172
159
173
}
0 commit comments