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


Python JsonObject.put方法代码示例

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


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

示例1: send_message

# 需要导入模块: from com.googlecode.fascinator.common import JsonObject [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonObject import put [as 别名]
 def send_message(self, oid):
     message = JsonObject()
     message.put("oid", oid)
     message.put("task", "curation-confirm")
     self.messaging.queueMessage(
             TransactionManagerQueueConsumer.LISTENER_ID,
             message.toString())
开发者ID:Deakin,项目名称:mint,代码行数:9,代码来源:nla.py

示例2: __getJson

# 需要导入模块: from com.googlecode.fascinator.common import JsonObject [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonObject import put [as 别名]
 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,代码行数:30,代码来源:jsonIms.py

示例3: __getUserInfo

# 需要导入模块: from com.googlecode.fascinator.common import JsonObject [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonObject import put [as 别名]
    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,代码行数:29,代码来源:userlookup.py

示例4: __activate__

# 需要导入模块: from com.googlecode.fascinator.common import JsonObject [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonObject import put [as 别名]
    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,代码行数:33,代码来源:committee.py

示例5: process

# 需要导入模块: from com.googlecode.fascinator.common import JsonObject [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonObject import put [as 别名]
    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,代码行数:35,代码来源:XMLAlertHandler.py

示例6: sendMessage

# 需要导入模块: from com.googlecode.fascinator.common import JsonObject [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonObject import put [as 别名]
 def sendMessage(self, oid):
     message = JsonObject()
     message.put("oid", oid)
     message.put("task", "reharvest")
     self.messaging.queueMessage(
             TransactionManagerQueueConsumer.LISTENER_ID,
             message.toString())
开发者ID:andrewbrazzatti,项目名称:redbox-core-dev-build,代码行数:9,代码来源:reharvest.py

示例7: sendMessage

# 需要导入模块: from com.googlecode.fascinator.common import JsonObject [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonObject import put [as 别名]
 def sendMessage(self, oid, eventType):
     message = JsonObject()
     message.put("oid", oid)
     message.put("eventType", eventType)
     message.put("username", self.vc("page").authentication.get_username())
     message.put("context", "Workflow")
     message.put("task", "workflow")
     self.messaging.queueMessage(TransactionManagerQueueConsumer.LISTENER_ID, message.toString())
开发者ID:jcu-eresearch-admin,项目名称:redbox,代码行数:10,代码来源:workflow.py

示例8: __getPackageTypes

# 需要导入模块: from com.googlecode.fascinator.common import JsonObject [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonObject import put [as 别名]
 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,代码行数:10,代码来源:package.py

示例9: __activate__

# 需要导入模块: from com.googlecode.fascinator.common import JsonObject [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonObject import put [as 别名]
    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")
             system = self.request.getParameter("system")

             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
             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)
                 relationship.put("system",system)
                 relationships.add(relationship)

             out.println(metadataJson.toString(True))
             istream = ByteArrayInputStream(String(metadataJson.toString(True)).getBytes())
             StorageUtils.createOrUpdatePayload(digitalObject,"metadata.json",istream)

             out.close()
         finally:
             self.sessionState.remove("username")
开发者ID:jcu-eresearch,项目名称:TDH-Name-Authority,代码行数:59,代码来源:notifyCuration.py

示例10: _readReviewers

# 需要导入模块: from com.googlecode.fascinator.common import JsonObject [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonObject import put [as 别名]
 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,代码行数:13,代码来源:assess.py

示例11: _addRelatedOid

# 需要导入模块: from com.googlecode.fascinator.common import JsonObject [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonObject import put [as 别名]
    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,代码行数:13,代码来源:copyTfPackage.py

示例12: transformLegacyArrays

# 需要导入模块: from com.googlecode.fascinator.common import JsonObject [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonObject import put [as 别名]
 def transformLegacyArrays(self, originalObject):
     outputJsonObject = JsonObject()
     dataUtil = StorageDataUtil()
     outputJsonObject = JsonObject()
     jsonObject = originalObject.getJsonObject()
     for keyString in jsonObject.keySet():
         if self.isAnArrayKey(keyString):
             prefix = self.getPrefix(keyString);
             outputJsonObject.put(prefix, dataUtil.getJavaList(json,prefix));
         else:
             outputJsonObject.put(keyString, jsonObject.get(keyString));
     return JsonSimple(outputJsonObject)
开发者ID:redbox-mint,项目名称:redbox,代码行数:14,代码来源:get.py

示例13: __activate__

# 需要导入模块: from com.googlecode.fascinator.common import JsonObject [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonObject import put [as 别名]
    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,代码行数:15,代码来源:userinfo.py

示例14: getCurationData

# 需要导入模块: from com.googlecode.fascinator.common import JsonObject [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonObject import put [as 别名]
    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,代码行数:29,代码来源:detail.py

示例15: __constructUserJson

# 需要导入模块: from com.googlecode.fascinator.common import JsonObject [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonObject import put [as 别名]
    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,代码行数:33,代码来源:grantAccess.py


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