Exemple #1
0
 def __createManifest(self):
     manifest = ManifestType()
     meta = MetadataType()
     meta.setSchema("IMS Content")
     meta.setSchemaversion("1.1.4")
     manifest.setMetadata(meta)
     
     portal = Services.getPortalManager().get(portalId)
     portalManifest = portal.getJsonMap("manifest")
     
     orgs = OrganizationsType()
     org = OrganizationType()
     org.setIdentifier("default")
     org.setTitle(portal.getDescription())
     orgs.getOrganization().add(org)
     orgs.setDefault(org)
     manifest.setOrganizations(orgs)
     
     resources = ResourcesType()
     manifest.setResources(resources)
     for key in portalManifest.keySet():
         jsonRes = portalManifest.get(key)
         # item
         visible = jsonRes.get("hidden", "false") != "true"
         item = ItemType()
         item.setIdentifier("default-" + key)
         item.setIdentifierref(key)
         item.setIsvisible(visible)
         item.setTitle(jsonRes.get("title"))
         # webcontent
         webRes = ResourceType()
         webRes.setIdentifier(key)
         webRes.setType("webcontent")
         oid = jsonRes.get("id")
         _, filename = os.path.split(oid)
         baseName = os.path.splitext(filename)[0]
         webRes.setHref("%s/%s.htm" % (key[5:], baseName))
         obj = Services.getStorage().getObject(oid)
         for payload in obj.getPayloadList():
             pid = payload.getId()
             if pid != "SOF-META":
                 file = FileType()
                 file.setHref(pid)
                 webRes.getFile().add(file)
         
         org.getItem().add(item)
         resources.getResource().add(webRes)
     
     return manifest
Exemple #2
0
 def __createItemAndResource(self, key, jsonRes):
     hidden = jsonRes.getBoolean(False, "hidden")
     # organization item
     item = ItemType()
     item.setIdentifier("default-%s" % key)
     item.setIdentifierref(key)
     item.setIsvisible(not hidden)
     item.setTitle(jsonRes.getString(None, "title"))
     # resource
     webRes = ResourceType()
     webRes.setIdentifier(key)
     webRes.setType("webcontent")
     oid = jsonRes.getString(None, "id")
     obj = Services.getStorage().getObject(oid)
     baseName = os.path.splitext(obj.getSourceId())[0]
     webRes.setHref("resources/%s/%s.htm" % (oid, baseName))
     for pid in obj.getPayloadIdList():
         payload = obj.getPayload(pid)
         if not PayloadType.Annotation.equals(payload.getType()):
             file = FileType()
             file.setHref(pid)
             webRes.getFile().add(file)
     obj.close()
     return item, webRes