public void validateUndeploymentTarget(String target, String name) { List<String> referencedTargets = domain.getAllReferencedTargetsForApplication(name); if (referencedTargets.size() > 1) { Application app = applications.getApplication(name); if (!DeploymentUtils.isDomainTarget(target)) { if (app.isLifecycleModule()) { throw new IllegalArgumentException(localStrings.getLocalString("delete_lifecycle_on_multiple_targets", "Lifecycle module {0} is referenced by more than one targets. Please remove other references before attempting delete operation.", name)); } else { throw new IllegalArgumentException(localStrings.getLocalString("undeploy_on_multiple_targets", "Application {0} is referenced by more than one targets. Please remove other references or specify all targets (or domain target if using asadmin command line) before attempting undeploy operation.", name)); } } } }
public static List<Application> getApplicationsInTarget(Domain me, String target) { if (target.equals("domain")) { // special target domain return me.getApplications().getApplications(); } List<Application> apps = new ArrayList<Application>(); List<ApplicationRef> applicationRefs = me.getApplicationRefsInTarget(target); for (ApplicationRef ref : applicationRefs) { Application app = me.getApplications().getApplication(ref.getRef()); if (app != null) { apps.add(app); } } return apps; }
public static <T> List<T> getModules(Applications apps, Class<T> type) { List<T> modules = new ArrayList<T>(); for (Object module : apps.getModules()) { if (type.isInstance(module)) { modules.add(type.cast(module)); } } // you have to return an umodifiable list since this list // is not the real list of elements as maintained by this config bean return Collections.unmodifiableList(modules); }
throw new TransactionFailure(localStrings.getLocalString( "noTransaction", "Internal Error - Cannot obtain transaction object")); if (domain.getNodeNamed(node) == null) { throw new TransactionFailure(localStrings.getLocalString( "noSuchNode", "Node {0} does not exist.", node)); instance.setConfigRef(configName); clusterExists = true; ourConfig = domain.getConfigNamed(configName); break; instance.setConfigRef(configName); final CopyConfig command = (CopyConfig) runner .getCommand("copy-config", context.getActionReport(), context.getLogger()); Configs configs = domain.getConfigs(); for (Application application : domain.getApplications().getApplications()) { if (application.getObjectType().equals("system-all") || application.getObjectType().equals("system-instance")) { ApplicationRef newAppRef = instance.createChild(ApplicationRef.class); newAppRef.setRef(application.getName()); ActionReport report = context.getActionReport(); report.setMessage(message);
public void decorate(AdminCommandContext context, final Cluster instance) throws TransactionFailure, PropertyVetoException { Logger logger = LogDomains.getLogger(Cluster.class, LogDomains.ADMIN_LOGGER); LocalStringManagerImpl localStrings = new LocalStringManagerImpl(Cluster.class); Transaction t = Transaction.getTransaction(instance); .getCommand("copy-config", context.getActionReport(), context.getLogger()); if (command == null ) { throw new TransactionFailure(localStrings.getLocalString("cannot.execute.command", "Cluster software is not installed")); Configs configs = domain.getConfigs(); Configs writableConfigs = t.enroll(configs); final String configName = instance.getName() + "-config"; Config specifiedConfig = domain.getConfigs().getConfigByName(configRef); for (Resource resource : domain.getResources().getResources()) { if (resource.getObjectType().equals("system-all") || resource.getObjectType().equals("system-instance")) { String name=null; for (Application application : domain.getApplications().getApplications()) { if (application.getObjectType().equals("system-all") || application.getObjectType().equals("system-instance")) { ApplicationRef newAppRef = instance.createChild(ApplicationRef.class); newAppRef.setRef(application.getName()); instance.getApplicationRef().add(newAppRef);
final ActionReport report = context.getActionReport(); final Logger logger = context.getLogger(); enabledVersionsInTargets = new HashMap<String, Set<String>>(); enabledVersionsInTargets.put(appName, new HashSet<String>(domain.getAllReferencedTargetsForApplication(appName))); report.setActionExitCode(ActionReport.ExitCode.SUCCESS); return; report.setActionExitCode(ActionReport.ExitCode.SUCCESS); return; report.setMessage(localStrings.getLocalString("application.notreg","Application {0} not registered", appName)); report.setActionExitCode(ActionReport.ExitCode.FAILURE); ApplicationRef ref = domain.getApplicationRefInTarget(appName, target); if (ref == null) { if (env.isDas()) { report.setMessage(localStrings.getLocalString("ref.not.referenced.target","Application {0} is not referenced by target {1}", appName, target)); report.setActionExitCode(ActionReport.ExitCode.FAILURE); Application app = applications.getApplication(appName); this.name = appName;
ActionReport.MessagePart part = report.getTopMessagePart(); part.addProperty(DeploymentProperties.NAME, name); new ApplicationConfigInfo(apps.getModule(Application.class, name)); Properties undeployProps = handleRedeploy(name, report, context); if (enabled == null) { final File reposDir = new File(env.getApplicationRepositoryPath(), VersioningUtils.getRepositoryName(name)); if (reposDir.exists()) { for (int i=0 ; i<domain.getApplications().getApplications().size() ; i++) { File existrepos = new File(new URI(domain.getApplications().getApplications().get(i).getLocation())); String appname = domain.getApplications().getApplications().get(i).getName(); if (!appname.equals(name) && existrepos.getAbsoluteFile().equals(reposDir.getAbsoluteFile())) { report.failure(logger,localStrings.getLocalString("deploy.dupdeployment","Application {0} is trying to use the same repository directory as application {1}, please choose a different application name to deploy",name,appname)); return; versioningService.handleDisable(name,target, report, context.getSubject()); } catch (VersioningSyntaxException e) { report.failure(logger, e.getMessage()); return; if (!force && versionFromSameDir != null) { report.failure(logger, VersioningUtils.LOCALSTRINGS.getLocalString( "versioning.deployment.dual.inplace", "GlassFish do not support versioning for directory deployment when using the same directory. The directory {0} is already assigned to the version {1}.",
context.getActionReport(). setResultType(DeployCommandSupplementalInfo.class, suppInfo); final ActionReport report = context.getActionReport(); final Logger logger = context.getLogger(); report.setMessage(localStrings.getLocalString("fnf","File not found", path.getAbsolutePath())); report.setActionExitCode(ActionReport.ExitCode.FAILURE); return; String msg = localStrings.getLocalString("nocontainer", "No container services registered, done..."); report.failure(logger,msg); return; final String msg = localStrings.getLocalString("deploy.errOpeningArtifact", "deploy.errOpeningArtifact", path.getAbsolutePath()); if (logReportedErrors) { new ApplicationConfigInfo(apps.getModule(Application.class, name)); Properties undeployProps = handleRedeploy(name, report); if (enabled == null) { if (!source.isDirectory()) { isDirectoryDeployed = false; expansionDir = new File(domain.getApplicationRoot(), name); path = expansionDir; } else {
final ActionReport report = context.getActionReport(); final Logger logger = context.getLogger(); } catch (VersioningWildcardException ex) { report.setMessage(localStrings.getLocalString("application.notreg", "Application {0} not registered", name)); report.setMessage(localStrings.getLocalString("ref.not.referenced.target","Application {0} is not referenced by target {1}", name, target)); while (it.hasNext()) { String appName = (String) it.next(); Application app = applications.getApplication(appName); ApplicationRef applicationRef = domain.getApplicationRefInTarget(appName, target); if ( applicationRef != null ) { if (app.isLifecycleModule()) { handleLifecycleModule(context, t); return; commandParams.lbenabled = lbenabled; if (app.containsSnifferType(Application.OSGI_SNIFFER_TYPE)) { commandParams.type = DeploymentProperties.OSGI; if (domain.isCurrentInstanceMatchingTarget(target, appName, server.getName(), null)) { deployment.deploy(deployment.getSniffersFromApp(app), deploymentContext); } else {
public void execute(AdminCommandContext context) { ActionReport report = context.getActionReport(); if (domain.getApplications().getApplication(appName) == null) { report.setActionExitCode(ActionReport.ExitCode.FAILURE); report.setMessage("No such application [" + appName + "] is deployed"); return; } ServiceDescription desc = orchestrator.getServiceDescription(appName, service); if (desc == null) { report.setMessage("Service by name [" + service + " ] does not exist for the given application [" + appName + " ]"); report.setActionExitCode(ActionReport.ExitCode.FAILURE); return; } Map<String, Object> descMap = getServiceDescriptionMap(desc); Properties extraProperties = new Properties(); extraProperties.put("list", descMap); report.setExtraProperties(extraProperties); report.setActionExitCode(ActionReport.ExitCode.SUCCESS); }
public void execute(AdminCommandContext context) { final ActionReport report = context.getActionReport(); ActionReport.MessagePart part = report.getTopMessagePart(); VersioningUtils.checkIdentifier(applicationName); } catch (VersioningSyntaxException ex) { report.setMessage(ex.getLocalizedMessage()); report.setActionExitCode(ActionReport.ExitCode.FAILURE); return; report.setMessage(localStrings.getLocalString("application.notreg","Application {0} not registered", applicationName)); report.setActionExitCode(ActionReport.ExitCode.FAILURE); return; Application application = applications.getApplication(applicationName); if (application.isLifecycleModule()) { if (!terse) { part.setMessage(localStrings.getLocalString("listsubcomponents.no.elements.to.list", "Nothing to List.")); report.setMessage(localStrings.getLocalString("application.not.enabled","Application {0} is not in an enabled state", applicationName)); return;
final ActionReport report = ctxt.getActionReport(); final Logger logger = ctxt.getLogger(); ReadableArchive archive = null; report.setMessage(localStrings.getLocalString("fnf","File not found", path.getAbsolutePath())); report.setActionExitCode(ActionReport.ExitCode.FAILURE); return; String msg = localStrings.getLocalString("nocontainer", "No container services registered, done..."); report.failure(logger,msg); return; ArchiveHandler archiveHandler = deployment.getArchiveHandler(archive, type); if (archiveHandler==null) { report.failure(logger,localStrings.getLocalString("deploy.unknownarchivetype","Archive type of {0} was not recognized",path.getName())); return; Application application = applications.getApplication(name); if (application != null) {
final ActionReport report = context.getActionReport(); final Logger logger = context.getLogger(); report.setMessage(localStrings.getLocalString("ref.not.referenced.target","Application {0} is not referenced by target {1}", name, target)); report.setActionExitCode(ActionReport.ExitCode.FAILURE); String appName = (String)it.next(); Application application = applications.getApplication(appName); if (application == null) { if (env.isDas()) { report.setMessage(localStrings.getLocalString("application.notreg","Application {0} not registered", appName)); ApplicationRef applicationRef = domain.getApplicationRefInTarget(appName, target); if (applicationRef == null) { if (env.isDas()) { report.setMessage(localStrings.getLocalString("appref.not.exists","Target {1} does not have a reference to application {0}.", appName, target)); if (application.isLifecycleModule()) { try { deployment.unregisterAppFromDomainXML(appName, target, true); if (domain.isCurrentInstanceMatchingTarget(target, appName, server.getName(), null)&& appInfo != null) {
public void execute(AdminCommandContext context) { ActionReport report = context.getActionReport(); final Logger logger = context.getLogger(); report.setMessage(localStrings.getLocalString("ref.not.referenced.target","Application {0} is not referenced by target {1}", name, target)); report.setActionExitCode(ActionReport.ExitCode.FAILURE); } else { logger.fine(localStrings.getLocalString("ref.not.referenced.target","Application {0} is not referenced by target {1}", name, target)); Application application = apps.getModule(Application.class, appName); report.setMessage(localStrings.getLocalString("application.notreg","Application {0} not registered", appName)); report.setActionExitCode(ActionReport.ExitCode.FAILURE); return; ApplicationRef ref = domain.getApplicationRefInTarget(appName, target); if (ref == null) { report.setMessage(localStrings.getLocalString("ref.not.referenced.target","Application {0} is not referenced by target {1}", appName, target)); appProps.putAll(application.getDeployProperties()); application.getModulePropertiesMap()); List<String> targets = domain.getAllReferencedTargetsForApplication(appName);
public void undeployResources(String applicationName){ Application app = applications.getApplication(applicationName); if(app != null){ List<Module> modules = app.getModule(); if(modules != null){ for(Module module : modules){ Resources moduleScopedResources = module.getResources(); if(moduleScopedResources != null){ undeployResources(moduleScopedResources); } } } Resources appScopedResources = app.getResources(); if(appScopedResources != null){ undeployResources(appScopedResources); } } }
public void execute(AdminCommandContext context) { ActionReport report = context.getActionReport(); report.setActionDescription(localStrings.getLocalString("list.containers.command", "List of Containers")); report.setActionExitCode(ActionReport.ExitCode.SUCCESS); ActionReport.MessagePart top = report.getTopMessagePart(); top.setMessage(localStrings.getLocalString("list.containers.command", "List of Containers")); top.setChildrenType(localStrings.getLocalString("container", "Container")); engineInfo.getContainer().getClass().toString()); boolean atLeastOne = false; for (Application app : applications.getApplications()) { for (com.sun.enterprise.config.serverbeans.Module module : app.getModule()) { Engine engine = module.getEngine(engineInfo.getSniffer().getModuleType()); if (engine!=null) { if (!atLeastOne) { container.addChild().setMessage(app.getName());
apps.getModules(ConnectorModule.class)) { ((Applications)apps_w).getModules().remove(connectorModule); ((Applications)apps_w).getModules().add(app); apps.getModules(EjbModule.class)) { ((Applications)apps_w).getModules().remove(ejbModule); ((Applications)apps_w).getModules().add(app); apps.getModules(WebModule.class)) { ((Applications)apps_w).getModules().remove(webModule); ((Applications)apps_w).getModules().add(app); apps.getModules(AppclientModule.class)) { ((Applications)apps_w).getModules().remove(appclientModule); ((Applications)apps_w).getModules().add(app); apps.getModules(J2eeApplication.class)) { ((Applications)apps_w).getModules().remove(j2eeApp); ((Applications)apps_w).getModules().add(app);
targets.add(tgt); } else { targets = domain.getAllReferencedTargetsForApplication(appName); Server servr = dmn.getServerNamed(target); if (servr != null) { Cluster cluster = dmn.getClusterNamed(target); if (cluster != null) { Applications apps = dmn.getApplications(); ConfigBeanProxy apps_w = t.enroll(apps); for (ApplicationName module : apps.getModules()) { if (module.getName().equals(appName)) { ((Applications)apps_w).getModules().remove(module); break;
@Override public void execute(AdminCommandContext context) { final ActionReport report = context.getActionReport(); final Logger logger = context.getLogger(); Application application = applications.getApplication(name); Transaction t = new Transaction(); report.failure(logger, e.getMessage());
Application app = apps.getModule(Application.class, name); if (app.isLifecycleModule()){ throw new IllegalArgumentException(localStrings.getLocalString("lifecyclemodule_withsamename_exists", "Lifecycle module with same name {0} already exists, please pick a different name for the application. ", name)); ActionReport subReport = report.addSubActionsReport(); subReport.setExtraProperties(new Properties()); context.getSubject()); return subReport.getExtraProperties();