本文整理汇总了Python中au.edu.usq.fascinator.api.PluginManager.getStorage方法的典型用法代码示例。如果您正苦于以下问题:Python PluginManager.getStorage方法的具体用法?Python PluginManager.getStorage怎么用?Python PluginManager.getStorage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类au.edu.usq.fascinator.api.PluginManager
的用法示例。
在下文中一共展示了PluginManager.getStorage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __processRequest
# 需要导入模块: from au.edu.usq.fascinator.api import PluginManager [as 别名]
# 或者: from au.edu.usq.fascinator.api.PluginManager import getStorage [as 别名]
def __processRequest(self):
baseUrl = "http://%s:%s%s/%s" % (request.serverName, serverPort, contextPath, portalId)
depositUrl = "%s/sword/deposit.post" % baseUrl
sword = SwordSimpleServer(depositUrl)
try:
p = request.path.split(portalId+"/"+pageName+"/")[1] # portalPath
except:
p = ""
if p=="post":
print "\n--- post ---"
c = sword.getClient()
c.clearProxy()
c.clearCredentials()
postMsg = sword.getPostMessage();
postMsg.filetype = "application/zip"
postMsg.filepath = "/home/ward/Desktop/Test.zip"
depositResponse = c.postFile(postMsg)
return str(depositResponse)
elif p=="servicedocument":
#print "\n--- servicedocument ---"
sdr = sword.getServiceDocumentRequest()
sdr.username = formData.get("username", "test")
sdr.password = formData.get("password", "test")
if formData.get("test"):
depositUrl += "?test=1"
sd = sword.doServiceDocument(sdr) # get a serviceDocument
out = response.getPrintWriter("text/xml")
out.println(str(sd))
out.close()
bindings["pageName"] = "-noTemplate-"
return sd
elif p=="deposit.post":
#print "\n--- deposit --- formData='%s'" % str(formData)
inputStream = formData.getInputStream()
headers = {}
for x in formData.getHeaders().entrySet():
headers[x.getKey()] = x.getValue()
deposit = sword.getDeposit()
noOp = headers.get("X-No-Op") or "false"
deposit.noOp = (noOp.lower()=="true") or \
(formData.get("test") is not None)
contentDisposition = headers.get("Content-Disposition", "")
filename = ""
if contentDisposition!="":
try:
filename = contentDisposition.split("filename=")[1]
deposit.filename = filename
except: pass
slug = headers.get("Slug")
if slug is not None and slug!="":
deposit.slug = slug
#elif filename!="":
# deposit.slug = filename
deposit.username = "SwordUser"
deposit.password = deposit.username
try:
file = File.createTempFile("tmptf", ".zip")
file.deleteOnExit()
fos = FileOutputStream(file.getAbsolutePath())
IOUtils.copy(inputStream, fos)
fos.close()
print "copied posted data to '%s'" % file.getAbsolutePath()
except Exception, e:
print "--- Exception - '%s'" % str(e)
deposit.contentDisposition = file.getAbsolutePath() #????
deposit.file = inputStream
depositResponse = sword.doDeposit(deposit)
id = str(depositResponse.getEntry().id)
try:
print
#imsPlugin = PluginManager.getTransformer("ims")
jsonConfig = JsonConfig()
#imsPlugin.init(jsonConfig.getSystemFile())
#harvestClient = HarvestClient(jsonConfig.getSystemFile());
storagePlugin = PluginManager.getStorage(jsonConfig.get("storage/type"))
#storagePlugin.init(jsonConfig.getSystemFile())
setConfigUri = self.__getPortal().getClass().getResource("/swordRule.json").toURI()
configFile = File(setConfigUri)
harvestConfig = JsonConfigHelper(configFile);
tFile = File.createTempFile("harvest", ".json")
tFile.deleteOnExit()
harvestConfig.set("configDir", configFile.getParent())
harvestConfig.set("sourceFile", file.getAbsolutePath())
harvestConfig.store(FileWriter(tFile))
zipObject = GenericDigitalObject(id)
zipObject.addPayload(FilePayload(file, id))
#digitalObject = imsPlugin.transform(zipObject, file)
qStorage = QueueStorage(storagePlugin, tFile)
qStorage.init(jsonConfig.getSystemFile())
qStorage.addObject(zipObject)
if deposit.noOp:
print "-- Testing noOp='true' --"
else:
# deposit the content
pass
except Exception, e:
print "---"
#.........这里部分代码省略.........