54
54
55
55
import javax .servlet .ServletInputStream ;
56
56
import javax .servlet .ServletRequestWrapper ;
57
+ import javax .servlet .http .HttpServletResponse ;
57
58
58
59
import static com .conveyal .datatools .common .status .MonitorableJob .JobType .BUILD_TRANSPORT_NETWORK ;
59
60
import static com .conveyal .datatools .common .utils .S3Utils .downloadFromS3 ;
@@ -80,19 +81,17 @@ enum Permission {
80
81
* Grab the feed version for the ID supplied in the request.
81
82
* If you pass in ?summarized=true, don't include the full tree of validation results, only the counts.
82
83
*/
83
- public static FeedVersion getFeedVersion (Request req , Response res ) {
84
- FeedVersion feedVersion = requestFeedVersion (req , "view" );
85
- return feedVersion ;
84
+ private static FeedVersion getFeedVersion (Request req , Response res ) {
85
+ return requestFeedVersion (req , "view" );
86
86
}
87
87
88
88
/**
89
89
* Get all feed versions for a given feedSource (whose ID is specified in the request).
90
90
*/
91
- public static Collection <FeedVersion > getAllFeedVersionsForFeedSource (Request req , Response res ) {
91
+ private static Collection <FeedVersion > getAllFeedVersionsForFeedSource (Request req , Response res ) {
92
92
// Check permissions and get the FeedSource whose FeedVersions we want.
93
93
FeedSource feedSource = requestFeedSourceById (req , "view" );
94
- Collection <FeedVersion > feedVersions = feedSource .retrieveFeedVersions ();
95
- return feedVersions ;
94
+ return feedSource .retrieveFeedVersions ();
96
95
}
97
96
98
97
public static FeedSource requestFeedSourceById (Request req , String action , String paramName ) {
@@ -103,7 +102,7 @@ public static FeedSource requestFeedSourceById(Request req, String action, Strin
103
102
return checkFeedSourcePermissions (req , Persistence .feedSources .getById (id ), action );
104
103
}
105
104
106
- public static FeedSource requestFeedSourceById (Request req , String action ) {
105
+ private static FeedSource requestFeedSourceById (Request req , String action ) {
107
106
return requestFeedSourceById (req , action , "feedSourceId" );
108
107
}
109
108
@@ -196,7 +195,7 @@ public static String createFeedVersionViaUpload(Request req, Response res) {
196
195
*
197
196
* OR we could just export the feed to a file and then re-import it per usual. This seems like it's wasting time/energy.
198
197
*/
199
- public static boolean createFeedVersionFromSnapshot (Request req , Response res ) {
198
+ private static boolean createFeedVersionFromSnapshot (Request req , Response res ) {
200
199
201
200
Auth0UserProfile userProfile = req .attribute ("user" );
202
201
// TODO: Should the ability to create a feedVersion from snapshot be controlled by the 'edit-gtfs' privilege?
@@ -216,13 +215,13 @@ public static boolean createFeedVersionFromSnapshot (Request req, Response res)
216
215
/**
217
216
* Spark HTTP API handler that deletes a single feed version based on the ID in the request.
218
217
*/
219
- public static FeedVersion deleteFeedVersion (Request req , Response res ) {
218
+ private static FeedVersion deleteFeedVersion (Request req , Response res ) {
220
219
FeedVersion version = requestFeedVersion (req , "manage" );
221
220
version .delete ();
222
221
return version ;
223
222
}
224
223
225
- public static FeedVersion requestFeedVersion (Request req , String action ) {
224
+ private static FeedVersion requestFeedVersion (Request req , String action ) {
226
225
return requestFeedVersion (req , action , req .params ("id" ));
227
226
}
228
227
@@ -241,7 +240,7 @@ public static FeedVersion requestFeedVersion(Request req, String action, String
241
240
* constructed in {@link #buildProfileRequest}). If a transport network does not exist for the feed version, an async
242
241
* build job is kicked off. Otherwise, the transport network cache is checked for the network.
243
242
*/
244
- public static String getIsochrones (Request req , Response res ) {
243
+ private static String getIsochrones (Request req , Response res ) {
245
244
if (!DataManager .isModuleEnabled ("r5_network" )) {
246
245
haltWithMessage (400 , "Isochrone generation not enabled in this application." );
247
246
}
@@ -357,7 +356,7 @@ private static AnalystClusterRequest buildProfileRequest(Request req) {
357
356
return clusterRequest ;
358
357
}
359
358
360
- public static Boolean renameFeedVersion (Request req , Response res ) {
359
+ private static boolean renameFeedVersion (Request req , Response res ) {
361
360
FeedVersion v = requestFeedVersion (req , "manage" );
362
361
363
362
String name = req .queryParams ("name" );
@@ -378,7 +377,7 @@ private static Object downloadFeedVersionDirectly(Request req, Response res) {
378
377
* Returns credentials that a client may use to then download a feed version. Functionality
379
378
* changes depending on whether application.data.use_s3_storage config property is true.
380
379
*/
381
- public static Object getFeedDownloadCredentials (Request req , Response res ) {
380
+ private static Object getFeedDownloadCredentials (Request req , Response res ) {
382
381
FeedVersion version = requestFeedVersion (req , "view" );
383
382
384
383
if (DataManager .useS3 ) {
@@ -398,7 +397,7 @@ public static Object getFeedDownloadCredentials(Request req, Response res) {
398
397
*/
399
398
private static JsonNode validate (Request req , Response res ) {
400
399
FeedVersion version = requestFeedVersion (req , "manage" );
401
-
400
+ haltWithMessage ( 400 , "Validate endpoint not currently configured!" );
402
401
// FIXME: Update for sql-loader validation process?
403
402
return null ;
404
403
// return version.retrieveValidationResult(true);
@@ -426,7 +425,7 @@ private static FeedVersion publishToExternalResource (Request req, Response res)
426
425
* Download locally stored feed version with token supplied by this application. This method is only used when
427
426
* useS3 is set to false. Otherwise, a direct download from s3 should be used.
428
427
*/
429
- private static Object downloadFeedVersionWithToken (Request req , Response res ) {
428
+ private static HttpServletResponse downloadFeedVersionWithToken (Request req , Response res ) {
430
429
String tokenValue = req .params ("token" );
431
430
FeedDownloadToken token = Persistence .tokens .getById (tokenValue );
432
431
0 commit comments