Example usage for javax.management AttributeNotFoundException getMessage

List of usage examples for javax.management AttributeNotFoundException getMessage

Introduction

In this page you can find the example usage for javax.management AttributeNotFoundException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.cyberway.issue.crawler.filter.PathDepthFilter.java

protected boolean returnTrueIfMatches(CrawlURI curi) {
    try {/*from  w  w  w  .  j ava2s  . c om*/
        return ((Boolean) getAttribute(ATTR_MATCH_RETURN_VALUE, curi)).booleanValue();
    } catch (AttributeNotFoundException e) {
        logger.severe(e.getMessage());
        return true;
    }
}

From source file:com.cyberway.issue.crawler.datamodel.credential.HtmlFormCredential.java

public String getPrerequisite(CrawlURI curi) {
    String loginUri = null;//from ww w. j a  va 2  s .  co m
    try {
        loginUri = getLoginUri(curi);
    } catch (AttributeNotFoundException e) {
        logger.severe("Failed to getLoginUri: " + this + ", " + curi + "," + e.getMessage());
        // Not much I can do here. What if I fail every time? Then
        // this prereq. will not ever be processed.  We'll never get on to
        // this server.
    }
    return loginUri;
}

From source file:com.cyberway.issue.crawler.datamodel.credential.Credential.java

/**
 * Test passed curi matches this credentials rootUri.
 * @param controller/*from  w ww.  j av a2  s . com*/
 * @param curi CrawlURI to test.
 * @return True if domain for credential matches that of the passed curi.
 */
public boolean rootUriMatch(CrawlController controller, CrawlURI curi) {
    String cd = null;
    try {
        cd = getCredentialDomain(curi);
    } catch (AttributeNotFoundException e) {
        logger.severe("Failed to get credential domain " + curi + ": " + e.getMessage());
    }

    String serverName = controller.getServerCache().getServerFor(curi).getName();
    logger.fine("RootURI: Comparing " + serverName + " " + cd);
    return cd != null && serverName != null && serverName.equalsIgnoreCase(cd);
}

From source file:com.cyberway.issue.crawler.settings.ComplexType.java

private DataContainer getOrCreateDataContainer(CrawlerSettings settings) throws InvalidAttributeValueException {

    // Get this ComplexType's data container for the submitted settings
    DataContainer data = settings.getData(this);

    // If there isn't a container, create one
    if (data == null) {
        ComplexType parent = getParent();
        if (parent == null) {
            settings.addTopLevelModule((ModuleType) this);
        } else {//w  w w .j a  v  a  2 s  .  c om
            DataContainer parentData = settings.getData(parent);
            if (parentData == null) {
                if (this instanceof ModuleType) {
                    settings.addTopLevelModule((ModuleType) this);
                } else {
                    settings.addTopLevelModule((ModuleType) parent);
                    try {
                        parent.setAttribute(settings, this);
                    } catch (AttributeNotFoundException e) {
                        logger.severe(e.getMessage());
                    }
                }
            } else {
                globalSettings().getData(parent).copyAttributeInfo(getName(), parentData);
            }
        }

        // Create fresh DataContainer
        data = settings.addComplexType(this);
    }

    // Make sure that the DataContainer references right type
    if (data.getComplexType() != this) {
        if (this instanceof ModuleType) {
            data = settings.addComplexType(this);
        }
    }
    return data;
}

From source file:com.cyberway.issue.crawler.admin.CrawlJobHandler.java

/**
 * Creates a new job. The new job will be returned and also registered as
 * the handler's 'new job'. The new job will be based on the settings
 * provided but created in a new location on disk.
 *
 * @param baseOn/*from w  w w.  j  a  v  a 2 s . co m*/
 *            A CrawlJob (with a valid settingshandler) to use as the
 *            template for the new job.
 * @param recovery Whether to preinitialize new job as recovery of
 * <code>baseOn</code> job.  String holds RECOVER_LOG if we are to
 * do the recovery based off the recover.gz log -- See RecoveryJournal in
 * the frontier package -- or it holds the name of
 * the checkpoint we're to use recoverying.
 * @param name
 *            The name of the new job.
 * @param description
 *            Descriptions of the job.
 * @param seeds
 *            The contents of the new settings' seed file.
 * @param priority
 *            The priority of the new job.
 *
 * @return The new crawl job.
 * @throws FatalConfigurationException If a problem occurs creating the
 *             settings.
 */
public CrawlJob newJob(CrawlJob baseOn, String recovery, String name, String description, String seeds,
        int priority) throws FatalConfigurationException {
    // See what the recover story is.
    File recover = null;
    try {
        if (recovery != null && recovery.length() > 0 && recovery.equals(RECOVER_LOG)) {
            // Then we're to do a recovery based off the RecoveryJournal
            // recover.gz log.
            File dir = baseOn.getSettingsHandler().getOrder().getSettingsDir(CrawlOrder.ATTR_LOGS_PATH);
            // Add name of recover file.  We're hardcoding it as
            // 'recover.gz'.
            recover = new File(dir, FrontierJournal.LOGNAME_RECOVER);
        } else if (recovery != null && recovery.length() > 0) {
            // Must be name of a checkpoint to use.
            recover = new File(
                    baseOn.getSettingsHandler().getOrder().getSettingsDir(CrawlOrder.ATTR_CHECKPOINTS_PATH),
                    recovery);
        }
    } catch (AttributeNotFoundException e1) {
        throw new FatalConfigurationException("AttributeNotFoundException occured while setting up"
                + "new job/profile " + name + " \n" + e1.getMessage());
    }

    CrawlJob cj = createNewJob(baseOn.getSettingsHandler().getOrderFile(), name, description, seeds, priority);

    updateRecoveryPaths(recover, cj.getSettingsHandler(), name);

    return cj;
}

From source file:com.cyberway.issue.crawler.admin.CrawlJobHandler.java

/**
 * @param recover//  w w  w .  j  av a2s.c  o  m
 *            Source to use recovering. Can be full path to a recovery log
 *            or full path to a checkpoint src dir.
 * @param sh
 *            Settings Handler to update.
 * @param jobName
 *            Name of this job.
 * @throws FatalConfigurationException 
 */
protected void updateRecoveryPaths(final File recover, final SettingsHandler sh, final String jobName)
        throws FatalConfigurationException {
    if (recover == null) {
        return;
    }
    checkDirectory(recover);
    try {
        // Set 'recover-path' to be old job's recovery log path
        updateRecoveryPaths(recover, sh);
    } catch (AttributeNotFoundException e1) {
        throw new FatalConfigurationException("AttributeNotFoundException occured while setting up"
                + "new job/profile " + jobName + " \n" + e1.getMessage());
    } catch (InvalidAttributeValueException e1) {
        throw new FatalConfigurationException("InvalidAttributeValueException occured while setting"
                + "new job/profile " + jobName + " \n" + e1.getMessage());
    } catch (MBeanException e1) {
        throw new FatalConfigurationException("MBeanException occured while setting up new" + "new job/profile "
                + jobName + " \n" + e1.getMessage());
    } catch (ReflectionException e1) {
        throw new FatalConfigurationException("ReflectionException occured while setting up"
                + "new job/profile " + jobName + " \n" + e1.getMessage());
    } catch (IOException e) {
        throw new FatalConfigurationException(
                "IOException occured while setting up" + "new job/profile " + jobName + " \n" + e.getMessage());
    }
}

From source file:com.cyberway.issue.crawler.admin.CrawlJobHandler.java

/**
 * Creates a new settings handler based on an existing job. Basically all
 * the settings file for the 'based on' will be copied to the specified
 * directory./*from   w w  w. j  av a  2  s .c  o m*/
 *
 * @param orderFile Order file to base new order file on.  Cannot be null.
 * @param name Name for the new settings
 * @param description Description of the new settings.
 * @param seeds The contents of the new settings' seed file.
 * @param newSettingsDir
 * @param errorHandler
 * @param filename Name of new order file.
 * @param seedfile Name of new seeds file.
 *
 * @return The new settings handler.
 * @throws FatalConfigurationException
 *             If there are problems with reading the 'base on'
 *             configuration, with writing the new configuration or it's
 *             seed file.
 */
protected XMLSettingsHandler createSettingsHandler(final File orderFile, final String name,
        final String description, final String seeds, final File newSettingsDir,
        final CrawlJobErrorHandler errorHandler, final String filename, final String seedfile)
        throws FatalConfigurationException {
    XMLSettingsHandler newHandler = null;
    try {
        newHandler = new XMLSettingsHandler(orderFile);
        if (errorHandler != null) {
            newHandler.registerValueErrorHandler(errorHandler);
        }
        newHandler.setErrorReportingLevel(errorHandler.getLevel());
        newHandler.initialize();
    } catch (InvalidAttributeValueException e2) {
        throw new FatalConfigurationException("InvalidAttributeValueException occured while creating"
                + " new settings handler for new job/profile\n" + e2.getMessage());
    }

    // Make sure the directory exists.
    newSettingsDir.mkdirs();

    try {
        // Set the seed file
        ((ComplexType) newHandler.getOrder().getAttribute("scope"))
                .setAttribute(new Attribute("seedsfile", seedfile));
    } catch (AttributeNotFoundException e1) {
        throw new FatalConfigurationException(
                "AttributeNotFoundException occured while setting up" + "new job/profile\n" + e1.getMessage());
    } catch (InvalidAttributeValueException e1) {
        throw new FatalConfigurationException("InvalidAttributeValueException occured while setting"
                + "up new job/profile\n" + e1.getMessage());
    } catch (MBeanException e1) {
        throw new FatalConfigurationException(
                "MBeanException occured while setting up new" + " job/profile\n" + e1.getMessage());
    } catch (ReflectionException e1) {
        throw new FatalConfigurationException(
                "ReflectionException occured while setting up" + " new job/profile\n" + e1.getMessage());
    }

    File newFile = new File(newSettingsDir.getAbsolutePath(), filename);

    try {
        newHandler.copySettings(newFile,
                (String) newHandler.getOrder().getAttribute(CrawlOrder.ATTR_SETTINGS_DIRECTORY));
    } catch (IOException e3) {
        // Print stack trace to help debug issue where cannot create
        // new job from an old that has overrides.
        e3.printStackTrace();
        throw new FatalConfigurationException("IOException occured while writing new settings files"
                + " for new job/profile\n" + e3.getMessage());
    } catch (AttributeNotFoundException e) {
        throw new FatalConfigurationException("AttributeNotFoundException occured while writing new"
                + " settings files for new job/profile\n" + e.getMessage());
    } catch (MBeanException e) {
        throw new FatalConfigurationException("MBeanException occured while writing new settings files"
                + " for new job/profile\n" + e.getMessage());
    } catch (ReflectionException e) {
        throw new FatalConfigurationException("ReflectionException occured while writing new settings"
                + " files for new job/profile\n" + e.getMessage());
    }
    CrawlerSettings orderfile = newHandler.getSettingsObject(null);

    orderfile.setName(name);
    orderfile.setDescription(description);

    if (seeds != null) {
        BufferedWriter writer = null;
        try {
            writer = new BufferedWriter(new FileWriter(newHandler.getPathRelativeToWorkingDirectory(seedfile)));
            try {
                writer.write(seeds);
            } finally {
                writer.close();
            }
        } catch (IOException e) {
            throw new FatalConfigurationException(
                    "IOException occured while writing seed file for new" + " job/profile\n" + e.getMessage());
        }
    }
    return newHandler;
}

From source file:com.cyberway.issue.crawler.fetcher.FetchHTTP.java

private void setAcceptHeaders(CrawlURI curi, HttpMethod get) {
    try {//ww w.  j  a va  2s.c o  m
        StringList accept_headers = (StringList) getAttribute(ATTR_ACCEPT_HEADERS, curi);
        if (!accept_headers.isEmpty()) {
            for (ListIterator i = accept_headers.listIterator(); i.hasNext();) {
                String hdr = (String) i.next();
                String[] nvp = hdr.split(": +");
                if (nvp.length == 2) {
                    get.setRequestHeader(nvp[0], nvp[1]);
                } else {
                    logger.warning("Invalid accept header: " + hdr);
                }
            }
        }
    } catch (AttributeNotFoundException e) {
        logger.severe(e.getMessage());
    }
}

From source file:com.cyberway.issue.crawler.fetcher.FetchHTTP.java

/**
 * Promote successful credential to the server.
 *
 * @param curi CrawlURI whose credentials we are to promote.
 *//*from w ww .j a  va2  s .  c om*/
private void promoteCredentials(final CrawlURI curi) {
    if (!curi.hasCredentialAvatars()) {
        logger.severe("No credentials to promote when there should be " + curi);
    } else {
        Set avatars = curi.getCredentialAvatars();
        for (Iterator i = avatars.iterator(); i.hasNext();) {
            CredentialAvatar ca = (CredentialAvatar) i.next();
            curi.removeCredentialAvatar(ca);
            // The server to attach too may not be the server that hosts
            // this passed curi.  It might be of another subdomain.
            // The avatar needs to be added to the server that is dependent
            // on this precondition.  Find it by name.  Get the name from
            // the credential this avatar represents.
            Credential c = ca.getCredential(getSettingsHandler(), curi);
            String cd = null;
            try {
                cd = c.getCredentialDomain(curi);
            } catch (AttributeNotFoundException e) {
                logger.severe("Failed to get cred domain for " + curi + " for " + ca + ": " + e.getMessage());
            }
            if (cd != null) {
                CrawlServer cs = getController().getServerCache().getServerFor(cd);
                if (cs != null) {
                    cs.addCredentialAvatar(ca);
                }
            }
        }
    }
}

From source file:com.cyberway.issue.crawler.framework.CrawlController.java

/**
 * @return The logging directory or null if problem reading the settings.
 *///from w ww .  ja va  2  s. c  o  m
public File getLogsDir() {
    File f = null;
    try {
        f = getSettingsDir(CrawlOrder.ATTR_LOGS_PATH);
    } catch (AttributeNotFoundException e) {
        LOGGER.severe("Failed get of logs directory: " + e.getMessage());
    }
    return f;
}