List of usage examples for java.lang IllegalAccessException IllegalAccessException
public IllegalAccessException()
IllegalAccessException
without a detail message. From source file:org.apache.archiva.rest.services.DefaultReportRepositoriesService.java
@Override public List<RepositoryProblemFacet> getHealthReport(String repository, String groupId, int rowCount) throws ArchivaRestServiceException { RepositorySession repositorySession = repositorySessionFactory.createSession(); try {//from ww w . ja v a2 s . co m List<String> observableRepositories = getObservableRepos(); if (!ALL_REPOSITORIES.equals(repository) && !observableRepositories.contains(repository)) { throw new ArchivaRestServiceException( "${$.i18n.prop('report.repository.illegal-access', " + repository + ")}", "repositoryId", new IllegalAccessException()); } if (!ALL_REPOSITORIES.equals(repository)) { observableRepositories = Collections.singletonList(repository); } List<RepositoryProblemFacet> problemArtifacts = new ArrayList<>(); MetadataRepository metadataRepository = repositorySession.getRepository(); for (String repoId : observableRepositories) { for (String name : metadataRepository.getMetadataFacets(repoId, RepositoryProblemFacet.FACET_ID)) { RepositoryProblemFacet metadataFacet = (RepositoryProblemFacet) metadataRepository .getMetadataFacet(repoId, RepositoryProblemFacet.FACET_ID, name); if (StringUtils.isEmpty(groupId) || groupId.equals(metadataFacet.getNamespace())) { problemArtifacts.add(metadataFacet); } } } return problemArtifacts; } catch (MetadataRepositoryException e) { throw new ArchivaRestServiceException(e.getMessage(), e); } finally { repositorySession.close(); } }
From source file:org.jtransfo.JTransfoImplTest.java
@Test public void testFindTargetIllegalAccessException() throws Exception { when(reflectionHelper.newInstance(SimpleClassDomain.class)).thenThrow(new IllegalAccessException()); exception.expect(JTransfoException.class); exception.expectMessage("Cannot create instance for domain class org.jtransfo.object.SimpleClassDomain."); jTransfo.findTarget(new SimpleClassNameTo(), SimpleClassDomain.class); }
From source file:org.seamless_if.services.servlets.SchedulerServlet.java
@SuppressWarnings("unchecked") private void handleRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // set-up some things for output as XML response.setContentType("text/xml"); XMLWriter writer = new XMLWriter(response.getOutputStream()); Element root = new DOMElement("scheduler"); Document document = DocumentHelper.createDocument(root); // parse arguments to figure out what to do String methodName = request.getParameter("method"); if (methodName == null) methodName = "info"; // invoke method based on reflection (names must match!) try {/*w ww.j a va 2 s . co m*/ if (ACCESSIBLE_METHODS.valueOf(methodName) == null) throw new IllegalAccessException(); Method method = this.getClass().getMethod(methodName, Element.class, HttpServletRequest.class); method.invoke(this, root, request); } catch (Exception e) { root.add(new DOMElement("error").addText(e.toString())); root.add(new DOMElement("method").addText(methodName)); Map<String, String[]> parameters = (Map<String, String[]>) request.getParameterMap(); for (Object key : parameters.keySet()) { Element param = new DOMElement("parameter").addAttribute("name", key.toString()); Element valuesNode = new DOMElement("values"); String[] values = parameters.get(key); for (String value : values) { valuesNode.add(new DOMElement("value").addText(value)); } param.add(valuesNode); root.add(param); } e.printStackTrace(); } // write the output try { writer.write(document); writer.close(); } catch (Exception ex) { throw new SeamException(ex, "Failed to create servlet xml output! Error: %s", ex.getMessage()); } }
From source file:org.logicblaze.lingo.jms.JmsRemotingTest.java
public void testJmsProxyFactoryBeanAndServiceExporterWithOneWays() throws Throwable { TestBean target = new TestBean("myname", 99); exporter = new JmsServiceExporter(); exporter.setServiceInterface(ITestBean.class); exporter.setService(target);/*w w w . j a va 2 s .c om*/ configure(exporter); subscribeToQueue(exporter, getDestinationName()); pfb = new JmsProxyFactoryBean(); pfb.setServiceInterface(ITestBean.class); pfb.setServiceUrl("http://myurl"); pfb.setRequestor(createRequestor(getDestinationName())); pfb.setRemoteInvocationFactory(new LingoRemoteInvocationFactory(new SimpleMetadataStrategy(true))); configure(pfb); ITestBean proxy = (ITestBean) pfb.getObject(); assertEquals("myname", proxy.getName()); assertEquals(99, proxy.getAge()); proxy.setAge(50); System.out.println("getting name: " + proxy.getName()); int age = proxy.getAge(); System.out.println("got age: " + age); assertEquals("myname", proxy.getName()); assertEquals(50, proxy.getAge()); try { proxy.exceptional(new IllegalStateException()); fail("Should have thrown IllegalStateException"); } catch (IllegalStateException ex) { // expected } try { proxy.exceptional(new IllegalAccessException()); fail("Should have thrown IllegalAccessException"); } catch (IllegalAccessException ex) { // expected } }
From source file:org.pentaho.platform.web.http.api.resources.services.SchedulerService.java
public Job createJob(JobScheduleRequest scheduleRequest) throws IOException, SchedulerException, IllegalAccessException { // Used to determine if created by a RunInBackgroundCommand boolean runInBackground = scheduleRequest.getSimpleJobTrigger() == null && scheduleRequest.getComplexJobTrigger() == null && scheduleRequest.getCronJobTrigger() == null; if (!runInBackground && !getPolicy().isAllowed(SchedulerAction.NAME)) { throw new SecurityException(); }/* www . j a v a 2s . c om*/ boolean hasInputFile = !StringUtils.isEmpty(scheduleRequest.getInputFile()); RepositoryFile file = null; if (hasInputFile) { try { file = getRepository().getFile(scheduleRequest.getInputFile()); } catch (UnifiedRepositoryException ure) { hasInputFile = false; logger.warn(ure.getMessage(), ure); } } // if we have an inputfile, generate job name based on that if the name is not passed in if (hasInputFile && StringUtils.isEmpty(scheduleRequest.getJobName())) { scheduleRequest.setJobName(file.getName().substring(0, file.getName().lastIndexOf("."))); //$NON-NLS-1$ } else if (!StringUtils.isEmpty(scheduleRequest.getActionClass())) { String actionClass = scheduleRequest.getActionClass() .substring(scheduleRequest.getActionClass().lastIndexOf(".") + 1); scheduleRequest.setJobName(actionClass); //$NON-NLS-1$ } else if (!hasInputFile && StringUtils.isEmpty(scheduleRequest.getJobName())) { // just make up a name scheduleRequest.setJobName("" + System.currentTimeMillis()); //$NON-NLS-1$ } if (hasInputFile) { Map<String, Serializable> metadata = getRepository().getFileMetadata(file.getId()); if (metadata.containsKey("_PERM_SCHEDULABLE")) { boolean schedulable = Boolean.parseBoolean((String) metadata.get("_PERM_SCHEDULABLE")); if (!schedulable) { throw new IllegalAccessException(); } } } Job job = null; IJobTrigger jobTrigger = SchedulerResourceUtil.convertScheduleRequestToJobTrigger(scheduleRequest, scheduler); HashMap<String, Serializable> parameterMap = new HashMap<String, Serializable>(); for (JobScheduleParam param : scheduleRequest.getJobParameters()) { parameterMap.put(param.getName(), param.getValue()); } if (isPdiFile(file)) { parameterMap = handlePDIScheduling(file, parameterMap); } parameterMap.put(LocaleHelper.USER_LOCALE_PARAM, LocaleHelper.getLocale()); if (hasInputFile) { SchedulerOutputPathResolver outputPathResolver = getSchedulerOutputPathResolver(scheduleRequest); String outputFile = outputPathResolver.resolveOutputFilePath(); String actionId = getExtension(scheduleRequest.getInputFile()) + ".backgroundExecution"; //$NON-NLS-1$ //$NON-NLS-2$ job = getScheduler().createJob(scheduleRequest.getJobName(), actionId, parameterMap, jobTrigger, new RepositoryFileStreamProvider(scheduleRequest.getInputFile(), outputFile, getAutoCreateUniqueFilename(scheduleRequest))); } else { // need to locate actions from plugins if done this way too (but for now, we're just on main) String actionClass = scheduleRequest.getActionClass(); try { @SuppressWarnings("unchecked") Class<IAction> iaction = getAction(actionClass); job = getScheduler().createJob(scheduleRequest.getJobName(), iaction, parameterMap, jobTrigger); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } } return job; }
From source file:com.liusoft.dlog4j.action.ActionBase.java
/** * ??// w ww.j a va 2 s . co m * @param req * @param form * @throws IllegalAccessException */ protected static void validateClientId(HttpServletRequest req, FormBean form) throws IllegalAccessException { if (!UserLoginManager.validateClientId(req, form.get__ClientId())) throw new IllegalAccessException(); }
From source file:org.jtransfo.internal.ConverterHelperTest.java
@Test public void testGetDeclaredTypeConverterIae() throws Exception { MappedBy mappedBy = mock(MappedBy.class); when(mappedBy.typeConverterClass()).thenReturn(MappedBy.DefaultTypeConverter.class); when(mappedBy.typeConverter()).thenReturn(NoConversionTypeConverter.class.getName()); when(mappedBy.field()).thenReturn(MappedBy.DEFAULT_FIELD); when(reflectionHelper.newInstance(NoConversionTypeConverter.class.getName())) .thenThrow(new IllegalAccessException()); exception.expect(JTransfoException.class); exception.expectMessage(/* w w w. j a va2s.c o m*/ "Declared TypeConverter class org.jtransfo.NoConversionTypeConverter cannot be accessed."); converterHelper.getDeclaredTypeConverter(mappedBy); }
From source file:org.wso2.carbon.bpel.core.ode.integration.store.repository.BPELPackageRepository.java
/** * At bpel package undeployment, remove the entires created in registry corresponding to the given BPEL package * @param packageName/* w w w. j av a2 s . c om*/ * @throws RegistryException */ public void handleBPELPackageUndeploy(String packageName) throws RegistryException { try { String packageLocation = BPELPackageRepositoryUtils.getResourcePathForBPELPackage(packageName); if (!configRegistry.getRegistryContext().isReadOnly() && configRegistry.resourceExists(packageLocation)) { configRegistry.delete(packageLocation); } else { throw new IllegalAccessException(); } } catch (RegistryException re) { String errMessage = "Unable to access registry for handling BPEL package " + "undeployment for Package: " + packageName; log.error(errMessage, re); throw re; } catch (IllegalAccessException e) { log.error("Trying to update a Read-only registry", e); } }
From source file:org.jgentleframework.utils.Utils.java
/** * Returns the specified default <code>getter</code> of the specified field. * //from ww w . j ava2s . c o m * @param declaringClass * the object class declared specified field. * @param fieldName * name of field * @return returns the <code>getter</code> method if it exists, if not, * return <code>null</code>. */ public static Method getDefaultGetter(Class<?> declaringClass, String fieldName) { Method getter = null; fieldName = fieldName.substring(0, 1).toUpperCase() + fieldName.substring(1); try { getter = ReflectUtils.getSupportedMethod(declaringClass, "get" + fieldName, null); } catch (NoSuchMethodException e) { try { getter = ReflectUtils.getSupportedMethod(declaringClass, "is" + fieldName, null); } catch (NoSuchMethodException e1) { return null; } } if (getter != null && !Modifier.isPublic(getter.getModifiers())) try { throw new IllegalAccessException(); } catch (IllegalAccessException e) { if (log.isErrorEnabled()) { log.error("The getter method [" + getter.getName() + "] declared in [" + declaringClass + "] must be public", e); } } return getter; }
From source file:org.jgentleframework.utils.Utils.java
/** * Returns the specified default <code>setter</code> of the specified field. * /*from ww w . ja va 2 s. com*/ * @param declaringClass * the object class declared specified field. * @param fieldName * name of field * @return returns the <code>setter</code> method if it exists, if not, * return <code>null</code>. */ public static Method getDefaultSetter(Class<?> declaringClass, String fieldName) { Method setter = null; Field field = null; String methodName = "set" + fieldName.substring(0, 1).toUpperCase() + fieldName.substring(1); try { field = ReflectUtils.getSupportedField(declaringClass, fieldName); setter = ReflectUtils.getSupportedMethod(declaringClass, methodName, new Class<?>[] { field.getType() }); } catch (NoSuchFieldException e1) { return null; } catch (NoSuchMethodException e) { return null; } try { if (setter != null && !Modifier.isPublic(setter.getModifiers())) throw new IllegalAccessException(); } catch (IllegalAccessException e) { if (log.isErrorEnabled()) { log.error("The setter method [" + methodName + "] declared in [" + declaringClass + "] must be public", e); } } return setter; }