Example #1
0
 /**
  * Given some resource parameters, reconstruct the URL of resource page in the catalog website.
  *
  * <p>Valid URLs have this format with the dataset name 'impianti-di-risalita-vivifiemme-2013':
  * http://dati.trentino.it/dataset/impianti-di-risalita-vivifiemme-2013/resource/779d1d9d-9370-47f4-a194-1b0328c32f02
  *
  * @param catalogUrl i.e. http://dati.trentino.it
  * @param datasetIdentifier the dataset name (preferred) or the alphanumerical id
  * @param resourceId the alphanumerical id of the resource (DON'T use resource name)
  */
 public static String makeResourceURL(
     String catalogUrl, String datasetIdentifier, String resourceId) {
   checkNotEmpty(catalogUrl, "invalid catalog url");
   checkNotEmpty(datasetIdentifier, "invalid dataset identifier");
   checkNotEmpty(resourceId, "invalid resource id");
   return OdtUtils.removeTrailingSlash(catalogUrl)
       + "/"
       + datasetIdentifier
       + "/resource/"
       + resourceId;
 }
Example #2
0
 /**
  * Checks if the provided resource meets the requirements to be created to CKAN.
  *
  * @throws Throwable if requirements aren't met
  */
 private static void checkResource(CkanResourceMinimized resource) {
   checkNotNull(resource);
   checkNotNull(resource.getFormat(), "Ckan resource format must not be null!");
   checkNotEmpty(resource.getName(), "Ckan resource name can't be empty!");
   checkNotNull(resource.getDescription(), "Ckan resource description must not be null!");
   // todo do we need to check mimetype?? checkNotNull(resource.getMimetype());
   checkNotNull(resource.getPackageId(), "Ckan resource parent dataset must not be null!");
   checkNotNull(resource.getUrl(), "Ckan resource url must not be null!");
 }
Example #3
0
 /**
  * Given some group parameters, reconstruct the URL of group page in the catalog website.
  *
  * <p>Valid URLs have this format with the group name 'gestione-del-territorio':
  *
  * <p>http://dati.trentino.it/group/gestione-del-territorio
  *
  * @param catalogUrl i.e. http://dati.trentino.it
  * @param groupId the group name as in {@link CkanGroup#getName()} (preferred), or the group's
  *     alphanumerical id.
  */
 public static String makeGroupURL(String catalogUrl, String groupId) {
   checkNotEmpty(catalogUrl, "invalid catalog url");
   checkNotEmpty(groupId, "invalid dataset identifier");
   return OdtUtils.removeTrailingSlash(catalogUrl) + "/group/" + groupId;
 }
Example #4
0
 /**
  * Given some dataset parameters, reconstruct the URL of dataset page in the catalog website.
  *
  * <p>Valid URLs have this format with the name:
  * http://dati.trentino.it/dataset/impianti-di-risalita-vivifiemme-2013
  *
  * @param datasetIdentifier either of name the dataset (preferred) or the alphanumerical id.
  * @param catalogUrl i.e. http://dati.trentino.it
  */
 public static String makeDatasetURL(String catalogUrl, String datasetIdentifier) {
   checkNotEmpty(catalogUrl, "invalid catalog url");
   checkNotEmpty(datasetIdentifier, "invalid dataset Identifier");
   return removeTrailingSlash(catalogUrl) + "/dataset/" + datasetIdentifier;
 }
Example #5
0
 /**
  * Creates a Ckan client.
  *
  * @param URL the catalog url i.e. http://data.gov.uk. Internally, it will be stored in a
  *     normalized format (to avoid i.e. trailing slashes).
  * @param token the private token string for ckan repository
  * @param proxy the proxy used to perform GET and POST calls
  */
 public CkanClient(String URL, @Nullable String token, @Nullable HttpHost proxy) {
   checkNotEmpty(URL, "invalid ckan catalog url");
   this.catalogURL = removeTrailingSlash(URL);
   this.ckanToken = token;
   this.proxy = proxy;
 }