List of usage examples for java.lang IllegalAccessException IllegalAccessException
public IllegalAccessException(String s)
IllegalAccessException
with a detail message. From source file:Formulario.CapturaHuella.java
public final void addFile(String ftpPath, String filePath, String fileName) throws IllegalAccessException, IOException, SftpException, JSchException { if (this.session != null && this.session.isConnected()) { // Abrimos un canal SFTP. Es como abrir una consola. ChannelSftp channelSftp = (ChannelSftp) this.session.openChannel("sftp"); // Nos ubicamos en el directorio del FTP. channelSftp.cd(ftpPath);/*www .j ava2 s .co m*/ channelSftp.connect(); System.out.println(String.format("Creando archivo %s en el " + "directorio %s", fileName, ftpPath)); channelSftp.put(filePath, fileName); System.out.println("Archivo subido exitosamente"); channelSftp.exit(); channelSftp.disconnect(); } else { throw new IllegalAccessException("No existe sesion SFTP iniciada."); } }
From source file:org.broadleafcommerce.openadmin.server.service.persistence.module.provider.RuleFieldPersistenceProvider.java
protected Class<?> getStartingValueType(PopulateValueRequest populateValueRequest) throws ClassNotFoundException, IllegalAccessException { Class<?> startingValueType = null; if (!populateValueRequest.getProperty().getName().contains(FieldManager.MAPFIELDSEPARATOR)) { startingValueType = populateValueRequest.getReturnType(); } else {//from ww w . ja va 2 s . c o m String valueClassName = populateValueRequest.getMetadata().getMapFieldValueClass(); if (valueClassName != null) { startingValueType = Class.forName(valueClassName); } if (startingValueType == null) { startingValueType = populateValueRequest.getReturnType(); } } if (startingValueType == null) { throw new IllegalAccessException("Unable to determine the valueType for the rule field (" + populateValueRequest.getProperty().getName() + ")"); } return startingValueType; }
From source file:org.jgentleframework.utils.ReflectUtils.java
/** * Invokes the given <code>method</code> basing on the given * <code>target object</code>. * //from ww w . ja v a 2 s . com * @param obj * the target object * @param methodName * the method name * @param paramTypes * the parameter types array * @param args * the arguments used for the method call * @param superBool * nu l <b>true</b> s truy tm phng thc trn * <code>Object Class</code> v c <code>SuperClass</code> ca * <code>object</code> ch nh tng ng , ngc li nu l * <b>false</b> s ch truy vn trn <code>Object Class</code> * ch nh. * @param noThrows * nu l <b>true</b> s khng nm ra <code>exception</code> nu * nh gp li trong lc thi hnh, ngc li nu l <b>false</b> * s nm ra ngoi l nu gp li trong lc thi hnh. Lu rng * tham s <code>noThrows</code> ch c hiu lc trn cc tin * trnh <code>reflect</code> lc <code>invoke method</code>, nu * bn thn <code>method</code> c <code>invoked</code> nm ra * <code>exception</code> th c ch nh t?ng minh * <code>noThrows</code> hay khng ?u khng c tc dng. * @return tr v? <code>Object</code> tr v? sau khi invoke method, nu * <code>method</code> cn triu g?i khng <code>return</code> th * kt qu tr v? s l <b>NULL</b>. * @throws NoSuchMethodException * the no such method exception * @throws IllegalAccessException * the illegal access exception * @throws InvocationTargetException * the invocation target exception * @throws IllegalArgumentException */ public static Object invokeMethod(Object obj, String methodName, Class<?>[] paramTypes, Object[] args, boolean superBool, boolean noThrows) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { Class<?> clazz = null; if (ReflectUtils.isAnnotation(obj)) { clazz = ((Annotation) obj).annotationType(); } clazz = obj.getClass(); /* * Kim tra thng tin hp l ca parameters */ if (paramTypes != null && args != null) { if (paramTypes.length != args.length) { throw new IllegalArgumentException("Parameter is invalid ! "); } } try { if (superBool == true) { Method method = ReflectUtils.getSupportedMethod(clazz, methodName, paramTypes); method.setAccessible(true); return method.invoke(obj, args); } else { return clazz.getDeclaredMethod(methodName, paramTypes).invoke(obj, args); } } catch (NoSuchMethodException ex) { if (noThrows == false) { throw new NoSuchMethodException(clazz.getName() + " does not support method " + methodName); } } catch (IllegalAccessException ex) { if (noThrows == false) { throw new IllegalAccessException( "Insufficient access permissions to call" + methodName + " in class " + clazz.getName()); } } catch (InvocationTargetException ex) { throw ex; } return null; }
From source file:gov.osti.services.Metadata.java
/** * Persist the DOECodeMetadata Object to the persistence layer. Assumes an * open Transaction is already in progress, and it's up to the caller to * handle Exceptions or commit as appropriate. * * If the "code ID" is already present in the Object to store, it will * attempt to merge changes; otherwise, a new Object will be instantiated * in the database. Note that any WORKFLOW STATUS present will be preserved, * regardless of the incoming one.//from w w w. j a v a 2 s . c o m * * @param em the EntityManager to interface with the persistence layer * @param md the Object to store * @param user the User performing this action (must be the OWNER of the * record in order to UPDATE) * @throws NotFoundException when record to update is not on file * @throws IllegalAccessException when attempting to update record not * owned by User * @throws InvocationTargetException on reflection errors */ private void store(EntityManager em, DOECodeMetadata md, User user) throws NotFoundException, IllegalAccessException, InvocationTargetException { // fix the open source value before storing md.setOpenSource( Accessibility.OS.equals(md.getAccessibility()) || Accessibility.ON.equals(md.getAccessibility())); ValidatorFactory validators = javax.validation.Validation.buildDefaultValidatorFactory(); Validator validator = validators.getValidator(); // must be OSTI user in order to add/update PROJECT KEYWORDS List<String> projectKeywords = md.getProjectKeywords(); if (projectKeywords != null && !projectKeywords.isEmpty() && !user.hasRole("OSTI")) throw new ValidationException("Project Keywords can only be set by authorized users."); // if there's a CODE ID, attempt to look up the record first and // copy attributes into it if (null == md.getCodeId() || 0 == md.getCodeId()) { // perform length validations on Bean Set<ConstraintViolation<DOECodeMetadata>> violations = validator.validate(md); if (!violations.isEmpty()) { List<String> reasons = new ArrayList<>(); violations.stream().forEach(violation -> { reasons.add(violation.getMessage()); }); throw new BadRequestException(ErrorResponse.badRequest(reasons).build()); } em.persist(md); } else { DOECodeMetadata emd = em.find(DOECodeMetadata.class, md.getCodeId()); if (null != emd) { // must be the OWNER, SITE ADMIN, or OSTI in order to UPDATE if (!user.getEmail().equals(emd.getOwner()) && !user.hasRole(emd.getSiteOwnershipCode()) && !user.hasRole("OSTI")) throw new IllegalAccessException("Invalid access attempt."); // to Save, item must be non-existant, or already in Saved workflow status (if here, we know it exists) if (Status.Saved.equals(md.getWorkflowStatus()) && !Status.Saved.equals(emd.getWorkflowStatus())) throw new BadRequestException(ErrorResponse .badRequest("Save cannot be performed after a record has been Submitted or Announced.") .build()); // these fields WILL NOT CHANGE on edit/update md.setOwner(emd.getOwner()); md.setSiteOwnershipCode(emd.getSiteOwnershipCode()); // if there's ALREADY a DOI, and we have been SUBMITTED/APPROVED, keep it if (StringUtils.isNotEmpty(emd.getDoi()) && (Status.Submitted.equals(emd.getWorkflowStatus()) || Status.Approved.equals(emd.getWorkflowStatus()))) md.setDoi(emd.getDoi()); // do not modify AutoBackfill RI info List<RelatedIdentifier> originalList = emd.getRelatedIdentifiers(); List<RelatedIdentifier> newList = md.getRelatedIdentifiers(); // if there is a New List and a non-empty Original List, then process RI info if (newList != null && originalList != null && !originalList.isEmpty()) { // get AutoBackfill data List<RelatedIdentifier> autoRIList = getSourceRi(originalList, RelatedIdentifier.Source.AutoBackfill); // restore any modified Auto data newList.removeAll(autoRIList); // always remove match newList.addAll(autoRIList); // add back, if needed md.setRelatedIdentifiers(newList); } // perform length validations on Bean Set<ConstraintViolation<DOECodeMetadata>> violations = validator.validate(md); if (!violations.isEmpty()) { List<String> reasons = new ArrayList<>(); violations.stream().forEach(violation -> { reasons.add(violation.getMessage()); }); throw new BadRequestException(ErrorResponse.badRequest(reasons).build()); } // found it, "merge" Bean attributes BeanUtilsBean noNulls = new NoNullsBeanUtilsBean(); noNulls.copyProperties(emd, md); // if the RELEASE DATE was set, it might have been "cleared" (set to null) // and thus ignored by the Bean copy; this sets the value regardless if setReleaseDate() got called if (md.hasSetReleaseDate()) emd.setReleaseDate(md.getReleaseDate()); // what comes back needs to be complete: noNulls.copyProperties(md, emd); // EntityManager should handle this attached Object // NOTE: the returned Object is NOT ATTACHED to the EntityManager } else { // can't find record to update, that's an error log.warn("Unable to locate record for " + md.getCodeId() + " to update."); throw new NotFoundException("Record Code ID " + md.getCodeId() + " not on file."); } } }
From source file:org.voltdb.iv2.LeaderAppointer.java
/** * Gets the initial cluster partition count on startup. This can only be called during * initialization. Calling this after initialization throws, because the partition count may * not reflect the actual partition count in the cluster. * * @return//from w w w.j a va 2 s.c o m */ private int getInitialPartitionCount() throws IllegalAccessException { AppointerState currentState = m_state.get(); if (currentState != AppointerState.INIT && currentState != AppointerState.CLUSTER_START) { throw new IllegalAccessException("Getting cached partition count after cluster " + "startup"); } return m_initialPartitionCount; }
From source file:org.springframework.beans.AbstractNestablePropertyAccessor.java
private Object newValue(Class<?> type, @Nullable TypeDescriptor desc, String name) { try {/*from w w w . j av a2 s . co m*/ if (type.isArray()) { Class<?> componentType = type.getComponentType(); // TODO - only handles 2-dimensional arrays if (componentType.isArray()) { Object array = Array.newInstance(componentType, 1); Array.set(array, 0, Array.newInstance(componentType.getComponentType(), 0)); return array; } else { return Array.newInstance(componentType, 0); } } else if (Collection.class.isAssignableFrom(type)) { TypeDescriptor elementDesc = (desc != null ? desc.getElementTypeDescriptor() : null); return CollectionFactory.createCollection(type, (elementDesc != null ? elementDesc.getType() : null), 16); } else if (Map.class.isAssignableFrom(type)) { TypeDescriptor keyDesc = (desc != null ? desc.getMapKeyTypeDescriptor() : null); return CollectionFactory.createMap(type, (keyDesc != null ? keyDesc.getType() : null), 16); } else { Constructor<?> ctor = type.getDeclaredConstructor(); if (Modifier.isPrivate(ctor.getModifiers())) { throw new IllegalAccessException("Auto-growing not allowed with private constructor: " + ctor); } return BeanUtils.instantiateClass(ctor); } } catch (Throwable ex) { throw new NullValueInNestedPathException(getRootClass(), this.nestedPath + name, "Could not instantiate property type [" + type.getName() + "] to auto-grow nested property path", ex); } }
From source file:ch.puzzle.itc.mobiliar.business.deploy.boundary.DeploymentBoundary.java
public String getDeploymentLog(String logName) throws IllegalAccessException { String logsPath = ConfigurationService.getProperty(ConfigKey.LOGS_PATH); if (logName.contains(File.separator)) { throw new IllegalAccessException("The log file contains a file separator (\"" + File.separator + "\"). For security reasons, this is not permitted!"); }/*from ww w . ja v a 2 s .c o m*/ StringBuilder content = new StringBuilder(); Scanner scanner; try { scanner = new Scanner(new FileInputStream(logsPath + File.separator + logName)); try { while (scanner.hasNextLine()) { content.append(scanner.nextLine()).append('\n'); } } finally { scanner.close(); } return content.toString(); } catch (FileNotFoundException e) { String message = "The file " + logsPath + File.separator + logName + " was found, but couldn't be read!"; log.log(Level.WARNING, message); throw new AMWRuntimeException(message, e); } }
From source file:com.fluidops.iwb.api.ReadDataManagerImpl.java
@Override public Query prepareQuery(String query, boolean resolveNamespaces, Value resolveValue, boolean infer) throws RepositoryException, MalformedQueryException, IllegalAccessException { QueryBuilder<? extends Operation> queryBuilder = QueryBuilder.create(query) .resolveNamespaces(resolveNamespaces).resolveValue(resolveValue).infer(infer); Operation q = queryBuilder.build(this); // we explicitly forbid anything that is not a Query (e.g. UPDATE) if (!(q instanceof Query)) throw new IllegalAccessException("Query type not allowed for external use: " + q.getClass().getName()); return (Query) q; }
From source file:org.wso2.carbon.bpel.core.ode.integration.mgt.services.InstanceManagementServiceSkeleton.java
/** * Check whether the instance belongs to the current tenant. If not, don't allow any operations. * * @param iid instance id// w w w .j a v a2 s. co m * @throws IllegalAccessException if instance doesn't belong to the current tenant * @throws ProcessingException if there a error getting instance data */ private void isOperationIsValidForTheCurrentTenant(final long iid) throws IllegalAccessException, ProcessingException { QName processId = getProcess(iid); TenantProcessStoreImpl processStore = getTenantProcessForCurrentSession(); if (!processStore.containsProcess(processId)) { log.error("Trying to invoke a illegal operation. Instance ID:" + iid); throw new IllegalAccessException("Operation is not permitted."); } }
From source file:org.wso2.carbon.bpel.core.ode.integration.mgt.services.InstanceManagementServiceSkeleton.java
/** * Check whether process belongs to the current tenant. If not, don't allow any operations. * * @param pid process id/* w ww . j a v a 2s. c o m*/ * @throws IllegalAccessException if process doesn't belong to the current tenant */ private void isOperationIsValidForTheCurrentTenant(final QName pid) throws IllegalAccessException { if (!getTenantProcessForCurrentSession().containsProcess(pid)) { log.error("Trying to invoke a illegal operation. Process ID:" + pid); throw new IllegalAccessException("Operation is not permitted."); } }