-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated with develop for release 1.2.5
- Loading branch information
Showing
7 changed files
with
181 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
""" | ||
|
||
__title__ = 'hs_restclient' | ||
__version__ = '1.2.4' | ||
__version__ = '1.2.5' | ||
|
||
|
||
import os | ||
|
@@ -472,6 +472,85 @@ def getScienceMetadata(self, pid): | |
|
||
return str(r.content) | ||
|
||
def getResourceMap(self, pid): | ||
""" Get resource map metadata for a resource | ||
:param pid: The HydroShare ID of the resource | ||
:raises: HydroShareNotAuthorized if the user is not authorized to view the metadata. | ||
:raises: HydroShareNotFound if the resource was not found. | ||
:raises: HydroShareHTTPException to signal an HTTP error. | ||
:return: A string representing the XML+RDF serialization of resource map metadata. | ||
Example of data returned: | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<rdf:RDF | ||
xmlns:citoterms="http://purl.org/spar/cito/" | ||
xmlns:dc="http://purl.org/dc/elements/1.1/" | ||
xmlns:dcterms="http://purl.org/dc/terms/" | ||
xmlns:foaf="http://xmlns.com/foaf/0.1/" | ||
xmlns:ore="http://www.openarchives.org/ore/terms/" | ||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" | ||
xmlns:rdfs1="http://www.w3.org/2001/01/rdf-schema#" | ||
> | ||
<rdf:Description rdf:about="http://foresite-toolkit.googlecode.com/#pythonAgent"> | ||
<foaf:name>Foresite Toolkit (Python)</foaf:name> | ||
<foaf:mbox>[email protected]</foaf:mbox> | ||
</rdf:Description> | ||
<rdf:Description rdf:about="http://www.hydroshare.org/terms/GenericResource"> | ||
<rdfs1:label>Generic</rdfs1:label> | ||
<rdfs1:isDefinedBy>http://www.hydroshare.org/terms</rdfs1:isDefinedBy> | ||
</rdf:Description> | ||
<rdf:Description rdf:about="http://www.hydroshare.org/resource/03c862ccf17b4853ac4288d63ab2d766/data/contents/test.txt"> | ||
<ore:isAggregatedBy>http://www.hydroshare.org/resource/03c862ccf17b4853ac4288d63ab2d766/data/resourcemap.xml#aggregation</ore:isAggregatedBy> | ||
<dc:format>text/plain</dc:format> | ||
</rdf:Description> | ||
<rdf:Description rdf:about="http://www.hydroshare.org/resource/03c862ccf17b4853ac4288d63ab2d766/data/resourcemap.xml"> | ||
<dc:identifier>03c862ccf17b4853ac4288d63ab2d766</dc:identifier> | ||
<ore:describes rdf:resource="http://www.hydroshare.org/resource/03c862ccf17b4853ac4288d63ab2d766/data/resourcemap.xml#aggregation"/> | ||
<rdf:type rdf:resource="http://www.openarchives.org/ore/terms/ResourceMap"/> | ||
<dc:format>application/rdf+xml</dc:format> | ||
<dc:creator rdf:resource="http://foresite-toolkit.googlecode.com/#pythonAgent"/> | ||
<dcterms:created>2016-11-29T16:17:52Z</dcterms:created> | ||
<dcterms:modified>2016-11-29T16:17:52Z</dcterms:modified> | ||
</rdf:Description> | ||
<rdf:Description rdf:about="http://www.openarchives.org/ore/terms/ResourceMap"> | ||
<rdfs1:isDefinedBy>http://www.openarchives.org/ore/terms/</rdfs1:isDefinedBy> | ||
<rdfs1:label>ResourceMap</rdfs1:label> | ||
</rdf:Description> | ||
<rdf:Description rdf:about="http://www.hydroshare.org/resource/03c862ccf17b4853ac4288d63ab2d766/data/resourcemap.xml#aggregation"> | ||
<citoterms:isDocumentedBy>http://www.hydroshare.org/resource/03c862ccf17b4853ac4288d63ab2d766/data/resourcemetadata.xml</citoterms:isDocumentedBy> | ||
<dc:title>Gen Res-1</dc:title> | ||
<dcterms:type rdf:resource="http://www.hydroshare.org/terms/GenericResource"/> | ||
<ore:isDescribedBy>http://www.hydroshare.org/resource/03c862ccf17b4853ac4288d63ab2d766/data/resourcemap.xml</ore:isDescribedBy> | ||
<ore:aggregates rdf:resource="http://www.hydroshare.org/resource/03c862ccf17b4853ac4288d63ab2d766/data/resourcemetadata.xml"/> | ||
<ore:aggregates rdf:resource="http://www.hydroshare.org/resource/03c862ccf17b4853ac4288d63ab2d766/data/contents/test.txt"/> | ||
<rdf:type rdf:resource="http://www.openarchives.org/ore/terms/Aggregation"/> | ||
</rdf:Description> | ||
<rdf:Description rdf:about="http://www.hydroshare.org/resource/03c862ccf17b4853ac4288d63ab2d766/data/resourcemetadata.xml"> | ||
<ore:isAggregatedBy>http://www.hydroshare.org/resource/03c862ccf17b4853ac4288d63ab2d766/data/resourcemap.xml#aggregation</ore:isAggregatedBy> | ||
<citoterms:documents>http://www.hydroshare.org/resource/03c862ccf17b4853ac4288d63ab2d766/data/resourcemap.xml#aggregation</citoterms:documents> | ||
<dc:title>Dublin Core science metadata document describing the HydroShare resource</dc:title> | ||
<dc:format>application/rdf+xml</dc:format> | ||
</rdf:Description> | ||
<rdf:Description rdf:about="http://www.openarchives.org/ore/terms/Aggregation"> | ||
<rdfs1:label>Aggregation</rdfs1:label> | ||
<rdfs1:isDefinedBy>http://www.openarchives.org/ore/terms/</rdfs1:isDefinedBy> | ||
</rdf:Description> | ||
</rdf:RDF> | ||
""" | ||
url = "{url_base}/resource/{pid}/map/".format(url_base=self.url_base, | ||
pid=pid) | ||
r = self._request('GET', url) | ||
if r.status_code != 200: | ||
if r.status_code == 403: | ||
raise HydroShareNotAuthorized(('GET', url)) | ||
elif r.status_code == 404: | ||
raise HydroShareNotFound((pid,)) | ||
else: | ||
raise HydroShareHTTPException((url, 'GET', r.status_code)) | ||
|
||
return str(r.content) | ||
|
||
def getResource(self, pid, destination=None, unzip=False, wait_for_bag_creation=True): | ||
""" Get a resource in BagIt format | ||
|
@@ -592,7 +671,7 @@ def getResourceTypes(self): | |
def createResource(self, resource_type, title, resource_file=None, resource_filename=None, | ||
abstract=None, keywords=None, | ||
edit_users=None, view_users=None, edit_groups=None, view_groups=None, | ||
metadata=None, progress_callback=None): | ||
metadata=None, extra_metadata=None, progress_callback=None): | ||
""" Create a new resource. | ||
:param resource_type: string representing the a HydroShare resource type recognized by this | ||
|
@@ -611,6 +690,7 @@ def createResource(self, resource_type, title, resource_file=None, resource_file | |
:param edit_groups: list of HydroShare group names that will be given edit permissions | ||
:param view_groups: list of HydroShare group names that will be given view permissions | ||
:param metadata: json string data for each of the metadata elements | ||
:param extra_metadata: json string data for key/value pair metadata elements defined by user | ||
:param progress_callback: user-defined function to provide feedback to the user about the progress | ||
of the upload of resource_file. For more information, see: | ||
http://toolbelt.readthedocs.org/en/latest/uploading-data.html#monitoring-your-streaming-multipart-upload | ||
|
@@ -626,7 +706,7 @@ def createResource(self, resource_type, title, resource_file=None, resource_file | |
|
||
close_fd = False | ||
|
||
if not resource_type in self.resource_types: | ||
if resource_type not in self.resource_types: | ||
raise HydroShareArgumentException("Resource type {0} is not among known resources: {1}".format(resource_type, | ||
", ".join([r for r in self.resource_types]))) | ||
|
||
|
@@ -651,6 +731,9 @@ def createResource(self, resource_type, title, resource_file=None, resource_file | |
if metadata: | ||
params['metadata'] = metadata | ||
|
||
if extra_metadata: | ||
params['extra_metadata'] = extra_metadata | ||
|
||
if resource_file: | ||
close_fd = self._prepareFileForUpload(params, resource_file, resource_filename) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
tests/www.hydroshare.org/hsapi/resource/6dbb0dfb8f3a498881e4de428cb1587c/map/resourcemap.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?xml version="1.0"?> | ||
<!DOCTYPE rdf:RDF PUBLIC "-//DUBLIN CORE//DCMES DTD 2002/07/31//EN" | ||
"http://dublincore.org/documents/2002/07/31/dcmes-xml/dcmes-xml-dtd.dtd"> | ||
<rdf:RDF xmlns:dcterms="http://purl.org/dc/terms/" xmlns:hsterms="http://hydroshare.org/terms/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs1="http://www.w3.org/2001/01/rdf-schema#" xmlns:dc="http://purl.org/dc/elements/1.1/"> | ||
<rdf:Description rdf:about="http://www.hydroshare.org/resource/6dbb0dfb8f3a498881e4de428cb1587c"> | ||
<dc:title>RHESSys model of Dead Run 5 watershed, Baltimore County, Maryland, USA (with rain gardens)</dc:title> | ||
<dc:type rdf:resource="http://www.hydroshare.org/terms/GenericResource"/> | ||
<dc:description> | ||
<rdf:Description> | ||
<dcterms:abstract>3-m spatial resolution RHESSys model for Dead Run 5 watershed in Baltimore County, Maryland. This model contains example implementation of rain gardens.</dcterms:abstract> | ||
</rdf:Description> | ||
</dc:description> | ||
<dc:creator> | ||
<rdf:Description rdf:about="http://www.hydroshare.org/user/28/"> | ||
<hsterms:name>Brian Miles</hsterms:name> | ||
<hsterms:creatorOrder>1</hsterms:creatorOrder> | ||
<hsterms:email>[email protected]</hsterms:email> | ||
</rdf:Description> | ||
</dc:creator> | ||
<dc:date> | ||
<dcterms:created> | ||
<rdf:value>2015-07-27T18:35:27.954135+00:00</rdf:value> | ||
</dcterms:created> | ||
</dc:date> | ||
<dc:date> | ||
<dcterms:modified> | ||
<rdf:value>2015-08-07T13:44:44.757870+00:00</rdf:value> | ||
</dcterms:modified> | ||
</dc:date> | ||
<dc:format>application/zip</dc:format> | ||
<dc:identifier> | ||
<rdf:Description> | ||
<hsterms:hydroShareIdentifier>http://www.hydroshare.org/resource/6dbb0dfb8f3a498881e4de428cb1587c</hsterms:hydroShareIdentifier> | ||
</rdf:Description> | ||
</dc:identifier> | ||
<dc:language>eng</dc:language> | ||
<dc:rights> | ||
<rdf:Description> | ||
<hsterms:rightsStatement>This resource is shared under the Creative Commons Attribution CC BY.</hsterms:rightsStatement> | ||
<hsterms:URL rdf:resource="http://creativecommons.org/licenses/by/4.0/"/> | ||
</rdf:Description> | ||
</dc:rights> | ||
<dc:subject>RHESSys</dc:subject> | ||
<dc:subject>Baltimore Ecosystem Study</dc:subject> | ||
<dc:subject>green infrastructure</dc:subject> | ||
</rdf:Description> | ||
<rdf:Description rdf:about="http://www.hydroshare.org/terms/GenericResource"> | ||
<rdfs1:label>Generic</rdfs1:label> | ||
<rdfs1:isDefinedBy>http://www.hydroshare.org/terms</rdfs1:isDefinedBy> | ||
</rdf:Description> | ||
</rdf:RDF> |