use of com.sun.enterprise.registration.RegistrationException in project Payara by payara.
the class RepositoryManager method remove.
/**
* Removes the XML element corresponding to the specified service tag (and
* persists the change to the file).
* @param serviceTag the ServiceTag for which the XML element should be removed
* @throws RegistrationException for errors writing the registration data
* to the local repository
*/
public void remove(ServiceTag serviceTag) throws RegistrationException {
Element st = findServiceTag(serviceTag);
if (st == null) {
throw new RegistrationException(StringManager.getString("rpmgr.noSuchSrvTag"));
// throw new RegistrationException("rpmgr.noSuchSrvTag");
}
registryElement.removeChild(st);
writeToFile();
}
use of com.sun.enterprise.registration.RegistrationException in project Payara by payara.
the class RepositoryManager method setRegistrationStatus.
/**
* Sets the status for the specified service tag in the repository (and
* persists the change to the file).
* @param serviceTag the service tag of interest
* @param the status to be assigned
* @throws RegistrationException for errors writing the registration data
* to the local repository
*/
public void setRegistrationStatus(ServiceTag serviceTag, ServiceTag.RegistrationStatus status) throws RegistrationException {
Element st = findServiceTag(serviceTag);
if (st == null) {
throw new RegistrationException(StringManager.getString("rpmgr.noSuchSrvTag"));
}
setSubElementValue(st, ServiceTag.REGISTRATION_STATUS, status.toString());
writeToFile();
}
use of com.sun.enterprise.registration.RegistrationException in project Payara by payara.
the class RepositoryManager method add.
/**
* Adds an element for the specified ServiceTag object (and writes the revised
* DOM to the file).
* @param serviceTag the ServiceTag for which to add an XML element
* @throws RegistrationException for errors writing the registration data
* to the local repository
*/
public void add(ServiceTag serviceTag) throws RegistrationException {
Element st = findServiceTag(serviceTag);
if (st != null) {
throw new RegistrationException(StringManager.getString("rpmgr.svrTagExists"));
// throw new RegistrationException("rpmgr.svrTagExists");
}
/*
* Create a new Element in the active document using the specified
* service tag information.
*/
st = serviceTag.getElement(document);
Element registrationReminderElement = findRegistrationReminderElement();
/*
* Insert the new service tag just before the registration status element, if it
* is found. Otherwise insert it under registryElement
*/
if (registrationReminderElement != null) {
registryElement.insertBefore(st, registrationReminderElement);
} else {
registryElement.appendChild(st);
}
writeToFile();
}
use of com.sun.enterprise.registration.RegistrationException in project Payara by payara.
the class PingService method postConstruct.
// private ActiveModules activeModules;
@Override
public void postConstruct() {
if (TIMER_INTERVAL <= 0) {
logger.fine("Domain Ping disabled : " + JVM_OPTION + " <= 0");
return;
}
SystemInfo.UpdateCheckFrequency frequency = SystemInfo.getUpdateCheckFrequency();
if (frequency.equals(SystemInfo.UpdateCheckFrequency.NEVER)) {
logger.fine("Domain Ping disabled by Update Center option");
return;
}
try {
RegistrationUtil.synchUUID();
} catch (RegistrationException ex) {
logger.fine("Domain Ping disabled due to UUID exception.");
logger.fine(ex.getMessage());
return;
}
// activeModules = new ActiveModules(logger, modulesRegistry);
// Mark the timer as daemon so that it does not hold up appserver shutdown
final Timer pingTimer = new Timer("PingService", true);
TimerTask pingTask = new TimerTask() {
public void run() {
Image img = null;
try {
HashMap<String, String> map = new HashMap<String, String>();
map.put("product", Version.getProductName().replace(";", ":"));
map.put("version", getVersionNumber());
map.put("context", CONTEXT);
// Disable module status usage tracking.
// map.put("modules", activeModules.generateModuleStatus());
img = RegistrationUtil.getUpdateCenterImage();
img.setMetaData(map);
img.refreshCatalog(img.getPreferredAuthorityName());
logger.log(Level.INFO, "Domain Pinged: {0}", img.getPreferredAuthorityName());
if (logger.isLoggable(Level.FINE)) {
logger.fine("X-JPkg-Metadata: product: " + map.get("product"));
logger.fine("X-JPkg-Metadata: version: " + map.get("version"));
logger.fine("X-JPkg-Metadata: context: " + map.get("context"));
// logger.fine("X-JPkg-Metadata: modules: " + map.get("modules"));
}
} catch (Exception e) {
// exception?
if (img != null)
logger.log(Level.FINE, "Domain Ping: Unable to refresh catalog: {0}", img.getPreferredAuthorityName());
else
logger.log(Level.FINE, "Domain Ping: Unable to refresh catalog. Null image.");
logger.fine(e.getMessage());
} finally // set the time stamp even in case of failure to ping,
// so that next attempt to ping remains startup agnostic.
{
try {
setTimeStamp();
} catch (Exception ex) {
logger.fine(ex.getMessage());
}
}
}
};
// nextPing is the time after which an initial ping would
// be attempted during the current server run. If we are due to
// ping now we delay the ping by 120 seconds to allow the domain
// to fully initialize.
long nextPing = 2 * 60 * 1000;
try {
long current = System.currentTimeMillis();
long lastPing = getTimeStamp();
// period, regardless of server restarts.
if (current - lastPing <= ONE_WEEK)
nextPing = lastPing - current + ONE_WEEK;
if (nextPing < 0)
nextPing = 2 * 60 * 1000;
} catch (Exception ex) {
logger.fine("Domain Ping: exception computing next ping time.");
logger.fine(ex.getMessage());
nextPing = 2 * 60 * 1000L;
}
logger.fine("Domain Ping: next ping in " + nextPing / (60 * 1000) + " minutes");
// ping after nextPing milliseconds and subsequenlty after
// TIMER_INTERVAL intervals
pingTimer.schedule(pingTask, nextPing, TIMER_INTERVAL);
}
use of com.sun.enterprise.registration.RegistrationException in project Payara by payara.
the class RegistrationUtil method getGFProductURN.
public static String getGFProductURN() throws RegistrationException {
try (InputStream is = RegistrationUtil.class.getClassLoader().getResourceAsStream(GLASSFISH_REGISTRY_PROPERTIES)) {
Properties props = new Properties();
props.load(is);
return props.getProperty("product_urn");
} catch (Exception ex) {
throw new RegistrationException(ex);
}
}
Aggregations