SWDirectories.cpp 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*##############################################################################
  2. HPCC SYSTEMS software Copyright (C) 2018 HPCC Systems®.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. ############################################################################## */
  13. #include "SWDirectories.hpp"
  14. #include "deployutils.hpp"
  15. #include "configenvhelper.hpp"
  16. #include "buildset.hpp"
  17. namespace ech
  18. {
  19. SWDirectories::SWDirectories(const char* name, EnvHelper * envHelper):ComponentBase(name, envHelper)
  20. {
  21. }
  22. void SWDirectories::create(IPropertyTree *params)
  23. {
  24. return;
  25. }
  26. unsigned SWDirectories::add(IPropertyTree *params)
  27. {
  28. return 0;
  29. }
  30. void SWDirectories::setCategoryAttributes(IPropertyTree *envTree, const char* dirName, const char* dirPath)
  31. {
  32. StringBuffer xpath;
  33. xpath.clear().appendf(XML_TAG_SOFTWARE"/Directories/Category[@name='%s']", dirName);
  34. IPropertyTree* pDir = envTree->queryPropTree(xpath.str());
  35. if (pDir)
  36. pDir->setProp("@dir", dirPath);
  37. else
  38. {
  39. pDir = envTree->queryPropTree(XML_TAG_SOFTWARE"/Directories/")->addPropTree("Category", createPTree());
  40. pDir->setProp(XML_ATTR_NAME, dirName);
  41. pDir->setProp("@dir", dirPath);
  42. }
  43. }
  44. void SWDirectories::modify(IPropertyTree *params)
  45. {
  46. synchronized block(mutex);
  47. IPropertyTree * envTree = m_envHelper->getEnvTree();
  48. IPropertyTree * pAttrsTree = params->queryPropTree("Attributes");
  49. //Todo: if name attribute given in @selector
  50. //const char* selector = params->queryProp("@selector");
  51. const char* selectorKey = params->queryProp("@selector-key");
  52. if (selectorKey)
  53. {
  54. const char* dirPath = pAttrsTree->queryProp("Attribute[1]/@value");
  55. setCategoryAttributes(envTree, selectorKey, dirPath);
  56. }
  57. else
  58. {
  59. Owned<IPropertyTreeIterator> attrsIter = pAttrsTree->getElements("Attribute");
  60. ForEach(*attrsIter)
  61. {
  62. IPropertyTree* pAttrTree = &attrsIter->query();
  63. const char* dirName = pAttrTree->queryProp("@name");
  64. const char* dirPath = pAttrTree->queryProp("@value");
  65. setCategoryAttributes(envTree, dirName, dirPath);
  66. }
  67. }
  68. //query id
  69. }
  70. void SWDirectories::remove(IPropertyTree *params)
  71. {
  72. return;
  73. }
  74. }