Search in sources :

Example 56 with TransactionFailure

use of org.jvnet.hk2.config.TransactionFailure in project Payara by payara.

the class ReferenceConstrainTest method jmxConnectorAuthRealmRefInvalid.

@Test
public void jmxConnectorAuthRealmRefInvalid() throws TransactionFailure {
    JmxConnector jmxConnector = habitat.getService(JmxConnector.class, "system");
    assertNotNull(jmxConnector);
    ConfigBean serverConfig = (ConfigBean) ConfigBean.unwrap(jmxConnector);
    Map<ConfigBean, Map<String, String>> changes = new HashMap<ConfigBean, Map<String, String>>();
    Map<String, String> configChanges = new HashMap<String, String>();
    configChanges.put("auth-realm-name", "realm-not-exist");
    changes.put(serverConfig, configChanges);
    try {
        ConfigSupport cs = getHabitat().getService(ConfigSupport.class);
        cs.apply(changes);
        fail("Can not reach this point");
    } catch (TransactionFailure tf) {
        ConstraintViolationException cv = findConstrViolation(tf);
        assertNotNull(cv);
    }
}
Also used : TransactionFailure(org.jvnet.hk2.config.TransactionFailure) ConfigSupport(org.jvnet.hk2.config.ConfigSupport) HashMap(java.util.HashMap) ConstraintViolationException(javax.validation.ConstraintViolationException) JmxConnector(com.sun.enterprise.config.serverbeans.JmxConnector) ConfigBean(org.jvnet.hk2.config.ConfigBean) HashMap(java.util.HashMap) Map(java.util.Map) ConfigApiTest(com.sun.enterprise.configapi.tests.ConfigApiTest) Test(org.junit.Test)

Example 57 with TransactionFailure

use of org.jvnet.hk2.config.TransactionFailure in project Payara by payara.

the class ReferenceConstrainTest method serverConfigRefInvalid.

@Test
public void serverConfigRefInvalid() throws TransactionFailure {
    Server server = habitat.getService(Server.class, "server");
    assertNotNull(server);
    ConfigBean serverConfig = (ConfigBean) ConfigBean.unwrap(server);
    Map<ConfigBean, Map<String, String>> changes = new HashMap<ConfigBean, Map<String, String>>();
    Map<String, String> configChanges = new HashMap<String, String>();
    configChanges.put("config-ref", "server-config-nonexist");
    changes.put(serverConfig, configChanges);
    try {
        ConfigSupport cs = getHabitat().getService(ConfigSupport.class);
        cs.apply(changes);
        fail("Can not reach this point");
    } catch (TransactionFailure tf) {
        ConstraintViolationException cv = findConstrViolation(tf);
        assertNotNull(cv);
    }
}
Also used : TransactionFailure(org.jvnet.hk2.config.TransactionFailure) ConfigSupport(org.jvnet.hk2.config.ConfigSupport) Server(com.sun.enterprise.config.serverbeans.Server) HashMap(java.util.HashMap) ConstraintViolationException(javax.validation.ConstraintViolationException) ConfigBean(org.jvnet.hk2.config.ConfigBean) HashMap(java.util.HashMap) Map(java.util.Map) ConfigApiTest(com.sun.enterprise.configapi.tests.ConfigApiTest) Test(org.junit.Test)

Example 58 with TransactionFailure

use of org.jvnet.hk2.config.TransactionFailure in project Payara by payara.

the class DefaultConfigUpgrade method createProviderConfigProperty.

private void createProviderConfigProperty(ProviderConfig pc) throws PropertyVetoException {
    while (!(parser.getEventType() == END_ELEMENT && parser.getLocalName().equals("provider-config"))) {
        try {
            if (parser.next() == START_ELEMENT) {
                if (parser.getLocalName().equals("property") && pc != null) {
                    Property p = pc.createChild(Property.class);
                    pc.getProperty().add(p);
                    createProperty(p);
                }
            }
        } catch (TransactionFailure ex) {
            logger.log(Level.SEVERE, createProviderConfigPropertyFailed, ex);
        } catch (XMLStreamException ex) {
            logger.log(Level.SEVERE, problemParsingProviderConfigProp, ex);
        }
    }
}
Also used : XMLStreamException(javax.xml.stream.XMLStreamException) Property(org.jvnet.hk2.config.types.Property)

Example 59 with TransactionFailure

use of org.jvnet.hk2.config.TransactionFailure in project Payara by payara.

the class DefaultConfigUpgrade method createAdminServiceProperty.

/*  <property value="${com.sun.aas.installRoot}/lib/install/applications/admingui.war"
     * name="adminConsoleDownloadLocation"/>
     */
private void createAdminServiceProperty(AdminService as) throws PropertyVetoException {
    while (true) {
        try {
            if (parser.next() == START_ELEMENT) {
                if (parser.getLocalName().equals("property")) {
                    Property p = as.createChild(Property.class);
                    as.getProperty().add(p);
                    createProperty(p);
                    break;
                }
            }
        } catch (TransactionFailure ex) {
            logger.log(Level.SEVERE, failedToCreateAdminService, ex);
        } catch (XMLStreamException ex) {
            logger.log(Level.SEVERE, problemParsingAdminService, ex);
        }
    }
}
Also used : XMLStreamException(javax.xml.stream.XMLStreamException) Property(org.jvnet.hk2.config.types.Property)

Example 60 with TransactionFailure

use of org.jvnet.hk2.config.TransactionFailure in project Payara by payara.

the class GrizzlyConfigSchemaMigrator method promoteVirtualServerProperties.

private void promoteVirtualServerProperties(HttpService service) throws TransactionFailure {
    for (VirtualServer virtualServer : service.getVirtualServer()) {
        ConfigSupport.apply(new SingleConfigCode<VirtualServer>() {

            @Override
            public Object run(VirtualServer param) throws PropertyVetoException {
                if (param.getHttpListeners() != null && !"".equals(param.getHttpListeners())) {
                    param.setNetworkListeners(param.getHttpListeners());
                }
                param.setHttpListeners(null);
                final List<Property> propertyList = new ArrayList<Property>(param.getProperty());
                final Iterator<Property> it = propertyList.iterator();
                while (it.hasNext()) {
                    final Property property = it.next();
                    if ("docroot".equals(property.getName())) {
                        param.setDocroot(property.getValue());
                        it.remove();
                    } else if ("accesslog".equals(property.getName())) {
                        param.setAccessLog(property.getValue());
                        it.remove();
                    } else if ("sso-enabled".equals(property.getName())) {
                        param.setSsoEnabled(property.getValue());
                        it.remove();
                    }
                }
                param.getProperty().clear();
                param.getProperty().addAll(propertyList);
                return null;
            }
        }, virtualServer);
    }
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) Property(org.jvnet.hk2.config.types.Property) VirtualServer(com.sun.enterprise.config.serverbeans.VirtualServer)

Aggregations

TransactionFailure (org.jvnet.hk2.config.TransactionFailure)191 PropertyVetoException (java.beans.PropertyVetoException)132 ActionReport (org.glassfish.api.ActionReport)86 Property (org.jvnet.hk2.config.types.Property)61 Config (com.sun.enterprise.config.serverbeans.Config)52 HashMap (java.util.HashMap)30 Test (org.junit.Test)27 Resources (com.sun.enterprise.config.serverbeans.Resources)25 Map (java.util.Map)25 List (java.util.List)21 CommandTarget (org.glassfish.config.support.CommandTarget)21 NetworkListener (org.glassfish.grizzly.config.dom.NetworkListener)21 Target (org.glassfish.internal.api.Target)21 NetworkConfig (org.glassfish.grizzly.config.dom.NetworkConfig)20 Protocol (org.glassfish.grizzly.config.dom.Protocol)20 ConfigBean (org.jvnet.hk2.config.ConfigBean)20 ConfigBeanProxy (org.jvnet.hk2.config.ConfigBeanProxy)18 ResourceStatus (org.glassfish.resourcebase.resources.api.ResourceStatus)17 SingleConfigCode (org.jvnet.hk2.config.SingleConfigCode)16 ParameterMap (org.glassfish.api.admin.ParameterMap)14