protected void checkStatus(ModificationStatus status) throws Exception { if(status.isFailed()) { Throwable t = status.getFailure(); if(t instanceof Exception) { throw Exception.class.cast(t); } else { throw new UndeclaredThrowableException(t); } } }
public void notify(ModificationEvent event) { // We bind our reload lifecycle to all other profiles // since we don't want to reload too often. if(event.getModificationType() != ProfileModificationType.GET) { view.markAsModified(); } }
@Override public void notify(final ModificationEvent event) { // TODO this should be more fine grained if(event.getModificationType() != ProfileModificationType.GET && getKey().equals(event.getKey())) { markAsModified(); } }
protected boolean doPrepare(ProfileModificationResponse response) { try { ProfileDeployment deployment = deploymentRepository.getDeployment(deploymentName); deployment.getDeploymentInfo().setFlag(ProfileDeploymentFlag.LOCKED); deploymentRepository.removeDeployment(deploymentName); // Notify response.fireModificationEvent(ProfileModificationEvent.create(ProfileModificationType.DELETE, key)); } catch(Exception e) { response.setFailure(e); return false; } return true; }
List<ProfileKey> keys = controller.getActiveProfiles(); getEventBus().addListener(view); if(view != null) getEventBus().removeListener(view); changed = true; if(view.load()) ManagedProfile managedProfile = controller.getManagedProfile(key); ProfileModificationAction<ProfileModificationContext> action = new ProfileViewUpdateAction(managedProfile, view, proxyFactory); controller.perform(key, ProfileModificationType.GET, Collections.singletonList(action));
/** * Get the available profiles with a DeploymentRepository. */ public Collection<ProfileKey> getProfiles() { List<ProfileKey> mutableProfiles = new ArrayList<ProfileKey>(); for(ProfileKey key : getActionController().getActiveProfiles()) { ManagedProfile managed = getActionController().getManagedProfile(key); ManagedProfileConfiguration configuration = managed != null ? managed.getConfiguration() : null; if(configuration != null && configuration.isDeploymentTarget()) { mutableProfiles.add(key); } } return mutableProfiles; }
public void removeComponent(ManagedComponent update, ManagedComponent original) throws Exception { ManagedDeployment deployment = original.getDeployment(); ProfileKey key = resolveProfile(deployment.getName()); ProfileModificationAction updateComponentAction = new RemoveComponentAction(original, persistenceRepository, null); List<ProfileModificationAction<ProfileModificationContext>> actions = new ArrayList<ProfileModificationAction<ProfileModificationContext>>(); actions.add(updateComponentAction); ModificationStatus status = this.controller.perform(key, ProfileModificationType.UPDATE, actions); getEventBus().fireModificationEvent(new ProfileModificationEvent(ProfileModificationType.DELETE, key)); if(status.isFailed()) { rethrowAsException(status.getFailure()); } }
/** * 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)); }
ManagedProfileConfiguration getProfileConfiguration(ProfileKey key) { ManagedProfile managed = getActionController().getManagedProfile(key); ManagedProfileConfiguration configuration = managed != null ? managed.getConfiguration() : null; return configuration; }
protected boolean doPrepare(ProfileModificationResponse response) { try { // TODO fail if not supported if(persistenceRepository.isSupportPersistence(component)) { ManagedDeployment deployment = component.getDeployment(); persistenceRepository.removeComponent(deployment.getName(), component); } } catch(Exception e) { response.setFailure(e); return false; } return true; }
response.fireModificationEvent(ProfileModificationEvent.create(ProfileModificationType.DELETE, managed.getProfileKey())); response.setFailure(e); return false;
/** * Resolve a deployment name against all registered profiles. * * @param name the simple deployment name * @return the resolved deployment name * @throws NoSuchDeploymentException */ protected String resolveDeploymentName(String name) throws NoSuchDeploymentException { for(ProfileKey key : actionController.getActiveProfiles()) { ManagedProfile managed = actionController.getManagedProfile(key); if(managed == null) { continue; } Profile profile = managed.getProfile(); if(profile.hasDeployment(name)) { ProfileDeployment deployment = profile.getDeployment(name); return deployment.getName(); } } throw new NoSuchDeploymentException(name); }
public void updateComponent(ManagedComponent update, ManagedComponent original) throws Exception { ManagedDeployment deployment = original.getDeployment(); ProfileKey key = resolveProfile(deployment.getName()); ProfileModificationAction updateComponentAction = new UpdateComponentAction(update, original, proxyFactory, persistenceRepository, null); List<ProfileModificationAction<ProfileModificationContext>> actions = new ArrayList<ProfileModificationAction<ProfileModificationContext>>(); actions.add(updateComponentAction); ModificationStatus status = this.controller.perform(key, ProfileModificationType.UPDATE, actions); getEventBus().fireModificationEvent(new ProfileModificationEvent(ProfileModificationType.UPDATE, key)); if(status.isFailed()) { rethrowAsException(status.getFailure()); } }
/** * 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)); }
protected boolean doPrepare(ProfileModificationResponse response) { try { final Profile profile = getManagedProfile().getProfile(); final ManagedProfileDeployer deployer = getManagedProfile().getManagedDeployer(); for(String deploymentName : getDeploymentNames()) { ProfileDeployment deployment = profile.getDeployment(deploymentName); ProfileDeploymentInfo info = deployment.getDeploymentInfo(); info.setFlag(ProfileDeploymentFlag.LOCKED); // Remove from deployer deployer.removeDeployment(deployment); // Add to the deployment list addDeployment(deployment); } // Process deployer.process(); // Notify response.fireModificationEvent(ProfileModificationEvent.create(ProfileModificationType.DELETE, getManagedProfile().getProfileKey())); } catch(Exception e) { response.setFailure(e); return false; } return true; }
for(ProfileKey key : actionController.getActiveProfiles()) ManagedProfile managed = actionController.getManagedProfile(key); if(managed == null)
/** * 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)); }
protected boolean doPrepare(ProfileModificationResponse response) { try { final String name = getDeploymentName(); final URL url = getDeploymentID().getContentURL(); if(url == null) { return false; } // final VirtualFile vf = VFS.getChild(url); // Create the deployment directly final ProfileDeployment deployment = deploymentFactory.createDeployment(vf, new TransientDeploymentMetaData(name)); deployment.getDeploymentInfo().setFlag(ProfileDeploymentFlag.LOCKED); // Attach original deployment url for resolving deployment names deployment.getTransientAttachments().putAttachment(TransientProfileActivator.TRANSIENT_DEPLOYMENT_URL_KEY, url.toExternalForm()); getProfile().addDeployment(deployment); // Notify response.fireModificationEvent(ProfileModificationEvent.create(ProfileModificationType.ADD, getProfile().getKey())); } catch(Exception e) { response.setFailure(e); return false; } return true; }
response.fireModificationEvent(ProfileModificationEvent.create(ProfileModificationType.UPDATE, getManagedProfile().getProfileKey())); response.setFailure(e); return false;
response.fireModificationEvent(ProfileModificationEvent.create(ProfileModificationType.ADD, getProfile().getKey())); response.setFailure(e); return false;