List of usage examples for java.lang IllegalAccessException IllegalAccessException
public IllegalAccessException(String s)
IllegalAccessException
with a detail message. From source file:de.xirp.plugin.SecurePluginView.java
/** * Prints a log message that the access to the given method was * not allowed from the given class//from www . j a v a 2s .co m * * @param methodName * the name of the method * @param callerClassName * the name of the class which tried to call this * method */ private void accessNotAllowed(String methodName, String callerClassName) { try { throw new IllegalAccessException(I18n.getString("SecurePluginView.exception.noPermission2", //$NON-NLS-1$ callerClassName, methodName, getName())); } catch (IllegalAccessException e) { logClass.error("Error: " + e.getMessage() + Constants.LINE_SEPARATOR, e); //$NON-NLS-1$ } }
From source file:org.neo4art.literature.analyzer.DocumentsNLPLinkedListAnalyzer.java
/** * Support method meant to check you called {@link #computeNLPAnalysis()} before running the other kind of statistics:<br/> * This implementation requires the presence of linked list of NLP POS Tags stored on the graph, to compute Redundancy Statistics and Sentiment Analysis. * // w ww .j a v a2 s.c o m * @throws IllegalAccessException if documents aren't stored on graph */ private void assertNLPAnalysisDone() { if (!this.nlpAnalysisRun) { throw new RuntimeException( new IllegalAccessException("You must run NLPAnalysis before running redundancy statistics")); } }
From source file:org.mycontroller.standalone.utils.McTemplateUtils.java
public static McTemplate get(String templateName) throws IOException, IllegalAccessException, McBadRequestException { String templatesLocation = McUtils.getDirectoryLocation( FileUtils.getFile(AppProperties.getInstance().getTemplatesLocation()).getCanonicalPath()); String fileFullPath = templatesLocation + templateName; if (McUtils.isInScope(templatesLocation, fileFullPath)) { if (!FileUtils.getFile(fileFullPath).exists()) { throw new McBadRequestException("File not found! " + fileFullPath); }// w ww .j av a 2 s . c o m File fileScript = FileUtils.getFile(fileFullPath); McTemplate mcTemplate = McTemplate.builder() .extension(FilenameUtils.getExtension(fileScript.getCanonicalPath())).size(fileScript.length()) .lastModified(fileScript.lastModified()) .data(FileUtils.readFileToString(fileScript, StandardCharsets.UTF_8)) .canonicalPath(fileScript.getCanonicalPath()) .name(FilenameUtils.getBaseName(fileScript.getCanonicalPath().replace(templatesLocation, ""))) .build(); return mcTemplate; } else { _logger.warn("Trying to get file from outside scope! Filepath:{}, CanonicalPath:{}", fileFullPath, FileUtils.getFile(fileFullPath).getCanonicalPath()); throw new IllegalAccessException("Trying to get file from outside scope!"); } }
From source file:net.neevek.android.lib.paginize.util.AnnotationUtils.java
public static void initAnnotatedFields(Class clazz, Object object, ViewFinder viewFinder, boolean initForLazy) throws InvocationTargetException, IllegalAccessException, NoSuchMethodException, InstantiationException {//from w w w.j a v a 2s. co m Field fields[] = clazz.getDeclaredFields(); Map<Class, Object> targetListenerCache = new HashMap<Class, Object>(); for (int i = 0; i < fields.length; ++i) { Field field = fields[i]; Annotation[] annotations = field.getAnnotations(); if (annotations == null || annotations.length == 0) { continue; } for (int j = 0; j < annotations.length; ++j) { Annotation anno = annotations[j]; if (!InjectView.class.isAssignableFrom(anno.getClass())) { continue; } InjectView injectViewAnno = (InjectView) anno; if ((!initForLazy && injectViewAnno.lazy()) || (initForLazy && !injectViewAnno.lazy())) { continue; } View view = viewFinder.findViewById(injectViewAnno.value()); if (view == null) { if (initForLazy && injectViewAnno.lazy()) { // view == null is tolerable in this case, we assume that this field // be injected later with another call to ViewWrapper.lazyInitializeLayout(). continue; } throw new IllegalArgumentException("View 0x" + Integer.toHexString(injectViewAnno.value()) + " specified in @InjectView on this field is not found: " + field.getName() + ", if this field is meant to be injected lazily, remember to specify the 'lazy' attribute."); } try { field.setAccessible(true); field.set(object, view); } catch (IllegalAccessException e) { String errMsg = "@InjectView() on '" + field.getName() + "' failed. "; if (field.getType() != view.getClass()) { errMsg += (view.getClass().getSimpleName() + " cannot be cast to " + field.getType().getSimpleName()); } throw new IllegalAccessException(errMsg); } catch (IllegalArgumentException e) { String errMsg = "@InjectView() on '" + field.getName() + "' failed. "; if (field.getType() != view.getClass()) { errMsg += (view.getClass().getSimpleName() + " cannot be cast to " + field.getType().getSimpleName()); } throw new IllegalArgumentException(errMsg); } Class[] listenerTypes = injectViewAnno.listenerTypes(); if (listenerTypes == null || listenerTypes.length == 0) { continue; } Object targetListener = getTargetListener(clazz, object, targetListenerCache, injectViewAnno.listener(), "@InjectView"); if (targetListener == null) { targetListener = object; } AnnotationUtils.setListenersForView(view, injectViewAnno.listenerTypes(), targetListener); } } }
From source file:com.openx.oauth.client.Helper.java
/** * Getter for the cookieStore/*from w ww . ja v a 2 s .c o m*/ * @return cookieStore */ public BasicCookieStore getCookieStore() throws IllegalAccessException { if (cookieStore == null) { throw new IllegalAccessException( "You must call createCookieStore() " + "before you can access the cookieStore!"); } return cookieStore; }
From source file:BeanUtil.java
/** * <p>Sets the specified attribute on the specified object. For example, * <code>getObjectAttribute(o, "address.line1", value)</code> will call * <code>o.getAddress().setLine1(value)</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 a <code>NullPointerException</code> is thrown.</p> * * @param bean the bean to call the getters on * @param propertyNames the name of the attribute(s) to set. If this is * null or the empty string, then an exception is thrown. * @param value the value of the object to set on the bean property * * @throws PropertyNotFoundException indicates the the given property * could not be found on the bean * @throws IllegalArgumentException if the supplied parameter is not of * a valid type/*from w w w . j a v a 2 s. com*/ * @throws NoSuchMethodException never * @throws IllegalAccessException if a getter or setter method is * not public or property is read-only. * @throws InvocationTargetException if a specified getter method throws an * exception. */ public static void setObjectAttribute(Object bean, String propertyNames, Object value) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException { Object result = bean; String propertyName = propertyNames; // Check if this has some embedded properties. If it does, use the // getObjectAttribute to get the proper object to call this on. int indexOfLastPropertySeparator = propertyName.lastIndexOf(PROPERTY_SEPARATOR); if (indexOfLastPropertySeparator >= 0) { String embeddedProperties = propertyName.substring(0, indexOfLastPropertySeparator); // Grab the final property name after the last property separator propertyName = propertyName.substring(indexOfLastPropertySeparator + PROPERTY_SEPARATOR.length()); result = getObjectAttribute(result, embeddedProperties); } Class resultClass = result.getClass(); PropertyDescriptor propertyDescriptor = getPropertyDescriptor(propertyName, resultClass); Method writeMethod = propertyDescriptor.getWriteMethod(); if (writeMethod == null) { throw new IllegalAccessException( "User is attempting to write " + "to a property that has no write method. This is likely " + "a read-only bean property. Caused by property [" + propertyName + "] on class [" + resultClass + "]"); } writeMethod.invoke(result, new Object[] { value }); }
From source file:kilim.Task.java
/** * Invoke a pausable method via reflection. Equivalent to Method.invoke(). * // w w w.j a v a 2 s . c om * @param mthd: The method to be invoked. (Implementation note: the corresponding woven method is invoked instead). * @param target: The object on which the method is invoked. Can be null if the method is static. * @param args: Arguments to the method * @return * @throws Pausable * @throws IllegalAccessException * @throws IllegalArgumentException * @throws InvocationTargetException */ public static Object invoke(Method mthd, Object target, Object... args) throws Pausable, IllegalAccessException, IllegalArgumentException, InvocationTargetException { Fiber f = getCurrentTask().fiber; Object[] fargs; if (f.pc == 0) { mthd = getWovenMethod(mthd); // Normal invocation. if (args == null) { fargs = new Object[1]; } else { fargs = new Object[args.length + 1]; // for fiber System.arraycopy(args, 0, fargs, 0, args.length); } fargs[fargs.length - 1] = f; } else { // Resuming from a previous yield ArgState as = (ArgState) f.getState(); mthd = (Method) as.mthd; target = as.obj; fargs = as.fargs; } f.down(); Object ret = mthd.invoke(target, fargs); switch (f.up()) { case Fiber.NOT_PAUSING__NO_STATE: case Fiber.NOT_PAUSING__HAS_STATE: return ret; case Fiber.PAUSING__NO_STATE: ArgState as = new ArgState(); as.obj = target; as.fargs = fargs; as.pc = 1; as.mthd = mthd; f.setState(as); return null; case Fiber.PAUSING__HAS_STATE: return null; } throw new IllegalAccessException("Internal Error"); }
From source file:org.apache.hadoop.chukwa.datastore.ViewStore.java
public static JSONArray list(String uid) throws IllegalAccessException { StringBuilder viewPath = new StringBuilder(); viewPath.append(usersViewPath);//from ww w . j ava 2 s .c o m viewPath.append(File.separator); viewPath.append(uid); String[] pathList = new String[2]; pathList[0] = viewPath.toString(); pathList[1] = publicViewPath; JSONArray list = new JSONArray(); for (String path : pathList) { Path viewFile = new Path(path); try { FileSystem fs = FileSystem.get(config); FileStatus[] fstatus = fs.listStatus(viewFile); if (fstatus != null) { for (int i = 0; i < fstatus.length; i++) { long size = fstatus[i].getLen(); FSDataInputStream viewStream = fs.open(fstatus[i].getPath()); byte[] buffer = new byte[(int) size]; viewStream.readFully(buffer); viewStream.close(); try { ViewBean view = new ViewBean(new JSONObject(new String(buffer))); JSONObject json = new JSONObject(); json.put("name", view.getName()); json.put("type", view.getPermissionType()); json.put("owner", view.getOwner()); if (uid.intern() == view.getOwner().intern()) { json.put("editable", "true"); } else { json.put("editable", "false"); } list.put(json); } catch (Exception e) { log.error(ExceptionUtil.getStackTrace(e)); } } } } catch (IOException ex) { log.error(ExceptionUtil.getStackTrace(ex)); throw new IllegalAccessException("Unable to access user view."); } } return list; }
From source file:gov.nih.nci.caarray.application.file.FileManagementServiceBean.java
/** * {@inheritDoc}/*from w w w . j a va 2s .c o m*/ */ @Override @TransactionAttribute(TransactionAttributeType.REQUIRED) public void reimportAndParseArrayDesign(Long arrayDesignId) throws InvalidDataFileException, IllegalAccessException { ArrayDesign arrayDesign = this.searchDao.retrieve(ArrayDesign.class, arrayDesignId); if (!arrayDesign.isUnparsedAndReimportable()) { throw new IllegalAccessException("This array design is not eligible for reimport"); } final ArrayDesignService ads = ServiceLocatorFactory.getArrayDesignService(); arrayDesign.getDesignFileSet().updateStatus(FileStatus.VALIDATING); try { arrayDesign = ads.saveArrayDesign(arrayDesign); ads.importDesign(arrayDesign); checkDesignFiles(arrayDesign.getDesignFileSet()); } catch (final InvalidDataFileException e) { arrayDesign.getDesignFileSet().updateStatus(FileStatus.IMPORT_FAILED); throw e; } catch (final IllegalAccessException e) { arrayDesign.getDesignFileSet().updateStatus(FileStatus.IMPORT_FAILED); throw e; } catch (final Exception e) { arrayDesign.getDesignFileSet().updateStatus(FileStatus.IMPORT_FAILED); throw new UnhandledException(e); } importArrayDesignDetails(arrayDesign); }
From source file:org.xmlactions.mapping.xml_to_bean.PopulateClassFromXml.java
private void setProperty(Object object, String propertyName, Object value, String fieldName, XMLObject xo) throws InvocationTargetException, NoSuchMethodException, NoSuchFieldException, IllegalAccessException { PropertyDescriptor pd = null; try {//ww w . j a v a 2 s . co m pd = findPropertyDescriptor(object, fieldName); if (pd != null) { BeanUtils.setProperty(object, fieldName, value); } else { Class<?> c = object.getClass(); Field field = c.getDeclaredField(fieldName); ConvertUtilsBean cub = new ConvertUtilsBean(); Object converted = cub.convert(value, field.getType()); field.set(object, converted); } } catch (ConversionException ex) { if (ignoreErrorWithEmptyValues == true && (value == null || ("" + value).length() == 0)) { // carry on processing, ignore because we have an empty value } else { throw new ConversionException("Unable to set property [" + propertyName + "] on bean [" + object.getClass().getName() + "] with value of [" + value + "] error:" + ex.getMessage(), ex); } } catch (NoSuchFieldException ex) { if (strict == true) { throw ex; } else { // log.warn(object.getClass().getName() + // " has no such field [" + propertyName + "]:" + // ex.getMessage()); } } catch (IllegalAccessException ex) { throw new IllegalAccessException("Unable to set property [" + propertyName + "] on bean [" + object.getClass().getName() + "] with value of [" + value + "] error:" + ex.getMessage()); } catch (IllegalArgumentException ex) { if (pd != null) { try { // try and match up a populator. Class<?> obj = pd.getPropertyType(); log.debug("obj:" + obj); if (obj != null) { if (List.class.getName().equals(obj.getName())) { useAction(PopulatorArrayList.class.getName(), null, object, fieldName, value, xo); } } } catch (Exception ex_ignore) { // ignore this, we'll throw the original exception throw ex; } } else { throw ex; } } }