Example usage for javax.management RuntimeErrorException RuntimeErrorException

List of usage examples for javax.management RuntimeErrorException RuntimeErrorException

Introduction

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

Prototype

public RuntimeErrorException(java.lang.Error e) 

Source Link

Document

Default constructor.

Usage

From source file:com.osbitools.ws.shared.prj.web.AbstractWsPrjInit.java

@Override
public void contextInitialized(ServletContextEvent evt) {
    super.contextInitialized(evt);
    ServletContext ctx = evt.getServletContext();

    // First - Load Custom Error List 
    try {/* ww w.j a va2s  .  c  om*/
        Class.forName("com.osbitools.ws.shared.prj.CustErrorList");
    } catch (ClassNotFoundException e) {
        // Ignore Error 
    }

    // Initialize Entity Utils
    IEntityUtils eut = getEntityUtils();
    ctx.setAttribute("entity_utils", eut);

    // Initiate LangSetFileUtils
    ctx.setAttribute("ll_set_utils", new LangSetUtils());

    // Check if git repository exists and create one
    // Using ds subdirectory as git root repository 
    File drepo = new File(
            getConfigDir(ctx) + File.separator + eut.getPrjRootDirName() + File.separator + ".git");
    Git git;
    try {

        if (!drepo.exists()) {
            if (!drepo.mkdirs())
                throw new RuntimeErrorException(
                        new Error("Unable create directory '" + drepo.getAbsolutePath() + "'"));

            try {
                git = createGitRepo(drepo);
            } catch (Exception e) {
                throw new RuntimeErrorException(new Error(
                        "Unable create new repo on path: " + drepo.getAbsolutePath() + ". " + e.getMessage()));
            }

            getLogger(ctx).info("Created new git repository '" + drepo.getAbsolutePath() + "'");
        } else if (!drepo.isDirectory()) {
            throw new RuntimeErrorException(
                    new Error(drepo.getAbsolutePath() + " is regular file and not a directory"));
        } else {
            git = Git.open(drepo);
            getLogger(ctx).debug("Open existing repository " + drepo.getAbsolutePath());
        }
    } catch (IOException e) {
        // Something unexpected and needs to be analyzed
        e.printStackTrace();

        throw new RuntimeErrorException(new Error(e));
    }

    // Save git handler
    ctx.setAttribute("git", git);

    // Check if remote destination set/changed
    StoredConfig config = git.getRepository().getConfig();
    String rname = (String) ctx.getAttribute(PrjMgrConstants.PREMOTE_GIT_NAME);
    String rurl = (String) ctx.getAttribute("git_remote_url");

    if (!Utils.isEmpty(rname) && !Utils.isEmpty(rurl)) {
        String url = config.getString("remote", rname, "url");
        if (!rurl.equals(url)) {
            config.setString("remote", rname, "url", rurl);
            try {
                config.save();
            } catch (IOException e) {
                getLogger(ctx).error("Error saving git remote url. " + e.getMessage());
            }
        }
    }

    // Temp directory for files upload
    String tname = System.getProperty("java.io.tmpdir");
    getLogger(ctx).info("Using temporarily directory '" + tname + "' for file uploads");
    File tdir = new File(tname);

    if (!tdir.exists())
        throw new RuntimeErrorException(
                new Error("Temporarily directory for file upload '" + tname + "' is not found"));
    if (!tdir.isDirectory())
        throw new RuntimeErrorException(
                new Error("Temporarily directory for file upload '" + tname + "' is not a directory"));

    DiskFileItemFactory dfi = new DiskFileItemFactory();
    dfi.setSizeThreshold(
            ((Integer) ctx.getAttribute(PrjMgrConstants.SMAX_FILE_UPLOAD_SIZE_NAME)) * 1024 * 1024);
    dfi.setRepository(tdir);
    evt.getServletContext().setAttribute("dfi", dfi);

    // Save entity utils in context
    evt.getServletContext().setAttribute("entity_utils", getEntityUtils());
}

From source file:org.r10r.doctester.testbrowser.TestBrowserImpl.java

@Override
public Response makeRequest(Request httpRequest) {

    Response httpResponse;/*from w  w w  .jav a  2  s  . c  om*/

    if (Sets.newHashSet(HEAD, GET, DELETE).contains(httpRequest.httpRequestType)) {

        httpResponse = makeHeadGetOrDeleteRequest(httpRequest);

    } else if (Sets.newHashSet(POST, PUT, PATCH).contains(httpRequest.httpRequestType)) {

        httpResponse = makePatchPostOrPutRequest(httpRequest);

    } else {

        throw new RuntimeErrorException(
                new Error("Your requested httpRequest.httpRequestType is not supported"));
    }

    return httpResponse;

}

From source file:org.doctester.testbrowser.TestBrowserImpl.java

@Override
public Response makeRequest(Request httpRequest) {

    Response httpResponse;/*ww  w  .jav a  2  s . co m*/

    if (Sets.newHashSet(HEAD, GET, DELETE).contains(httpRequest.httpRequestType)) {

        httpResponse = makeHeadGetOrDeleteRequest(httpRequest);

    } else if (Sets.newHashSet(POST, PUT).contains(httpRequest.httpRequestType)) {

        httpResponse = makePostOrPutRequest(httpRequest);

    } else {

        throw new RuntimeErrorException(
                new Error("Your requested httpRequest.httpRequestType is not supported"));
    }

    return httpResponse;

}

From source file:com.github.ibm.domino.client.BaseClient.java

protected void init(String pathSuffix) throws RuntimeException {

    if (database == null || database.isEmpty()) {
        throw new RuntimeErrorException(new Error("Database parameter not found"));
    }//  w  w  w.  j  ava  2 s  .  c  o  m
    if (ignoreHostNameMatching) {
        HttpsURLConnection.setDefaultHostnameVerifier((hostname, session) -> true);
    }

    StringBuilder p = new StringBuilder();
    if (pathSuffix != null && !pathSuffix.isEmpty()) {
        p.append("/mail");
        p.append("/").append(database);
    }
    p.append("/api/calendar");
    if (pathSuffix != null && !pathSuffix.isEmpty()) {
        p.append("/").append(pathSuffix);
    }
    setPath(p.toString());

    ObjectMapper mapper = new ObjectMapper();
    mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    mapper.setSerializationInclusion(Include.NON_NULL);
    //        mapper.configure(SerializationFeature. WRITE_NULL_MAP_VALUES, false);

    mapper.registerModule(new Jackson2HalModule());

    MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
    converter.setSupportedMediaTypes(
            Arrays.asList(MediaType.APPLICATION_JSON, MediaType.APPLICATION_OCTET_STREAM));
    converter.setObjectMapper(mapper);

    restTemplate = new RestTemplate(Collections.<HttpMessageConverter<?>>singletonList(converter));

    List<ClientHttpRequestInterceptor> interceptors = Collections
            .<ClientHttpRequestInterceptor>singletonList(new BasicAuthorizationInterceptor(username, password));
    restTemplate.setRequestFactory(
            new InterceptingClientHttpRequestFactory(restTemplate.getRequestFactory(), interceptors));

}

From source file:org.mule.module.dynamicFlows.DynamicFlowsModule.java

private Flow getFlowUsing(String flowName, MuleContext context) {
    Flow flow = (Flow) context.getRegistry().lookupFlowConstruct(flowName);
    if (flow == null)
        throw new RuntimeErrorException(new Error("flow does not exist"));
    return flow;/*from w ww .ja  v  a2 s.  c  o m*/
}

From source file:org.mule.module.dynamicFlows.DynamicFlowsModule.java

private MuleContext getContextWith(String contextName) {
    MuleContext context = contexts.get(contextName);

    if (context == null)
        throw new RuntimeErrorException(new Error("Context does not exist"));
    return context;
}

From source file:org.mule.module.dynamicFlows.DynamicFlowsModule.java

private void checkExistenceOf(String contextName) {
    if (contexts.containsKey(contextName))
        throw new RuntimeErrorException(new Error("Context already exists"));
}

From source file:org.evosuite.regression.ObjectFields.java

private static Object getFieldValue(Field field, Object p) {
    try {//  www .  ja  v  a2  s .co  m
        /*Class objClass = p.getClass();
        if(p instanceof java.lang.String){
           ((String) p).hashCode();
        }*/
        Class<?> fieldType = field.getType();
        field.setAccessible(true);
        if (fieldType.isPrimitive()) {
            if (fieldType.equals(Boolean.TYPE)) {
                return field.getBoolean(p);
            }
            if (fieldType.equals(Integer.TYPE)) {
                return field.getInt(p);
            }
            if (fieldType.equals(Byte.TYPE)) {
                return field.getByte(p);
            }
            if (fieldType.equals(Short.TYPE)) {
                return field.getShort(p);
            }
            if (fieldType.equals(Long.TYPE)) {
                return field.getLong(p);
            }
            if (fieldType.equals(Double.TYPE)) {
                return field.getDouble(p);
            }
            if (fieldType.equals(Float.TYPE)) {
                return field.getFloat(p);
            }
            if (fieldType.equals(Character.TYPE)) {
                return field.getChar(p);
            }
            throw new UnsupportedOperationException("Primitive type " + fieldType + " not implemented!");
        }
        return field.get(p);
    } catch (IllegalAccessException exc) {
        throw new RuntimeException(exc);
    } catch (OutOfMemoryError e) {
        e.printStackTrace();
        if (MAX_RECURSION != 0)
            MAX_RECURSION = 0;
        else
            throw new RuntimeErrorException(e);
        return getFieldValue(field, p);
    }
}