void ResourceManager::addWebServiceInfo(IPropertyTree *wsinfo) { //convert legacy web service info to the new resource format if (wsinfo) { if (wsinfo->hasProp("SOAP")) ensureManifestInfo()->addProp("WS-PARAMS", wsinfo->queryProp("SOAP")); if (wsinfo->hasProp("HELP")) { const char *content = wsinfo->queryProp("HELP"); addCompress("HELP", strlen(content)+1, content); } if (wsinfo->hasProp("INFO")) { const char *content = wsinfo->queryProp("INFO"); addCompress("INFO", strlen(content)+1, content); } if (wsinfo->hasProp("OTX")) { const char *content = wsinfo->queryProp("OTX"); addCompress("HYPER-LINK", strlen(content)+1, content); } if (wsinfo->hasProp("HTML")) { const char *content = wsinfo->queryProp("HTML"); Owned<IPropertyTree> manifestEntry = createPTree("Resource"); manifestEntry->setProp("@name", "Custom Form"); addCompress("XSLT", strlen(content)+1, content, manifestEntry); IPropertyTree *view = ensurePTree(ensureManifestInfo(), "Views/XSLT/FORM"); view->setProp("@resource", "Custom Form"); } if (wsinfo->hasProp("HTMLD")) { const char *content = wsinfo->queryProp("HTMLD"); Owned<IPropertyTree> manifestEntry = createPTree("Resource"); manifestEntry->setProp("@name", "Custom HTML"); addCompress("HTML", strlen(content)+1, content, manifestEntry); IPropertyTree *view = ensurePTree(ensureManifestInfo(), "Views/HTML/FORM"); view->setProp("@resource", "Custom HTML"); } if (wsinfo->hasProp("RESULT")) { const char *content = wsinfo->queryProp("RESULT"); Owned<IPropertyTree> manifestEntry = createPTree("Resource"); manifestEntry->setProp("@name", "Results"); addCompress("XSLT", strlen(content)+1, content, manifestEntry); IPropertyTree *view = ensurePTree(ensureManifestInfo(), "Views/XSLT/RESULTS"); view->setProp("@resource", "Results"); } if (wsinfo->hasProp("ERROR")) { const char *content = wsinfo->queryProp("ERROR"); Owned<IPropertyTree> manifestEntry = createPTree("Resource"); manifestEntry->setProp("@name", "Error"); addCompress("XSLT", strlen(content)+1, content, manifestEntry); IPropertyTree *view = ensurePTree(ensureManifestInfo(), "Views/XSLT/ERROR"); view->setProp("@resource", "Error"); } } }
void ResourceManager::addManifest(const char *filename) { StringBuffer path; Owned<IPropertyTree> t = createPTree(); t->setProp("@originalFilename", makeAbsolutePath(filename, path).str()); ensureManifestInfo()->addPropTree("Include", t.getClear()); addManifestFile(filename); }
void ResourceManager::addManifestFromArchive(IPropertyTree *archive) { if (!archive) return; if (finalized) throwError1(HQLERR_ResourceAddAfterFinalManifest, "MANIFEST"); ensureManifestInfo(); Owned<IPropertyTreeIterator> manifests = archive->getElements("AdditionalFiles/Manifest"); ForEach(*manifests) { const char *xml = manifests->query().queryProp(NULL); Owned<IPropertyTree> manifestSrc = createPTreeFromXMLString(xml); Owned<IAttributeIterator> aiter = manifestSrc->getAttributes(); ForEach (*aiter) manifest->setProp(aiter->queryName(), aiter->queryValue()); StringBuffer manifestDir; if (manifestSrc->hasProp("@originalFilename")) splitDirTail(manifestSrc->queryProp("@originalFilename"), manifestDir); Owned<IPropertyTreeIterator> iter = manifestSrc->getElements("*"); ForEach(*iter) { IPropertyTree &item = iter->query(); if (streq(item.queryName(), "Resource") && item.hasProp("@filename")) { if (!item.hasProp("@type")) item.setProp("@type", "UNKNOWN"); const char *filename; if (item.hasProp("@originalFilename")) filename = item.queryProp("@originalFilename"); else filename = item.queryProp("@filename"); int id; if (getDuplicateResourceId(item.queryProp("@type"), NULL, filename, id)) { item.setPropInt("@id", (int)id); manifest->addPropTree("Resource", LINK(&item)); } else { VStringBuffer xpath("AdditionalFiles/Resource[@originalFilename=\"%s\"]", filename); MemoryBuffer content; archive->getPropBin(xpath.str(), content); addCompress(item.queryProp("@type"), content.length(), content.toByteArray(), &item); } } else manifest->addPropTree(item.queryName(), LINK(&item)); } } }
void ResourceManager::addManifest(const char *filename) { if (finalized) throwError1(HQLERR_ResourceAddAfterFinalManifest, "MANIFEST"); Owned<IPropertyTree> manifestSrc = createPTreeFromXMLFile(filename); StringBuffer dir; splitDirTail(filename, dir); ensureManifestInfo(); Owned<IAttributeIterator> aiter = manifestSrc->getAttributes(); ForEach (*aiter) manifest->setProp(aiter->queryName(), aiter->queryValue()); Owned<IPropertyTreeIterator> iter = manifestSrc->getElements("*"); ForEach(*iter) { IPropertyTree &item = iter->query(); if (streq(item.queryName(), "Resource") && item.hasProp("@filename")) { if (!item.hasProp("@type")) item.setProp("@type", "UNKNOWN"); const char *filename = item.queryProp("@filename"); int id; if (getDuplicateResourceId(item.queryProp("@type"), filename, id)) { item.setPropInt("@id", id); manifest->addPropTree("Resource", LINK(&item)); } else { StringBuffer fullpath; if (!isAbsolutePath(filename)) fullpath.append(dir); fullpath.append(filename); MemoryBuffer content; loadResource(fullpath.str(), content); addCompress(item.queryProp("@type"), content.length(), content.toByteArray(), &item); } } else manifest->addPropTree(item.queryName(), LINK(&item)); } }
void ResourceManager::addNamed(const char * type, unsigned len, const void * data, IPropertyTree *manifestEntry, unsigned id, bool addToManifest, bool compressed) { if (id==(unsigned)-1) id = nextmfid++; if (addToManifest) { if (finalized) throwError1(HQLERR_ResourceAddAfterFinalManifest, type); Owned<IPropertyTree> entry=createPTree("Resource"); entry->setProp("@type", type); entry->setPropInt("@id", id); if (compressed) entry->setPropBool("@compressed", true); if (manifestEntry) mergePTree(entry, manifestEntry); ensureManifestInfo()->addPropTree("Resource", entry.getClear()); } resources.append(*new ResourceItem(type, id, len, data)); }
void ResourceManager::addManifestFile(const char *filename) { Owned<IPropertyTree> manifestSrc = createPTreeFromXMLFile(filename); StringBuffer dir; splitDirTail(filename, dir); ensureManifestInfo(); Owned<IAttributeIterator> aiter = manifestSrc->getAttributes(); ForEach (*aiter) manifest->setProp(aiter->queryName(), aiter->queryValue()); Owned<IPropertyTreeIterator> iter = manifestSrc->getElements("*"); ForEach(*iter) { IPropertyTree &item = iter->query(); if (streq(item.queryName(), "Include") && item.hasProp("@filename")) addManifestInclude(item, dir.str()); else if (streq(item.queryName(), "Resource") && item.hasProp("@filename")) { StringBuffer filepath; StringBuffer respath; makeAbsolutePath(item.queryProp("@filename"), dir.str(), filepath); makePathUniversal(filepath.str(), respath); item.setProp("@originalFilename", filepath.str()); item.setProp("@resourcePath", respath.str()); if (containsFileWildcard(filepath)) { StringBuffer wildpath; const char *tail = splitDirTail(filepath, wildpath); expandManifestDirectory(manifestSrc, item, dir, wildpath, tail, item.getPropBool("@recursive")); manifestSrc->removeTree(&item); } } else manifest->addPropTree(item.queryName(), LINK(&item)); } Owned<IPropertyTreeIterator> resources = manifestSrc->getElements("Resource[@filename]"); ForEach(*resources) { IPropertyTree &item = resources->query(); if (!item.hasProp("@type")) item.setProp("@type", "UNKNOWN"); int id; if (getDuplicateResourceId(item.queryProp("@type"), item.queryProp("@resourcePath"), NULL, id)) { item.setPropInt("@id", id); manifest->addPropTree("Resource", LINK(&item)); } else { MemoryBuffer content; loadResource(item.queryProp("@originalFilename"), content); addCompress(item.queryProp("@type"), content.length(), content.toByteArray(), &item); } } }