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


Python JsonObject.toString方法代码示例

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


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

示例1: __getRvtManifest

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

示例2: send_message

# 需要导入模块: from com.googlecode.fascinator.common import JsonObject [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonObject import toString [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

示例3: __activate__

# 需要导入模块: from com.googlecode.fascinator.common import JsonObject [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonObject import toString [as 别名]
    def __activate__(self, context):
        response = context["response"]
        json = JsonObject()
        auth = context["page"].authentication
        if auth.is_logged_in():
            formData = context["formData"]
            oid = formData.get("oid")
            if oid:
                # TODO check security on object
                json.put("oid", oid)
                try:
                    metaNode = JsonObject()
                    json.put("meta", metaNode)

                    object = context["Services"].storage.getObject(oid)
                    metadata = object.getMetadata()

                    for key in metadata.keySet():
                        metaNode.put(key, metadata.get(key))
                except StorageException:
                    response.setStatus(500)
                    json.put("error", "Object '%s' not found" % oid)
            else:
                response.setStatus(500)
                json.put("error", "An object identifier is required")
        else:
            response.setStatus(500)
            json.put("error", "Only registered users can access this API")
        
        writer = response.getPrintWriter("text/plain; charset=UTF-8")
        writer.println(json.toString())
        writer.close()
开发者ID:Deakin,项目名称:the-fascinator,代码行数:34,代码来源:objectMeta.py

示例4: sendMessage

# 需要导入模块: from com.googlecode.fascinator.common import JsonObject [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonObject import toString [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

示例5: sendMessage

# 需要导入模块: from com.googlecode.fascinator.common import JsonObject [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonObject import toString [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

示例6: __sendMessage

# 需要导入模块: from com.googlecode.fascinator.common import JsonObject [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonObject import toString [as 别名]
 def __sendMessage(self, oid, step):
     message = JsonObject()
     message.put("oid", oid)
     if step is None:
         message.put("eventType", "ReIndex")
     else:
         message.put("eventType", "NewStep : %s" % step)
     message.put("newStep", step)
     message.put("username", "admin")
     message.put("context", "Workflow")
     message.put("task", "workflow")
     self.messaging.queueMessage(
             TransactionManagerQueueConsumer.LISTENER_ID,
             message.toString())
开发者ID:DanielBaird,项目名称:TDH-Research-Data-Catalogue,代码行数:16,代码来源:directoryNames.py

示例7: __activate__

# 需要导入模块: from com.googlecode.fascinator.common import JsonObject [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonObject import toString [as 别名]
    def __activate__(self, context):
        self.sysConfig = JsonSimpleConfig()
        self.velocityContext = context
        self.log = context["log"]
        self.__meta = {}
        formData = self.vc("formData")

        self.isAjax = formData.get("ajax") != None
        if self.isAjax:
            ok = JsonObject()
            ok.put("ok", "OK")
            self.json = ok.toString()
        else:
            self.json = ""

        self.__selectedPackageType = formData.get("packageType", "default")
        self.log.debug("formData = %s" % self.vc("formData"))
        self.log.debug("selectedPackageType = '%s'" % self.__selectedPackageType)
        self.__meta["packageType"] = formData.get("packageType", "default")
        self.__meta["description"] = formData.get("description", "")
开发者ID:Deakin,项目名称:the-fascinator,代码行数:22,代码来源:package.py

示例8: _reharvestPackage

# 需要导入模块: from com.googlecode.fascinator.common import JsonObject [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonObject import toString [as 别名]
 def _reharvestPackage(self):
     message = JsonObject()
     message.put("oid", self.formData.get("toOid"))
     message.put("task", "reharvest")
     self.messaging.queueMessage( TransactionManagerQueueConsumer.LISTENER_ID, message.toString())
开发者ID:ozej8y,项目名称:redbox,代码行数:7,代码来源:copyTfPackage.py

示例9: saveResponse

# 需要导入模块: from com.googlecode.fascinator.common import JsonObject [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonObject import toString [as 别名]
    def saveResponse(self, context):
        """ Save into object storage key to assessor's name
            It has four keys: status, recommendation, size-agreement and comments
            when status == "submitted", reviewer sees it
        """
        oid = self.request.getParameter("oid")
        action = self.request.getParameter("action")
        if action and re.match("submit", action, re.I):
            status = "submitted"
        else:
            status = "draft"

        recommendation = self.request.getParameter("recommendation")
        sizeAgreement = self.request.getParameter("size-agreement")
        comments = self.request.getParameter("comments")

        storedObj, fileExisted = self.hasResponses(oid)
        if fileExisted:
            committeeResponses = self.getResponses(storedObj)
        else:
            committeeResponses = JsonObject()

        assessorResponse = JsonObject()
        assessorResponse.put("status", status)
        if status == 'submitted':
            assessorResponse.put("date",self._getToday())
        assessorResponse.put("recommendation",recommendation)
        assessorResponse.put("size-agreement",sizeAgreement)
        assessorResponse.put("comments",comments)

        committeeResponses.put(self.assessor,assessorResponse)

        StorageUtils.createOrUpdatePayload(storedObj,self.PAYLOAD,IOUtils.toInputStream(committeeResponses.toString(), "UTF-8"))
        context["response"].sendRedirect(context["portalPath"] +"/detail/"+oid)
开发者ID:qcif,项目名称:rdsi-arms,代码行数:36,代码来源:Assessment.py

示例10: __activate__

# 需要导入模块: from com.googlecode.fascinator.common import JsonObject [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonObject import toString [as 别名]
    def __activate__(self, context):
        response = context["response"]
        log = context["log"]
        writer = response.getPrintWriter("text/plain; charset=UTF-8")
        auth = context["page"].authentication
        sessionState = context["sessionState"]

        result = JsonObject()
        result.put("status", "error")
        result.put("message", "An unknown error has occurred")

        if auth.is_admin():
            services = context["Services"]
            formData = context["formData"]
            func = formData.get("func")
            oid = formData.get("oid")
            portalId = formData.get("portalId")
            portalManager = services.portalManager

            if func == "reharvest":
                # One object
                if oid:
                    log.info(" * Reharvesting object '{}'", oid)
                    portalManager.reharvest(oid)
                    result.put("status", "ok")
                    result.put("message", "Object '%s' queued for reharvest")

                # The whole portal
                elif portalId:
                    log.info(" * Reharvesting view '{}'", portalId)
                    sessionState.set("reharvest/running/" + portalId, "true")
                    # TODO security filter - not necessary because this requires admin anyway?
                    portal = portalManager.get(portalId)
                    query = "*:*"
                    if portal.query != "":
                        query = portal.query
                    if portal.searchQuery != "":
                        if query == "*:*":
                            query = portal.searchQuery
                        else:
                            query = query + " AND " + portal.searchQuery
                    # query solr to get the objects to reharvest
                    rows = 25
                    req = SearchRequest(query)
                    req.setParam("fq", 'item_type:"object"')
                    req.setParam("rows", str(rows))
                    req.setParam("fl", "id")
                    done = False
                    count = 0
                    while not done:
                        req.setParam("start", str(count))
                        out = ByteArrayOutputStream()
                        services.indexer.search(req, out)
                        json = SolrResult(ByteArrayInputStream(out.toByteArray()))
                        objectIds = HashSet(json.getFieldList("id"))
                        if not objectIds.isEmpty():
                            portalManager.reharvest(objectIds)
                        count = count + rows
                        total = json.getNumFound()
                        log.info(" * Queued {} of {}...", (min(count, total), total))
                        done = (count >= total)
                    sessionState.remove("reharvest/running/" + portalId)
                    result.put("status", "ok")
                    result.put("message", "Objects in '%s' queued for reharvest" % portalId)
                else:
                    response.setStatus(500)
                    result.put("message", "No object or view specified for reharvest")

            elif func == "reindex":
                if oid:
                    log.info(" * Reindexing object '{}'", oid)
                    services.indexer.index(oid)
                    services.indexer.commit()
                    result.put("status", "ok")
                    result.put("message", "Object '%s' queued for reindex" % portalId)
                else:
                    response.setStatus(500)
                    result.put("message", "No object specified to reindex")
            else:
                response.setStatus(500)
                result.put("message", "Unknown action '%s'" % func)
        else:
            response.setStatus(500)
            result.put("message", "Only administrative users can access this API")
        writer.println(result.toString())
        writer.close()
开发者ID:Deakin,项目名称:the-fascinator,代码行数:88,代码来源:reharvest.py

示例11: process

# 需要导入模块: from com.googlecode.fascinator.common import JsonObject [as 别名]
# 或者: from com.googlecode.fascinator.common.JsonObject import toString [as 别名]
    def process(self):
        self.log.debug(" * settings.py: formData={}", self.vc("formData"))

        valid = self.vc("page").csrfSecurePage()
        if not valid:
            self.throw_error("Invalid request")
            return

        result = "{}"
        portalManager = self.vc("Services").getPortalManager()
        portal = portalManager.get(self.vc("portalId"))
        func = self.vc("formData").get("func")

        if func == "view-update":
            portal.setDescription(self.vc("formData").get("view-description"))
            portal.setQuery(self.vc("formData").get("view-query"))
            portal.setSearchQuery(self.vc("formData").get("view-search-query"))
            portal.setRecordsPerPage(int(self.vc("formData").get("view-records-per-page")))
            portal.setFacetCount(int(self.vc("formData").get("view-facet-count")))
            portal.setFacetDisplay(int(self.vc("formData").get("view-facet-display")))
            portal.setFacetSort(self.vc("formData").get("view-facet-sort") is not None)
            portalManager.save(portal)

        elif func == "general-update":
            config = JsonSimpleConfig()
            email = StringUtils.trimToEmpty(self.vc("formData").get("general-email"))
            systemEmail = StringUtils.trimToEmpty(config.getString(None, ["email"]))
            if systemEmail != email:
                obj = config.writableSystemConfig()
                obj.put("email", self.vc("formData").get("general-email"))
                obj.put("configured", "true")
                config.storeSystemConfig()
                # mark restart
                self.vc("Services").getHouseKeepingManager().requestUrgentRestart()
            else:
                self.log.debug(" * settings.py: email not updated: did not change")
                self.throw_error("Email address is the same! No change saved.")

        elif func == "facets-update":
            portal.getObject(["portal"]).remove("facet-fields")
            fields = self.vc("formData").getValues("field")
            labels = self.vc("formData").getValues("label")
            displays = self.vc("formData").getValues("display")
            deletes = self.vc("formData").getValues("delete")
            for i in range(0, len(fields)):
                field = fields[i]
                if deletes[i] == "false":
                    node = portal.writeObject(["portal", "facet-fields", field])
                    node.put("label", labels[i])
                    node.put("display", displays[i])
            portalManager.save(portal)

        elif func == "sort-update":
            portal.getObject(["portal"]).remove("sort-fields")
            default = self.vc("formData").get("default")
            if default:
                portal.setSortFieldDefault(default)
            order = self.vc("formData").get("order")
            if order:
                portal.setSortFieldDefaultOrder(order)
            fields = self.vc("formData").getValues("field")
            labels = self.vc("formData").getValues("label")
            deletes = self.vc("formData").getValues("delete")
            for i in range(0, len(fields)):
                field = fields[i]
                if deletes[i] == "false":
                    node = portal.writeObject(["portal", "sort-fields"])
                    node.put(field, labels[i])
            portalManager.save(portal)

        elif func == "watcher-update":
            configFile = self.getWatcherFile()
            if configFile is not None:
                json = JsonSimpleConfig(configFile)
                pathIds = self.vc("formData").get("pathIds").split(",")
                actives = self.vc("formData").getValues("watcher-active")
                if actives is None:
                    actives = []
                deletes = self.vc("formData").getValues("watcher-delete")
                if deletes is None:
                    deletes = []
                for pathId in pathIds:
                    if pathId not in deletes:
                        path = self.vc("formData").get("%s-path" % pathId)
                        stopped = str(pathId not in actives).lower()
                        watchDir = json.writeObject(["watcher", "watchDirs", path])
                        watchDir.put("ignoreFileFilter", self.vc("formData").get("%s-file" % pathId))
                        watchDir.put("ignoreDirectories", self.vc("formData").get("%s-dir" % pathId))
                        watchDir.put("stopped", stopped)
                        json.writeArray(["watcher", "watchDirs", path, "cxtTags"])
                writer = FileWriter(configFile)
                writer.write(json.toString(True))
                writer.close()
            else:
                result = "The Watcher is not installed properly."

        elif func == "restore-default-config":
            # backup the file
            JsonSimpleConfig.backupSystemFile()
            # delete the file
#.........这里部分代码省略.........
开发者ID:Deakin,项目名称:the-fascinator,代码行数:103,代码来源:settings.py


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