Example usage for java.lang IllegalAccessException IllegalAccessException

List of usage examples for java.lang IllegalAccessException IllegalAccessException

Introduction

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

Prototype

public IllegalAccessException(String s) 

Source Link

Document

Constructs an IllegalAccessException with a detail message.

Usage

From source file:no.abmu.abmstatistikk.annualstatistic.util.KostaReportGeneratorH2.java

public KostaReportGeneratorH2() throws IOException, IllegalAccessException {
    Properties properties = new Properties();

    String hibFile = System.getProperty(HIB_FILE_KEY, "conf/hibernate/hibernate.properties");
    properties.load(/*from   w  w w  .j a  va2 s. c o  m*/
            ClassLoader.getSystemClassLoader().getResourceAsStream("conf/hibernate/hibernate.properties"));
    //        properties.load(ClassLoader.getSystemClassLoader().getResourceAsStream(hibFile));
    dialect = (String) properties.get(HIB_DIALECT_KEY);
    if (dialect == null) {
        throw new IllegalAccessException("The file " + hibFile + " had no key " + HIB_DIALECT_KEY);
    }

    System.getProperties().setProperty("applicationContextConfig", "conf/spring/application-context.xml");
    System.getProperties().setProperty("config_locs_cp",
            "conf/spring/appContext-util.xml," + "conf/spring/appContext-configuration.xml,"
                    + "conf/spring/appContext-db-dataLayer.xml,"
                    + "conf/spring/appContext-service-orgRegister.xml,"
                    + "conf/spring/appContext-service-annualStatistic.xml,"
                    + "conf/spring/appContext-service-user.xml");
    /*
    +
        "conf/spring/appContext-security.xml"
        */
    System.getProperties().setProperty("config_locs", "");
    ApplicationContextLoaderH2.getInstance().init();

    ApplicationContext context = ApplicationContextLoaderH2.getInstance().getApplicationContext();
    annualStatisticService = (AnnualStatisticService) ApplicationContextLoaderH2.getInstance()
            .getApplicationContext().getBean("AnnualStatisticService");
    organisationUnitService = (OrganisationUnitService) ApplicationContextLoaderH2.getInstance()
            .getApplicationContext().getBean("organisationUnitService");

}

From source file:org.broadleafcommerce.common.cache.AbstractCacheMissAware.java

/**
 * Retrieve a null representation of the cache item. This representation is the same for
 * all cache misses and is used as the object representation to store in the cache for a
 * cache miss./*from w  w  w .  j a va2 s  .c  om*/
 *
 * @param responseClass the class representing the type of the cache item
 * @param <T> the type of the cache item
 * @return the null representation for the cache item
 */
protected synchronized <T> T getNullObject(final Class<T> responseClass) {
    if (nullObject == null) {
        Class<?>[] interfaces = (Class<?>[]) ArrayUtils.add(ClassUtils.getAllInterfacesForClass(responseClass),
                Serializable.class);
        nullObject = Proxy.newProxyInstance(getClass().getClassLoader(), interfaces, new InvocationHandler() {
            @Override
            public Object invoke(Object o, Method method, Object[] objects) throws Throwable {
                if (method.getName().equals("equals")) {
                    return !(objects[0] == null) && objects[0].hashCode() == 31;
                } else if (method.getName().equals("hashCode")) {
                    return 31;
                } else if (method.getName().equals("toString")) {
                    return "Null_" + responseClass.getSimpleName();
                }
                throw new IllegalAccessException("Not a real object");
            }
        });
    }
    return (T) nullObject;
}

From source file:BeanUtil.java

/**
 * <p>Gets the specified attribute from the specified object.  For example,
 * <code>getObjectAttribute(o, "address.line1")</code> will return
 * the result of calling <code>o.getAddress().getLine1()</code>.<p>
 *
 * <p>The attribute specified may contain as many levels as you like. If at
 * any time a null reference is acquired by calling one of the successive
 * getter methods, then the return value from this method is also null.</p>
 *
 * <p>When reading from a boolean property the underlying bean introspector
 * first looks for an is&lt;Property&gt; read method, not finding one it will
 * still look for a get&lt;Property&gt; read method.  Not finding either, the
 * property is considered write-only.</p>
 *
 * @param bean the bean to set the property on
 * @param propertyNames the name of the propertie(s) to retrieve.  If this is
 *        null or the empty string, then <code>bean</code> will be returned.
 * @return the object value of the bean attribute
 *
 * @throws PropertyNotFoundException indicates the the given property
 *         could not be found on the bean
 * @throws NoSuchMethodException Not thrown
 * @throws InvocationTargetException if a specified getter method throws an
 *   exception./*from  www .  j av a2 s.co m*/
 * @throws IllegalAccessException if a getter method is
 *   not public or property is write-only.
 */
public static Object getObjectAttribute(Object bean, String propertyNames)
        throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {

    Object result = bean;

    StringTokenizer propertyTokenizer = new StringTokenizer(propertyNames, PROPERTY_SEPARATOR);

    // Run through the tokens, calling get methods and
    // replacing result with the new object each time.
    // If the result equals null, then simply return null.
    while (propertyTokenizer.hasMoreElements() && result != null) {
        Class resultClass = result.getClass();
        String currentPropertyName = propertyTokenizer.nextToken();

        PropertyDescriptor propertyDescriptor = getPropertyDescriptor(currentPropertyName, resultClass);

        Method readMethod = propertyDescriptor.getReadMethod();
        if (readMethod == null) {
            throw new IllegalAccessException(
                    "User is attempting to " + "read from a property that has no read method.  "
                            + " This is likely a write-only bean property.  Caused " + "by property ["
                            + currentPropertyName + "] on class [" + resultClass + "]");
        }

        result = readMethod.invoke(result, NO_ARGUMENTS_ARRAY);
    }

    return result;
}

From source file:org.apache.hadoop.chukwa.datastore.ViewStore.java

public void set(ViewBean view) throws IllegalAccessException {
    try {/*from www  . j a v  a2  s.c  om*/
        if (this.view == null || (this.view.getOwner().intern() == view.getOwner().intern())) {
            if (this.view != null) {
                delete();
            }
            StringBuilder viewPath = new StringBuilder();
            if (view.getPermissionType().intern() == PUBLIC) {
                viewPath.append(publicViewPath);
            } else {
                viewPath.append(usersViewPath);
                viewPath.append(File.separator);
                viewPath.append(uid);
            }
            viewPath.append(File.separator);
            viewPath.append(view.getName());
            viewPath.append(".view");
            Path viewFile = new Path(viewPath.toString());
            try {
                FileSystem fs = FileSystem.get(config);
                FSDataOutputStream out = fs.create(viewFile, true);
                out.write(view.deserialize().toString().getBytes());
                out.close();
            } catch (IOException ex) {
                log.error(ExceptionUtil.getStackTrace(ex));
            }
            this.view = view;
        } else {
            if (view.getPermissionType().intern() == PUBLIC) {
                throw new IllegalAccessException("Unable to save public view, duplicated view exists.");
            } else {
                throw new IllegalAccessException("Unable to save user view.");
            }
        }
    } catch (Exception e) {
        log.error(ExceptionUtil.getStackTrace(e));
        throw new IllegalAccessException("Unable to access user view.");
    }
}

From source file:com.stratelia.webactiv.servlets.RestOnlineFileServer.java

protected OnlineFile getWantedVersionnedDocument(RestRequest restRequest) throws Exception {
    String componentId = restRequest.getElementValue("componentId");
    OnlineFile file = null;/*from ww w  . j  ava  2s  .  c om*/
    String documentId = restRequest.getElementValue("documentId");
    if (StringUtil.isDefined(documentId)) {
        String versionId = restRequest.getElementValue("versionId");
        VersioningUtil versioning = new VersioningUtil();
        DocumentVersionPK versionPK = new DocumentVersionPK(Integer.parseInt(versionId), "useless",
                componentId);
        DocumentVersion version = versioning.getDocumentVersion(versionPK);
        if (version != null) {
            if (isUserAuthorized(restRequest, componentId, version)) {
                String[] path = new String[1];
                path[0] = "Versioning";
                file = new OnlineFile(version.getMimeType(), version.getPhysicalName(),
                        FileRepositoryManager.getRelativePath(path));
                file.setComponentId(componentId);
            } else {
                throw new IllegalAccessException("You can't access this file " + version.getLogicalName());
            }
        }
    }
    return file;
}

From source file:com.reactivetechnologies.platform.datagrid.core.HazelcastClusterServiceBean.java

/**
 * /*from   w  w  w .j a va 2s  .  co  m*/
 * @param callback
 * @throws IllegalAccessException 
 */
public void addPartitionMigrationCallback(PartitionMigrationCallback<?> callback)
        throws IllegalAccessException {
    if (!started) {
        migrCallbacks.put(callback.keyspace(), callback);
    } else
        throw new IllegalAccessException(
                "PartitionMigrationListener cannot be added after Hazelcast service has been started");
}

From source file:org.mycontroller.standalone.utils.McServerFileUtils.java

public static synchronized ImageFile getImageFile(String imageFileName)
        throws IOException, IllegalAccessException {
    String filesLocation = AppProperties.getInstance().getControllerSettings().getWidgetImageFilesLocation();
    if (!getImageFilesList().contains(imageFileName)) {
        throw new IllegalAccessException("You do not have access (or) file not found (or) "
                + "file size exceeded the allowed limit of 7 MB. File name: '" + imageFileName + "'");
    }//  w w  w.  ja va  2  s  . c o m
    if (FileUtils.getFile(filesLocation).exists()) {
        File imageFile = FileUtils.getFile(filesLocation + imageFileName);
        if (imageFile.exists()) {
            if (imageFile.length() > IMAGE_DISPLAY_WIDGET_FILE_SIZE_LIMIT) {
                throw new BadRequestException("File size exceeded the allowed limit of 7 MB, actual size: "
                        + imageFile.length() / McUtils.MB + " MB");
            }
            return ImageFile.builder().size(imageFile.length()).timestamp(imageFile.lastModified())
                    .name(imageFileName).canonicalPath(imageFile.getCanonicalPath())
                    .extension(FilenameUtils.getExtension(imageFileName).toLowerCase())
                    .data(FileUtils.readFileToByteArray(imageFile)).build();
        } else {
            throw new FileNotFoundException("File not found: " + imageFileName);
        }
    } else {
        throw new FileNotFoundException("File location not found: " + filesLocation);
    }
}

From source file:org.wso2.andes.server.virtualhost.VirtualHostImpl.java

private VirtualHostImpl(IApplicationRegistry appRegistry, VirtualHostConfiguration hostConfig,
        MessageStore store) throws Exception {
    if (hostConfig == null) {
        throw new IllegalAccessException("HostConfig and MessageStore cannot be null");
    }//from www  .  j  a  v a  2 s.c  om

    this.appRegistry = appRegistry;
    broker = this.appRegistry.getBroker();
    configuration = hostConfig;
    name = configuration.getName();

    id = this.appRegistry.getConfigStore().createId();

    CurrentActor.get().message(VirtualHostMessages.CREATED(name));

    if (name == null || name.length() == 0) {
        throw new IllegalArgumentException("Illegal name (" + name + ") for virtualhost.");
    }

    securityManager = new SecurityManager(this.appRegistry.getSecurityManager());
    securityManager.configureHostPlugins(configuration);

    virtualHostMBean = new VirtualHostMBean();

    connectionRegistry = new ConnectionRegistry();

    houseKeepingTasks = new ScheduledThreadPoolExecutor(configuration.getHouseKeepingThreadCount());

    queueRegistry = new DefaultQueueRegistry(this);

    exchangeFactory = new DefaultExchangeFactory(this);
    exchangeFactory.initialise(configuration);

    StartupRoutingTable configFileRT = new StartupRoutingTable();

    durableConfigurationStore = configFileRT;

    if (store != null) {
        messageStore = store;
        durableConfigurationStore = store;
    } else {
        initialiseAndesStores(hostConfig);
    }

    AndesKernelBoot.startAndesCluster();
    exchangeRegistry = new DefaultExchangeRegistry(this);
    bindingFactory = new BindingFactory(this);

    // This needs to be after the RT has been defined as it creates the default durable exchanges.
    initialiseModel(configuration);
    exchangeRegistry.initialise();

    authenticationManager = ApplicationRegistry.getInstance().getAuthenticationManager();

    brokerMBean = new AMQBrokerManagerMBean(virtualHostMBean);
    brokerMBean.register();

    queueManagementInformationMBean = new QueueManagementInformationMBean(virtualHostMBean);
    queueManagementInformationMBean.register();

    initialiseHouseKeeping(hostConfig.getHousekeepingExpiredMessageCheckPeriod());

    initialiseStatistics();

}

From source file:org.neo4art.literature.analyzer.DocumentsNLPLinkedListAnalyzer.java

/**
 * Support method meant to check if the collection of document is not empty
 * //from w w  w  .  ja  v  a  2  s  .  c o m
 * @throws IllegalAccessException if the collection of document is empty
 */
private void assertDocumentListIsNotEmpty() {
    if (CollectionUtils.isEmpty(this.documents)) {
        throw new RuntimeException(new IllegalAccessException(
                "You must supply a non-empty set of documents to store on the graph"));
    }
}