예제 #1
0
void CEspBinding::getNavigationData(IEspContext &context, IPropertyTree & data)
{
    IEspWsdlSections *wsdl = dynamic_cast<IEspWsdlSections *>(this);
    if (wsdl)
    {
        StringBuffer serviceName, params;
        wsdl->getServiceName(serviceName);
        if (!getUrlParams(context.queryRequestParameters(), params))
        {
            if (context.getClientVersion()>0)
                params.appendf("%cver_=%g", params.length()?'&':'?', context.getClientVersion());
        }

        StringBuffer encodedparams;
        if (params.length())
            encodeUtf8XML(params.str(), encodedparams, 0);

        if (params.length())
            params.setCharAt(0,'&'); //the entire params string will follow the initial param: "?form"

        VStringBuffer folderpath("Folder[@name='%s']", serviceName.str());

        IPropertyTree *folder = data.queryPropTree(folderpath.str());
        if(!folder)
        {
            folder=createPTree("Folder");
            folder->addProp("@name", serviceName.str());
            folder->addProp("@info", serviceName.str());
            folder->addProp("@urlParams", encodedparams);
            if (showSchemaLinks())
                folder->addProp("@showSchemaLinks", "true");
            folder->addPropBool("@isDynamicBinding", isDynamicBinding());
            folder->addPropBool("@isBound", isBound());
            data.addPropTree("Folder", folder);
        }

        MethodInfoArray methods;
        wsdl->getQualifiedNames(context, methods);
        ForEachItemIn(idx, methods)
        {
            CMethodInfo &method = methods.item(idx);
            IPropertyTree *link=createPTree("Link");
            link->addProp("@name", method.m_label.str());
            link->addProp("@info", method.m_label.str());
            StringBuffer path;
            path.appendf("../%s/%s?form%s", serviceName.str(), method.m_label.str(),params.str());
            link->addProp("@path", path.str());

            folder->addPropTree("Link", link);
        }
    }
예제 #2
0
void CEspBinding::getNavigationData(IEspContext &context, IPropertyTree & data)
{
    IEspWsdlSections *wsdl = dynamic_cast<IEspWsdlSections *>(this);
    if (wsdl)
    {
        StringBuffer serviceName, params;
        wsdl->getServiceName(serviceName);
        if (!getUrlParams(context.queryRequestParameters(), params))
        {
            if (context.getClientVersion()>0)
                params.appendf("&ver_=%g", context.getClientVersion());
        }
        if (params.length())
            params.setCharAt(0,'&');
        
        IPropertyTree *folder=createPTree("Folder");
        folder->addProp("@name", serviceName.str());
        folder->addProp("@info", serviceName.str());
        folder->addProp("@urlParams", params.str());
        if (showSchemaLinks())
            folder->addProp("@showSchemaLinks", "true");
        
        MethodInfoArray methods;
        wsdl->getQualifiedNames(context, methods);
        ForEachItemIn(idx, methods)
        {
            CMethodInfo &method = methods.item(idx);
            IPropertyTree *link=createPTree("Link");
            link->addProp("@name", method.m_label.str());
            link->addProp("@info", method.m_label.str());
            StringBuffer path;
            path.appendf("../%s/%s?form%s", serviceName.str(), method.m_label.str(),params.str());
            link->addProp("@path", path.str());

            folder->addPropTree("Link", link);
        }

        data.addPropTree("Folder", folder);
    }
bool Cws_machineEx::onStartStopBegin( IEspContext &context, IEspStartStopBeginRequest &req, 
                                         IEspStartStopBeginResponse &resp)
{
    throw MakeStringException(ECLWATCH_INTERNAL_ERROR, "StartStopBegin feature not supported.");
    //following code is no longer accessible but will remain for reference

    try
    {
        if (!context.validateFeatureAccess(EXEC_FEATURE_URL, SecAccess_Full, false))
            throw MakeStringException(ECLWATCH_EXECUTION_ACCESS_DENIED, "Permission denied.");

        StringBuffer addresses;
        StringArray& addresses0 = req.getAddresses();
        for(unsigned i = 0; i < addresses0.length(); i++)
        {
            StringBuffer addrStr;
            const char* address = addresses0.item(i);
            updatePathInAddress(address, addrStr);
            if (i > 0)
                addresses.appendf("|Addresses_i%d=%s", i+1, addrStr.str());
            else
                addresses.appendf("Addresses_i1=%s", addrStr.str());
        }

        resp.setAddresses(addresses);
        resp.setKey1(req.getKey1());
        resp.setKey2(req.getKey2());
        resp.setStop(req.getStop());
        double version = context.getClientVersion();
        if (version > 1.07)
        {
            resp.setAutoRefresh( req.getAutoRefresh() );
            resp.setMemThreshold(req.getMemThreshold());
            resp.setDiskThreshold(req.getDiskThreshold());
            resp.setCpuThreshold(req.getCpuThreshold());
            resp.setMemThresholdType(req.getMemThresholdType());
            resp.setDiskThresholdType(req.getDiskThresholdType());
        }
    }
    catch(IException* e)
    {   
        FORWARDEXCEPTION(context, e,  ECLWATCH_INTERNAL_ERROR);
    }
    return true;
}
예제 #4
0
int CEclDirectSoapBindingEx::sendRunEclExForm(IEspContext &context, CHttpRequest* request, CHttpResponse* response)
{
    StringBuffer xml;
    xml.append("<RunEclEx clientVersion='").append(context.getClientVersion()).append("'>");
    appendXMLTag(xml, "UseEclRepository", (supportRepository) ? "Yes" : "No");
    appendXMLTag(xml, "Redirect", (redirect) ? "Yes" : "No");
    appendXMLTag(xml, "IncludeResults", (redirect) ? "No" : "Yes");
    ForEachItemIn(i, clusters)
        appendXMLTag(xml, "Cluster", clusters.item(i));
    xml.append("</RunEclEx>");

    StringBuffer xslt(getCFD());
    xslt.append("./smc_xslt/run_ecl.xslt");

    StringBuffer html;
    xsltTransform(xml.str(), xslt.str(), NULL, html);
    response->setContent(html.str());
    response->setContentType(HTTP_TYPE_TEXT_HTML_UTF8);
    response->send();

    return 0;
}
bool Cws_machineEx::onStartStopDone( IEspContext &context, IEspStartStopDoneRequest &req, 
                                         IEspStartStopResponse &resp)
{
    throw MakeStringException(ECLWATCH_INTERNAL_ERROR, "StartStopDone feature not supported.");
    //following code is no longer accessible but will remain for reference

    try
    {
        if (!context.validateFeatureAccess(EXEC_FEATURE_URL, SecAccess_Full, false))
            throw MakeStringException(ECLWATCH_EXECUTION_ACCESS_DENIED, "Permission denied.");

        const char*addresses0 = req.getAddresses();
        bool bStop = req.getStop();

        char* userName = (char*) m_sTestStr1.str();
        char* password = (char*) m_sTestStr2.str();

        StringArray addresses;
        char* pAddr = (char*) addresses0;
        while (pAddr)
        {
            char* ppAddr = strstr(pAddr, "|Addresses_");
            if (!ppAddr)
            {
                char* ppAddr0 = strchr(pAddr, '=');
                if (!ppAddr0)
                    addresses.append(pAddr);
                else
                    addresses.append(ppAddr0+1);
                break;
            }
            else
            {
                char addr[1024];
                strncpy(addr, pAddr, ppAddr - pAddr);
                addr[ppAddr - pAddr] = 0;
                char* ppAddr0 = strchr(addr, '=');
                if (!ppAddr0)
                    addresses.append(addr);
                else
                    addresses.append(ppAddr0+1);

                pAddr = ppAddr + 1;
            }
        }

        doStartStop(context, addresses, userName, password, bStop, resp);

        double version = context.getClientVersion();
        if (version > 1.07)
        {
            resp.setAutoRefresh( req.getAutoRefresh() );
            resp.setMemThreshold(req.getMemThreshold());
            resp.setDiskThreshold(req.getDiskThreshold());
            resp.setCpuThreshold(req.getCpuThreshold());
            resp.setMemThresholdType(req.getMemThresholdType());
            resp.setDiskThresholdType(req.getDiskThresholdType());
        }
    }
    catch(IException* e)
    {   
        FORWARDEXCEPTION(context, e,  ECLWATCH_INTERNAL_ERROR);
    }
    return true;
}
bool Cws_machineEx::doStartStop(IEspContext &context, StringArray& addresses, char* userName, char* password, bool bStop,
                                                     IEspStartStopResponse &resp)
{
    bool containCluster = false;
    double version = context.getClientVersion();
    const int ordinality= addresses.ordinality();

    UnsignedArray threadHandles;
    IArrayOf<IEspStartStopResult> resultsArray;

    for (int index=0; index<ordinality; index++)
    {
        const char* address0 = addresses.item(index);

        //address passed in is of the form "192.168.1.4:EspProcess:2:path1"
        StringArray sArray;
        sArray.appendList(addresses.item(index), ":");

        if (sArray.ordinality() < 4)
            throw MakeStringException(ECLWATCH_MISSING_PARAMS, "Incomplete arguments");

        Owned<IEspStartStopResult> pResult = static_cast<IEspStartStopResult*>(new CStartStopResult(""));
        const char* address = sArray.item(0);
        const char* compType= sArray.item(1);
        const char* OS        = sArray.item(3);//index 2 is component name
        const char* path      = sArray.item(4);

        if (!(address && *address && compType && *compType && OS && *OS && path && *path))
            throw MakeStringExceptionDirect(ECLWATCH_INVALID_INPUT, "Invalid input");

        if (!stricmp(compType, "ThorCluster") || !stricmp(compType, "RoxieCluster"))
            containCluster = true;

#ifndef OLD_START_STOP
        {
            char* configAddress = NULL;
            char* props1 = (char*) strchr(address, '|');
            if (props1)
            {
                configAddress = props1+1;
                *props1 = '\0';
            }
            else
            {
                configAddress = (char*) address;
            }

            StringBuffer newAddress;
            ConvertAddress(address0, newAddress);
            pResult->setAddressOrig ( newAddress.str() );//can be either IP or name of component
            pResult->setAddress ( address );//can be either IP or name of component
            pResult->setCompType( compType );
            if (version > 1.04)
            {       
                pResult->setName( path );
                const char* pStr2 = strstr(path, "LexisNexis");
                if (pStr2)
                {
                    char name[256];
                    const char* pStr1 = strchr(pStr2, '|');
                    if (!pStr1)
                    {
                        strcpy(name, pStr2+11);
                    }
                    else
                    {
                        strncpy(name, pStr2+11, pStr1 - pStr2 -11);
                        name[pStr1 - pStr2 -11] = 0;
                    }
                    pResult->setName( name );
                }   
            }
            
            pResult->setOS( atoi(OS) ); 
            pResult->setPath( path );

            resultsArray.append(*pResult.getLink());

            CStartStopThreadParam* pThreadReq;
            pThreadReq = new CStartStopThreadParam(address, configAddress, bStop, m_useDefaultHPCCInit, this, context);
            pThreadReq->setResultObject( pResult );

            if (userName && *userName)
                pThreadReq->setUserID( userName );
            if (password && *password)
                pThreadReq->setPassword( password );

            PooledThreadHandle handle = m_threadPool->start( pThreadReq );
            threadHandles.append(handle);
        }
#else
        {
            StringBuffer newAddress;
            ConvertAddress(address0, newAddress);
            char* pStr = (char*) strchr(address, '|');;
            if (pStr)
                pStr[0] = 0;

            pResult->setAddressOrig ( newAddress.str() );//can be either IP or name of component
            pResult->setAddress ( address );//can be either IP or name of component
            pResult->setCompType( compType );
            pResult->setOS( atoi(OS) ); 
            pResult->setPath( path );

            resultsArray.append(*pResult.getLink());

            CStartStopThreadParam* pThreadReq;
            pThreadReq = new CStartStopThreadParam(address, bStop, this, context);
            pThreadReq->setResultObject( pResult );

            if (userName && *userName)
                pThreadReq->setUserID( userName );
            if (password && *password)
                pThreadReq->setPassword( password );

            PooledThreadHandle handle = m_threadPool->start( pThreadReq );
            threadHandles.append(handle);
        }
#endif
    }

    //block for worker theads to finish, if necessary, and then collect results
    //
    PooledThreadHandle* pThreadHandle = threadHandles.getArray();
    unsigned i=threadHandles.ordinality();
    while (i--) 
    {
        m_threadPool->join(*pThreadHandle, 30000);//abort after 30 secs in remote possibility that the command blocks
        pThreadHandle++;
    }

    resp.setStartStopResults(resultsArray);
    resp.setStop(bStop);

    if (version > 1.08)
    {
        resp.setContainCluster(containCluster);
    }
    return true;
}
int CFileSpraySoapBindingEx::onGetInstantQuery(IEspContext &context, CHttpRequest* request, CHttpResponse* response, const char *service, const char *method)
{
    bool permission = true;
    bool bDownloadFile = false;
    bool bProcess;
    StringBuffer sourceLogicalFile;
    StringBuffer methodbuf;
    StringBuffer submethod;
    StringBuffer xsltFileName(getCFD());
    xsltFileName.append("smc_xslt/");

    if (stricmp(method, "SprayFixedInput")==0)
    {
        if (!context.validateFeatureAccess(FILE_SPRAY_URL, SecAccess_Write, false))
            permission = false;

        bProcess = true;
        xsltFileName.append("fs_sprayForm.xslt");
        methodbuf.append("SprayFixed");
    }
    else if(stricmp(method, "SprayVariableInput")==0)
    {
        if (!context.validateFeatureAccess(FILE_SPRAY_URL, SecAccess_Write, false))
            permission = false;

        bProcess = true;
        xsltFileName.append("fs_sprayForm.xslt");
        methodbuf.append("SprayVariable");
        request->getParameter("submethod", submethod);
    }
    else if (stricmp(method, "DesprayInput")==0)
    {
        if (!context.validateFeatureAccess(FILE_DESPRAY_URL, SecAccess_Write, false))
            permission = false;

        request->getParameter("sourceLogicalName", sourceLogicalFile);
        xsltFileName.append("fs_desprayCopyForm.xslt");
        methodbuf.append("Despray");
        bProcess = true;
    }
    else if (stricmp(method, "CopyInput") == 0)
    {
        if (!context.validateFeatureAccess(FILE_SPRAY_URL, SecAccess_Write, false))
            permission = false;

        request->getParameter("sourceLogicalName", sourceLogicalFile);
        xsltFileName.append("fs_desprayCopyForm.xslt");
        methodbuf.append("Copy");
        bProcess = true;
    }
    else if (stricmp(method, "RenameInput") == 0)
    {
        if (!context.validateFeatureAccess(FILE_SPRAY_URL, SecAccess_Write, false))
            permission = false;

        request->getParameter("sourceLogicalName", sourceLogicalFile);
        xsltFileName.append("fs_renameForm.xslt");
        methodbuf.append("Rename");
        bProcess = true;
    }
    else if (stricmp(method, "DownloadFile") == 0)
    {
        if (!context.validateFeatureAccess(FILE_SPRAY_URL, SecAccess_Full, false))
            permission = false;

        downloadFile(context, request, response);
        bDownloadFile = true;
        bProcess = true;
    }
    else
        bProcess = false;

    if (bProcess)
    {
        if (bDownloadFile)
            return 0;

        StringBuffer xml;
        Owned<IProperties> params(createProperties());
        if (!permission)
        {
            params->setProp("@method", methodbuf.str());
            xml.append("<Environment><ErrorMessage>Permission denied.</ErrorMessage></Environment>");
        }
        else
        {
            if(submethod.length() > 0)
                params->setProp("@submethod", submethod.str());
            params->setProp("@method", methodbuf.str());

            if (*sourceLogicalFile.str())
            {
                params->setProp("@sourceLogicalName", sourceLogicalFile.str());

                Owned<IUserDescriptor> userdesc;
                StringBuffer username;
                context.getUserID(username);
                if(username.length() > 0)
                {
                    const char* passwd = context.queryPassword();
                    userdesc.setown(createUserDescriptor());
                    userdesc->set(username.str(), passwd, context.querySessionToken(), context.querySignature());

                    try 
                    {
                        if (stricmp(method, "CopyInput") == 0)
                        {
                            Owned<IDistributedFile> df = queryDistributedFileDirectory().lookup(sourceLogicalFile.str(), userdesc.get());
                            if(!df)
                            {
                                throw MakeStringException(ECLWATCH_FILE_NOT_EXIST,"Could not find file %s.",sourceLogicalFile.str());
                            }
            
                            const char *kind = df->queryAttributes().queryProp("@kind");
                            if (kind && strcmp(kind,"key")==0)
                            {
                                params->setProp("@compressflag", 0);
                            }
                            else if(df->isCompressed())
                            {
                                params->setProp("@compressflag", 2);
                            }
                            else
                            {
                                params->setProp("@compressflag", 1);
                            }
                        }
                    }
                    catch (IException *E)
                    {
                        Owned<IXslProcessor> xslp = getXslProcessor();
                        if (!xslp)
                            throw E;

                        Owned<IMultiException> me = MakeMultiException();
                        me->append(*E);
                        response->handleExceptions(xslp, me, "FileSpray", method, StringBuffer(getCFD()).append("./smc_xslt/exceptions.xslt").str(), false);
                        return 0;
                    }
                }
            }
            else
            {
                params->setProp("@compressflag", 1);
            }

            StringBuffer wuid;
            request->getParameter("wuid", wuid);
            Owned<IPropertyTree> pTree = createPTreeForXslt(context.getClientVersion(), method, wuid.str());
            toXML(pTree, xml, false);
        }
    
        IProperties* requestparams = request->queryParameters();
        if(requestparams && requestparams->hasProp("rawxml_"))
        {
            response->setContent(xml.str());
            response->setContentType(HTTP_TYPE_APPLICATION_XML);
        }
        else{
            StringBuffer htmlbuf;
            xsltTransform(xml.str(), xsltFileName.str(), params, htmlbuf);
            response->setContent(htmlbuf.str());
            response->setContentType(HTTP_TYPE_TEXT_HTML_UTF8);
        }

        response->send();
        return 0;
    }
    else
        return CFileSpraySoapBinding::onGetInstantQuery(context, request, response, service, method);
}