Example usage for java.lang IllegalAccessError IllegalAccessError

List of usage examples for java.lang IllegalAccessError IllegalAccessError

Introduction

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

Prototype

public IllegalAccessError(String s) 

Source Link

Document

Constructs an IllegalAccessError with the specified detail message.

Usage

From source file:org.onecmdb.core.utils.xml.XmlParser.java

public CiBean parseBlueprint(Element ci) {
    if (!ci.getName().equals(TEMPLATE_ELEMENT.getName())) {
        throw new IllegalAccessError(
                "Unknown element <" + ci.getName() + "> must be <" + TEMPLATE_ELEMENT.getName() + ">");
    }//from  www.  ja  v  a2s . com
    String alias = getAttributeValue(ci, ALIAS_ATTR, null);
    if (alias == null) {
        throw new IllegalAccessError("Alias must be specified on element <" + ci.getName() + ">");
    }
    String instanceNameExpression = getAttributeValue(ci, INSTANCE_NAME_EXPRESSION_ATTR, null);
    //log.debug("found template " + alias);

    String id = getAttributeValue(ci, ID_ATTR, null);
    CiBean ciBean = new CiBean();
    ciBean.setAlias(alias);
    ciBean.setDisplayNameExpression(instanceNameExpression);
    ciBean.setTemplate(true);

    String group = getAttributeValue(ci, GROUP_ATTR, null);
    ciBean.setGroup(group);

    if (id != null) {
        ciBean.setId(Long.parseLong(id));
    }

    List<Element> attributes = ci.elements();
    List<AttributeBean> aBeans = new ArrayList<AttributeBean>();
    for (Element el : attributes) {
        if (el.getName().equals(ATTRIBUTE_ELEMENT.getName())) {
            String attrAlias = getAttributeValue(el, ATT_ALIAS_ATTR, null);
            String name = getAttributeValue(el, NAME_ATTR, null);
            String derived = getAttributeValue(el, ATTR_DERIVED, "false");
            String attrId = getAttributeValue(el, ID_ATTR, null);

            AttributeBean aBean = new AttributeBean();
            aBean.setDisplayName(name);
            aBean.setAlias(attrAlias);
            aBean.setDerived(Boolean.parseBoolean(derived));
            if (attrId != null) {
                aBean.setId(Long.parseLong(attrId));
            }
            for (Element aEl : (List<Element>) el.elements()) {
                if (aEl.getName().equals(SIMPLE_TYPE_ELEMENT.getName())) {
                    aBean.setType(aEl.getTextTrim());
                    aBean.setComplexType(false);
                }
                if (aEl.getName().equals(POLICY_ELEMENT.getName())) {
                    Element max = aEl.element(MAX_OCCURS_ELEMENT.getName());
                    if (max != null) {
                        aBean.setMaxOccurs(max.getTextTrim());
                    }
                    Element min = aEl.element(MIN_OCCURS_ELEMENT.getName());
                    if (min != null) {
                        aBean.setMinOccurs(min.getTextTrim());
                    }
                }
                if (aEl.getName().equals(COMPLEX_TYPE_ELEMENT.getName())) {
                    Element ref = aEl.element(REF_ELEMENT.getName());
                    if (ref == null) {
                        throw new IllegalAccessError(
                                "Missing element <" + REF_ELEMENT.getName() + "> in element <" + aEl.getName()
                                        + "> template=" + alias + ", attribute=" + attrAlias);
                    }
                    Element refType = aEl.element(REF_TYPE_ELEMENT.getName());
                    // It's ok, atleast for references.
                    String refTypeAlias = null;
                    if (refType != null) {
                        /*
                        throw new IllegalAccessError("Missing element <"
                              + REF_TYPE_ELEMENT.getName()
                              + "> in element <" + aEl.getName()
                              + ">  template=" + alias + ", attribute="
                              + attrAlias);
                        */

                        Element refTypeRef = refType.element(REF_ELEMENT.getName());
                        if (refTypeRef == null) {
                            throw new IllegalAccessError("Missing element <" + REF_ELEMENT.getName()
                                    + "> in element <" + refType.getName() + "> template=" + alias
                                    + ", attribute=" + attrAlias);
                        }
                        refTypeAlias = getAttributeValue(refTypeRef, ALIAS_ATTR, null);

                    }
                    String refAlias = getAttributeValue(ref, ALIAS_ATTR, null);
                    aBean.setRefType(refTypeAlias);
                    aBean.setType(refAlias);
                    aBean.setComplexType(true);
                }
                if (aEl.getName().equals(DESCRIPTION_ELEMENT.getName())) {

                    aBean.setDescription(aEl.getTextTrim());
                }
                if (aEl.getName().equals(SET_SIMPLE_VALUE_ELEMENT.getName())) {
                    ValueBean vBean = new ValueBean();
                    String vId = getAttributeValue(aEl, ID_ATTR, null);
                    if (vId != null) {
                        vBean.setId(Long.parseLong(vId));
                    }
                    vBean.setValue(getValue(aEl));
                    vBean.setAlias(attrAlias);
                    vBean.setComplexValue(false);
                    ciBean.addAttributeValue(vBean);
                }
                if (el.getName().equals(SET_COMPLEX_VALUE_ELEMENT.getName())) {
                    ValueBean vBean = new ValueBean();
                    String vId = getAttributeValue(aEl, ID_ATTR, null);
                    if (vId != null) {
                        vBean.setId(Long.parseLong(vId));
                    }
                    Element ref = aEl.element(REF_ELEMENT.getName());
                    if (ref == null) {
                        throw new IllegalAccessError(
                                "Missing element <" + REF_ELEMENT.getName() + "> in element <" + el.getName()
                                        + "> template=" + alias + ", attribute=" + attrAlias);
                    }
                    String aliasValue = getAttributeValue(ref, ALIAS_ATTR, null);
                    vBean.setValue(aliasValue);
                    vBean.setComplexValue(true);

                    vBean.setAlias(attrAlias);
                    ciBean.addAttributeValue(vBean);
                }
            }
            ciBean.addAttribute(aBean);
        } else if (el.getName().equals(SET_SIMPLE_VALUE_ELEMENT.getName())) {
            String attrAlias = getAttributeValue(el, ATT_ALIAS_ATTR, null);
            ValueBean vBean = new ValueBean();

            String vId = getAttributeValue(el, ID_ATTR, null);
            if (vId != null) {
                vBean.setId(Long.parseLong(vId));
            }

            vBean.setValue(getValue(el));
            vBean.setAlias(attrAlias);
            vBean.setComplexValue(false);
            ciBean.addAttributeValue(vBean);
        } else if (el.getName().equals(SET_COMPLEX_VALUE_ELEMENT.getName())) {
            String attrAlias = getAttributeValue(el, ATT_ALIAS_ATTR, null);
            ValueBean vBean = new ValueBean();
            String vId = getAttributeValue(el, ID_ATTR, null);
            if (vId != null) {
                vBean.setId(Long.parseLong(vId));
            }

            Element ref = el.element(REF_ELEMENT.getName());
            if (ref == null) {
                throw new IllegalAccessError("Missing element <" + REF_ELEMENT.getName() + "> in element <"
                        + el.getName() + "> template=" + alias + ", attribute=" + attrAlias);
            }
            String aliasValue = getAttributeValue(ref, ALIAS_ATTR, null);
            vBean.setValue(aliasValue);
            vBean.setComplexValue(true);

            vBean.setAlias(attrAlias);
            ciBean.addAttributeValue(vBean);
        } else if (el.getName().equals(DERIVED_FROM_ELEMENT.getName())) {
            Element ref = el.element(REF_ELEMENT.getName());
            if (ref == null) {
                throw new IllegalAccessError("Missing element <" + REF_ELEMENT.getName() + "> in element <"
                        + el.getName() + "> template=" + alias);
            }
            String aliasValue = getAttributeValue(ref, ALIAS_ATTR, null);
            ciBean.setDerivedFrom(aliasValue);
        } else if (el.getName().equals(DESCRIPTION_ELEMENT.getName())) {
            ciBean.setDescription(el.getTextTrim());
        } else {
            throw new IllegalAccessError("Unkown element <" + el.getName() + "> in element <" + ci.getName()
                    + "> template=" + alias);
        }
    }
    // Validate alias and derivedFrom
    if (ciBean.getAlias() == null) {
        throw new IllegalArgumentException("No alias specified on element '" + ci.getName() + "'");
    }
    if (ciBean.getDerivedFrom() == null) {
        //log.warn("No derivedFrom specified on element '" + ciBean.getAlias() + "'");
        //throw new IllegalArgumentException("No derivedFrom specified on element '" + ciBean.getAlias() + "'");
    }

    return (ciBean);
}

From source file:org.jenkinsci.plugins.GitLabSecurityRealm.java

/**
 * Calls {@code SecurityListener.fireAuthenticated()} but through reflection
 * to avoid hard dependency on non-LTS core version. TODO delete in 1.569+
 *///from   w ww .ja  v a 2s. c om
private void fireAuthenticated(UserDetails details) {
    try {
        Class<?> c = Class.forName("jenkins.security.SecurityListener");
        Method m = c.getMethod("fireAuthenticated", UserDetails.class);
        m.invoke(null, details);
    } catch (ClassNotFoundException e) {
        // running with old core
    } catch (NoSuchMethodException e) {
        // running with old core
    } catch (IllegalAccessException e) {
        throw (Error) new IllegalAccessError(e.getMessage()).initCause(e);
    } catch (InvocationTargetException e) {
        LOGGER.log(Level.WARNING, "Failed to invoke fireAuthenticated", e);
    }
}

From source file:org.apache.http.impl.client.AbstractHttpClient.java

protected ClientConnectionManager createClientConnectionManager() {
    final SchemeRegistry registry = SchemeRegistryFactory.createDefault();

    ClientConnectionManager connManager = null;
    final HttpParams params = getParams();

    ClientConnectionManagerFactory factory = null;

    final String className = (String) params.getParameter(ClientPNames.CONNECTION_MANAGER_FACTORY_CLASS_NAME);
    if (className != null) {
        try {//  w  w  w  . j  av  a2 s.c o  m
            final Class<?> clazz = Class.forName(className);
            factory = (ClientConnectionManagerFactory) clazz.newInstance();
        } catch (final ClassNotFoundException ex) {
            throw new IllegalStateException("Invalid class name: " + className);
        } catch (final IllegalAccessException ex) {
            throw new IllegalAccessError(ex.getMessage());
        } catch (final InstantiationException ex) {
            throw new InstantiationError(ex.getMessage());
        }
    }
    if (factory != null) {
        connManager = factory.newInstance(params, registry);
    } else {
        connManager = new BasicClientConnectionManager(registry);
    }

    return connManager;
}

From source file:org.apache.http2.impl.client.AbstractHttpClient.java

protected ClientConnectionManager createClientConnectionManager() {
    SchemeRegistry registry = SchemeRegistryFactory.createDefault();

    ClientConnectionManager connManager = null;
    HttpParams params = getParams();// ww  w  .  j a  v  a2  s .com

    ClientConnectionManagerFactory factory = null;

    String className = (String) params.getParameter(ClientPNames.CONNECTION_MANAGER_FACTORY_CLASS_NAME);
    if (className != null) {
        try {
            Class<?> clazz = Class.forName(className);
            factory = (ClientConnectionManagerFactory) clazz.newInstance();
        } catch (ClassNotFoundException ex) {
            throw new IllegalStateException("Invalid class name: " + className);
        } catch (IllegalAccessException ex) {
            throw new IllegalAccessError(ex.getMessage());
        } catch (InstantiationException ex) {
            throw new InstantiationError(ex.getMessage());
        }
    }
    if (factory != null) {
        connManager = factory.newInstance(params, registry);
    } else {
        connManager = new BasicClientConnectionManager(registry);
    }

    return connManager;
}

From source file:net.grandcentrix.thirtyinch.TiPresenter.java

/**
 * the first lifecycle method after the presenter was created. This will be called only once!
 * The view is not attached at this state. But doing network requests is possible at this
 * state.//from   w  w w .  j  av  a  2 s .  c o  m
 *
 * @see #create()
 * @see #onDestroy()
 */
protected void onCreate() {
    if (mCalled) {
        throw new IllegalAccessError("don't call #onCreate() directly, call #create()");
    }
    mCalled = true;
}

From source file:com.baidu.cc.web.rpc.ConfigServerServiceImpl.java

/**
 * ????????.//w  ww .jav a2s.  co m
 * 
 * @param user
 *            ??
 * @param password
 *            ?
 * @param projectName
 *            ??
 * @param envName
 *            ???
 * @return ?
 */
@Override
public Long getLastestConfigVersion(String user, String password, String projectName, String envName) {
    User u = authenticate(user, password);

    // check project name
    Project project = projectService.findByName(projectName);
    if (project == null) {
        throw new IllegalAccessError("No project name found'" + projectName + "'");
    }

    authorizeProject(u, project.getId());

    Environment environment;
    environment = environmentService.findByNameAndProjectId(envName, project.getId());

    if (environment == null) {
        throw new IllegalAccessError(
                "No environment name found'" + envName + "' under project name '" + projectName + "'");
    }
    long envId = environment.getId();
    Version version = getLastestConfigVersion(envId);
    if (version == null) {
        throw new IllegalAccessError("No version under environemt id:" + envId);
    }

    return version.getId();
}

From source file:net.grandcentrix.thirtyinch.TiPresenter.java

/**
 * this Presenter is about to die. make a complete cleanup and don't leak anything. i.e.
 * complete Subjects/*from w w  w . j a  v  a  2  s .c  o m*/
 *
 * @see #destroy()
 * @see #onCreate()
 */
protected void onDestroy() {
    if (mCalled) {
        throw new IllegalAccessError("don't call #onDestroy() directly, call #destroy()");
    }
    mCalled = true;
}

From source file:org.apache.http.impl.client.AbstractStatisticsGatheringHttpClient.java

protected ClientConnectionManager createClientConnectionManager() {
    SchemeRegistry registry = SchemeRegistryFactory.createDefault();

    ClientConnectionManager connManager = null;
    HttpParams params = getParams();//from ww w  .  j  av a 2 s .c o m

    ClientConnectionManagerFactory factory = null;

    String className = (String) params.getParameter(ClientPNames.CONNECTION_MANAGER_FACTORY_CLASS_NAME);
    if (className != null) {
        try {
            Class<?> clazz = Class.forName(className);
            factory = (ClientConnectionManagerFactory) clazz.newInstance();
        } catch (ClassNotFoundException ex) {
            throw new IllegalStateException("Invalid class name: " + className);
        } catch (IllegalAccessException ex) {
            throw new IllegalAccessError(ex.getMessage());
        } catch (InstantiationException ex) {
            throw new InstantiationError(ex.getMessage());
        }
    }
    if (factory != null) {
        connManager = factory.newInstance(params, registry);
    } else {
        connManager = new SingleClientConnManager(registry);
    }

    return connManager;
}

From source file:net.grandcentrix.thirtyinch.TiPresenter.java

/**
 * Right after this method the view will be detached. {@link #getView()} will return
 * <code>null</code> afterwards.
 *
 * @see #onAttachView(TiView)/*w  w w . j ava2s.c om*/
 * @see #detachView()
 */
protected void onDetachView() {
    if (mCalled) {
        throw new IllegalAccessError("don't call #onDetachView() directly, call #detachView()");
    }
    mCalled = true;
}

From source file:net.grandcentrix.thirtyinch.TiPresenter.java

/**
 * @deprecated use {@link #onDetachView()} instead
 *///from ww  w  . j av  a  2s. co  m
@Deprecated
protected void onSleep() {
    if (mCalled) {
        throw new IllegalAccessError("don't call #onSleep() directly, call #detachView()");
    }
    mCalled = true;
}