#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Provides a convenience class for handling and parsing Error Document responses.
"""

from deposit_receipt import Deposit_Receipt
from server_errors import SWORD2ERRORSBYIRI, get_error

from sword2_logging import logging
ed_l = logging.getLogger(__name__)

class Error_Document(Deposit_Receipt):
    """
Example Error document:

<?xml version="1.0" encoding="utf-8"?>
<sword:error xmlns="http://www.w3.org/2005/Atom"
       xmlns:sword="http://purl.org/net/sword/"
       xmlns:arxiv="http://arxiv.org/schemas/atom"
       href="http://example.org/errors/BadManifest">
    <author>
        <name>Example repository</name>
    </author>
    <title>ERROR</title>
    <updated>2008-02-19T09:34:27Z</updated>

    <generator uri="https://example.org/sword-app/"
               version="0.9">[email protected]</generator>

    <summary>The manifest could be parsed, but was not valid - 
Example #2
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Provides a convenience class for handling and parsing Error Document responses.
"""

from deposit_receipt import Deposit_Receipt
from server_errors import SWORD2ERRORSBYIRI, get_error

from sword2_logging import logging
ed_l = logging.getLogger(__name__)


class Error_Document(Deposit_Receipt):
    """
Example Error document:

<?xml version="1.0" encoding="utf-8"?>
<sword:error xmlns="http://www.w3.org/2005/Atom"
       xmlns:sword="http://purl.org/net/sword/"
       xmlns:arxiv="http://arxiv.org/schemas/atom"
       href="http://example.org/errors/BadManifest">
    <author>
        <name>Example repository</name>
    </author>
    <title>ERROR</title>
    <updated>2008-02-19T09:34:27Z</updated>

    <generator uri="https://example.org/sword-app/"
               version="0.9">[email protected]</generator>
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Dictionary of SWORD2-specific IRI errors to simple description and expected accompanying HTTP codes.
"""

from sword2_logging import logging
sworderror_l = logging.getLogger(__name__)

SWORD2ERRORSBYNAME = {}
SWORD2ERRORSBYIRI = {}

SWORD2ERRORSBYNAME["ErrorContent"] = {   "name":"ErrorContent",
                                         "IRI":"http://purl.org/net/sword/error/ErrorContent",
                                         "description": "The supplied format is not the same as that identified in the Packaging header and/or that supported by the server",
                                         "codes": [406, 415] }


SWORD2ERRORSBYNAME["ErrorChecksumMismatch"] = { "name":"ErrorChecksumMismatch",
                                                "IRI":"http://purl.org/net/sword/error/ErrorChecksumMismatch",
                                                "description": "Checksum sent does not match the calculated checksum.",
                                                "codes":[412] }

SWORD2ERRORSBYNAME["ErrorBadRequest"] = {   "name":"ErrorBadRequest",
                                            "IRI":"http://purl.org/net/sword/error/ErrorBadRequest",
                                            "description":"Some parameters sent with the POST were not understood. ",
                                            "codes":[400] }
                    
SWORD2ERRORSBYNAME["TargetOwnerUnknown"] = {"name":"TargetOwnerUnknown",
                                            "IRI":"http://purl.org/net/sword/error/TargetOwnerUnknown",
                                            "description":"Used in mediated deposit when the server does not know the identity of the On-Behalf-Of user.",
Example #4
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
Utility methods used within the module
"""

from sword2_logging import logging
utils_l = logging.getLogger(__name__)

from time import time
from datetime import datetime

from base64 import b64encode

try:
    from hashlib import md5
except ImportError:
    import md5

import mimetypes

NS = {}
NS['dcterms'] = "{http://purl.org/dc/terms/}%s"
NS['sword'] ="{http://purl.org/net/sword/terms/}%s"
NS['atom'] = "{http://www.w3.org/2005/Atom}%s"
NS['app'] = "{http://www.w3.org/2007/app}%s"
NS['rdf'] = "{http://www.w3.org/1999/02/22-rdf-syntax-ns#}%s"
NS['ore'] = "{http://www.openarchives.org/ore/terms/}%s"

def get_text(parent, tag, plural = False):
Example #5
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Utility methods used within the module
"""

from sword2_logging import logging

utils_l = logging.getLogger(__name__)

from time import time
from datetime import datetime

from base64 import b64encode

from mimetools import Message

try:
    from hashlib import md5
except ImportError:
    import md5

import mimetypes

NS = {}
NS['dcterms'] = "{http://purl.org/dc/terms/}%s"
NS['sword'] = "{http://purl.org/net/sword/terms/}%s"
NS['atom'] = "{http://www.w3.org/2005/Atom}%s"
NS['app'] = "{http://www.w3.org/2007/app}%s"

Example #6
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Dictionary of SWORD2-specific IRI errors to simple description and expected accompanying HTTP codes.
"""

from sword2_logging import logging
sworderror_l = logging.getLogger(__name__)

SWORD2ERRORSBYNAME = {}
SWORD2ERRORSBYIRI = {}

SWORD2ERRORSBYNAME["ErrorContent"] = {
    "name": "ErrorContent",
    "IRI": "http://purl.org/net/sword/error/ErrorContent",
    "description":
    "The supplied format is not the same as that identified in the Packaging header and/or that supported by the server",
    "codes": [406, 415]
}

SWORD2ERRORSBYNAME["ErrorChecksumMismatch"] = {
    "name": "ErrorChecksumMismatch",
    "IRI": "http://purl.org/net/sword/error/ErrorChecksumMismatch",
    "description": "Checksum sent does not match the calculated checksum.",
    "codes": [412]
}

SWORD2ERRORSBYNAME["ErrorBadRequest"] = {
    "name": "ErrorBadRequest",
    "IRI": "http://purl.org/net/sword/error/ErrorBadRequest",
    "description": "Some parameters sent with the POST were not understood. ",