public void subscribe(String cartridgeType, String alias, String policy, String externalRepoURL,
boolean privateRepo, String username, String password, String dataCartridgeType, String dataCartridgeAlias)
throws CommandException {
SubscriptionInfo subcriptionConnectInfo = null;
if (StringUtils.isNotBlank(dataCartridgeType) && StringUtils.isNotBlank(dataCartridgeAlias)) {
System.out.format("Subscribing to data cartridge %s with alias %s.%n", dataCartridgeType,
dataCartridgeAlias);
try {
subcriptionConnectInfo = stub.subscribe(dataCartridgeType, dataCartridgeAlias, null, null, false, null,
null, null, null);
System.out.format("You have successfully subscribed to %s cartridge with alias %s.%n",
dataCartridgeType, dataCartridgeAlias);
System.out.format("%nSubscribing to %s cartridge and connecting with %s data cartridge.%n", alias,
dataCartridgeAlias);
} catch (RemoteException e) {
handleException(e);
} catch (ApplicationManagementServiceADCExceptionException e) {
handleException("cannot.subscribe", e);
} catch (ApplicationManagementServiceRepositoryRequiredExceptionException e) {
handleException("repository.required", e);
} catch (ApplicationManagementServiceUnregisteredCartridgeExceptionException e) {
handleException("cartridge.notregistered", e, dataCartridgeType);
} catch (ApplicationManagementServiceInvalidCartridgeAliasExceptionException e) {
handleException("cartridge.invalid.alias", e);
} catch (ApplicationManagementServiceAlreadySubscribedExceptionException e) {
handleException("cartridge.already.subscribed", e, e.getFaultMessage().getAlreadySubscribedException()
.getCartridgeType());
} catch (ApplicationManagementServiceDuplicateCartridgeAliasExceptionException e) {
handleException("cartridge.alias.duplicate", e, dataCartridgeAlias);
} catch (ApplicationManagementServicePolicyExceptionException e) {
handleException("policy.error", e);
} catch (ApplicationManagementServiceRepositoryTransportExceptionException e) {
handleException("repository.transport.error", e, externalRepoURL);
} catch (ApplicationManagementServiceRepositoryCredentialsRequiredExceptionException e) {
handleException("repository.credentials.required", e, externalRepoURL);
} catch (ApplicationManagementServiceInvalidRepositoryExceptionException e) {
handleException("repository.invalid.error", e, externalRepoURL);
}
}
try {
SubscriptionInfo subcriptionInfo = stub.subscribe(cartridgeType, alias, policy, externalRepoURL,
privateRepo, username, password, dataCartridgeType, dataCartridgeAlias);
System.out.format("You have successfully subscribed to %s cartridge with alias %s.%n", cartridgeType, alias);
String repoURL = null;
String hostnames = null;
String hostnamesLabel = null;
if (subcriptionInfo != null) {
repoURL = subcriptionInfo.getRepositoryURL();
hostnames = subcriptionInfo.getHostname();
hostnamesLabel = "host name";
if (repoURL != null) {
System.out.println("GIT Repository URL: " + repoURL);
}