Search in sources :

Example 6 with RegistrationException

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);
    }
}
Also used : RegistrationException(com.sun.enterprise.registration.RegistrationException) Image(com.sun.pkg.client.Image) IOException(java.io.IOException) RegistrationException(com.sun.enterprise.registration.RegistrationException)

Example 7 with RegistrationException

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);
    }
}
Also used : RegistrationException(com.sun.enterprise.registration.RegistrationException) Timer(java.util.Timer) TimerTask(java.util.TimerTask)

Example 8 with RegistrationException

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);
    }
}
Also used : RegistrationException(com.sun.enterprise.registration.RegistrationException) IOException(java.io.IOException) RegistrationException(com.sun.enterprise.registration.RegistrationException)

Example 9 with RegistrationException

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) {
            }
        }
    }
}
Also used : RegistrationException(com.sun.enterprise.registration.RegistrationException)

Example 10 with RegistrationException

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();
}
Also used : RegistrationException(com.sun.enterprise.registration.RegistrationException) ServiceTag(com.sun.enterprise.registration.impl.ServiceTag) SysnetRegistrationService(com.sun.enterprise.registration.impl.SysnetRegistrationService)

Aggregations

RegistrationException (com.sun.enterprise.registration.RegistrationException)14 Element (org.w3c.dom.Element)6 IOException (java.io.IOException)5 Image (com.sun.pkg.client.Image)2 Timer (java.util.Timer)2 TimerTask (java.util.TimerTask)2 ServiceTag (com.sun.enterprise.registration.impl.ServiceTag)1 SysnetRegistrationService (com.sun.enterprise.registration.impl.SysnetRegistrationService)1 SystemInfo (com.sun.pkg.client.SystemInfo)1 FileOutputStream (java.io.FileOutputStream)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 HashMap (java.util.HashMap)1 Properties (java.util.Properties)1 NodeList (org.w3c.dom.NodeList)1