softwarecontainer  0.18.0-739e8d7 2017-05-04
softwarecontainer::ServiceManifestFileLoader Class Reference
Inheritance diagram for softwarecontainer::ServiceManifestFileLoader:
[legend]
Collaboration diagram for softwarecontainer::ServiceManifestFileLoader:
[legend]

Public Member Functions

 ServiceManifestFileLoader (const std::string &source)
 
virtual std::vector< json_t * > loadContent () override
 Loads the json content from the Service Manifest(s) More...
 

Protected Attributes

std::vector< json_t * > m_content
 
const std::string m_source
 

Detailed Description

Definition at line 31 of file servicemanifestfileloader.h.

Member Function Documentation

std::vector< json_t * > softwarecontainer::ServiceManifestFileLoader::loadContent ( )
overridevirtual

Loads the json content from the Service Manifest(s)

Returns
a vector of json_t representing the Service Manifest(s)
Exceptions
ServiceManifestPathErrorif the path to the file or dir is invalid
ServiceManifestParseErrorif parsing of one or more files is unsuccessful

Implements softwarecontainer::ServiceManifestLoader.

Definition at line 30 of file servicemanifestfileloader.cpp.

References softwarecontainer::isDirectory(), softwarecontainer::isDirectoryEmpty(), and softwarecontainer::isFile().

31 {
32  std::string errorMessage;
33 
34  if (m_source.empty()) {
35  //File path is empty, this is ok
36  log_debug() << "Path to service manifests is empty";
37  } else if (m_source.compare("/") == 0) {
38  errorMessage = "Searching for configuration files from root dir not allowed";
39  log_error() << errorMessage;
40  throw ServiceManifestPathError(errorMessage);
41  } else if (isDirectory(m_source)) {
42  log_debug() << "Path to service manifests is a directory";
43  loadServiceManifestDir();
44  } else if (isFile(m_source)) {
45  log_debug() << "Path to service manifest is a file";
46  if (isJsonFile(m_source)) {
47  loadServiceManifestFile(m_source);
48  } else {
49  errorMessage = "Path to service manifest is not a json file";
50  log_debug() << errorMessage;
51  throw ServiceManifestPathError(errorMessage);
52  }
53  } else {
54  errorMessage = "The path to the service manifest(s) is not a directory or file: \""
55  + m_source + "\"";
56  log_error() << errorMessage;
57  throw ServiceManifestPathError(errorMessage);
58  }
59  return m_content;
60 }
bool isDirectory(const std::string &path)
isDirectory Check if path is a directory
bool isFile(const std::string &path)
isFile Check if path is a file

Here is the call graph for this function:


The documentation for this class was generated from the following files: