use of com.sun.enterprise.config.serverbeans.Application in project Payara by payara.
the class VersioningService method getVersionFromSameDir.
/**
* Get the version directory-deployed from the given directory
*
* @param directory
* @return the name of the version currently using the directory, else null
* @throws VersioningSyntaxException *
*/
public String getVersionFromSameDir(File dir) throws VersioningSyntaxException {
try {
Iterator it = domain.getApplications().getApplications().iterator();
Application app = null;
// check if directory deployment exist
while (it.hasNext()) {
app = (Application) it.next();
/*
* A lifecycle module appears as an application but has a null location.
*/
if (dir.toURI().toString().equals(app.getLocation())) {
if (!VersioningUtils.getUntaggedName(app.getName()).equals(app.getName())) {
return app.getName();
}
}
}
} catch (VersioningSyntaxException ex) {
// return null if an exception is thrown
}
return null;
}
use of com.sun.enterprise.config.serverbeans.Application in project Payara by payara.
the class VersioningUtils method getVersions.
/**
* Extract the set of version(s) of the given application from a set of
* applications. This method is used by unit tests.
*
* @param untaggedName the application name as an untagged version : an
* application name without version identifier
* @param allApplications the set of applications
* @return all the version(s) of the given application in the given set of
* applications
*/
public static final List<String> getVersions(String untaggedName, List<Application> allApplications) {
List<String> allVersions = new ArrayList<String>();
Iterator<Application> it = allApplications.iterator();
while (it.hasNext()) {
Application app = it.next();
// if a tagged version or untagged version of the app
if (app.getName().startsWith(untaggedName + EXPRESSION_SEPARATOR) || app.getName().equals(untaggedName)) {
allVersions.add(app.getName());
}
}
return allVersions;
}
use of com.sun.enterprise.config.serverbeans.Application in project Payara by payara.
the class ApplicationConfigSource method deleteValue.
public boolean deleteValue(String propertyName) throws TransactionFailure {
boolean result = false;
Application app = domainConfiguration.getApplications().getApplication(configurationName);
if (app != null) {
for (Property object : app.getProperty()) {
if ((PROPERTY_PREFIX + propertyName).equals(object.getName())) {
ConfigSupport.deleteChild((ConfigBean) ConfigBean.unwrap(app), (ConfigBean) ConfigBean.unwrap(object));
result = true;
}
}
}
return result;
}
use of com.sun.enterprise.config.serverbeans.Application in project Payara by payara.
the class ApplicationConfigSource method setValue.
public boolean setValue(final String propertyName, final String propertyValue) throws TransactionFailure {
boolean result = false;
Application app = domainConfiguration.getApplications().getApplication(configurationName);
if (app != null) {
// does the property exist
Property p = app.getProperty(PROPERTY_PREFIX + propertyName);
if (p == null) {
ConfigSupport.apply(new SingleConfigCode<Application>() {
@Override
public Object run(Application config) throws TransactionFailure, PropertyVetoException {
Property prop = config.createChild(Property.class);
prop.setName(PROPERTY_PREFIX + propertyName);
prop.setValue(propertyValue);
config.getProperty().add(prop);
return null;
}
}, app);
} else {
ConfigSupport.apply(new SingleConfigCode<Property>() {
@Override
public Object run(Property config) throws TransactionFailure, PropertyVetoException {
config.setValue(propertyValue);
return null;
}
}, p);
}
result = true;
}
return result;
}
use of com.sun.enterprise.config.serverbeans.Application in project Payara by payara.
the class ApplicationConfigSource method getProperties.
@Override
public Map<String, String> getProperties() {
Application config = domainConfiguration.getApplications().getApplication(configurationName);
HashMap<String, String> result = new HashMap<>();
if (config != null) {
List<Property> properties = config.getProperty();
for (Property property : properties) {
if (property.getName().startsWith(PROPERTY_PREFIX)) {
result.put(property.getName().substring(PROPERTY_PREFIX.length()), property.getValue());
}
}
}
return result;
}
Aggregations