use of com.sun.enterprise.registration.RegistrationException in project Payara by payara.
the class RegistrationUtil method setUpdateCenterUUID.
public static void setUpdateCenterUUID(String instanceURN) throws RegistrationException {
final String prefix = "urn:st:";
try {
Image image = getUpdateCenterImage();
String[] authorities = image.getAuthorityNames();
if (instanceURN.startsWith(prefix))
instanceURN = instanceURN.substring(prefix.length());
for (String authority : authorities) {
image.setAuthority(authority, null, instanceURN);
}
image.saveConfig();
} catch (Exception ex) {
throw new RegistrationException(ex);
}
}
use of com.sun.enterprise.registration.RegistrationException in project Payara by payara.
the class RegistrationDaemon method start.
public static void start(File serviceTagRegistry) {
final SysnetRegistrationService registrationService = new SysnetRegistrationService(serviceTagRegistry);
// same work as an attempt to transfer the tags - which is to open the file an enumerate the tags.
if (registrationService.isRegistrationEnabled()) {
// Mark the timer as daemon so that it does not hold up appserver shutdown
final Timer registrationTimer = new Timer("registration", true);
TimerTask registrationTask = new TimerTask() {
public void run() {
try {
registrationService.transferEligibleServiceTagsToSysNet();
// Transfer was succseeful cancel the timer thread
registrationTimer.cancel();
} catch (RegistrationException e) {
// Log exception.
logger.log(Level.INFO, "Exception while transfering tags" + e);
}
}
};
registrationTimer.schedule(registrationTask, 0L, TIMER_INTERVAL);
}
}
use of com.sun.enterprise.registration.RegistrationException in project Payara by payara.
the class SysnetTransferManager method transferServiceTags.
/**
* Transfers previously-untransferred service tags from the local repository
* to SysNet using the stclient utility for the current platform.
*<p>
* Each local service tag is marked as transferred immediately after the
* corresponding stclient invocation completes. So, an error during the
* stclient invocation for a given service tag does not erase the fact that
* earlier transfers of other service tags succeeded.
* @return the number of tags transferred; -1 if the stclient command is not available
* @throws RegistrationException for errors encountered during transfer
*/
public int transferServiceTags() throws RegistrationException {
int result = -1;
try {
/*
* If the SysNet stclient utility is not present there is no work to do.
*/
if (!isSTClientInstalled()) {
logger.info("stclient tool not found; tag transfer to SysNet skipped");
return result;
}
/*
* Make sure the runtime values are up-to-date.
*/
rm.updateRuntimeValues();
List<ServiceTag> unTransferredTags = getUntransferredServiceTags(rm);
/*
* Transfer each untransferred tag.
*/
for (ServiceTag tag : unTransferredTags) {
addTagToSysNet(tag);
rm.setStatus(tag, ServiceTag.Status.TRANSFERRED);
}
result = unTransferredTags.size();
logger.info(result + " service tags successfully transferred to SysNet");
return result;
} catch (Exception e) {
throw new RegistrationException(StringManager.getString("xfmgr.errTransTags"), e);
}
}
use of com.sun.enterprise.registration.RegistrationException in project Payara by payara.
the class RelayService method generateRegistrationPage.
public void generateRegistrationPage(String outputFile, Locale locale) throws Exception {
bundle = getResourceBundle(locale);
InputStream is = getClass().getClassLoader().getResourceAsStream(TEMPLATE_FILE);
if (is == null)
throw new RegistrationException("Template file [" + TEMPLATE_FILE + "] not found");
List<ServiceTag> serviceTags = rm.getServiceTags();
StringBuilder productName = new StringBuilder();
for (ServiceTag tag : serviceTags) {
if (productName.length() > 0)
productName = productName.append(" + ");
productName = productName.append(tag.getSource());
}
String tags = getHtml(serviceTags);
String env = getEnvironmentInformation();
BufferedReader br = null;
BufferedWriter bw = null;
try {
br = new BufferedReader(new InputStreamReader(is));
bw = new BufferedWriter(new FileWriter(outputFile));
String line;
while ((line = br.readLine()) != null) {
if (line.indexOf(ENV_TOKEN) >= 0)
line = line.replaceAll(ENV_TOKEN, env);
if (line.indexOf(TAG_TOKEN) >= 0)
line = line.replaceAll(TAG_TOKEN, tags);
if (line.indexOf(PRODUCTNAME_TOKEN) >= 0)
line = line.replaceAll(PRODUCTNAME_TOKEN, productName.toString());
line = replaceStringTokens(line);
bw.write(line);
bw.newLine();
}
bw.flush();
} finally {
if (br != null) {
try {
br.close();
} catch (IOException ioex) {
}
}
if (bw != null) {
try {
bw.close();
} catch (IOException ioex) {
}
}
}
}
use of com.sun.enterprise.registration.RegistrationException in project Payara by payara.
the class RegistrationUtil method getGFInstanceURN.
public static String getGFInstanceURN() throws RegistrationException {
SysnetRegistrationService srs = new SysnetRegistrationService(getServiceTagRegistry());
List<ServiceTag> st = srs.getRegistrationDescriptors(getGFProductURN());
if (st.isEmpty()) {
throw new RegistrationException("Instance URN for " + getGFProductURN() + // i18n
" not found");
}
return st.get(0).getInstanceURN();
}
Aggregations