当前位置: 首页>>代码示例>>Python>>正文


Python common.JsonObject类代码示例

本文整理汇总了Python中com.googlecode.fascinator.common.JsonObject的典型用法代码示例。如果您正苦于以下问题:Python JsonObject类的具体用法?Python JsonObject怎么用?Python JsonObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了JsonObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: process

    def process(self):
        #We'll return a list with 1 JsonSimple object
        jsonList = []
        data = None
        reader = None
        inStream = None
        document = None
        
        # Run the XML through our parser
        try:
            inStream = FileInputStream(File(self.file))
            reader = InputStreamReader(inStream, "UTF-8")
            document = self.saxReader.read(reader)
        # Parse fails
        except:
            raise
        # Close our file access objects
        finally:
            if reader is not None:
                reader.close()
            if inStream is not None:
                inStream.close()

        # Now go looking for all our data
        data = JsonObject()
        data.put("workflow_source", "XML Alert") # Default
        self.__mapXpathToFields(document, self.map, data)
        
        if data is None:
            return None
        
        jsonList.append(JsonSimple(data))
        return jsonList
开发者ID:andrewbrazzatti,项目名称:redbox-core-dev-build,代码行数:33,代码来源:XMLAlertHandler.py

示例2: __getRvtManifest

 def __getRvtManifest(self, manifest):
     rvtMap = HashMap()
     rvtMap.put("title", manifest.getTitle())
     rvtMap.put("toc", self.__getRvtNodes(manifest.getTopNodes()))
     json = JsonObject(rvtMap)
     #print json.toString()
     return json.toString()
开发者ID:Deakin,项目名称:the-fascinator,代码行数:7,代码来源:organiser.py

示例3: __getJson

 def __getJson(self):
     rvtMap = JsonObject()
     try:
         oid = self.vc("formData").get("oid")
         object = Services.storage.getObject(oid)
         payload = object.getPayload("imsmanifest.xml")
         try:
             from xml.etree import ElementTree
             xmlStr = IOUtils.toString(payload.open(), "UTF-8")
             payload.close()
             xml = ElementTree.XML(xmlStr.encode("UTF-8"))
             ns = xml.tag[:xml.tag.find("}")+1]
             resources = {}
             for res in xml.findall(ns+"resources/"+ns+"resource"):
                 resources[res.attrib.get("identifier")] = res.attrib.get("href")
             organizations = xml.find(ns+"organizations")
             defaultName = organizations.attrib.get("default")
             organizations = organizations.findall(ns+"organization")
             organizations = [o for o in organizations if o.attrib.get("identifier")==defaultName]
             organization = organizations[0]
             title = organization.find(ns+"title").text
             rvtMap.put("title", title)
             items = organization.findall(ns+"item")
             rvtMap.put("toc", self.__getJsonItems(ns, items, resources))
         except Exception, e:
              data["error"] = "Error - %s" % str(e)
              print data["error"]
         object.close()
开发者ID:Deakin,项目名称:the-fascinator,代码行数:28,代码来源:jsonIms.py

示例4: __getUserInfo

    def __getUserInfo(self, username):
        """
            Query HibernateUser to get a user information
            There are users managed by internal auth manager with no attributes other than password
            There are users managed by external auth managers e.g. shibboleth who have attributes
            Each user, at the time of writing: 20140904, each user has multiple identical attribute sets,
            so, only the first one is used
            We put all available attributes of a user in to return value 
        """
        username = username.strip()

        authUserDao = ApplicationContextProvider.getApplicationContext().getBean("hibernateAuthUserDao")
        parameters = HashMap()
        parameters.put("username", username)
        userObjectList = authUserDao.query("getUser", parameters)

        userJson = JsonObject()
        userJson.put("username", username) 
        try:
            if userObjectList.size() > 0:
                # One hit will be enough to get user object
                userJson = self.__constructUserAttribs(userObjectList.get(0), self.ATTRIB_FILTER)
            else:
               # This should not be reached with external sourced users
                self.log.warn("Wrong username or internal user is queried")
        except Exception, e:
            self.log.error("%s: cannot construct user attribute JSON, detail = %s" % (self.__class__.__name__ , str(e)))
开发者ID:the-fascinator,项目名称:fascinator-portal,代码行数:27,代码来源:userlookup.py

示例5: __activate__

    def __activate__(self, context):
        request = context["request"]
        storage = context["Services"].getStorage()
        auth = context["page"].authentication
        log = context["log"]
        
        username = auth.get_name()
        
        oid = request.getParameter("oid")
        approval = request.getParameter("approval")
        approval_comment = request.getParameter("approval_comment")
        
        storedObj = storage.getObject(oid)
        committeeResponses = None
        
        payloadList = storedObj.getPayloadIdList()
        if payloadList.contains("committee-responses.metadata"):
            committeeResponsePayload = storedObj.getPayload("committee-responses.metadata")
            committeeResponses = JsonSimple(committeeResponsePayload.open()).getJsonObject()
        else:
            committeeResponses = JsonObject()
        
        committeeResponse = JsonObject()
        committeeResponse.put("approval",approval)
        committeeResponse.put("approval_comment",approval_comment)
        
        committeeResponses.put(username,committeeResponse)

        log.debug(" %s: Committee %s, approval = %s, comment = %s"  % ( oid, username, approval, approval_comment))
        StorageUtils.createOrUpdatePayload(storedObj,"committee-responses.metadata",IOUtils.toInputStream(committeeResponses.toString(), "UTF-8"))
        context["response"].sendRedirect(context["portalPath"] +"/detail/"+oid)
开发者ID:qcif,项目名称:qcloud-arms,代码行数:31,代码来源:committee.py

示例6: __getPackageTypes

 def __getPackageTypes(self):
     object = self.sysConfig.getObject(["portal", "packageTypes"])
     packageTypes = JsonSimple.toJavaMap(object)
     if packageTypes.isEmpty():
         defaultPackage = JsonObject()
         defaultPackage.put("jsonconfig", "packaging-config.json")
         packageTypes.put("default", JsonSimple(defaultPackage))
     return packageTypes
开发者ID:Deakin,项目名称:the-fascinator,代码行数:8,代码来源:package.py

示例7: getCurationData

    def getCurationData(self, oid):
        json = JsonObject()
        try:
            # Get the object from storage
            storage = self.Services.getStorage()
            object = storage.getObject(oid)

            # Find the package payload
            payload = object.getPayload("metadata.json")
            # Not found?
            if payload is None:
                self.log.error(" * detail.py => Can't find package data!")
                json.put("error", True)
                return json

            # Parse the data
            data = JsonSimple(payload.open())
            payload.close()

            # Return it
            json.put("error", False)
            json.put("relationships", data.writeArray("relationships"))
            return json
        except StorageException, ex:
            self.log.error(" * detail.py => Storage Error accessing data: ", ex)
            json.put("error", True)
            return json
开发者ID:Paul-Nguyen,项目名称:mint,代码行数:27,代码来源:detail.py

示例8: __activate__

    def __activate__(self, context):

         try:
             self.log = context["log"]
             self.response = context["response"]
             self.request = context["request"]
             self.systemConfig = context["systemConfig"]
             self.storage = context["Services"].getStorage()
             self.indexer = context["Services"].getIndexer()
             self.sessionState = context["sessionState"]
             self.sessionState.set("username", "admin")

             out = self.response.getPrintWriter("text/plain; charset=UTF-8")
             relationshipMapper = ApplicationContextProvider.getApplicationContext().getBean("relationshipMapper")
             externalCurationMessageBuilder = ApplicationContextProvider.getApplicationContext().getBean("externalCurationMessageBuilder")

             oid = self.request.getParameter("oid")

             if oid is None :
                 identifier = self.request.getParameter("identifier")
                 oid = self.findOidByIdentifier(identifier)

             relationshipType = self.request.getParameter("relationship")
             curatedPid = self.request.getParameter("curatedPid")
             sourceId = self.request.getParameter("sourceIdentifier")

             digitalObject = StorageUtils.getDigitalObject(self.storage, oid)

             metadataJson = self.getTfPackage(digitalObject)


             relationships = metadataJson.getArray("relationships")
             found = False
             for relationship in relationships:
                 if relationship.get("identifier") == sourceId:
                     relationship.put("isCurated",True)
                     relationship.put("curatedPid",curatedPid)
                     found = True

             if not found:
                 relationship = JsonObject()
                 relationship.put("isCurated",True)
                 relationship.put("curatedPid",curatedPid)
                 relationship.put("relationship",relationshipType)
                 relationship.put("identifier",sourceId)
                 relationships.add(relationship)

             self.log.info(metadataJson.toString(True))
             out.println(metadataJson.toString(True))
             istream = ByteArrayInputStream(String(metadataJson.toString(True)).getBytes())

             for pid in digitalObject.getPayloadIdList():

                 if pid.endswith(".tfpackage"):
                     StorageUtils.createOrUpdatePayload(digitalObject,pid,istream)


             out.close()
         finally:
             self.sessionState.remove("username")
开发者ID:redbox-mint,项目名称:redbox,代码行数:60,代码来源:notifyCuration.py

示例9: __constructUserJson

    def __constructUserJson(self, username):
        """
            There are users managed by internal auth manager with no attributes
            There are users managed by external auth manages e.g. shibboleth who have attributes
            These users username is not necessarily the same as there normal display name
            This function currently solves this issue by checking commonName attribute for shibboleth users  
        """
        username = username.strip()
        userJson = JsonObject()
        userJson.put("userName", username) 
        parameters = HashMap()
#         print "Checking user info for %s" % username
        parameters.put("username", username)
        userObjectList = self.authUserDao.query("getUser", parameters)
#         print "Returned size = %d" % userObjectList.size() 
        if userObjectList.size() > 0:
            userObject = userObjectList.get(0)
            #Check if this is a user with attributes?
            attrb = userObject.getAttributes().get("commonName")
            if attrb is None:
#                 print "We cannot find so called commonName, use %s instead" % username
                userJson.put("realName", username)
            else:
#                 print "We found so called commonName, use %s instead of %s" % (attrb.getValStr(), username)
                userJson.put("realName", attrb.getValStr().strip())
        else:
            # This should not be reached
            self.log.warn("What is going on here? why ends up here?")
            userJson.put("realName", username)
            
        return userJson
开发者ID:qcif,项目名称:qcloud-arms,代码行数:31,代码来源:grantAccess.py

示例10: _addRelatedOid

    def _addRelatedOid(self, tfPackageJson, relatedOid):
        relatedOids = tfPackageJson.getArray("related.datasets")
        if relatedOids is None:
            relatedOids = JSONArray()

        relatedOidJsonObject = JsonObject()
        relatedOidJsonObject.put("oid", relatedOid)
        relatedOids.add(relatedOidJsonObject)
        jsonObject = tfPackageJson.getJsonObject()
        jsonObject.put("related.datasets", relatedOids)
        return jsonObject
开发者ID:nishen,项目名称:redbox,代码行数:11,代码来源:copyTfPackage.py

示例11: _readReviewers

 def _readReviewers(self, storedObj, tfpackage):
     """Read from TFPACKAGE for reviewer's recommendation and map to a json with short keys:
          reviewer-recommend-for : for
          reviewer-recommended-storage : storage   
     """
     reviewersPayload = storedObj.getPayload(tfpackage)
     reviewersRecommends = JsonSimple(reviewersPayload.open()).getJsonObject()
     reviewers = JsonObject()
     reviewers.put("for", reviewersRecommends.get("reviewer-recommend-for"))
     reviewers.put("storage", reviewersRecommends.get("reviewer-recommended-storage"))
     return reviewers
开发者ID:qcif,项目名称:rdsi-arms,代码行数:11,代码来源:assess.py

示例12: __activate__

    def __activate__(self, context):
        self.log = context["log"]
        self.services = context["Services"]

        auth = context["page"].authentication
        username = auth.get_username() # get system username

        try:
            result = self.__constructInfoJson(username)
        except Exception, e:
             self.log.error("%s: cannot get user attributes, detail = %s" % (self.__class__.__name__ , str(e)))
             result = JsonObject()
             result.put("realName", auth.get_name()) # default value: user's realName
开发者ID:qcif,项目名称:rdsi-arms,代码行数:13,代码来源:userinfo.py

示例13: regenerate_key

    def regenerate_key(self):
        clientArray = self.getKeysArray()
        name = self.formData.get("name")
        clientToBeReplaced = None
        index = 0
        for client in clientArray:
            if client.get("name") == name:
                clientToBeReplaced = client
                break
            index = index + 1

        if clientToBeReplaced is not None:
            clientObject = JsonObject()
            clientObject.put("name", self.formData.get("name"))
            clientObject.put("key", self.get_random_key())
            clientArray.set(index,clientObject)
            self.apiKeyService.updateAndSaveKeys(clientArray)
开发者ID:redbox-mint,项目名称:redbox,代码行数:17,代码来源:apiAdmin.py

示例14: __constructInfoJson

    def __constructInfoJson(self, username):
        """
            There are users managed by internal auth manager with no attributes
            There are users managed by external auth managers e.g. shibboleth who have attributes
            We put all available attributes of a user in to return value 
        """
        # print "Query username = %s" % username
        username = username.strip()

        authUserDao = ApplicationContextProvider.getApplicationContext().getBean("hibernateAuthUserDao")
        parameters = HashMap()
        parameters.put("username", username)
        userObjectList = authUserDao.query("getUser", parameters)

        # print "Returned object = %s" % str(userObjectList)
        # print "Returned size = %d" % userObjectList.size() 
        userJson = JsonObject()
        try:
            if userObjectList.size() > 0:
                # One hit will be enough to get user object
                userObj = userObjectList.get(0)
                attrbs = userObj.getAttributes()
                for attrb in attrbs.keySet():
#                     print "Attribute %s = %s) % (attrb, attrbs.get(attrb).getValStr())
                    userJson.put(attrb, attrbs.get(attrb).getValStr())
            else:
               # This should not be reached with external sourced users
                self.log.warn("Wrong username? Every user should have a record")
                userJson.put("userName", username) 
        except Exception, e:
            self.log.error("%s: cannot construct user attribute JSON, detail = %s" % (self.__class__.__name__ , str(e)))
            userJson.put("userName", username)
开发者ID:qcif,项目名称:rdsi-arms,代码行数:32,代码来源:userinfo.py

示例15: updateRelationships

    def updateRelationships(self, relationship,pid,identifier):
        oid = self.findOidByIdentifier(relationship.get("identifier"))
        self.writer.println(oid)
        digitalObject = StorageUtils.getDigitalObject(self.storage, oid)
        metadataJsonPayload = digitalObject.getPayload("metadata.json")
        metadataJsonInstream = metadataJsonPayload.open()
        metadataJson = JsonSimple(metadataJsonInstream)
        metadataJsonPayload.close()
        relationships = metadataJson.getArray("relationships")


        found = False
        if relationships is None:
            relationships = JSONArray()
            metadataJson.getJsonObject().put("relationships",relationships)

        for relationship1 in relationships:
             if relationship1.get("identifier") == identifier:
                 relationship1.put("isCurated",True)
                 relationship1.put("curatedPid",pid)
                 found = True

        if not found:
            newRelationship = JsonObject()
            newRelationship.put("isCurated",True)
            newRelationship.put("curatedPid",pid)
            newRelationship.put("relationship",relationship.get("relationship"))
            newRelationship.put("identifier",identifier)
            relationships.add(newRelationship)


        istream = ByteArrayInputStream(String(metadataJson.toString(True)).getBytes())
        StorageUtils.createOrUpdatePayload(digitalObject,"metadata.json",istream)
开发者ID:ozej8y,项目名称:mint,代码行数:33,代码来源:updateRelationships.py


注:本文中的com.googlecode.fascinator.common.JsonObject类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。