public static <T extends ConfigBeanProxy> T createChild(ConfigBeanProxy self, Class<T> c) throws TransactionFailure { try { WriteableView bean = WriteableView.class.cast(Proxy.getInvocationHandler(Proxy.class.cast(self))); return bean.allocateProxy(c); } catch (ClassCastException e) { throw new TransactionFailure("Must use a locked parent config object for instantiating new config object", e); } }
static void setMBeanEnabled(MonitoringService ms, final String enabled, final ActionReport report) { try { ConfigSupport.apply(new SingleConfigCode<MonitoringService>() { public Object run(MonitoringService param) throws PropertyVetoException, TransactionFailure { param.setMbeanEnabled(enabled); return param; } }, ms); } catch(TransactionFailure tfe) { report.setMessage(localStrings.getLocalString("disable.monitoring.exception", "Encountered exception while setting mbean-enabled to false {0}", tfe.getMessage())); report.setActionExitCode(ActionReport.ExitCode.FAILURE); } }
final ActionReport report = context.getActionReport(); Config targetConfig = domain.getConfigNamed(target); if (targetConfig != null) config = targetConfig; Server targetServer = domain.getServerNamed(target); if (targetServer!=null) { config = domain.getConfigNamed(targetServer.getConfigRef()); com.sun.enterprise.config.serverbeans.Cluster cluster =domain.getClusterNamed(target); report.setMessage(localStrings.getLocalString("list.jms.host.invalidTarget", "Invalid Target specified.")); report.setActionExitCode(ActionReport.ExitCode.FAILURE); report.setMessage(localStrings.getLocalString("list.jms.host.noJmsHostFound", "JMS Host {0} does not exist.", jmsHostName)); report.setActionExitCode(ActionReport.ExitCode.FAILURE); report.setMessage(localStrings.getLocalString("delete.jms.host.fail", "Unable to delete jms host {0}.", jmsHostName) + " " + tfe.getLocalizedMessage()); report.setActionExitCode(ActionReport.ExitCode.FAILURE); report.setFailureCause(tfe);
/** * Executes the command with the command parameters passed as Properties * where the keys are the paramter names and the values the parameter values * * @param context information */ public void execute(AdminCommandContext context) { ActionReport report = context.getActionReport(); try { ConfigSupport.apply(new SingleConfigCode<SecurityService>() { public Object run(SecurityService param) throws PropertyVetoException, TransactionFailure { param.getAuthRealm().remove(authRealm); //temporary fix - since the SecurityConfigListener is not being called on an realm delete. SecurityConfigListener.authRealmDeleted(authRealm); return null; } }, securityService); } catch(TransactionFailure e) { report.setMessage(localStrings.getLocalString( "delete.auth.realm.fail", "Deletion of Authrealm {0} failed", authRealmName) + " " + e.getLocalizedMessage()); report.setActionExitCode(ActionReport.ExitCode.FAILURE); report.setFailureCause(e); return; } report.setActionExitCode(ActionReport.ExitCode.SUCCESS); }
LbConfig lbConfig = domain.getExtensionByType(LbConfigs.class).getLbConfig(lbConfigName); for (LoadBalancer lb:domain.getExtensionByType(LoadBalancers.class).getLoadBalancer()) { if (!lb.getName().equals(lbName) && lb.getLbConfigName().equals(lbConfigName)) { String msg = localStrings.getLocalString("LbConfigIsInUse", lbConfigName); report.setMessage(msg); report.setActionExitCode(ActionReport.ExitCode.FAILURE); throw new TransactionFailure(msg); LbConfigs configs = domain.getExtensionByType(LbConfigs.class); try { if (t != null) { localStrings.getLocalString("DeleteLbConfigFailed", "Unable to remove lb config {0}", lbConfigName), ex); String msg = ex.getMessage() != null ? ex.getMessage() : localStrings.getLocalString("DeleteLbConfigFailed", "Unable to remove lb config {0}", lbConfigName); report.setMessage(msg); report.setActionExitCode(ActionReport.ExitCode.FAILURE); report.setFailureCause(ex);
ActionReport report = context.getActionReport(); ConfigSupport.apply(new SingleConfigCode<ThreadPools>() { public Object run(ThreadPools param) throws PropertyVetoException, TransactionFailure { report.setActionExitCode(ExitCode.SUCCESS); } catch(TransactionFailure e) { String str = e.getMessage(); report.setMessage(localStrings.getLocalString("delete.threadpool" + ".failed", "Delete Thread Pool failed because of: ", str)); report.setActionExitCode(ExitCode.FAILURE); report.setFailureCause(e);
@Override public void execute(AdminCommandContext context) { ActionReport report = context.getActionReport(); report.setActionExitCode(ActionReport.ExitCode.SUCCESS); report.setMessage(localStrings.getLocalString("Config.badConfigNames", "You must specify a source and destination config.")); report.setActionExitCode(ActionReport.ExitCode.FAILURE); return; final Config config = domain.getConfigNamed(srcConfig); if (config == null ){ report.setMessage(localStrings.getLocalString( "Config.noSuchConfig", "Config {0} does not exist.", srcConfig)); report.setActionExitCode(ActionReport.ExitCode.FAILURE); final Config destinationConfig = domain.getConfigNamed(destConfig); if (destinationConfig != null ){ report.setMessage(localStrings.getLocalString( "Config.configExists", "Config {0} already exists.", destConfig)); report.setActionExitCode(ActionReport.ExitCode.FAILURE); } ,domain.getConfigs()); "Config.copyConfigError", "CopyConfig error caused by " , e.getLocalizedMessage())); report.setActionExitCode(ActionReport.ExitCode.FAILURE); report.setFailureCause(e);
public void execute(AdminCommandContext context) { ActionReport report = context.getActionReport(); report.setActionExitCode(ActionReport.ExitCode.SUCCESS); final Config config = domain.getConfigNamed(destConfig); if (config == null ){ report.setMessage(localStrings.getLocalString( "Config.noSuchConfig", "Config {0} does not exist.", destConfig)); report.setActionExitCode(ActionReport.ExitCode.FAILURE); List<ReferenceContainer> refContainers = domain.getReferenceContainersOf(config); if(refContainers.size() >= 1) { StringBuffer namesOfContainers = new StringBuffer(); namesOfContainers.append(rc.getReference()).append(','); report.setMessage(localStrings.getLocalString( "Config.inUseConfig", "Config {0} is in use " + "and must be referenced by no server instances or clusters", ConfigSupport.apply(new SingleConfigCode<Configs>() { localStrings.getLocalString("Config.deleteConfigFailed", "Unable to remove config {0} ", config) + " " +ex.getLocalizedMessage()); report.setActionExitCode(ActionReport.ExitCode.FAILURE); report.setFailureCause(ex);
final ActionReport report = context.getActionReport(); Config targetConfig = domain.getConfigNamed(target); if (targetConfig != null) config = targetConfig; Server targetServer = domain.getServerNamed(target); config = domain.getConfigNamed(targetServer.getConfigRef()); com.sun.enterprise.config.serverbeans.Cluster cluster =domain.getClusterNamed(target); report.setMessage(localStrings.getLocalString("create.jms.host.noJmsHost", "No JMS Host name specified.")); report.setActionExitCode(ActionReport.ExitCode.FAILURE); return; report.setMessage(localStrings.getLocalString("create.jms.host.duplicate", "A JMS Host named {0} already exists.", jmsHostName)); report.setActionExitCode(ActionReport.ExitCode.FAILURE); ConfigSupport.apply(new SingleConfigCode<JmsService>() { public Object run(JmsService param) throws PropertyVetoException, TransactionFailure { report.setMessage(localStrings.getLocalString("create.jms.host.fail", "Unable to create jms host {0}.", jmsHostName) + " " + tfe.getLocalizedMessage()); report.setActionExitCode(ActionReport.ExitCode.FAILURE); report.setFailureCause(tfe);
final ActionReport report = context.getActionReport(); Cluster cluster =domain.getClusterNamed(clusterName); report.setMessage(localStrings.getLocalString("configure.jms.cluster.invalidClusterName", "No Cluster by this name has been configured")); report.setActionExitCode(ActionReport.ExitCode.FAILURE); return; ParameterMap parameters = new ParameterMap(); parameters.set("DEFAULT", clusterName); commandRunner.getCommandInvocation("list-instances", listReport, context.getSubject()).parameters(parameters).execute(); Config config = domain.getConfigNamed(cluster.getConfigRef()); JmsService jmsService = config.getExtensionByType(JmsService.class); "Unable to change the JMS integration mode to LOCAL for Enhanced cluster {0}.", clusterName) + " " + tfe.getLocalizedMessage()); config = domain.getConfigNamed(cluster.getConfigRef()); ConfigSupport.apply(new SingleConfigCode<JmsAvailability>() { public Object run(JmsAvailability param) throws PropertyVetoException, TransactionFailure { param.setAvailabilityEnabled(availabilityEnabled.toString()); " " + tfe.getLocalizedMessage());
context.getActionReport(). setResultType(String.class, cluster.getName()); if (config != null && domain.getReferenceContainersOf(config).size() > 1) { return; localStrings.getLocalString("deleteConfigFailed", "Unable to remove config {0}", instanceConfig), ex); String msg = ex.getMessage() != null ? ex.getMessage() : localStrings.getLocalString("deleteConfigFailed", "Unable to remove config {0}", instanceConfig); report.setMessage(msg); report.setActionExitCode(ActionReport.ExitCode.FAILURE); report.setFailureCause(ex); throw ex; localStrings.getLocalString("deleteServerRefFailed", "Unable to remove server-ref {0} from cluster {1}", instanceName, cluster.getName()), ex); String msg = ex.getMessage() != null ? ex.getMessage() : localStrings.getLocalString("deleteServerRefFailed", "Unable to remove server-ref {0} from cluster {1}", instanceName, cluster.getName());
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); if (specifiedConfig == null) { throw new TransactionFailure(localStrings.getLocalString( "noSuchConfig", "Configuration {0} does not exist.", configRef)); for (Resource resource : domain.getResources().getResources()) { if (resource.getObjectType().equals("system-all") || resource.getObjectType().equals("system-instance")) { String name=null; throw new TransactionFailure("Cannot add un-named resources to the new server instance");
LbConfig lbConfig = domain.getLbConfigs().getLbConfig(lbConfigName); for (LoadBalancer lb:domain.getLoadBalancers().getLoadBalancer()) { if (!lb.getName().equals(lbName) && lb.getLbConfigName().equals(lbConfigName)) { String msg = localStrings.getLocalString("LbConfigIsInUse", lbConfigName); report.setMessage(msg); report.setActionExitCode(ActionReport.ExitCode.FAILURE); throw new TransactionFailure(msg); LbConfigs configs = domain.getLbConfigs(); try { if (t != null) { localStrings.getLocalString("DeleteLbConfigFailed", "Unable to remove lb config {0}", lbConfigName), ex); String msg = ex.getMessage() != null ? ex.getMessage() : localStrings.getLocalString("DeleteLbConfigFailed", "Unable to remove lb config {0}", lbConfigName); report.setMessage(msg); report.setActionExitCode(ActionReport.ExitCode.FAILURE); report.setFailureCause(ex);
ActionReport report = context.getActionReport(); thePC = pc; try { ConfigSupport.apply( new SingleConfigCode<MessageSecurityConfig>() { e.printStackTrace(); report.setMessage(localStrings.getLocalString( "delete.message.security.provider.fail", "Deletion of message security provider named {0} failed", providerId)); report.setActionExitCode(ActionReport.ExitCode.FAILURE); report.setFailureCause(e); return;
throw new TransactionFailure(localStrings.getLocalString( "noTransaction", "Internal Error - Cannot obtain transaction object")); Node theNode = domain.getNodeNamed(node); if (theNode == null) { throw new TransactionFailure(localStrings.getLocalString( "noSuchNode", "Node {0} does not exist.", node)); throw new TransactionFailure(localStrings.getLocalString( "instanceCreationNotAllowed", "Instance creation is disabled on node {0}.", throw new TransactionFailure(localStrings.getLocalString( "Server.cannotSpecifyBothConfigAndCluster", "A configuration name and cluster name cannot both be specified.")); throw new TransactionFailure(localStrings.getLocalString( "noSuchCluster", "Cluster {0} does not exist.", clusterName)); File docroot = new File(configConfigDir, "docroot"); if (!docroot.exists() && !docroot.mkdirs()) { throw new TransactionFailure(localStrings.getLocalString( "noMkdir", "Cannot create configuration specific directory {0}", "docroot")); throw new TransactionFailure(localStrings.getLocalString( "noMkdir", "Cannot create configuration specific directory {0}", "lib/ext")); throw new TransactionFailure(localStrings.getLocalString( "noSuchConfig", "Configuration {0} does not exist.", configRef));
@Override public void execute(final AdminCommandContext context) { final ActionReport result = context.getActionReport(); String msg = localStrings.getLocalString(GenericDeleteCommand.class, "TypeAndNameResolver.target_object_not_found", "Cannot find a {0} with a name {1}", targetType.getSimpleName(), name); logger.log(Level.SEVERE, ConfigApiLoggerInfo.TARGET_OBJ_NOT_FOUND, new Object[] {resolver.getClass().toString(), parentType, targetType}); result.failure(logger, msg); return; ConfigSupport.apply(new SingleConfigCode<ConfigBeanProxy>() { @Override public Object run(ConfigBeanProxy parentProxy) throws PropertyVetoException, TransactionFailure { String msg = localStrings.getLocalString(GenericCrudCommand.class, "GenericDeleteCommand.transaction_exception", "Exception while deleting the configuration {0} :{1}", child.getImplementation(), e.getMessage()); result.failure(logger, msg);
if (config.checkIfExtensionExists(configBeanType)) { try { ConfigSupport.apply(new SingleConfigCode<Config>() { @Override public Object run(Config param) throws PropertyVetoException, report.setActionExitCode(ActionReport.ExitCode.SUCCESS); } catch (TransactionFailure e) { String actual = e.getMessage(); String msg = localStrings.getLocalString("delete.module.config.failed.to.delete.config", DEFAULT_FORMAT, serviceName, actual); report.setMessage(msg); report.setActionExitCode(ActionReport.ExitCode.FAILURE); report.setFailureCause(e); report.setMessage(localStrings.getLocalString("delete.module.config.no.configuration", "No customized configuration exist for this service nor the default configuration has been added to the domain.xml.")); report.setActionExitCode(ActionReport.ExitCode.FAILURE); report.setActionExitCode(ActionReport.ExitCode.SUCCESS); } catch (TransactionFailure e) { String actual = e.getMessage(); String msg = localStrings.getLocalString("delete.module.config.failed.to.delete.config", DEFAULT_FORMAT, serviceName, actual); report.setMessage(msg);
public ResourceStatus create(Resources resources, HashMap attributes, final Properties properties, String target) throws Exception { setAttributes(attributes, target); ResourceStatus validationStatus = isValid(resources, true, target); if(validationStatus.getStatus() == ResourceStatus.FAILURE){ return validationStatus; } try { ConfigSupport.apply(new SingleConfigCode<Resources>() { public Object run(Resources param) throws PropertyVetoException, TransactionFailure { return createResource(param, properties); } }, resources); resourceUtil.createResourceRef(jndiName, enabledValueForTarget, target); } catch (TransactionFailure tfe) { String msg = localStrings.getLocalString("create.managed.executor.service.failed", "Managed executor service {0} creation failed", jndiName) + " " + tfe.getLocalizedMessage(); if (getResourceType().equals(ServerTags.MANAGED_SCHEDULED_EXECUTOR_SERVICE)) { msg = localStrings.getLocalString("create.managed.scheduled.executor.service.failed", "Managed scheduled executor service {0} creation failed", jndiName) + " " + tfe.getLocalizedMessage(); } ResourceStatus status = new ResourceStatus(ResourceStatus.FAILURE, msg); status.setException(tfe); return status; } String msg = localStrings.getLocalString("create.managed.executor.service.success", "Managed executor service {0} created successfully", jndiName); if (getResourceType().equals(ServerTags.MANAGED_SCHEDULED_EXECUTOR_SERVICE)) { msg = localStrings.getLocalString("create.managed.scheduled.executor.service.success", "Managed scheduled executor service {0} created successfully", jndiName); } return new ResourceStatus(ResourceStatus.SUCCESS, msg); }
@Override public void execute(AdminCommandContext context) { ActionReport report = context.getActionReport(); Logger logger= context.getLogger(); ManagedJobConfig managedJobConfig = domain.getExtensionByType(ManagedJobConfig.class); if (managedJobConfig == null ) { logger.warning(KernelLoggerInfo.getFailManagedJobConfig); report.setActionExitCode(ActionReport.ExitCode.FAILURE); report.setMessage(KernelLoggerInfo.getLogger().getResourceBundle().getString(KernelLoggerInfo.getFailManagedJobConfig)); return; ConfigSupport.apply(new SingleConfigCode<ManagedJobConfig>() { report.setActionExitCode(ActionReport.ExitCode.FAILURE); report.setMessage(e.getMessage());
PropertyVetoException, TransactionFailure{ Logger logger = LogDomains.getLogger(Node.class, LogDomains.ADMIN_LOGGER); LocalStringManagerImpl localStrings = new LocalStringManagerImpl(Node.class); final ActionReport report = context.getActionReport(); String nodeName = child.getName(); if (nodeName.equals("localhost-" + domain.getName())) { // can't delete localhost node final String msg = localStrings.getLocalString( "Node.localhost", "Cannot remove Node {0}. ",child.getName() ); throw new TransactionFailure(msg); final String msg = localStrings.getLocalString( "Node.referencedByInstance", "Node {0} referenced in server instance(s): {1}. Remove instances before removing node." , child.getName(), sb.toString() ); logger.log(Level.SEVERE, msg); throw new TransactionFailure(msg);