コード例 #1
0
ファイル: manifest.py プロジェクト: kiranba/the-fascinator
 def __init__(self):
     print "formData=%s" % formData
     
     result = "{}"
     func = formData.get("func")
     oid = formData.get("oid")
     
     if func != "set-package-title":
         nodeId = formData.get("nodeId")
         nodePath = self.__getNodePath(formData.get("parents"), nodeId)
         originalPath = "manifest//%s" % nodeId
     
     self.__object = Services.getStorage().getObject(oid)
     sourceId = self.__object.getSourceId()
     payload = self.__object.getPayload(sourceId)
     self.__manifest = JsonConfigHelper(payload.open())
     payload.close()
     
     if func == "set-package-title":
         title = formData.get("title")
         self.__manifest.set("title", StringEscapeUtils.escapeHtml(title))
         self.__saveManifest()
     if func == "rename":
         title = formData.get("title")
         self.__manifest.set("%s/title" % nodePath, title)
         self.__saveManifest()
     elif func == "move":
         refNodeId = formData.get("refNodeId")
         refNodePath = self.__getNodePath(formData.get("refParents"),
                                          formData.get("refNodeId"));
         moveType = formData.get("type")
         if moveType == "before":
             self.__manifest.moveBefore(originalPath, refNodePath)
         elif moveType == "after":
             self.__manifest.moveAfter(originalPath, refNodePath)
         elif moveType == "inside":
             self.__manifest.move(originalPath, nodePath)
         self.__saveManifest()
     elif func == "update":
         title = StringEscapeUtils.escapeHtml(formData.get("title"))
         hidden = formData.get("hidden")
         hidden = hidden == "true"
         self.__manifest.set("%s/title" % nodePath, title)
         self.__manifest.set("%s/hidden" % nodePath, str(hidden))
         self.__saveManifest()
         result = '{ title: "%s", hidden: "%s" }' % (title, hidden)
     
     self.__object.close()
     writer = response.getPrintWriter("text/plain; charset=UTF-8")
     writer.println(result)
     writer.close()
コード例 #2
0
ファイル: docxexporter.py プロジェクト: qcif/rdsi-arms
 def handle_data(self, data):
     # ~ print("Data     :", data)
     d = " ".join(data.split())
     if d:
         # ~ print ("This is real: ", d)
         if self.current_tag == "span":
             d = map2(d)
             # ~ if d in ["checked", "unchecked"]:
             # ~ print "Do yes/no, radio buttons, checkboxes stuff, how many spans?"
             if d in self.contacts:
                 # ~ print "We need to process %s " % self.contacts[d]
                 # if span has interesting string, trigger recording next tr
                 self.nexts["td"] = True
                 self.current_contact = self.contacts[d]
             if d in "Select the appropriate re-use condition for this research data":
                 print "Hit: collection-details-access-level but different, skip for now"
             if d in "Indicate an anticipated number of users of this data":
                 print "Hit: exp-number-users,skip for now"
             if d in self.simple_fields:
                 # ~ print "Simle field, the content of the next cell need to be packed"
                 self.current_field["name"] = self.simple_fields[d]
                 self.current_field["type"] = "simple"
                 self.nexts["td"] = True
             ## the if-else block is not useful if field names and values are in different cells
             ## it is useful when one next to each other
             # if self.leading:
             #    self.current_key = d
             #    #~ print "create key %s" % self.current_key
             #    self.jobj[self.current_key] = ""
             # else:
             #    #~ print "save value [ %s ] to %s" % (data, self.current_key)
             #    self.jobj[self.current_key] = d
             if self.nexts["p"] and self.start_push:
                 self.stacks.append(StringEscapeUtils.escapeHtml(d))
コード例 #3
0
    def getContent(self, oid, metadata):
        # Get the object
        object = Services.getStorage().getObject(oid)
        if object is None:
            return ""

        # Get the preview/source payload
        pid = metadata.getFirst("preview")
        if pid is None:
            pid = object.getSourceId()
        if pid is None:
            return ""
        payload = object.getPayload(object.getSourceId())
        if payload is None:
            return ""

        # Stream the content out to string
        out = ByteArrayOutputStream()
        IOUtils.copy(payload.open(), out)
        payload.close()
        string = out.toString("UTF-8")

        return "<pre>" + StringEscapeUtils.escapeHtml(string) + "</pre>"
コード例 #4
0
ファイル: detail.py プロジェクト: Deakin/the-fascinator
    def getContent(self, oid, metadata):
        # Get the object
        object = Services.getStorage().getObject(oid)
        if object is None:
            return ""

        # Get the preview/source payload
        pid = metadata.getFirst("preview")
        if pid is None:
            pid = object.getSourceId()
        if pid is None:
            return ""
        payload = object.getPayload(object.getSourceId())
        if payload is None:
            return ""

        # Stream the content out to string
        out = ByteArrayOutputStream()
        IOUtils.copy(payload.open(), out)
        payload.close()
        string = out.toString("UTF-8")

        return "<pre>" + StringEscapeUtils.escapeHtml(string) + "</pre>"
コード例 #5
0
ファイル: organiser.py プロジェクト: Deakin/the-fascinator
 def getFormData(self, field):
     return StringEscapeUtils.escapeHtml(self.vc("formData").get(field, ""))
コード例 #6
0
ファイル: detail.py プロジェクト: ozej8y/redbox
 def escapeHtml(self, value):
     if value:
         return StringEscapeUtils.escapeHtml(value) or ""
     return ""
コード例 #7
0
 def getEscapeHtml(self, value):
     return StringEscapeUtils.escapeHtml(value)
コード例 #8
0
ファイル: layout.py プロジェクト: kiranba/the-fascinator
 def escapeHtml(self, text):
     return StringEscapeUtils.escapeHtml(text)
コード例 #9
0
ファイル: nameAuthority.py プロジェクト: Paul-Nguyen/mint
 def getMeta(self, metaName):
     return StringEscapeUtils.escapeHtml(
         self.formData.get(metaName, self.__manifest.get(metaName)))
コード例 #10
0
 def getText(self):
     return StringEscapeUtils.escapeHtml(
         self.__metadata.get("user_agreement_text"))
コード例 #11
0
ファイル: manifest.py プロジェクト: kiranba/the-fascinator
    def __init__(self):
        print "formData=%s" % formData

        result = "{}"
        func = formData.get("func")
        oid = formData.get("oid")

        if func != "update-package-meta":
            nodeId = formData.get("nodeId")
            nodePath = self.__getNodePath(formData.get("parents"), nodeId)
            originalPath = "manifest//%s" % nodeId

        self.__object = Services.getStorage().getObject(oid)
        sourceId = self.__object.getSourceId()
        payload = self.__object.getPayload(sourceId)
        self.__manifest = JsonConfigHelper(payload.open())
        payload.close()

        if func == "update-package-meta":
            print "*********  update-package-meta ***************"
            metaList = list(formData.getValues("metaList"))
            for metaName in metaList:
                value = formData.get(metaName)
                self.__manifest.set(metaName, value)
            # title = formData.get("title")
            # self.__manifest.set("title", StringEscapeUtils.escapeHtml(title))
            self.__saveManifest()
        if func == "rename":
            title = formData.get("title")
            self.__manifest.set("%s/title" % nodePath, title)
            self.__saveManifest()
        elif func == "move":
            refNodeId = formData.get("refNodeId")
            refNodePath = self.__getNodePath(formData.get("refParents"), formData.get("refNodeId"))
            moveType = formData.get("type")
            if moveType == "before":
                self.__manifest.moveBefore(originalPath, refNodePath)
            elif moveType == "after":
                self.__manifest.moveAfter(originalPath, refNodePath)
            elif moveType == "inside":
                self.__manifest.move(originalPath, nodePath)
            self.__saveManifest()
        elif func == "update":
            title = StringEscapeUtils.escapeHtml(formData.get("title"))
            hidden = formData.get("hidden")
            hidden = hidden == "true"
            self.__manifest.set("%s/title" % nodePath, title)
            self.__manifest.set("%s/hidden" % nodePath, str(hidden))
            # if self.__manifest.get("%s/id" % nodePath) is None:
            #    print "blank node!"
            self.__saveManifest()
            result = '{ title: "%s", hidden: "%s" }' % (title, hidden)
        elif func == "delete":
            title = self.__manifest.get("%s/title" % nodePath)
            if title:
                self.__manifest.removePath(nodePath)
                self.__saveManifest()
            else:
                title = "Untitled"
            result = '{ title: "%s" }' % title

        self.__object.close()
        writer = response.getPrintWriter("text/plain; charset=UTF-8")
        writer.println(result)
        writer.close()
コード例 #12
0
 def getRequestData(self, field):
     return StringEscapeUtils.escapeHtml(self.__requestData.getString("", [field]))
コード例 #13
0
ファイル: organiser.py プロジェクト: Deakin/the-fascinator
 def getPackageTitle(self):
     return StringEscapeUtils.escapeHtml(self.vc("formData").get("title", self.__manifest.getTitle()))
コード例 #14
0
 def getText(self):
     return StringEscapeUtils.escapeHtml(self.__metadata.get("user_agreement_text"))
コード例 #15
0
ファイル: manifest.py プロジェクト: kiranba/the-fascinator
    def __activate__(self, context):
        self.velocityContext = context
        auth = context["page"].authentication
        if auth.is_logged_in():
            self.fd = self.vc("formData").get

            print "formData=%s" % self.vc("formData")
            result = "{}"
            func = self.fd("func")
            oid = self.fd("oid")
    
            if func != "update-package-meta":
                nodeId = self.fd("nodeId")
                nodePath = self.__getNodePath(self.fd("parents"), nodeId)
                originalPath = "manifest//%s" % nodeId
    
            self.__object = Services.getStorage().getObject(oid)
            sourceId = self.__object.getSourceId()
            payload = self.__object.getPayload(sourceId)
            self.__manifest = JsonConfigHelper(payload.open())
            payload.close()
    
            if func == "update-package-meta":
                print "*********  update-package-meta ***************"
                metaList = list(self.vc("formData").getValues("metaList"))
                for metaName in metaList:
                    value = self.fd(metaName)
                    self.__manifest.set(metaName, value)
                #title = formData.get("title")
                #self.__manifest.set("title", StringEscapeUtils.escapeHtml(title))
                self.__saveManifest()
            if func == "rename":
                title = self.fd("title")
                self.__manifest.set("%s/title" % nodePath, title)
                self.__saveManifest()
            elif func == "move":
                refNodeId = self.fd("refNodeId")
                refNodePath = self.__getNodePath(self.fd("refParents"),
                                                 self.fd("refNodeId"));
                moveType = self.fd("type")
                if moveType == "before":
                    self.__manifest.moveBefore(originalPath, refNodePath)
                elif moveType == "after":
                    self.__manifest.moveAfter(originalPath, refNodePath)
                elif moveType == "inside":
                    self.__manifest.move(originalPath, nodePath)
                self.__saveManifest()
            elif func == "update":
                title = StringEscapeUtils.escapeHtml(self.fd("title"))
                hidden = self.fd("hidden")
                hidden = hidden == "true"
                self.__manifest.set("%s/title" % nodePath, title)
                self.__manifest.set("%s/hidden" % nodePath, str(hidden))
                #if self.__manifest.get("%s/id" % nodePath) is None:
                #    print "blank node!"
                self.__saveManifest()
                result = '{ title: "%s", hidden: "%s" }' % (title, hidden)
            elif func == "delete":
                title = self.__manifest.get("%s/title" % nodePath)
                if title:
                    self.__manifest.removePath(nodePath)
                    self.__saveManifest()
                else:
                    title = "Untitled"
                result = '{ title: "%s" }' % title
            
            self.__object.close()
        else:
            result = '{ "status": "error", "message": "Only registered users can access this API" }'
        
        writer = self.vc("response").getPrintWriter("text/plain; charset=UTF-8")
        writer.println(result)
        writer.close()
コード例 #16
0
 def getFormData(self, field):
     formData = self.vc("formData")
     return StringEscapeUtils.escapeHtml(formData.get(field, ""))
コード例 #17
0
 def getMeta(self, metaName):
     return StringEscapeUtils.escapeHtml(
         self.vc("formData").get(
             metaName, self.__manifest.getString(None, [metaName])))
コード例 #18
0
 def getPackageTitle(self):
     return StringEscapeUtils.escapeHtml(
         self.vc("formData").get("title", self.__manifest.getTitle()))
コード例 #19
0
ファイル: organiser.py プロジェクト: Deakin/the-fascinator
 def getMeta(self, metaName):
     return StringEscapeUtils.escapeHtml(self.vc("formData").get(metaName, self.__manifest.getString(None, [metaName])))
コード例 #20
0
 def escapeHtml(self, value):
     if value:
         return StringEscapeUtils.escapeHtml(value) or ""
     return ""
コード例 #21
0
 def escapeHtml(self, text):
     return StringEscapeUtils.escapeHtml(text)
コード例 #22
0
 def getFormData(self, field):
     return StringEscapeUtils.escapeHtml(self.__formData.get(field, ""))
コード例 #23
0
 def getEscapeHtml(self, value):
     return StringEscapeUtils.escapeHtml(value)
コード例 #24
0
 def getRequestData(self, field):
     return StringEscapeUtils.escapeHtml(
         self.__requestData.getString("", [field]))
コード例 #25
0
    def __activate__(self, context):
        self.velocityContext = context
        auth = context["page"].authentication
        if auth.is_logged_in():
            self.fd = self.vc("formData").get

            #print "formData=%s" % self.vc("formData")
            result = "{}"
            func = self.fd("func")
            oid = self.fd("oid")
    
            self.__object = Services.getStorage().getObject(oid)
            sourceId = self.__object.getSourceId()
            payload = self.__object.getPayload(sourceId)
            self.__manifest = Manifest(payload.open())
            payload.close()

            # Add a new custom node at the top leve
            if func == "add-custom":
                id = md5.new(str(uuid.uuid4())).hexdigest()
                self.__manifest.addTopNode(id, "Untitled")
                # We gave an ID for the Library to use in storage, but as
                #  metadata we want it to say 'blank'
                node = self.__manifest.getNode("node-%s" % id)
                node.setId("blank")
                print "Adding blank node: '%s'" % id
                self.__saveManifest()
                result = '{ "attributes": { "id": "node-%s", "rel": "blank" }, "data": "Untitled" }' % id

            # Update top-level package metadata
            if func == "update-package-meta":
                metaList = list(self.vc("formData").getValues("metaList"))
                jsonObj = self.__manifest.getJsonObject()
                for metaName in metaList:
                    value = self.fd(metaName)
                    jsonObj.put(metaName, value)
                #title = formData.get("title")
                #self.__manifest.set("title", StringEscapeUtils.escapeHtml(title))
                self.__saveManifest()

            # Rename the indicated node
            if func == "rename":
                node = self.__manifest.getNode(self.fd("nodeId"))
                node.setTitle(self.fd("title"))
                self.__saveManifest()

            # Move a node from one location to another
            elif func == "move":
                moveType = self.fd("type")
                if moveType == "before":
                    self.__manifest.moveBefore(self.fd("nodeId"), self.fd("refNodeId"))
                elif moveType == "after":
                    self.__manifest.moveAfter(self.fd("nodeId"), self.fd("refNodeId"))
                elif moveType == "inside":
                    self.__manifest.move(self.fd("nodeId"), self.fd("refNodeId"))
                self.__saveManifest()

            # Update the metadata of the indicated node
            elif func == "update":
                title = StringEscapeUtils.escapeHtml(self.fd("title"))
                hidden = self.fd("hidden")
                hidden = hidden == "true"

                node = self.__manifest.getNode(self.fd("nodeId"))
                node.setTitle(title)
                node.setHidden(hidden)
                self.__saveManifest()
                result = '{ "title": "%s", "hidden": "%s" }' % (title, hidden)

            # Update the metadata of the indicated node
            elif func == "delete":
                node = self.__manifest.getNode(self.fd("nodeId"))
                title = node.getTitle()
                if title:
                    self.__manifest.delete(self.fd("nodeId"))
                    self.__saveManifest()
                else:
                    title = "Untitled"
                result = '{ "title": "%s" }' % title
            self.__object.close()

        else:
            self.vc("response").setStatus(403)
            result = '{ "status": "error", "message": "Only registered users can access this API" }'

        writer = self.vc("response").getPrintWriter("text/plain; charset=UTF-8")
        writer.println(result)
        writer.close()
コード例 #26
0
ファイル: organiser.py プロジェクト: kiranba/the-fascinator
 def getMeta(self, metaName):
     return StringEscapeUtils.escapeHtml(formData.get(metaName, self.__manifest.get(metaName)))