diff --git a/src/main/java/org/gcube/gcat/rest/Configuration.java b/src/main/java/org/gcube/gcat/rest/Configuration.java index 46db684..0159f50 100644 --- a/src/main/java/org/gcube/gcat/rest/Configuration.java +++ b/src/main/java/org/gcube/gcat/rest/Configuration.java @@ -95,48 +95,84 @@ public class Configuration extends BaseREST implements org.gcube.gcat.api.interf } } + /** + * Creates the catalogue configuration for the current context using the json + * provided as request body. + * + * Let consider the following example: + * + *
+	 * 	{
+	 *		"context": "/gcube/devsec/devVRE",
+	 *		"defaultOrganization": "devvre",
+	 *		"supportedOrganizations": [ "devvre" "nextnext" ],
+	 *		"sysAdminToken": "SYS_ADMIN_TOKEN_HERE",
+	 *		"ckanURL": "https://ckan-d-d4s.d4science.org",
+	 *		"solrURL": "https://ckan-d-d4s.d4science.org/solr/",
+	 *		"socialPostEnabled": false,
+	 *		"notificationToUsersEnabled": true,
+	 *		"moderationEnabled": true,
+	 *		"ckanDB": {
+	 *			"url": "jdbc:postgresql://ckan-d-d4s.d4science.org:5432/ckan_dev",
+	 *			"username": "ckan",
+	 *			"password": "PWD_HERE"
+	 *		}
+	 * 	}
+	 * 
+ * + * We have the following properties: + * + *
+ *
context (string)
+ *
;
+ * + *
defaultOrganization (string)
+ *
;
+ * + *
supportedOrganizations (array of string)
+ *
;
+ * + *
sysAdminToken (string)
+ *
;
+ * + *
ckanURL (string)
+ *
;
+ * + *
solrURL (string)
+ *
;
+ * + *
socialPostEnabled (bool)
+ *
;
+ * + *
notificationToUsersEnabled (bool)
+ *
;
+ * + *
moderationEnabled (bool)
+ *
;
+ * + *
ckanDB (object)
+ *
+ *
+ * + *
+ * + * @param json the configuration representation + * @return the created configuration + * @throws WebServiceException when the request fails + * + * @requestExample application/json;charset=UTF-8 classpath:/api-docs-examples/configuration/create-configuration-request.json + * @responseExample application/json;charset=UTF-8 classpath:/api-docs-examples/configuration/create-configuration-response.json + */ @POST @Consumes(GCatConstants.APPLICATION_JSON_CHARSET_UTF_8) @Produces(GCatConstants.APPLICATION_JSON_CHARSET_UTF_8) - @Override -// @AuthorizationControl(allowedRoles={Role.CATALOGUE_MANAGER}, exception=NotAuthorizedException.class) @StatusCodes ({ @ResponseCode(code = 201, condition = "Catalogue configuration successfully created."), @ResponseCode(code = 401, condition = "Only Catalogue-Managers can create catalogue configuration."), @ResponseCode(code = 500, condition = "Error while persisting catalogue configuration."), }) - /** - * Creates the catalogue configuration for the current context using the json provided as parameter - * @param json the configuration representation - * - * { - * "id": "584b8503-a490-4a89-8372-e21830fa716c", - * "context": "/gcube/devsec/devVRE", - * "defaultOrganization": "devvre", - * "supportedOrganizations": [ "devvre" ], - * "ckanURL": "https://ckan-d-d4s.d4science.org", - * "solrURL": "https://ckan-d-d4s.d4science.org/solr/", - * "socialPostEnabled": false, - * "notificationToUsersEnabled": true, - * "moderationEnabled": true - * } - * - * @return the created configuration - * - * { - * "id": "584b8503-a490-4a89-8372-e21830fa716c", - * "context": "/gcube/devsec/devVRE", - * "defaultOrganization": "devvre", - * "supportedOrganizations": [ "devvre" ], - * "ckanURL": "https://ckan-d-d4s.d4science.org", - * "solrURL": "https://ckan-d-d4s.d4science.org/solr/", - * "socialPostEnabled": false, - * "notificationToUsersEnabled": true, - * "moderationEnabled": true - * } - * - * @throws WebServiceException - */ + @Override +// @AuthorizationControl(allowedRoles={Role.CATALOGUE_MANAGER}, exception=NotAuthorizedException.class) public Response create(String json) throws WebServiceException { try { ServiceCatalogueConfiguration catalogueConfiguration = ServiceCatalogueConfiguration.getServiceCatalogueConfiguration(json); diff --git a/src/main/java/org/gcube/gcat/rest/Item.java b/src/main/java/org/gcube/gcat/rest/Item.java index f8d33f9..21edf18 100644 --- a/src/main/java/org/gcube/gcat/rest/Item.java +++ b/src/main/java/org/gcube/gcat/rest/Item.java @@ -321,7 +321,7 @@ public class Item extends REST implements org.gcube.gcat.api.interf *

Parameter automatically managed:

*
* - *
author (string)
+ *
author (string)
*
the name of the item’s author (the owner of the gcube-token);
* *
author_email (string)
@@ -389,8 +389,8 @@ public class Item extends REST implements org.gcube.gcat.api.interf * Some operation could continue in background such as the social post creation. * * @pathExample /items?social_post=true - * @requestExample application/json;charset=UTF-8 classpath:/create-item-request.json - * @responseExample application/json;charset=UTF-8 classpath:/create-item-response.json + * @requestExample application/json;charset=UTF-8 classpath:/api-docs-examples/item/create-item-request.json + * @responseExample application/json;charset=UTF-8 classpath:/api-docs-examples/item/create-item-response.json * */ @POST @@ -407,7 +407,7 @@ public class Item extends REST implements org.gcube.gcat.api.interf /** * @pathExample /items/my_test_item - * @responseExample application/json;charset=UTF-8 classpath:/read-item-response.json + * @responseExample application/json;charset=UTF-8 classpath:/api-docs-examples/item/read-item-response.json */ @GET @Path("/{" + ITEM_ID_PARAMETER + "}") @@ -425,8 +425,8 @@ public class Item extends REST implements org.gcube.gcat.api.interf /** * @pathExample /items/my_test_item - * @requestExample application/json;charset=UTF-8 classpath:/update-item-request.json - * @responseExample application/json;charset=UTF-8 classpath:/update-item-response.json + * @requestExample application/json;charset=UTF-8 classpath:/api-docs-examples/item/update-item-request.json + * @responseExample application/json;charset=UTF-8 classpath:/api-docs-examples/item/update-item-response.json */ @PUT @Path("/{" + ITEM_ID_PARAMETER + "}") @@ -443,8 +443,8 @@ public class Item extends REST implements org.gcube.gcat.api.interf /** * @pathExample /items/my_test_item - * @requestExample application/json;charset=UTF-8 classpath:/patch-item-request.json - * @responseExample application/json;charset=UTF-8 classpath:/patch-item-response.json + * @requestExample application/json;charset=UTF-8 classpath:/api-docs-examples/item/patch-item-request.json + * @responseExample application/json;charset=UTF-8 classpath:/api-docs-examples/item/patch-item-response.json */ @PATCH @Path("/{" + ITEM_ID_PARAMETER + "}") @@ -643,7 +643,7 @@ public class Item extends REST implements org.gcube.gcat.api.interf * The operation will continue in background. * * @pathExample /items/my_test_item - * @requestExample application/json;charset=UTF-8 classpath:/reject.json + * @requestExample application/json;charset=UTF-8 classpath:/api-docs-examples/item/reject.json */ @POST @Path("/{" + ITEM_ID_PARAMETER + "}") diff --git a/src/main/resources/api-docs-examples/configuration/create-configuration-request.json b/src/main/resources/api-docs-examples/configuration/create-configuration-request.json new file mode 100644 index 0000000..0e0f75f --- /dev/null +++ b/src/main/resources/api-docs-examples/configuration/create-configuration-request.json @@ -0,0 +1,19 @@ +{ + "context": "/gcube/devsec/devVRE", + "defaultOrganization": "devvre", + "supportedOrganizations": [ + "nextnext", + "devvre" + ], + "sysAdminToken": "SYS_ADMIN_TOKEN_HERE", + "ckanURL": "https://ckan-d-d4s.d4science.org", + "solrURL": "https://ckan-d-d4s.d4science.org/solr/", + "socialPostEnabled": false, + "notificationToUsersEnabled": true, + "moderationEnabled": false, + "ckanDB": { + "url": "jdbc:postgresql://ckan-d-d4s.d4science.org:5432/ckan_dev", + "username": "ckan", + "password": "PWD_HERE" + } +} \ No newline at end of file diff --git a/src/main/resources/api-docs-examples/configuration/create-configuration-response.json b/src/main/resources/api-docs-examples/configuration/create-configuration-response.json new file mode 100644 index 0000000..e521c47 --- /dev/null +++ b/src/main/resources/api-docs-examples/configuration/create-configuration-response.json @@ -0,0 +1,20 @@ +{ + "id": "584b8503-a490-4a89-8372-e21830fa716c", + "context": "/gcube/devsec/devVRE", + "defaultOrganization": "devvre", + "supportedOrganizations": [ + "nextnext", + "devvre" + ], + "sysAdminToken": "SYS_ADMIN_TOKEN", + "ckanURL": "https://ckan-d-d4s.d4science.org", + "solrURL": "https://ckan-d-d4s.d4science.org/solr/", + "socialPostEnabled": false, + "notificationToUsersEnabled": true, + "moderationEnabled": false, + "ckanDB": { + "url": "jdbc:postgresql://ckan-d-d4s.d4science.org:5432/ckan_dev", + "username": "ckan", + "password": "PWD" + } +} \ No newline at end of file diff --git a/src/main/resources/create-item-request.json b/src/main/resources/api-docs-examples/item/create-item-request.json similarity index 100% rename from src/main/resources/create-item-request.json rename to src/main/resources/api-docs-examples/item/create-item-request.json diff --git a/src/main/resources/create-item-response.json b/src/main/resources/api-docs-examples/item/create-item-response.json similarity index 100% rename from src/main/resources/create-item-response.json rename to src/main/resources/api-docs-examples/item/create-item-response.json diff --git a/src/main/resources/patch-item-request.json b/src/main/resources/api-docs-examples/item/patch-item-request.json similarity index 100% rename from src/main/resources/patch-item-request.json rename to src/main/resources/api-docs-examples/item/patch-item-request.json diff --git a/src/main/resources/patch-item-response.json b/src/main/resources/api-docs-examples/item/patch-item-response.json similarity index 100% rename from src/main/resources/patch-item-response.json rename to src/main/resources/api-docs-examples/item/patch-item-response.json diff --git a/src/main/resources/read-item-response.json b/src/main/resources/api-docs-examples/item/read-item-response.json similarity index 100% rename from src/main/resources/read-item-response.json rename to src/main/resources/api-docs-examples/item/read-item-response.json diff --git a/src/main/resources/reject.json b/src/main/resources/api-docs-examples/item/reject.json similarity index 100% rename from src/main/resources/reject.json rename to src/main/resources/api-docs-examples/item/reject.json diff --git a/src/main/resources/update-item-request.json b/src/main/resources/api-docs-examples/item/update-item-request.json similarity index 100% rename from src/main/resources/update-item-request.json rename to src/main/resources/api-docs-examples/item/update-item-request.json diff --git a/src/main/resources/update-item-response.json b/src/main/resources/api-docs-examples/item/update-item-response.json similarity index 100% rename from src/main/resources/update-item-response.json rename to src/main/resources/api-docs-examples/item/update-item-response.json