コード例 #1
0
ファイル: RemoteJobManager.cpp プロジェクト: DanNixon/mantid
RemoteJobManager::RemoteJobManager(const Poco::XML::Element *elem)
    : m_displayName(elem->getAttribute("name")),
      m_session(
          nullptr) // Make sure this is always either NULL or a valid pointer.
{
  // Sanity check m_displayName
  if (m_displayName.length() == 0) {
    g_log.error("Compute Resources must have a name attribute");
    throw std::runtime_error("Compute Resources must have a name attribute");
  }

  Poco::AutoPtr<Poco::XML::NodeList> nl = elem->getElementsByTagName("baseURL");
  if (nl->length() != 1) {
    g_log.error("HTTP Compute Resources must have exactly one baseURL tag");
    throw std::runtime_error(
        "HTTP Compute Resources must have exactly one baseURL tag");
  } else {
    nl = nl->item(0)->childNodes();
    if (nl->length() > 0) {
      Poco::XML::Text *txt = dynamic_cast<Poco::XML::Text *>(nl->item(0));
      if (txt) {
        m_serviceBaseUrl = txt->getData();
      }
    }
  }
}
コード例 #2
0
    /// Called from constructor to fill live listener name
    void InstrumentInfo::fillTechniques(const Poco::XML::Element* elem)
    {
      Poco::AutoPtr<Poco::XML::NodeList> pNL_technique = elem->getElementsByTagName("technique");
      unsigned long n = pNL_technique->length();

      for (unsigned long i = 0; i < n; ++i)
      {
        Poco::AutoPtr<Poco::XML::NodeList> pNL = pNL_technique->item(i)->childNodes();
        if (pNL->length() > 0)
        {
          Poco::XML::Text* txt = dynamic_cast<Poco::XML::Text*>(pNL->item(0));
          if (txt)
          {
            std::string tech = txt->getData();
            if ( !tech.empty() )
            {
              m_technique.insert(tech);
            }
          }
        }
      }

      if (m_technique.empty())
      {
        throw std::runtime_error("No technique is defined for instrument "+m_name);
      }
    }
コード例 #3
0
/**
 * Construct a compute resource from information found in a facilities
 * definition file.
 *
 * @param fac Facility where this (remote) compute resource is available
 * @param elem A (Poco::XML::) Element to read the data from
 *
 * @throw std::runtime_error if name or required attributes are not
 * found
 */
ComputeResourceInfo::ComputeResourceInfo(const FacilityInfo *fac,
                                         const Poco::XML::Element *elem)
    : m_facility(fac) {

  m_name = elem->getAttribute("name");
  if (m_name.empty()) {
    std::string elemStr;
    if (elem)
      elemStr = elem->innerText();
    throw std::runtime_error(
        "The compute resource name is not defined, at element: " + elemStr);
  }

  // default: Mantid web service API:
  // http://www.mantidproject.org/Remote_Job_Submission_API
  m_managerType = "MantidWebServiceAPIJobManager";
  std::string type = elem->getAttribute("jobmanagertype");
  if (!type.empty()) {
    m_managerType = type;
  }

  const std::string baseTag = "baseURL";
  Poco::AutoPtr<Poco::XML::NodeList> nl = elem->getElementsByTagName(baseTag);
  if (!nl || nl->length() != 1 || !nl->item(0) ||
      !nl->item(0)->hasChildNodes()) {
    g_log.error("Failed to get base URL for remote compute resource '" +
                m_name + "'");
    throw std::runtime_error("Remote compute resources must have exactly one "
                             "baseURL tag. It was not found for the resource "
                             "'" +
                             m_name + "'");
  } else {
    nl = nl->item(0)->childNodes();
    if (nl->length() > 0) {
      Poco::XML::Text *txt = dynamic_cast<Poco::XML::Text *>(nl->item(0));
      if (txt) {
        m_baseURL = txt->getData();
      } else {
        g_log.error("Failed to get base URL for remote compute resource '" +
                    m_name + "'. The " + baseTag + " tag seems empty!");
        throw std::runtime_error(
            "Remote compute resources must have exactly one "
            "baseURL tag containing a URL string. A tag was found for the "
            "resource "
            "'" +
            m_name + "', but it seems empty!");
      }
    }
  }
}