/** * Check if the Profile has a associated DeploymentRepository. * This will be needed by the DeployHandler to add the deployment content. * * @param key the profile key * @throws NoSuchProfileException if the profile does not exist or is not mutable */ public void checkProfile(ProfileKey key) throws NoSuchProfileException { ManagedProfileConfiguration configuration = getProfileConfiguration(key); if(configuration == null || configuration.isDeploymentTarget() == false) { formatter.applyPattern(i18n.getString("DeploymentManager.NoMutableProfileException")); //$NON-NLS-1$ Object[] args = { key }; String msg = formatter.format(args); throw new NoSuchProfileException(msg); } }
/** * Stop a set of deployments. * * @param deploymentNames the deployment names * @throws Exception for any error */ protected void stopDeployments(String... deploymentNames) throws Exception { Map<ProfileKey, Set<String>> mappings = resolveProfiles(deploymentNames, false, true); BasicProfileModificationRequest actions = new BasicProfileModificationRequest(ProfileModificationType.UPDATE); for(ProfileKey key : mappings.keySet()) { ManagedProfile managed = actionController.getManagedProfile(key); if(managed == null) { throw new NoSuchProfileException(key.getName()); } actions.addAction(key, new DeploymentStopAction(managed, mappings.get(key), null)); } checkStatus(actionController.perform(actions)); }
/** * Start a set of deployments. * * @param deploymentNames the deployment names * @throws Exception for any error */ protected void startDeployments(String... deploymentNames) throws Exception { Map<ProfileKey, Set<String>> mappings = resolveProfiles(deploymentNames, false, true); BasicProfileModificationRequest actions = new BasicProfileModificationRequest(ProfileModificationType.UPDATE); for(ProfileKey key : mappings.keySet()) { ManagedProfile managed = actionController.getManagedProfile(key); if(managed == null) { throw new NoSuchProfileException(key.getName()); } actions.addAction(key, new DeploymentStartAction(managed, mappings.get(key), null)); } checkStatus(actionController.perform(actions)); }
/** * Remove a set of deployments. * * @param deploymentNames the deployment names * @throws Exception for any error */ protected void removeDeployments(String... deploymentNames) throws Exception { Map<ProfileKey, Set<String>> mappings = resolveProfiles(deploymentNames, true, true); BasicProfileModificationRequest actions = new BasicProfileModificationRequest(ProfileModificationType.DELETE); for(ProfileKey key : mappings.keySet()) { ManagedProfile managed = actionController.getManagedProfile(key); if(managed == null) { throw new NoSuchProfileException(key.getName()); } Set<String> names = mappings.get(key); for(final String deploymentName : names) { DeploymentAction<? extends DeploymentActionContext> action = createWoraroundRemoveAction(key, managed, deploymentName); if(action == null) { action = new DeploymentRemoveAction(managed, deploymentName, null); } actions.addAction(key, action); } } checkStatus(actionController.perform(actions)); }