diff --git a/src/main/java/org/gcube/gcat/rest/Configuration.java b/src/main/java/org/gcube/gcat/rest/Configuration.java index 3d76778..5190bc1 100644 --- a/src/main/java/org/gcube/gcat/rest/Configuration.java +++ b/src/main/java/org/gcube/gcat/rest/Configuration.java @@ -96,13 +96,12 @@ 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. - * Only a Catalogue-Manager can invoke this API. + * This API allows to create the catalogue configuration for the + * context of the request (i.e. the context where the token has been generated) + * using the json provided as request body. + * Only a Catalogue-Manager can invoke this API. * The configuration will be persisted in the infrastructure - * Information System (IS) in the context of the request - * (i.e. the context where the token has been generated). - * + * Information System (IS) in the context of the request. * * Let consider the following example: * @@ -224,6 +223,41 @@ public class Configuration extends BaseREST implements org.gcube.gcat.api.interf } } + /** + * This API allows to read the catalogue configuration for the + * current context (i.e. the context where the token has been generated). + * + * Please refers to Create Configuration API + * for the list of configuration properties and their meaning. + * + * This API can be invoked by any user with at least + * Catalogue-Editor role. + * + * For any non Catalogue-Manager user the configuration + * will contain only a subset of the properties of the configuration. * + * Here is an example: + * + *
+	 * 	{
+	 *		"context": "/gcube/devsec/devVRE",
+	 *		"defaultOrganization": "devvre",
+	 *		"supportedOrganizations": [ "devvre" "nextnext" ],
+	 *		"ckanURL": "https://ckan-d-d4s.d4science.org",
+	 *		"solrURL": "https://ckan-d-d4s.d4science.org/solr/",
+	 *		"socialPostEnabled": false,
+	 *		"notificationToUsersEnabled": true,
+	 *		"moderationEnabled": true
+	 * 	}
+	 * 
+ * + * @param context must contains the context of the request + * or the placeholder CURRENT_CONTEXT.
+ * Please note that the context must be URL encoded, + * e.g. /gcube/devsec/devVRE -> %2Fgcube%2Fdevsec%2FdevVRE + * + * @pathExample /configurations/CURRENT_CONTEXT + * @responseExample application/json;charset=UTF-8 classpath:/api-docs-examples/configuration/read-configuration-response.json + */ @GET @Path("/{" + CONTEXT_FULLNAME_PARAMETER + "}") @Produces(GCatConstants.APPLICATION_JSON_CHARSET_UTF_8) @@ -267,6 +301,112 @@ public class Configuration extends BaseREST implements org.gcube.gcat.api.interf } } + /** + * This API allows to create/update the catalogue configuration for the + * context of the request (i.e. the context where the token has been generated) + * using the json provided as request body. + * Only a Catalogue-Manager can invoke this API. + * The configuration will be persisted in the infrastructure + * Information System (IS) in the context of the request. + * + * 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)
+ *
it must contains the same value of requesting context;
+ * + *
defaultOrganization (string)
+ *
+ * the default ckan organization where an item is created for + * the context of the request; + *
+ * + *
supportedOrganizations (array of string)
+ *
+ * it defines the list of organization where an item can be created. + * All the organizations must be present in the catalogue of the VRE. + * It must contains at least the defaultOrganization value; + *
+ * + *
sysAdminToken (string)
+ *
+ * the token can be provided encrypted with the context key as well as plain. + * It any case it is persisted encrypted in IS; + *
+ * + *
ckanURL (string)
+ *
+ * the Ckan URL used for the catalogue of the VRE. + *
+ * + *
solrURL (string)
+ *
+ * the Solr URL used by the Ckan instance. + * This is normally, but not necessary, the same URL of Ckan plus the path /solr + *
+ * + *
socialPostEnabled (bool)
+ *
+ * it indicates if the social posts are enabled in the context of the request. + * The creation of a social post can be requested by a user when he/she creates + * an item; + *
+ * + *
notificationToUsersEnabled (bool)
+ *
+ * it indicates if a notification must be created when a social post + * is created. It is ignored if socialPostEnabled=false; + *
+ * + *
moderationEnabled (bool)
+ *
+ * it indicates if the catalogue is moderated. + * See Moderated Catalogues + *
+ * + *
ckanDB (object)
+ *
+ * it contains the url, username and password to contact the db used by the + * Ckan instance used for the catalogue of the VRE. + * The password can be provided encrypted with the context key as well as plain. + * It any case it is persisted encrypted in IS. + *
+ * + *
+ * + * @param context must contains the context of the request + * or the placeholder CURRENT_CONTEXT.
+ * Please note that the context must be URL encoded, + * e.g. /gcube/devsec/devVRE -> %2Fgcube%2Fdevsec%2FdevVRE + * @param json the configuration representation + * @return the updated/created configuration + * @throws WebServiceException when the request fails + * + * @pathExample /configurations/CURRENT_CONTEXT + * @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 + */ @PUT @Path("/{" + CONTEXT_FULLNAME_PARAMETER + "}") @Consumes(GCatConstants.APPLICATION_JSON_CHARSET_UTF_8) @@ -309,6 +449,31 @@ public class Configuration extends BaseREST implements org.gcube.gcat.api.interf } } + /** + * This API allows to patch the catalogue configuration for the + * context of the request (i.e. the context where the token has been generated) + * using the json provided as request body. + * Only a Catalogue-Manager can invoke this API. + * The configuration will be persisted in the infrastructure + * Information System (IS) in the context of the request. + * + * + * + * Please refers to Create Configuration API + * for the list of configuration properties and their meaning. + * + * @param context must contains the context of the request + * or the placeholder CURRENT_CONTEXT.
+ * Please note that the context must be URL encoded, + * e.g. /gcube/devsec/devVRE -> %2Fgcube%2Fdevsec%2FdevVRE + * @param json must contains only the properties of the configuratoin the user wants to change. + * @return the patched configuration. + * @throws WebServiceException when the request fails + * + * @pathExample /configurations/CURRENT_CONTEXT + * @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 + */ @PATCH @Path("/{" + CONTEXT_FULLNAME_PARAMETER + "}") @Consumes(GCatConstants.APPLICATION_JSON_CHARSET_UTF_8) @@ -370,6 +535,27 @@ public class Configuration extends BaseREST implements org.gcube.gcat.api.interf } } + /** + * It removes from the cache the configuration for the + * context of the request (i.e. the context where the token has been generated). + * + * This API forces the service to read again from the Information System (IS) + * the catalogue configuration for the context of the request. + * + * If the user specifies the purge query parameter this API + * remove the configuration from the IS. Please note that this implies that + * the catalogue is no more configured for the context of the request. + * + * + * @param context context must contains the context of the request + * or the placeholder CURRENT_CONTEXT.
+ * Please note that the context must be URL encoded, + * e.g. /gcube/devsec/devVRE -> %2Fgcube%2Fdevsec%2FdevVRE + * @param purge indicates to the service to remvoe the configuration from the IS + * @throws WebServiceException + * + * @pathExample /configurations/CURRENT_CONTEXT + */ @DELETE @Path("/{" + CONTEXT_FULLNAME_PARAMETER + "}") // @AuthorizationControl(allowedRoles={Role.CATALOGUE_MANAGER}, exception=NotAuthorizedException.class) @@ -407,6 +593,21 @@ public class Configuration extends BaseREST implements org.gcube.gcat.api.interf } } + /** + * It removes remove the configuration from the IS for the + * context of the request (i.e. the context where the token has been generated). + * + * Please note that this implies that + * the catalogue is no more configured for the context of the request. + * + * @param context context must contains the context of the request + * or the placeholder CURRENT_CONTEXT.
+ * Please note that the context must be URL encoded, + * e.g. /gcube/devsec/devVRE -> %2Fgcube%2Fdevsec%2FdevVRE + * @throws WebServiceException + * + * @pathExample /configurations/CURRENT_CONTEXT + */ @PURGE @Path("/{" + CONTEXT_FULLNAME_PARAMETER + "}") // @AuthorizationControl(allowedRoles={Role.CATALOGUE_MANAGER}, exception=NotAuthorizedException.class) diff --git a/src/main/resources/api-docs-examples/configuration/read-configuration-response.json b/src/main/resources/api-docs-examples/configuration/read-configuration-response.json new file mode 100644 index 0000000..e60480a --- /dev/null +++ b/src/main/resources/api-docs-examples/configuration/read-configuration-response.json @@ -0,0 +1,14 @@ +{ + "id": "584b8503-a490-4a89-8372-e21830fa716c", + "context": "/gcube/devsec/devVRE", + "defaultOrganization": "devvre", + "supportedOrganizations": [ + "nextnext", + "devvre" + ], + "ckanURL": "https://ckan-d-d4s.d4science.org", + "solrURL": "https://ckan-d-d4s.d4science.org/solr/", + "socialPostEnabled": false, + "notificationToUsersEnabled": true, + "moderationEnabled": false +} \ No newline at end of file