Example usage for org.apache.commons.lang NullArgumentException NullArgumentException

List of usage examples for org.apache.commons.lang NullArgumentException NullArgumentException

Introduction

In this page you can find the example usage for org.apache.commons.lang NullArgumentException NullArgumentException.

Prototype

public NullArgumentException(String argName) 

Source Link

Document

Instantiates with the given argument name.

Usage

From source file:org.geoserver.cluster.impl.handlers.catalog.CatalogUtils.java

/**
 * @param info/*from  w ww .ja  v  a 2  s  .c  o  m*/
 * @param catalog
 * @return the local style or the passed one (if not exists locally)
 */
public static StyleInfo localizeStyle(final StyleInfo info, final Catalog catalog) {
    if (info == null || catalog == null)
        throw new NullArgumentException("Arguments may never be null");

    final StyleInfo localObject = catalog.getStyleByName(info.getWorkspace(), info.getName());
    if (localObject != null) {
        return localObject;
    } else {
        if (LOGGER.isLoggable(java.util.logging.Level.INFO)) {
            LOGGER.info("No such style called \'" + info.getName() + "\' can be found: LOCALIZATION");
        }
        final CatalogBuilder builder = new CatalogBuilder(catalog);
        builder.attach(info);
        return info;
    }
}

From source file:org.geoserver.cluster.impl.handlers.catalog.CatalogUtils.java

public static LayerInfo localizeLayer(final LayerInfo info, final Catalog catalog)
        throws IllegalAccessException, InvocationTargetException {
    if (info == null || catalog == null)
        throw new NullArgumentException("Arguments may never be null");

    // make sure we use the prefixed name to include the workspace
    final LayerInfo localObject = catalog.getLayerByName(info.prefixedName());

    if (localObject != null) {
        return localObject;
    }/*www  .ja v  a 2 s.  c o m*/
    final LayerInfo createdObject = catalog.getFactory().createLayer();

    // RESOURCE
    ResourceInfo resource = info.getResource();
    if (resource != null) {
        resource = localizeResource(resource, catalog);
    } else {
        throw new NullPointerException("No resource found !!!");
    }

    // we have to set the resource before [and after] calling copyProperties
    // it is needed to call setName(String)
    createdObject.setResource(resource);

    // let's use the newly created object
    BeanUtils.copyProperties(createdObject, info);

    // we have to set the resource before [and after] calling copyProperties
    // it is overwritten (set to null) by the copyProperties function
    createdObject.setResource(resource);

    final StyleInfo deserDefaultStyle = info.getDefaultStyle();
    if (deserDefaultStyle != null) {
        final StyleInfo localDefaultStyle = localizeStyle(deserDefaultStyle, catalog);
        if (localDefaultStyle == null) {
            throw new NullPointerException(
                    "No matching style called \'" + deserDefaultStyle.getName() + "\'found locally.");
        }
        createdObject.setDefaultStyle(localDefaultStyle);
    } else {

        // the default style is set by the builder 

        // TODO: check: this happens when configuring a layer using GeoServer REST manager (see ImageMosaicTest)
    }

    // STYLES
    createdObject.getStyles().addAll(localizeStyles(createdObject.getStyles(), catalog));

    final CatalogBuilder builder = new CatalogBuilder(catalog);
    builder.attach(createdObject);
    return createdObject;
}

From source file:org.geoserver.cluster.impl.handlers.catalog.CatalogUtils.java

public static LayerGroupInfo localizeLayerGroup(final LayerGroupInfo info, final Catalog catalog)
        throws IllegalAccessException, InvocationTargetException {
    if (info == null || catalog == null)
        throw new NullArgumentException("Arguments may never be null");

    // make sure we use the prefixed name to include the workspace
    final LayerGroupInfo localObject = catalog.getLayerGroupByName(info.prefixedName());

    if (localObject != null) {
        return localObject;
    }// w ww. ja v  a 2  s  .c o m

    try {
        info.getLayers().addAll(localizeLayers(info.getLayers(), catalog));
    } catch (IllegalAccessException e) {
        if (LOGGER.isLoggable(java.util.logging.Level.SEVERE))
            LOGGER.severe(e.getLocalizedMessage());
        throw e;
    } catch (InvocationTargetException e) {
        if (LOGGER.isLoggable(java.util.logging.Level.SEVERE))
            LOGGER.severe(e.getLocalizedMessage());
        throw e;
    }

    // make sure catalog transient fields are properly initiated
    List<PublishedInfo> layers = info.getLayers();
    if (layers != null) {
        for (PublishedInfo layer : layers) {
            if (layer instanceof LayerInfo) {
                ResourceInfo resource = ((LayerInfo) layer).getResource();
                if (resource == null) {
                    continue;
                }
                StoreInfo store = resource.getStore();
                // we need the non proxy instance
                store = ModificationProxy.unwrap(store);
                if (store instanceof StoreInfoImpl) {
                    // setting the catalog
                    ((StoreInfoImpl) store).setCatalog(catalog);
                }
            }
        }
    }

    // localize layers
    info.getStyles().addAll(localizeStyles(new HashSet<StyleInfo>(info.getStyles()), catalog));

    // attach to the catalog
    final CatalogBuilder builder = new CatalogBuilder(catalog);
    builder.attach(info);
    return info;

}

From source file:org.geoserver.cluster.impl.handlers.catalog.JMSCatalogStylesFileHandler.java

@Override
public boolean synchronize(DocumentFile event) throws Exception {
    if (event == null) {
        throw new NullArgumentException("Incoming object is null");
    }/*  w w  w  .jav  a 2 s. c  om*/
    if (config == null) {
        throw new IllegalStateException("Unable to load configuration");
    } else if (!ReadOnlyConfiguration.isReadOnly(config)) {
        try {
            Resource file = loader.get("styles").get(event.getResourceName());

            if (!Resources.exists(file)) {
                final String styleAbsolutePath = event.getResourcePath();
                if (styleAbsolutePath.indexOf("workspaces") > 0) {
                    file = loader.get(styleAbsolutePath.substring(styleAbsolutePath.indexOf("workspaces")));
                }
            }

            event.writeTo(file);
            return true;
        } catch (Exception e) {
            if (LOGGER.isLoggable(java.util.logging.Level.SEVERE))
                LOGGER.severe(this.getClass() + " is unable to synchronize the incoming event: " + event);
            throw e;
        }
    }
    return true;
}

From source file:org.geoserver.cluster.impl.handlers.configuration.JMSServiceHandler.java

@Override
public boolean synchronize(JMSServiceModifyEvent ev) throws Exception {
    if (ev == null) {
        throw new NullArgumentException("Incoming event is null");
    }/*from   www  .j  a v  a 2  s  . c  o m*/
    try {
        // disable the message producer to avoid recursion
        producer.disable();
        // let's see which type of event we have
        switch (ev.getEventType()) {
        case MODIFIED:
            // localize service
            final ServiceInfo localObject = localizeService(geoServer, ev);
            // save the localized object
            geoServer.save(localObject);
            break;
        case ADDED:
            // checking that this service is not already present, we don't synchronize this check
            // if two threads add the same service well one of them will fail and throw an exception
            // this event may be generated for a service that already exists
            if (geoServer.getService(ev.getSource().getId(), ServiceInfo.class) == null) {
                // this is a new service so let's add it to this GeoServer instance
                geoServer.add(ev.getSource());
            }
            break;
        case REMOVED:
            // this service was removed so let's remove it from this geoserver
            geoServer.remove(ev.getSource());
            break;
        }
    } catch (Exception e) {
        if (LOGGER.isLoggable(java.util.logging.Level.SEVERE))
            LOGGER.severe(this.getClass() + " is unable to synchronize the incoming event: " + ev);
        throw e;
    } finally {
        producer.enable();
    }
    return true;

}

From source file:org.geoserver.cluster.impl.handlers.configuration.JMSSettingsHandler.java

@Override
public boolean synchronize(JMSSettingsModifyEvent event) throws Exception {
    if (event == null) {
        throw new NullArgumentException("Incoming event is NULL.");
    }//from   w w w . j av  a  2  s  . c o  m
    try {
        // disable the message producer to avoid recursion
        producer.disable();
        // let's see which type of event we have and handle it
        switch (event.getEventType()) {
        case MODIFIED:
            handleModifiedSettings(event);
            break;
        case ADDED:
            handleAddedSettings(event);
            break;
        case REMOVED:
            handleRemovedSettings(event);
            break;
        }
    } catch (Exception exception) {
        LOGGER.log(Level.SEVERE, "Error handling settings event.", exception);
        throw exception;
    } finally {
        // enabling the events producer again
        producer.enable();
    }
    return true;
}

From source file:org.hyperic.hq.api.model.resources.ResourceBatchResponse.java

public ResourceBatchResponse(BatchResponse<ResourceModel> batchResponse,
        ExceptionToErrorCodeMapper exceptionToErrorCodeMapper) {
    if (null == exceptionToErrorCodeMapper) {
        throw new NullArgumentException("exceptionToErrorCodeMap");
    }/*from ww w  .  j  a v a2s .com*/
    if (null != batchResponse) {
        if (null != batchResponse.getResponse()) {
            resources = batchResponse.getResponse();
        }

        Map<String, Exception> failedIds = batchResponse.getFailedIds();
        if (null != failedIds) {
            List<FailedResource> failedResources = new ArrayList<FailedResource>(failedIds.size());
            for (Entry<String, Exception> failedIdException : failedIds.entrySet()) {
                Exception exception = failedIdException.getValue();
                String resourceId = failedIdException.getKey();
                failedResources.add(new FailedResource(resourceId,
                        exceptionToErrorCodeMapper.getErrorCode(exception), exception.getMessage()));
            }
            super.setFailedResources(failedResources);
        }
    }
}

From source file:org.jenkinsci.plugins.zap.ZAPDriver.java

/**
 * Verify parameters of the build setup are correct (null, empty, negative ...)
 *
 * @param build//from ww  w . ja  v a  2  s  .c  o m
 * @param listener
 *            of type BuildListener: the display log listener during the Jenkins job execution.
 * @throws InterruptedException
 * @throws IOException
 * @throws Exception
 *             throw an exception if a parameter is invalid.
 */
private void checkParams(AbstractBuild<?, ?> build, BuildListener listener)
        throws IllegalArgumentException, IOException, InterruptedException {
    zapProgram = retrieveZapHomeWithToolInstall(build, listener);
    Utils.loggerMessage(listener, 0,
            "[{0}] PLUGIN VALIDATION (PLG), VARIABLE VALIDATION AND ENVIRONMENT INJECTOR EXPANSION (EXP)",
            Utils.ZAP);

    if (this.zapProgram == null || this.zapProgram.isEmpty())
        throw new IllegalArgumentException(
                "ZAP INSTALLATION DIRECTORY IS MISSING, PROVIDED [ " + this.zapProgram + " ]");
    else
        Utils.loggerMessage(listener, 1, "ZAP INSTALLATION DIRECTORY = [ {0} ]", this.zapProgram);

    /* System Environment and Build Environment variables will be expanded already, the following step will expand Environment Injector variables. Note: cannot be expanded in pre-build step. */
    EnvVars envVars = build.getEnvironment(listener);

    this.evaluatedZapHost = envVars.expand(this.evaluatedZapHost);
    if (this.evaluatedZapHost == null || this.evaluatedZapHost.isEmpty())
        throw new IllegalArgumentException("ZAP HOST IS MISSING, PROVIDED [ " + this.evaluatedZapHost + " ]");
    else
        Utils.loggerMessage(listener, 1, "(EXP) HOST = [ {0} ]", this.evaluatedZapHost);

    this.evaluatedZapPort = Integer.parseInt(envVars.expand(String.valueOf(this.evaluatedZapPort)));
    if (this.evaluatedZapPort < 0)
        throw new IllegalArgumentException(
                "ZAP PORT IS LESS THAN 0, PROVIDED [ " + this.evaluatedZapPort + " ]");
    else
        Utils.loggerMessage(listener, 1, "(EXP) PORT = [ {0} ]", String.valueOf(this.evaluatedZapPort));

    this.evaluatedSessionFilename = envVars.expand(this.evaluatedSessionFilename);
    this.evaluatedInternalSites = envVars.expand(this.evaluatedInternalSites);
    if (this.startZAPFirst) {
        if (!this.autoLoadSession) {
            if (this.evaluatedSessionFilename == null || this.evaluatedSessionFilename.isEmpty())
                throw new IllegalArgumentException(
                        "SESSION FILENAME IS MISSING, PROVIDED [ " + this.evaluatedSessionFilename + " ]");
            else
                Utils.loggerMessage(listener, 1, "(EXP) SESSION FILENAME = [ {0} ]",
                        this.evaluatedSessionFilename);

            if (this.removeExternalSites) {
                if (this.evaluatedInternalSites == null || this.evaluatedInternalSites.isEmpty())
                    throw new IllegalArgumentException(
                            "INTERNAL SITES IS MISSING, PROVIDED [ " + this.evaluatedInternalSites + " ]");
                else
                    Utils.loggerMessage(listener, 1, "(EXP) INTERNAL SITES = [ {0} ]",
                            this.evaluatedInternalSites.trim().replace("\n", ", "));
            }
        } else
            throw new IllegalArgumentException("LOADED SESSION FILES CANNOT BE USED IN PRE-BUILD");
    } else {
        if (this.autoLoadSession) {
            if (this.loadSession != null && this.loadSession.length() != 0)
                Utils.loggerMessage(listener, 1, "(EXP) LOAD SESSION = [ {0} ]", this.loadSession);
            else
                throw new IllegalArgumentException(
                        "LOAD SESSION IS MISSING, PROVIDED [ " + this.loadSession + " ]");
        }
    }

    this.evaluatedContextName = envVars.expand(this.evaluatedContextName);
    if (this.evaluatedContextName == null || this.evaluatedContextName.isEmpty())
        this.evaluatedContextName = "Jenkins Default Context";
    else
        Utils.loggerMessage(listener, 1, "(EXP) CONTEXT NAME = [ {0} ]", this.evaluatedContextName);

    this.evaluatedIncludedURL = envVars.expand(this.evaluatedIncludedURL);
    if (this.evaluatedIncludedURL == null || this.evaluatedIncludedURL.isEmpty())
        throw new IllegalArgumentException(
                "INCLUDE IN CONTEXT IS MISSING, PROVIDED [ " + this.evaluatedIncludedURL + " ]");
    else
        Utils.loggerMessage(listener, 1, "(EXP) INCLUDE IN CONTEXT = [ {0} ]",
                this.evaluatedIncludedURL.trim().replace("\n", ", "));

    this.evaluatedExcludedURL = envVars.expand(this.evaluatedExcludedURL);
    Utils.loggerMessage(listener, 1, "(EXP) EXCLUDE FROM CONTEXT = [ {0} ]",
            this.evaluatedExcludedURL.trim().replace("\n", ", "));

    this.evaluatedTargetURL = envVars.expand(this.evaluatedTargetURL);
    if (this.evaluatedTargetURL == null || this.evaluatedTargetURL.isEmpty())
        throw new IllegalArgumentException(
                "STARTING POINT (URL) IS MISSING, PROVIDED [ " + this.evaluatedTargetURL + " ]");
    else
        Utils.loggerMessage(listener, 1, "(EXP) STARTING POINT (URL) = [ {0} ]", this.evaluatedTargetURL);

    if (this.generateReports) {
        this.evaluatedReportFilename = envVars.expand(this.evaluatedReportFilename);
        if (this.evaluatedReportFilename == null || this.evaluatedReportFilename.isEmpty())
            throw new IllegalArgumentException(
                    "REPORT FILENAME IS MISSING, PROVIDED [ " + this.evaluatedReportFilename + " ]");
        else
            Utils.loggerMessage(listener, 1, "(EXP) REPORT FILENAME = [ {0} ]", this.evaluatedReportFilename);

        if (selectedReportMethod.equals(DEFAULT_REPORT)) {
            if (this.selectedReportFormats.size() == 0)
                throw new NullArgumentException("GENERATE REPORTS IS CHECKED, DEFAULT REPORT FORMAT");
        } else if (selectedReportMethod.equals(EXPORT_REPORT)) {
            if (this.selectedExportFormats.size() == 0)
                throw new NullArgumentException("GENERATE REPORTS IS CHECKED, EXPORT REPORT FORMAT");

            this.evaluatedExportreportTitle = envVars.expand(this.evaluatedExportreportTitle);
            if (this.evaluatedExportreportTitle == null || this.evaluatedExportreportTitle.isEmpty())
                throw new IllegalArgumentException(
                        "REPORT TITLE IS MISSING, PROVIDED [ " + this.evaluatedExportreportTitle + " ]");
            else
                Utils.loggerMessage(listener, 1, "(EXP) REPORT TITLE = [ {0} ]",
                        this.evaluatedExportreportTitle);
        }
    }

    if (this.jiraCreate) {
        /* Minimum : the url is needed */
        if (this.jiraBaseURL == null || this.jiraBaseURL.isEmpty())
            throw new IllegalArgumentException(
                    "JIRA BASE URL IS MISSING, PROVIDED [ " + this.jiraBaseURL + " ]");
        else
            Utils.loggerMessage(listener, 1, "JIRA BASE URL = [ {0} ]", this.jiraBaseURL);

        /* the username can be empty */
        if (this.jiraUsername == null)
            throw new IllegalArgumentException(
                    "JIRA USERNAME IS MISSING, PROVIDED [ " + this.jiraUsername + " ]");
        else
            Utils.loggerMessage(listener, 1, "JIRA USERNAME = [ {0} ]", this.jiraUsername);

        /* the password can be empty */
        if (this.jiraPassword == null)
            throw new IllegalArgumentException("JIRA PASSWORD IS MISSING");
        else
            Utils.loggerMessage(listener, 1, "JIRA PASSWORD = [ OK ]");
    }

    Utils.lineBreak(listener);
}

From source file:org.mili.core.logging.java.JavaAdapterTest.java

@Test
public void shouldLogsATraceException() {
    logger.trace(new NullArgumentException("an exception"), "abbas");
}

From source file:org.monkeys.gui.matcher.MatcherContext.java

public void setText(final String txt) {
    if (null == txt) {
        throw new NullArgumentException("text");
    }// ww w  .  j  a  v a2s . c  o m
    this.text = txt;
}