コード例 #1
0
    /**
        Get port from a specialEndpoints tag from the serverindex.xml file
        
       \param[in]  node   specialEndpoint node to get port from
       \param[out] found  Set to true if successfully read port
       \param[out] port   Return the port if found
    */
    void WebSphereAppServerInstance::GetPortFromXml(const XElementPtr& node, bool& found, wstring& port)
    {
        const string cEndPointNodeName("endPoint");
        const string cPortAttributeName("port");

        XElementPtr endPoint;
        if (node->GetChild(cEndPointNodeName, endPoint))
        {
            string portstr;
            if (endPoint->GetAttributeValue(cPortAttributeName, portstr))
            {
                port = StrFromUTF8(portstr);
                found = true;
            }
        }
    }
コード例 #2
0
    /**
        Update version
        
        Load XML file <disk path>\properties\version\profile.version

        <?xml version="1.0" encoding="UTF-8"?>
        <profile>
          <id>default</id>
          <version>7.0.0.0</version>
          <build-info date="8/31/08" level="r0835.03"/>
        </profile>
              
    */
    void WebSphereAppServerInstance::UpdateVersion()
    {
        const string cProfileNodeName("profile");
        const string cVersionNodeName("version");
        
        string xmlcontent;
        SCXFilePath filename(GetProfileVersionXml());

        try {
            SCXHandle<istream> mystream = m_deps->OpenXmlVersionFile(filename.Get());
            GetStringFromStream(mystream, xmlcontent);

            XElementPtr profileNode;
            XElement::Load(xmlcontent, profileNode);

            if (profileNode->GetName() == cProfileNodeName)
            {
                XElementPtr versionNode;
                if (profileNode->GetChild(cVersionNodeName, versionNode))
                {
                    wstring version;
                    versionNode->GetContent(version);
                    SetVersion(version);
                }
            }
        }
        catch (SCXFilePathNotFoundException&)
        {
            SCX_LOGERROR(m_log, wstring(L"WebSphereAppServerInstance::UpdateVersion() - ").append(GetId()).append(L" - Could not find file: ").append(filename));
        }
        catch (SCXUnauthorizedFileSystemAccessException&)
        {
            SCX_LOGERROR(m_log, wstring(L"WebSphereAppServerInstance::UpdateVersion() - ").append(GetId()).append(L" - not authorized to open file: ").append(filename));
        }
        catch (XmlException&)
        {
            SCX_LOGERROR(m_log, wstring(L"WebSphereAppServerInstance::UpdateVersion() - ").append(GetId()).append(L" - Could not load XML from file: ").append(filename));
        }
    }
コード例 #3
0
    /**
        Update ports for Tomcat

        Load XML file <ConfigPath>/conf/server.xml

        Get node /Server/Service/Connector where attribute protocol is HTTP/1.1 and secure is true
        Get attribute named port for HTTPS Port
        Get node /Server/Service/Connector where attribute protocol is HTTP/1.1 and no attribute named secure exist
        Get attribute named port for HTTP Port
    */
    void TomcatAppServerInstance::UpdatePorts()
    {
        const string cDeploymentNodeName("deployment");
        const string cServerNodeName("Server");
        const string cServiceNodeName("Service");
        const string cConnectorNodeName("Connector");
        const string cProtocolAttributeName("protocol");
        const string cSecureAttributeName("secure");
        const string cPortAttributeName("port");
        const string cHTTP11Name("HTTP/1.1");
        const string cTrueName("true");

        SCXFilePath filename(m_diskPath);

        string xmlcontent;
        filename.Append(L"/conf/server.xml");

        try {
            SCXHandle<istream> mystream = m_deps->OpenXmlServerFile(filename.Get());
            GetStringFromStream(mystream, xmlcontent);

            XElementPtr serverNode;
            XElement::Load(xmlcontent, serverNode);
            if (serverNode->GetName() == cServerNodeName)
            {
                XElementPtr serviceNode;

                if (serverNode->GetChild(cServiceNodeName, serviceNode))
                {
                    XElementList connectorNodes;
                    bool foundHTTPnode = false;
                    bool foundHTTPSnode = false;

                    serviceNode->GetChildren(connectorNodes);
                    for (size_t idx = 0; !(foundHTTPnode && foundHTTPSnode) && idx < connectorNodes.size(); ++idx)
                    {
                        string protocolprop;
                        if (connectorNodes[idx]->GetName() == cConnectorNodeName)
                        {
                            // For Tomcat 5 there is no 'Protocol' specified for the HTTP Connector
                            // we will use the Connectors as they appear in the file.
                            bool hasAttribute = connectorNodes[idx]->GetAttributeValue(cProtocolAttributeName, protocolprop);
                            if( ( hasAttribute && (cHTTP11Name == protocolprop) ) ||
                                !hasAttribute )
                            {
                                string secureprop;
                                string portprop;

                                if (connectorNodes[idx]->GetAttributeValue(cPortAttributeName, portprop))
                                {
                                    if (connectorNodes[idx]->GetAttributeValue(cSecureAttributeName, secureprop) && 
                                        cTrueName == secureprop)
                                    {
                                        m_httpsPort = StrFromUTF8(portprop);
                                        foundHTTPSnode = true;
                                    }
                                    else
                                    {
                                        m_httpPort = StrFromUTF8(portprop);
                                        foundHTTPnode = true;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        catch (SCXFilePathNotFoundException&)
        {
            SCX_LOGERROR(m_log, wstring(L"TomcatAppServerInstance::UpdateTomcatPorts() - ").append(GetId()).append(L" - Could not find file: ").append(filename));
        }
        catch (SCXUnauthorizedFileSystemAccessException&)
        {
            SCX_LOGERROR(m_log, wstring(L"TomcatAppServerInstance::UpdateTomcatPorts() - ").append(GetId()).append(L" - not authorized to open file: ").append(filename));
        }
        catch (XmlException&)
        {
            SCX_LOGERROR(m_log, wstring(L"TomcatAppServerInstance::UpdateTomcatPorts() - ").append(GetId()).append(L" - Could not load XML from file: ").append(filename));
        }
    }