def updateLocalRecordRelations(self, jobItems):
        oidIdentifierMap = HashMap()
        for jobItem in jobItems:
            oidIdentifierMap.put(jobItem.get("oid"),jobItem.get("required_identifiers")[0].get("identifier"))
            
        for jobItem in jobItems:
            type = jobItem.get("type");
            targetSystem = self.systemConfig.getString(None, "curation", "supported-types", type);
            if targetSystem == "redbox":
                oid = jobItem.get("oid")
                digitalObject = StorageUtils.getDigitalObject(self.services.getStorage(), oid)
                tfPackagePid = self.getPackageData(digitalObject)
                metadataJsonPayload = digitalObject.getPayload(tfPackagePid)
                metadataJsonInstream = metadataJsonPayload.open()
                metadataJson = JsonSimple(metadataJsonInstream)
                metadataJsonPayload.close()
                relationships = metadataJson.getArray("relationships")
                if relationships is not None:
                    for relationship in relationships:
			system = relationship.get("system")
                        if system != "redbox" or system != None:
			    url = self.systemConfig.getString("can't find it", "curation","external-system-urls","get-oid-for-identifier",system)
                            client = BasicHttpClient(url+ "&identifier="+relationship.get("identifier"))
                            get = GetMethod(url+ "&identifier="+relationship.get("identifier"))
                            client.executeMethod(get)
                            if get.getStatusCode() == 200:
                                response = JsonSimple(get.getResponseBodyAsString())
                                relationship.put("curatedPid",oidIdentifierMap.get(response.getString(None,"oid")))
                                relationship.put("isCurated",True)
                            
                            #Now update the relationship on Mint's side
                            break
                    
        istream = ByteArrayInputStream(String(metadataJson.toString(True)).getBytes())
        StorageUtils.createOrUpdatePayload(digitalObject,tfPackagePid,istream)
Exemplo n.º 2
0
 def __get(self):
     try:
         get = GetMethod(self.url)
         statusInt = client.executeMethod(get)
         r = str(statusInt), get.getResponseBodyAsString().strip()
     except Exception, e:
         r = str(e), None
 def __get(self):
     try:
         get = GetMethod(self.url)
         statusInt = self.client.executeMethod(get)
         r = str(statusInt), get.getResponseBodyAsString().strip()
     except Exception, e:
         r = str(e), None
Exemplo n.º 4
0
 def __get(self, url):
     try:
         client = BasicHttpClient(url)
         get = GetMethod(url)
         statusInt = client.executeMethod(get)
         s = get.getResponseBodyAsString().strip()
     except Exception, e:
         print "__get() Error - '%s'" % str(e)
         s = ""
Exemplo n.º 5
0
 def urlGet(self, url):
     try:
         client = BasicHttpClient(url)
         get = GetMethod(url)
         code = client.executeMethod(get)
         body = get.getResponseBodyAsString().strip()
         return (str(code), body)
     except Exception, e:
         self.log.error("Error during HTTP request: ", e)
         return (None, None)
Exemplo n.º 6
0
 def urlGet(self, url):
     try:
         client = BasicHttpClient(url)
         get = GetMethod(url)
         code = client.executeMethod(get)
         body = get.getResponseBodyAsString().strip()
         return (str(code), body)
     except Exception, e:
         self.log.error("Error during HTTP request: ", e)
         return (None, None)
Exemplo n.º 7
0
 def __init__(self):
     responseType = "text/html; charset=UTF-8"
     responseMsg = ""
     func = formData.get("func")
     if func == "placeName":
         try:
             placeName = formData.get("q")
             url = "http://ws.geonames.org/searchJSON?fuzzy=0.7&q=" + placeName
             client = BasicHttpClient(url)
             get = GetMethod(url)
             statusInt = client.executeMethod(get)
             r = str(statusInt)
             jsonConfigHelper = JsonConfigHelper(get.getResponseBodyAsString().strip())
             for geoName in jsonConfigHelper.getJsonList("geonames"):
                 responseMsg += "%s, %s|%s \n" % (geoName.get("name"), geoName.get("countryName"), geoName.get("geonameId"))
         except Exception, e:
             print "exception: ", str(e)
             r = str(e), None
         responseType = "text/plain; charset=UTF-8"
Exemplo n.º 8
0
    def __activate__(self, context):
        self.vc = context

        responseType = "text/html; charset=UTF-8"
        responseMsg = ""
        func = self.vc("formData").get("func")
        if func == "placeName":
            try:
                placeName = self.vc("formData").get("q")
                url = "http://ws.geonames.org/searchJSON?fuzzy=0.7&q=" + placeName
                client = BasicHttpClient(url)
                get = GetMethod(url)
                statusInt = client.executeMethod(get)
                r = str(statusInt)
                json = JsonSimple(get.getResponseBodyAsString().strip())
                for geoName in json.getJsonSimpleList("geonames"):
                    responseMsg += "%s, %s|%s \n" % (geoName.getString(None, "name"), geoName.getString(None, "countryName"), geoName.getString(None, "geonameId"))
            except Exception, e:
                print "exception: ", str(e)
                r = str(e), None
            responseType = "text/plain; charset=UTF-8"
Exemplo n.º 9
0
    def __activate__(self, context):
        self.vc = context

        responseType = "text/html; charset=UTF-8"
        responseMsg = ""
        func = self.vc("formData").get("func")
        if func == "placeName":
            try:
                placeName = self.vc("formData").get("q")
                url = "http://ws.geonames.org/searchJSON?fuzzy=0.7&q=" + placeName
                client = BasicHttpClient(url)
                get = GetMethod(url)
                statusInt = client.executeMethod(get)
                r = str(statusInt)
                json = JsonSimple(get.getResponseBodyAsString().strip())
                for geoName in json.getJsonSimpleList("geonames"):
                    responseMsg += "%s, %s|%s \n" % (geoName.getString(
                        None, "name"), geoName.getString(None, "countryName"),
                                                     geoName.getString(
                                                         None, "geonameId"))
            except Exception, e:
                print "exception: ", str(e)
                r = str(e), None
            responseType = "text/plain; charset=UTF-8"