Package com.sforce.soap.metadata

Examples of com.sforce.soap.metadata.AsyncResult


    // Deploy to Salesforce
    DeployOptions deployOptions = new DeployOptions();
    deployOptions.setSinglePackage(true);
    deployOptions.setPerformRetrieve(false);
    deployOptions.setRollbackOnError(true);
    AsyncResult asyncResult = metadataConnection.deploy(baos.toByteArray(), deployOptions);

    // Given the client the AysncResult to poll for the result of the deploy
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.getSerializationConfig().addMixInAnnotations(AsyncResult.class, AsyncResultMixIn.class);
    return objectMapper.writeValueAsString(asyncResult);
View Full Code Here


    public String checkStatus(@PathVariable("asyncId") String asyncId) throws Exception
    {
      // Connect to Metadata API, check async status and return to client
        ForceServiceConnector connector = new ForceServiceConnector(ForceServiceConnector.getThreadLocalConnectorConfig());
        MetadataConnection metadataConnection = connector.getMetadataConnection();
        AsyncResult asyncResult =  metadataConnection.checkStatus(new String[] { asyncId })[0];
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.getSerializationConfig().addMixInAnnotations(AsyncResult.class, AsyncResultMixIn.class);     
    return objectMapper.writeValueAsString(asyncResult);
    }
View Full Code Here

        public AsyncResult deploy(byte[] zipFile, DeployOptions deployOptions) throws ConnectionException {
            Assert.assertEquals(deployOptions.getPurgeOnDelete(), purgeOnDeleteShouldBeSet,
                    "The deploy options have purge on delete as " + deployOptions.getPurgeOnDelete()
                    + " but we expected " + purgeOnDeleteShouldBeSet);
           
            AsyncResult result = new AsyncResult();
            result.setDone(true);
            return result;
        }
View Full Code Here

        deployOptions.setAllowMissingFiles(true);
        deployOptions.setPurgeOnDelete(deleteProperty.getPurgeSchemaOnDelete());

        MetadataConnection metadatabinding = mconn.getMetadataConnection();
        createZipFile(schemaFiles.toArray(new File[schemaFiles.size()]), DEPLOY_ZIP);
        AsyncResult asyncResult = metadatabinding.deploy(readZipFile(DEPLOY_ZIP), deployOptions);

        // Wait for the deploy to complete 
        waitForAsyncResult(metadatabinding, new AsyncResult[] {asyncResult}, true, DEPLOY_ZIP);

        DeployResult result = metadatabinding.checkDeployStatus(asyncResult.getId());
       
        // Log any messages 
        StringBuilder buf = new StringBuilder();
        if (result.getMessages() != null) {
            for (DeployMessage rm : result.getMessages()) {
View Full Code Here

        if (logger.isDebugEnabled()) {
            logger.debug("Timeout set to " + getReadTimeout() + " milliseconds");
        }

        AsyncResult asyncResult = null;
        try {
            asyncResult = metadataConnection.retrieve(retrieveRequest);
        } catch (ConnectionException e) {
            ForceExceptionUtils.throwTranslatedException(e, connection);
        }
View Full Code Here

        if (logger.isDebugEnabled()) {
            logger.debug("Timeout set to " + getReadTimeout() + " milliseconds");
        }

        AsyncResult asyncResult = null;
        try {
            asyncResult = metadataConnection.deploy(zipFile, deployOptions);
        } catch (ConnectionException e) {
            ForceExceptionUtils.throwTranslatedException(e, connection);
        }
View Full Code Here

            // send request and wait for result
            if (logger.isDebugEnabled()) {
                logger.debug("Calling retrieve() at " + (new Date()).toString());
            }

            AsyncResult asyncResult = metadataStubExt.retrieve(retrieveRequest);
            monitorWork(monitor);

            // get async result
            retrieveResultExt = getRetrieveResult(retrieveResultExt, asyncResult, metadataStubExt, monitor);
View Full Code Here

        if (metadataStubExt == null) {
            throw new IllegalArgumentException("Metadata stub cannot be null");
        }

        AsyncResult asyncResult = result.getAsyncResult();
        long timeSoFarMillis = getTimeSoFarInitMillis();
        long pollingInternal = getInitialPollingInterval();
        int applyMultipleAtCycle = getApplyMultipleRound();
        int maxPollingTime = metadataStubExt.getReadTimeout();

        if (logger.isDebugEnabled()) {
            logger.debug("Start polling for response " + Calendar.getInstance().getTime().toString());
            logger.debug("Initial polling interval will be " + pollingInternal + " milliseconds for "
                    + applyMultipleAtCycle + " rounds");
            logger.debug("Metadata API timeout set to " + Utils.timeoutToSecs(metadataStubExt.getReadTimeout()));

        }

        for (int i = 0;; i++) {
            if (logger.isDebugEnabled()) {
                logger.debug("");
                logger.debug("####  Polling cycle round " + (i + 1) + "  ####");
            }

            monitorSubTask(monitor, result.retrieveRealTimeStatusUpdatesIfAny());

            // poll until it's done:
            result.checkStatus();

            if (logger.isDebugEnabled()) {
                result.logStatus(logger);
            }

            if (result.isDone()) {
                if (logger.isDebugEnabled()) {
                    addToCumulative(operationStats, timeSoFarMillis);
                    result.logResult(logger, operationStats);
                }

                // failed
                if (result.isFailure()) {
                    String failureString = result.logFailure(logger);
                    if (logger.isDebugEnabled()) {

                        logger.debug("Polling failed after " + (timeSoFarMillis / 1000) + " secs for id '"
                                + asyncResult.getId() + "'");
                    }
                    throw new ServiceException(failureString, result.getAsyncResult());
                }

                if (logger.isDebugEnabled()) {
                    logger.debug("Polling complete for operation id '" + asyncResult.getId() + "' after "
                            + (timeSoFarMillis / 1000) + " secs");
                }

                // success
                break;
            }

            try {
                if (logger.isDebugEnabled()) {
                    logger.debug("Next poll will be in ~" + (double) pollingInternal / 1000 + " secs");
                }
                Thread.sleep(pollingInternal);
            } catch (InterruptedException e) {} finally {
                timeSoFarMillis += pollingInternal;
            }

            // record polling time to this point and evaluate base on limit
            if (timeSoFarMillis > getMaxPollingTime()) {
                logger.warn("Polling aborted after " + (timeSoFarMillis / 1000) + " secs for id '"
                        + asyncResult.getId() + "'");

                if (logger.isDebugEnabled()) {
                    addToCumulative(operationStats, timeSoFarMillis);
                }

                throw new ServiceTimeoutException("Server processing time has exceeded limit ("
                        + Utils.timeoutToSecs(getMaxPollingTime()) + ")", metadataStubExt, result.getAsyncResult(),
                        operationStats);
            }

            // determine if polling multiple is to be applied
            if (pollingInternal < maxPollingTime && i == (applyMultipleAtCycle - 1)) {
                pollingInternal = pollingInternal * getPollingMultiple();
                applyMultipleAtCycle += getApplyMultipleRound();
                if (logger.isDebugEnabled()) {
                    logger.debug("Adjusted polling multiple, next application will be after round "
                            + applyMultipleAtCycle);
                }
            }

            try {
                monitorCheck(monitor);
            } catch (InterruptedException e) {
                logger.warn("Polling canceled by user after " + (timeSoFarMillis / 1000) + " secs for id '"
                        + asyncResult.getId() + "'");
                throw e;
            }
        }

        return result;
View Full Code Here

            // call deploy and wait for response
            if (logger.isDebugEnabled()) {
                logger.debug("Calling deploy() at " + (new Date()).toString());
            }

            AsyncResult asyncResult = metadataStubExt.deploy(zipFile, deployOptions);
            monitorWork(monitor);

            // get async result
            deployResultHandler = getDeployResult(deployResultHandler, asyncResult, metadataStubExt, monitor);
View Full Code Here

TOP

Related Classes of com.sforce.soap.metadata.AsyncResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.