org.wso2.carbon.application.mgt.stub.ApplicationAdminExceptionException Java Examples

The following examples show how to use org.wso2.carbon.application.mgt.stub.ApplicationAdminExceptionException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SoapHeaderBlocksTestCase.java    From micro-integrator with Apache License 2.0 6 votes vote down vote up
/**
 * Checks if a CAR file is deployed.
 *
 * @param carFileName CAR file name.
 * @return True if exists, False otherwise.
 */
private Callable<Boolean> isCarFileDeployed(final String carFileName) {
    return new Callable<Boolean>() {
        @Override
        public Boolean call() throws ApplicationAdminExceptionException, RemoteException {
            log.info("waiting " + MAX_TIME + " millis for car deployment " + carFileName);
            Calendar startTime = Calendar.getInstance();
            long time = Calendar.getInstance().getTimeInMillis() - startTime.getTimeInMillis();
            String[] applicationList = applicationAdminClient.listAllApplications();
            if (applicationList != null) {
                if (ArrayUtils.contains(applicationList, carFileName)) {
                    log.info("car file deployed in " + time + " milliseconds");
                    return true;
                }
            }
            return false;
        }
    };
}
 
Example #2
Source File: SoapHeaderBlocksTestCase.java    From product-ei with Apache License 2.0 6 votes vote down vote up
/**
 * Checks if a CAR file is deployed.
 *
 * @param carFileName   CAR file name.
 * @return  True if exists, False otherwise.
 */
private Callable<Boolean> isCarFileDeployed(final String carFileName) {
    return new Callable<Boolean>() {
        @Override
        public Boolean call() throws ApplicationAdminExceptionException, RemoteException {
            log.info("waiting " + MAX_TIME + " millis for car deployment " + carFileName);
            Calendar startTime = Calendar.getInstance();
            long time = Calendar.getInstance().getTimeInMillis() - startTime.getTimeInMillis();
            String[] applicationList = applicationAdminClient.listAllApplications();
            if (applicationList != null) {
                if (ArrayUtils.contains(applicationList, carFileName)) {
                    log.info("car file deployed in " + time + " milliseconds");
                    return true;
                }
            }
            return false;
        }
    };
}
 
Example #3
Source File: ApplicationAdminClient.java    From carbon-commons with Apache License 2.0 6 votes vote down vote up
public void downloadCappArchive(String filename, HttpServletResponse response)
        throws IOException, ApplicationAdminExceptionException {

    ServletOutputStream out = response.getOutputStream();
    DataHandler dataHandler = stub.downloadCappArchive(filename);
    if (dataHandler != null) {
        if (!filename.endsWith(".car")) {
            filename += ".car";
        }
        response.setHeader("Content-Disposition", "fileName=" + filename);
        response.setContentType(dataHandler.getContentType());
        InputStream in = dataHandler.getDataSource().getInputStream();
        int nextChar;
        while ((nextChar = in.read()) != -1) {
            out.write((char) nextChar);
        }
        out.flush();
        in.close();
        out.close();
    } else {
        out.write("The requested capp archive was not found on the server".getBytes());
    }
}
 
Example #4
Source File: TestPrepExecutionListener.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * Function to undeploy carbon application
 *
 * @param applicationName
 * @throws ApplicationAdminExceptionException
 * @throws RemoteException
 */
private void undeployCarbonApplication(String applicationName)
        throws ApplicationAdminExceptionException, RemoteException {
    if (standaloneMode) {
        applicationAdminClient.deleteApplication(applicationName);

        // Wait for Capp to undeploy
        Awaitility.await()
                .pollInterval(500, TimeUnit.MILLISECONDS)
                .atMost(ScenarioConstants.ARTIFACT_DEPLOYMENT_WAIT_TIME_MS, TimeUnit.MILLISECONDS)
                .until(isCAppUnDeployed(applicationAdminClient, applicationName));
    }
}
 
Example #5
Source File: TestPrepExecutionListener.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
private boolean checkCAppDeployed(ApplicationAdminClient applicationAdminClient, final String cAppName)
        throws ApplicationAdminExceptionException, RemoteException {
    String[] applicationList = applicationAdminClient.listAllApplications();
    if (applicationList != null) {
        for (String app : applicationList) {
            if (app.equals(cAppName)) {
                return true;
            }
        }
    }
    return false;
}
 
Example #6
Source File: ScenarioTestBase.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * Function to undeploy carbon application
 *
 * @param applicationName name of the Carbon application to be undeployed
 * @throws ApplicationAdminExceptionException if an error occurs while undeploying carbon application
 * @throws RemoteException                    if the admin client becomes unable to connect to the service
 */
public void undeployCarbonApplication(String applicationName)
        throws ApplicationAdminExceptionException, RemoteException {
    if (standaloneMode) {
        applicationAdminClient.deleteApplication(applicationName);

        // Wait for Capp to undeploy
        Awaitility.await()
                  .pollInterval(500, TimeUnit.MILLISECONDS)
                  .atMost(ScenarioConstants.ARTIFACT_DEPLOYMENT_WAIT_TIME_MS, TimeUnit.MILLISECONDS)
                  .until(isCAppUnDeployed(applicationAdminClient, applicationName));
    }

}
 
Example #7
Source File: TestPrepExecutionListener.java    From product-ei with Apache License 2.0 5 votes vote down vote up
/**
 * Function to undeploy carbon application
 *
 * @param applicationName
 * @throws ApplicationAdminExceptionException
 * @throws RemoteException
 */
private void undeployCarbonApplication(String applicationName)
        throws ApplicationAdminExceptionException, RemoteException {
    if (standaloneMode) {
        applicationAdminClient.deleteApplication(applicationName);

        // Wait for Capp to undeploy
        Awaitility.await()
                .pollInterval(500, TimeUnit.MILLISECONDS)
                .atMost(ScenarioConstants.ARTIFACT_DEPLOYMENT_WAIT_TIME_MS, TimeUnit.MILLISECONDS)
                .until(isCAppUnDeployed(applicationAdminClient, applicationName));
    }
}
 
Example #8
Source File: TestPrepExecutionListener.java    From product-ei with Apache License 2.0 5 votes vote down vote up
private boolean checkCAppDeployed(ApplicationAdminClient applicationAdminClient, final String cAppName)
        throws ApplicationAdminExceptionException, RemoteException {
    String[] applicationList = applicationAdminClient.listAllApplications();
    if (applicationList != null) {
        for (String app : applicationList) {
            if (app.equals(cAppName)) {
                return true;
            }
        }
    }
    return false;
}
 
Example #9
Source File: ScenarioTestBase.java    From product-ei with Apache License 2.0 5 votes vote down vote up
/**
 * Function to undeploy carbon application
 *
 * @param applicationName name of the Carbon application to be undeployed
 * @throws ApplicationAdminExceptionException if an error occurs while undeploying carbon application
 * @throws RemoteException                    if the admin client becomes unable to connect to the service
 */
public void undeployCarbonApplication(String applicationName)
        throws ApplicationAdminExceptionException, RemoteException {
    if (standaloneMode) {
        applicationAdminClient.deleteApplication(applicationName);

        // Wait for Capp to undeploy
        Awaitility.await()
                  .pollInterval(500, TimeUnit.MILLISECONDS)
                  .atMost(ScenarioConstants.ARTIFACT_DEPLOYMENT_WAIT_TIME_MS, TimeUnit.MILLISECONDS)
                  .until(isCAppUnDeployed(applicationAdminClient, applicationName));
    }

}
 
Example #10
Source File: ApplicationAdminClient.java    From product-es with Apache License 2.0 5 votes vote down vote up
public String[] listAllApplications()
        throws ApplicationAdminExceptionException,
        RemoteException {
    String[] appList;
    appList = applicationAdminStub.listAllApplications();
    return appList;
}
 
Example #11
Source File: ApplicationAdminClient.java    From product-es with Apache License 2.0 5 votes vote down vote up
public String[] deleteMatchingApplication(String appName)
        throws ApplicationAdminExceptionException, RemoteException {
    String[] appList;
    appList = applicationAdminStub.listAllApplications();

    for (String anAppList : appList) {
        if (appName.contains(anAppList)) {
            applicationAdminStub.deleteApplication(anAppList);
        }
    }
    return appList;
}
 
Example #12
Source File: TestPrepExecutionListener.java    From micro-integrator with Apache License 2.0 4 votes vote down vote up
/**
 * Function to upload carbon application
 *
 * @param carFileName
 * @return
 * @throws RemoteException
 */
private void deployCarbonApplication(String carFileName) throws RemoteException, ApplicationAdminExceptionException {

    if (standaloneMode) {
        if (applicationAdminClient == null) {
            applicationAdminClient = new ApplicationAdminClient(backendURL, sessionCookie);
        }

        if (!checkCAppDeployed(applicationAdminClient, carFileName)) {

            log.info("Deploying carbon application : " + carFileName);
            // If standalone mode, deploy the CApp to the server
            String cappFilePath = carbonApplicationsDir + File.separator + carFileName + ScenarioConstants.CAPP_EXTENSION;

            if (carbonAppUploaderClient == null) {
                carbonAppUploaderClient = new CarbonAppUploaderClient(backendURL, sessionCookie);
            }

            DataHandler dh = new DataHandler(new FileDataSource(new File(cappFilePath)));
            // Upload carbon application
            carbonAppUploaderClient.uploadCarbonAppArtifact(carFileName + ScenarioConstants.CAPP_EXTENSION, dh);

            //TODO - This thread sleep is added temporarily to wait until the ESB Instances sync in the cluster in clustered test environment
            if (!Boolean.valueOf(infraProperties.getProperty(ScenarioConstants.STANDALONE_DEPLOYMENT))) {
                log.info("Waiting for artifacts synchronized across cluster nodes");
                try {
                    Thread.sleep(300000);
                } catch (InterruptedException e) {
                    // log and ignore
                    log.error("Error occurred while waiting for artifacts synchronized across cluster nodes", e);
                }
            }

            // Wait for Capp to sync
            log.info("Waiting for Carbon Application deployment ..");
            Awaitility.await()
                    .pollInterval(500, TimeUnit.MILLISECONDS)
                    .atMost(ScenarioConstants.ARTIFACT_DEPLOYMENT_WAIT_TIME_MS, TimeUnit.MILLISECONDS)
                    .until(isCAppDeployed(applicationAdminClient, carFileName));

        } else {
            log.info("Carbon application : " + carFileName + " already deployed");
        }
    }
}
 
Example #13
Source File: TestPrepExecutionListener.java    From product-ei with Apache License 2.0 4 votes vote down vote up
/**
 * Function to upload carbon application
 *
 * @param carFileName
 * @return
 * @throws RemoteException
 */
private void deployCarbonApplication(String carFileName) throws RemoteException, ApplicationAdminExceptionException {

    if (standaloneMode) {
        if (applicationAdminClient == null) {
            applicationAdminClient = new ApplicationAdminClient(backendURL, sessionCookie);
        }

        if (!checkCAppDeployed(applicationAdminClient, carFileName)) {

            log.info("Deploying carbon application : " + carFileName);
            // If standalone mode, deploy the CApp to the server
            String cappFilePath = carbonApplicationsDir + File.separator + carFileName + ScenarioConstants.CAPP_EXTENSION;

            if (carbonAppUploaderClient == null) {
                carbonAppUploaderClient = new CarbonAppUploaderClient(backendURL, sessionCookie);
            }

            DataHandler dh = new DataHandler(new FileDataSource(new File(cappFilePath)));
            // Upload carbon application
            carbonAppUploaderClient.uploadCarbonAppArtifact(carFileName + ScenarioConstants.CAPP_EXTENSION, dh);

            //TODO - This thread sleep is added temporarily to wait until the ESB Instances sync in the cluster in clustered test environment
            if (!Boolean.valueOf(infraProperties.getProperty(ScenarioConstants.STANDALONE_DEPLOYMENT))) {
                log.info("Waiting for artifacts synchronized across cluster nodes");
                try {
                    Thread.sleep(300000);
                } catch (InterruptedException e) {
                    // log and ignore
                    log.error("Error occurred while waiting for artifacts synchronized across cluster nodes", e);
                }
            }

            // Wait for Capp to sync
            log.info("Waiting for Carbon Application deployment ..");
            Awaitility.await()
                    .pollInterval(500, TimeUnit.MILLISECONDS)
                    .atMost(ScenarioConstants.ARTIFACT_DEPLOYMENT_WAIT_TIME_MS, TimeUnit.MILLISECONDS)
                    .until(isCAppDeployed(applicationAdminClient, carFileName));

        } else {
            log.info("Carbon application : " + carFileName + " already deployed");
        }
    }
}
 
Example #14
Source File: ApplicationAdminClient.java    From product-es with Apache License 2.0 4 votes vote down vote up
public ApplicationMetadata getMetaData(String appName)
        throws ApplicationAdminExceptionException, RemoteException {
    ApplicationMetadata appList;
    appList = applicationAdminStub.getAppData(appName);
    return appList;
}
 
Example #15
Source File: ApplicationAdminClient.java    From product-es with Apache License 2.0 3 votes vote down vote up
public void deleteApplication(String appName)
        throws ApplicationAdminExceptionException, RemoteException {


    applicationAdminStub.deleteApplication(appName);
    log.info("Application Deleted");

}