本文整理匯總了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())
示例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()
示例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)))
示例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)
示例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
示例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())
示例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())
示例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
示例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")
示例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
示例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
示例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)
示例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
示例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
示例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