Example usage for java.lang Error Error

List of usage examples for java.lang Error Error

Introduction

In this page you can find the example usage for java.lang Error Error.

Prototype

public Error(Throwable cause) 

Source Link

Document

Constructs a new error with the specified cause and a detail message of (cause==null ?

Usage

From source file:com.scoopit.weedfs.client.WeedFSClientBuilder.java

public WeedFSClient build() {
    if (masterUrl == null) {
        try {/*from w  w  w  .  j a  va 2s. c o m*/
            // default url for testing purpose
            masterUrl = new URL("http://localhost:9333");
        } catch (MalformedURLException e) {
            // This cannot happen by construction
            throw new Error(e);
        }
    }

    if (httpClient == null) {
        // minimal http client
        RequestConfig config = RequestConfig.custom().setSocketTimeout(5000).setConnectTimeout(5000).build();

        httpClient = HttpClientBuilder.create().setDefaultRequestConfig(config).build();
    }

    return new WeedFSClientImpl(masterUrl, httpClient, lookupCache);
}

From source file:edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.MultiValueEditSubmission.java

public MultiValueEditSubmission(Map<String, String[]> queryParameters, EditConfigurationVTwo editConfig) {
    if (editConfig == null)
        throw new Error("EditSubmission needs an EditConfiguration");
    this.editKey = editConfig.getEditKey();
    if (this.editKey == null || this.editKey.trim().length() == 0)
        throw new Error("EditSubmission needs an 'editKey' parameter from the EditConfiguration");

    entityToReturnTo = editConfig.getEntityToReturnTo();

    validationErrors = new HashMap<String, String>();

    this.urisFromForm = new HashMap<String, List<String>>();
    for (String var : editConfig.getUrisOnform()) {
        String[] valuesArray = queryParameters.get(var);
        //String uri = null;
        addUriToForm(editConfig, var, valuesArray);
    }//  w  w w .  jav  a 2  s.com

    this.literalsFromForm = new HashMap<String, List<Literal>>();
    for (String var : editConfig.getLiteralsOnForm()) {
        FieldVTwo field = editConfig.getField(var);
        if (field == null) {
            log.error("could not find field " + var + " in EditConfiguration");
            continue;
        } else if (field.getEditElement() != null) {
            log.debug("skipping field with edit element, it should not be in literals on form list");
        } else {
            String[] valuesArray = queryParameters.get(var);
            addLiteralToForm(editConfig, field, var, valuesArray);
        }
    }

    if (log.isDebugEnabled()) {
        for (String key : literalsFromForm.keySet()) {
            log.debug(key + " literal " + literalsFromForm.get(key));
        }
        for (String key : urisFromForm.keySet()) {
            log.debug(key + " uri " + urisFromForm.get(key));
        }
    }

    processEditElementFields(editConfig, queryParameters);
    //Incorporating basic validation
    //Validate URIS
    this.basicValidation = new BasicValidationVTwo(editConfig, this);
    Map<String, String> errors = basicValidation.validateUris(urisFromForm);
    //Validate literals and add errors to the list of existing errors
    errors.putAll(basicValidation.validateLiterals(literalsFromForm));
    if (errors != null) {
        validationErrors.putAll(errors);
    }

    if (editConfig.getValidators() != null) {
        for (N3ValidatorVTwo validator : editConfig.getValidators()) {
            if (validator != null) {
                //throw new Error("need to implemente a validator interface that works with the new MultivalueEditSubmission.");
                errors = validator.validate(editConfig, this);
                if (errors != null)
                    validationErrors.putAll(errors);
            }
        }
    }

    if (log.isDebugEnabled())
        log.debug(this.toString());
}

From source file:MathUtil.java

/** 
 * Method that calculates the Least Common Multiple (LCM) of two strictly
 * positive integer numbers./*from  w ww  . j a va  2s  .c  o m*/
 *
 * @param x1 First number
 *
 * @param x2 Second number
 * */
public static final int lcm(int x1, int x2) {
    if (x1 <= 0 || x2 <= 0) {
        throw new IllegalArgumentException("Cannot compute the least " + "common multiple of two "
                + "numbers if one, at least," + "is negative.");
    }
    int max, min;
    if (x1 > x2) {
        max = x1;
        min = x2;
    } else {
        max = x2;
        min = x1;
    }
    for (int i = 1; i <= min; i++) {
        if ((max * i) % min == 0) {
            return i * max;
        }
    }
    throw new Error("Cannot find the least common multiple of numbers " + x1 + " and " + x2);
}

From source file:edu.berkeley.compbio.ncbitaxonomy.service.NcbiCiccarelliHybridClient.java

public NcbiCiccarelliHybridClient() {
    ApplicationContext ctx = null;//from   w ww  .j  ava 2 s  . c o  m
    try {
        ctx = NcbiTaxonomyServicesContextFactory.makeNcbiTaxonomyServicesContext();
    } catch (IOException e) {
        logger.error("Error", e);
        throw new Error(e);
    }

    ncbiCiccarelliHybrid = (NcbiCiccarelliHybridService) ctx.getBean("ncbiCiccarelliHybridService");
}

From source file:gobblin.source.extractor.extract.kafka.ConfigStoreUtils.java

/**
 * Will return the list of URIs given which are importing tag {@param tagUri}
 *//*from  w w  w . j ava  2 s . c  om*/
public static Collection<URI> getTopicsURIFromConfigStore(ConfigClient configClient, Path tagUri,
        String filterString, Optional<Config> runtimeConfig) {
    try {
        Collection<URI> importedBy = configClient.getImportedBy(new URI(tagUri.toString()), true,
                runtimeConfig);
        return importedBy.stream().filter((URI u) -> u.toString().contains(filterString))
                .collect(Collectors.toList());
    } catch (URISyntaxException | ConfigStoreFactoryDoesNotExistsException | ConfigStoreCreationException e) {
        throw new Error(e);
    }
}

From source file:mx.bigdata.sat.cfdi.TFDv1_v32.java

private static final JAXBContext createContext() {
    try {//  www .  j ava2  s . com
        List<String> ctx = Lists.asList("mx.bigdata.sat.cfdi.schema.v32", new String[] {
                "mx.bigdata.sat.complementos.schema.nomina", "mx.bigdata.sat.complementos.schema.implocal" });
        //return JAXBContext.newInstance("mx.bigdata.sat.cfdi.schema.v32");
        return JAXBContext.newInstance(JOINER.join(ctx));
    } catch (Exception e) {
        throw new Error(e);
    }
}

From source file:com.adito.security.tags.PermissionTag.java

public int doStartTag() {

    User user = null;/*from   www  .  ja v  a 2  s  .  co m*/
    try {
        user = LogonControllerFactory.getInstance().getUser(pageContext.getSession(), null);
        if (user == null) {
            return required ? SKIP_BODY : EVAL_BODY_INCLUDE;
        } else {

            ResourceType resourceType = null;
            if (resourceTypeId != -1) {
                if (permissionList.equals("")) {
                    throw new Error("No permissionMask attribute supplied.");
                }
                resourceType = PolicyDatabaseFactory.getInstance().getResourceType(resourceTypeId);
            }
            if (resourceType != null) {
                StringTokenizer t = new StringTokenizer(permissionList, ",");
                List allowed = new ArrayList();
                List denied = new ArrayList();
                while (t.hasMoreTokens()) {
                    String perm = t.nextToken();
                    if (perm.startsWith("!")) {
                        int id = Integer.parseInt(perm.substring(1));
                        Permission permInfo = resourceType.getPermission(id);
                        if (permInfo == null) {
                            throw new Error("No permission with ID of " + id + " in resource type "
                                    + resourceType.getResourceTypeId());
                        }
                        denied.add(permInfo);
                    } else {
                        int id = Integer.parseInt(perm);
                        Permission permInfo = resourceType.getPermission(id);
                        if (permInfo == null) {
                            throw new Error("No permission with ID of " + id + " in resource type "
                                    + resourceType.getResourceTypeId());
                        }
                        allowed.add(permInfo);
                    }
                }
                Permission[] allowedPerms = (Permission[]) allowed.toArray(new Permission[allowed.size()]);
                Permission[] deniedPerms = (Permission[]) denied.toArray(new Permission[denied.size()]);
                boolean allowedOk = allowedPerms.length == 0 ? true
                        : PolicyDatabaseFactory.getInstance().isPermitted(resourceType, allowedPerms, user,
                                all);
                boolean deniedOk = deniedPerms.length == 0 ? all
                        : !PolicyDatabaseFactory.getInstance().isPermitted(resourceType, deniedPerms, user,
                                all);
                if (all) {
                    if (allowedOk && deniedOk) {
                        return required ? EVAL_BODY_INCLUDE : SKIP_BODY;
                    } else {
                        return required ? SKIP_BODY : EVAL_BODY_INCLUDE;
                    }
                } else {
                    if (allowedOk || deniedOk) {
                        return required ? EVAL_BODY_INCLUDE : SKIP_BODY;
                    } else {
                        return required ? SKIP_BODY : EVAL_BODY_INCLUDE;
                    }
                }
            } else {
                if (!PolicyDatabaseFactory.getInstance().isAnyAccessRightAllowed(user, true, true, false)) {
                    return SKIP_BODY;
                } else {
                    return EVAL_BODY_INCLUDE;
                }
            }
        }
    } catch (Exception e) {
        log.error("Failed to term permissions.", e);
    }
    return SKIP_BODY;
}

From source file:com.manydesigns.portofino.actions.admin.tables.forms.DatabaseSelectionProviderForm.java

public DatabaseSelectionProvider copyTo(DatabaseSelectionProvider dsp) {
    try {//from w w w  .  jav  a2s .c  o  m
        BeanUtils.copyProperties(dsp, this);
    } catch (Exception e) {
        throw new Error(e);
    }
    return dsp;
}

From source file:ca.uhn.fhir.rest.client.BaseHttpClientInvocation.java

protected static void appendExtraParamsWithQuestionMark(Map<String, List<String>> theExtraParams,
        StringBuilder theUrlBuilder, boolean theWithQuestionMark) {
    if (theExtraParams == null) {
        return;// w w w  . j a va 2s.co  m
    }
    boolean first = theWithQuestionMark;

    if (theExtraParams != null && theExtraParams.isEmpty() == false) {
        for (Entry<String, List<String>> next : theExtraParams.entrySet()) {
            for (String nextValue : next.getValue()) {
                if (first) {
                    theUrlBuilder.append('?');
                    first = false;
                } else {
                    theUrlBuilder.append('&');
                }
                try {
                    theUrlBuilder.append(URLEncoder.encode(next.getKey(), "UTF-8"));
                    theUrlBuilder.append('=');
                    theUrlBuilder.append(URLEncoder.encode(nextValue, "UTF-8"));
                } catch (UnsupportedEncodingException e) {
                    throw new Error("UTF-8 not supported - This should not happen");
                }
            }
        }
    }
}

From source file:com.github.rnewson.couchdb.lucene.couchdb.View.java

private static byte[] toBytes(final String str) {
    if (str == null) {
        return new byte[0];
    }//from   ww  w.j  a v a  2s.  co m
    try {
        return str.getBytes("UTF-8");
    } catch (final UnsupportedEncodingException e) {
        throw new Error("UTF-8 support missing.");
    }
}