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);
}
}
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);
}
}
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);
}
}
}
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);
}
}
}
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);
}
}
Aggregations