List of usage examples for java.lang IllegalAccessException getMessage
public String getMessage()
From source file:org.jaffa.soa.dataaccess.TransformerUtils.java
/** * Same as printGraph(Object source), except the objectStack lists all the parent * objects its printed, and if this is one of them, it stops. This allows detection * of possible infinite recusion./*from w w w. j a v a 2 s. c om*/ * * @param source Javabean who's contents should be printed * @param objectStack List of objects already traversed * @return multi-line string of this beans properties and their values */ public static String printGraph(Object source, List objectStack) { if (source == null) return null; // Prevent infinite object recursion if (objectStack != null) if (objectStack.contains(source)) return "Object Already Used. " + source.getClass().getName() + '@' + source.hashCode(); else objectStack.add(source); else { objectStack = new ArrayList(); objectStack.add(source); } StringBuffer out = new StringBuffer(); out.append(source.getClass().getName()); out.append("\n"); try { BeanInfo sInfo = Introspector.getBeanInfo(source.getClass()); PropertyDescriptor[] sDescriptors = sInfo.getPropertyDescriptors(); if (sDescriptors != null && sDescriptors.length != 0) for (int i = 0; i < sDescriptors.length; i++) { PropertyDescriptor sDesc = sDescriptors[i]; Method sm = sDesc.getReadMethod(); if (sm != null && sDesc.getWriteMethod() != null) { if (!sm.isAccessible()) sm.setAccessible(true); Object sValue = sm.invoke(source, (Object[]) null); out.append(" "); out.append(sDesc.getName()); if (source instanceof GraphDataObject) { if (((GraphDataObject) source).hasChanged(sDesc.getName())) out.append('*'); } out.append('='); if (sValue == null) out.append("<--NULL-->\n"); else if (sm.getReturnType().isArray() && !sm.getReturnType().getComponentType().isPrimitive()) { StringBuffer out2 = new StringBuffer(); out2.append("Array of "); out2.append(sm.getReturnType().getComponentType().getName()); out2.append("\n"); // Loop through array Object[] a = (Object[]) sValue; for (int j = 0; j < a.length; j++) { out2.append('['); out2.append(j); out2.append("] "); if (a[j] == null) out2.append("<--NULL-->"); else if (GraphDataObject.class.isAssignableFrom(a[j].getClass())) out2.append(((GraphDataObject) a[j]).toString(objectStack)); else //out2.append(StringHelper.linePad(a[j].toString(), 4, " ",true)); out2.append(a[j].toString()); } out.append(StringHelper.linePad(out2.toString(), 4, " ", true)); } else { if (GraphDataObject.class.isAssignableFrom(sValue.getClass())) out.append(StringHelper.linePad(((GraphDataObject) sValue).toString(objectStack), 4, " ", true)); else { out.append(StringHelper.linePad(sValue.toString(), 4, " ", true)); out.append("\n"); } } } } } catch (IllegalAccessException e) { TransformException me = new TransformException(TransformException.ACCESS_ERROR, "???", e.getMessage()); log.error(me.getLocalizedMessage(), e); //throw me; } catch (InvocationTargetException e) { TransformException me = new TransformException(TransformException.INVOCATION_ERROR, "???", e); log.error(me.getLocalizedMessage(), me.getCause()); //throw me; } catch (IntrospectionException e) { TransformException me = new TransformException(TransformException.INTROSPECT_ERROR, "???", e.getMessage()); log.error(me.getLocalizedMessage(), e); //throw me; } return out.toString(); }
From source file:com.sm.query.ObjectQueryVisitorImpl.java
/** * treat String as non primitive/*w ww . ja va2 s . c o m*/ * @param from * @param list * @return target object let populate only in field list */ private void trim(Object from, List<String> list, String prefix) { ClassInfo classInfo = findClassInfo(from, classInfoMap); for (FieldInfo each : classInfo.getFieldInfos()) { int rs = inList(prefix + each.getField().getName(), list); if (rs == 0) { //no match and not primitive if (!QueryUtils.isPrimitive(each.getType())) { try { each.getField().set(from, null); } catch (IllegalAccessException e) { //swallow exception logger.error(e.getMessage()); } } } else if (rs == 2) { //match but it is object with field try { Object obj = each.getField().get(from); if (obj != null) { //it is object that has field in the list //with prefix of simple name +"." trim(obj, list, obj.getClass().getSimpleName() + "."); } } catch (IllegalAccessException e) { //swallow exception logger.error(e.getMessage()); } } else if (rs == 1) ; // match do nothing else { logger.warn("wrong inList " + rs + " for " + each.getField().getName()); } } }
From source file:org.acegisecurity.acl.basic.jdbc.JdbcDaoImpl.java
/** * Constructs an individual <code>BasicAclEntry</code> from the passed <code>AclDetailsHolder</code>s.<P>Guarantees * to never return <code>null</code> (exceptions are thrown in the event of any issues).</p> * * @param propertiesInformation mandatory information about which instance to create, the object identity, and the * parent object identity (<code>null</code> or empty <code>String</code>s prohibited for * <code>aclClass</code> and <code>aclObjectIdentity</code> * @param aclInformation optional information about the individual ACL record (if <code>null</code> only an * "inheritence marker" instance is returned which will include a recipient of {@link * #RECIPIENT_USED_FOR_INHERITENCE_MARKER} ; if not <code>null</code>, it is prohibited to present * <code>null</code> or an empty <code>String</code> for <code>recipient</code>) * * @return a fully populated instance suitable for use by external objects * * @throws IllegalArgumentException if the indicated ACL class could not be created *//*from www.j a va 2 s. com*/ private BasicAclEntry createBasicAclEntry(AclDetailsHolder propertiesInformation, AclDetailsHolder aclInformation) { BasicAclEntry entry; try { entry = (BasicAclEntry) propertiesInformation.getAclClass().newInstance(); } catch (InstantiationException ie) { throw new IllegalArgumentException(ie.getMessage()); } catch (IllegalAccessException iae) { throw new IllegalArgumentException(iae.getMessage()); } entry.setAclObjectIdentity(propertiesInformation.getAclObjectIdentity()); entry.setAclObjectParentIdentity(propertiesInformation.getAclObjectParentIdentity()); if (aclInformation == null) { // this is an inheritence marker instance only entry.setMask(0); entry.setRecipient(RECIPIENT_USED_FOR_INHERITENCE_MARKER); } else { // this is an individual ACL entry entry.setMask(aclInformation.getMask()); entry.setRecipient(aclInformation.getRecipient()); } return entry; }
From source file:com.cws.esolutions.security.config.xml.SecurityConfigurationData.java
@Override public final String toString() { final String methodName = SecurityConfigurationData.CNAME + "#toString()"; if (DEBUG) {/*from w w w .j a v a 2 s. c o m*/ DEBUGGER.debug(methodName); } StringBuilder sBuilder = new StringBuilder().append("[" + this.getClass().getName() + "]" + SecurityServiceConstants.LINE_BREAK + "{" + SecurityServiceConstants.LINE_BREAK); for (Field field : this.getClass().getDeclaredFields()) { if (DEBUG) { DEBUGGER.debug("field: {}", field); } if (!(field.getName().equals("methodName")) && (!(field.getName().equals("CNAME"))) && (!(field.getName().equals("DEBUGGER"))) && (!(field.getName().equals("DEBUG"))) && (!(field.getName().equals("ERROR_RECORDER"))) && (!(field.getName().equals("serialVersionUID")))) { try { if (field.get(this) != null) { sBuilder.append("\t" + field.getName() + " --> " + field.get(this) + SecurityServiceConstants.LINE_BREAK); } } catch (IllegalAccessException iax) { ERROR_RECORDER.error(iax.getMessage(), iax); } } } sBuilder.append('}'); if (DEBUG) { DEBUGGER.debug("sBuilder: {}", sBuilder); } return sBuilder.toString(); }
From source file:com.square.tarificateur.noyau.util.comparaison.famille.ComparaisonFamilleUtil.java
/** * Compare les champs des 2 objets passs en paramtres. * @param objetDto le DTO de l'objet//w w w. j av a 2 s . co m * @param objetModel le modle de l'objet * @return true si les objets sont identiques, false sinon */ @SuppressWarnings("unchecked") private boolean isObjetsIdentiques(Object objetDto, Object objetModel, List<String> listeProprietesAComparer) { // Si les 2 objets sont vides ==> identiques if (objetDto == null && objetModel == null) { return true; } // Si un objet est vide et l'autre pas ==> diffrents else if ((objetDto == null && objetModel != null) || (objetDto != null && objetModel == null)) { logger.debug(messageSourceUtil.get(MessageKeyUtil.LOGGER_DEBUG_OBJET_DIFFERENTS)); return false; } // Rcupration des proprits des objets Map<String, String> mapProprietesObjetDto = null; Map<String, String> mapProprietesObjetModele = null; try { mapProprietesObjetDto = BeanUtils.describe(objetDto); mapProprietesObjetModele = BeanUtils.describe(objetModel); } catch (IllegalAccessException e) { logger.error(messageSourceUtil.get(MessageKeyUtil.LOGGER_ERROR_WHILE_OBJECT_PROPERTY_RECUPERATION, new String[] { e.getMessage() })); throw new TechnicalException(messageSourceUtil.get(MessageKeyUtil.ERROR_COMPARAISON_FAMILLES)); } catch (InvocationTargetException e) { logger.error(messageSourceUtil.get(MessageKeyUtil.LOGGER_ERROR_WHILE_OBJECT_PROPERTY_RECUPERATION, new String[] { e.getMessage() })); throw new TechnicalException(messageSourceUtil.get(MessageKeyUtil.ERROR_COMPARAISON_FAMILLES)); } catch (NoSuchMethodException e) { logger.error(messageSourceUtil.get(MessageKeyUtil.LOGGER_ERROR_WHILE_OBJECT_PROPERTY_RECUPERATION, new String[] { e.getMessage() })); throw new TechnicalException(messageSourceUtil.get(MessageKeyUtil.ERROR_COMPARAISON_FAMILLES)); } // Parcours des proprits comparer for (String nomPropriete : listeProprietesAComparer) { // Vrification que la proprit est prsente dans le DTO if (!mapProprietesObjetDto.containsKey(nomPropriete)) { logger.warn(messageSourceUtil.get(MessageKeyUtil.LOGGER_WARN_PROPERTY_MISSING_DTO, new String[] { nomPropriete })); } // Vrification que la proprit est prsente dans le MODEL if (!mapProprietesObjetModele.containsKey(nomPropriete)) { logger.warn(messageSourceUtil.get(MessageKeyUtil.LOGGER_WARN_PROPERTY_MISSING_MODEL, new String[] { nomPropriete })); } // Rcupration de la valeur du DTO et du modle final String valeurProprieteObjetDto = mapProprietesObjetDto.get(nomPropriete); final String valeurProprieteObjetModele = mapProprietesObjetModele.get(nomPropriete); // Comparaison des valeurs if (valeurProprieteObjetDto != null && valeurProprieteObjetModele != null && !valeurProprieteObjetDto.equalsIgnoreCase(valeurProprieteObjetModele)) { logger.debug(messageSourceUtil.get(MessageKeyUtil.LOGGER_DEBUG_PROPERTY_DIFFERE_DTO_MODEL, new String[] { nomPropriete, valeurProprieteObjetDto, valeurProprieteObjetModele })); return false; } else if ((valeurProprieteObjetDto != null && !"".equals(valeurProprieteObjetDto) && valeurProprieteObjetModele == null) || (valeurProprieteObjetDto == null && valeurProprieteObjetModele != null && !"".equals(valeurProprieteObjetModele))) { logger.debug(messageSourceUtil.get(MessageKeyUtil.LOGGER_DEBUG_PROPERTY_DIFFERE_DTO_MODEL_NULL, new String[] { nomPropriete, valeurProprieteObjetDto, valeurProprieteObjetModele })); return false; } } return true; }
From source file:org.kuali.rice.krad.util.ObjectUtils.java
/** * Returns the value of the property in the object. * * @param businessObject/*w ww.j a v a 2 s.c om*/ * @param propertyName * @return Object will be null if any parent property for the given property is null. * * @deprecated use {@link org.kuali.rice.krad.data.DataObjectWrapper#getPropertyValueNullSafe(String)} instead */ @Deprecated public static Object getPropertyValue(Object businessObject, String propertyName) { if (businessObject == null || propertyName == null) { throw new RuntimeException("Business object and property name can not be null"); } Object propertyValue = null; try { propertyValue = PropertyUtils.getProperty(businessObject, propertyName); } catch (NestedNullException e) { // continue and return null for propertyValue } catch (IllegalAccessException e1) { LOG.error("error getting property value for " + businessObject.getClass() + "." + propertyName + " " + e1.getMessage()); throw new RuntimeException("error getting property value for " + businessObject.getClass() + "." + propertyName + " " + e1.getMessage(), e1); } catch (InvocationTargetException e1) { // continue and return null for propertyValue } catch (NoSuchMethodException e1) { LOG.error("error getting property value for " + businessObject.getClass() + "." + propertyName + " " + e1.getMessage()); throw new RuntimeException("error getting property value for " + businessObject.getClass() + "." + propertyName + " " + e1.getMessage(), e1); } return propertyValue; }
From source file:edu.wustl.bulkoperator.processor.AbstractBulkOperationProcessor.java
protected void setValueToObject(Object mainObj, BulkOperationClass mainMigrationClass, CsvReader csvReader, String columnSuffix, boolean validate, Attribute attribute) throws BulkOperationException { String csvDataValue = null;/*from w w w . j a va2 s . c om*/ if (csvReader.getColumn(attribute.getCsvColumnName() + columnSuffix) != null) { csvDataValue = csvReader.getColumn(attribute.getCsvColumnName() + columnSuffix); } if (Validator.isEmpty(csvDataValue) && attribute.getDefaultValue() != null) { csvDataValue = attribute.getDefaultValue(); } if (!Validator.isEmpty(csvDataValue)) { try { if (attribute.getFormat() != null) { DateValue value = new DateValue(csvDataValue, attribute.getFormat()); BeanUtils.copyProperty(mainObj, attribute.getName(), value); } else { BeanUtils.copyProperty(mainObj, attribute.getName(), csvDataValue); } } catch (IllegalAccessException exp) { logger.error(exp.getMessage(), exp); ErrorKey errorkey = ErrorKey.getErrorKey("bulk.operation.issues"); throw new BulkOperationException(errorkey, exp, exp.getMessage()); } catch (InvocationTargetException exp) { logger.error(exp.getMessage(), exp); ErrorKey errorkey = ErrorKey.getErrorKey("bulk.operation.issues"); throw new BulkOperationException(errorkey, exp, exp.getMessage()); } } }
From source file:jerry.c2c.action.UploadProductAction.java
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { String target = "result"; String resultPageTitle = "error"; String msgTitle = "error"; String msgContent = "error"; NewProductForm productForm = (NewProductForm) form; HttpSession session = request.getSession(); Item item = new Item(); try {//from w w w. j a va 2s. c o m BeanUtils.copyProperties(item, productForm); item.setCreateTime(DateTimeUtil.getCurrentTimestamp()); Timestamp createTime = DateTimeUtil.getCurrentTimestamp(); Calendar calendar = Calendar.getInstance(); calendar.add(Calendar.DAY_OF_YEAR, productForm.getDays()); Timestamp endTime = new Timestamp(calendar.getTimeInMillis()); item.setBelongTo((Shop) session.getAttribute("user_shop")); item.setCreateTime(createTime); item.setEndTime(endTime); Category category = categoryService.getById(productForm.getCategoryId()); item.setCategory(category); itemService.save(item); this.handleUploadImage(productForm.getImageFile(), item.getBelongTo().getName(), item.getId()); resultPageTitle = "??"; msgTitle = "??"; msgContent = "?(" + item.getName() + ")?"; } catch (IllegalAccessException e) { itemService.delete(item); resultPageTitle = "?"; msgTitle = "?"; msgContent = "?,?:" + e.getMessage(); } catch (InvocationTargetException e) { itemService.delete(item); resultPageTitle = "?"; msgTitle = "?"; msgContent = "?,?:" + e.getMessage(); } catch (IOException e) { itemService.delete(item); e.printStackTrace(); resultPageTitle = "?"; msgTitle = "?"; msgContent = "?,?:" + e.getMessage(); } catch (BusinessException e) { itemService.delete(item); e.printStackTrace(); resultPageTitle = "?"; msgTitle = "?"; msgContent = "?,?:" + e.getMessage(); } finally { request.setAttribute("title", resultPageTitle); request.setAttribute("message_title", msgTitle); request.setAttribute("message_content", msgContent); } return mapping.findForward(target); }
From source file:au.org.theark.lims.web.component.barcodelabel.form.DetailForm.java
@Override protected void onSave(Form<BarcodeLabel> containerForm, AjaxRequestTarget target) { if (barcodePrinterName == null) { this.error("Barcode Printer is required"); } else {/* w ww . jav a 2s .c o m*/ containerForm.getModelObject().setBarcodePrinterName(barcodePrinterName.toString()); if (isNew()) { if (barcodeLabelTemplateDdc.getModelObject() != null) { List<BarcodeLabelData> cloneBarcodeLabelDataList = iLimsAdminService .getBarcodeLabelDataByBarcodeLabel(barcodeLabelTemplateDdc.getModelObject()); List<BarcodeLabelData> barcodeLabelDataList = new ArrayList<BarcodeLabelData>(0); for (Iterator<BarcodeLabelData> iterator = cloneBarcodeLabelDataList.iterator(); iterator .hasNext();) { BarcodeLabelData clonebarcodeLabelData = (BarcodeLabelData) iterator.next(); BarcodeLabelData barcodeLabelData = new BarcodeLabelData(); // Copy parent details to new barcodeLabelData try { PropertyUtils.copyProperties(barcodeLabelData, clonebarcodeLabelData); } catch (IllegalAccessException e) { log.error(e.getMessage()); } catch (InvocationTargetException e) { log.error(e.getMessage()); } catch (NoSuchMethodException e) { log.error(e.getMessage()); } barcodeLabelData.setId(null); barcodeLabelDataList.add(barcodeLabelData); } containerForm.getModelObject().setBarcodeLabelData(barcodeLabelDataList); } try { iLimsAdminService.createBarcodeLabel(containerForm.getModelObject()); this.info("Barcode label: " + containerForm.getModelObject().getName() + " was created successfully."); } catch (ConstraintViolationException e) { e.printStackTrace(); this.error("A Barcode Label named \"" + containerForm.getModelObject().getName() + "\" already exists for this study."); } } else { iLimsAdminService.updateBarcodeLabel(containerForm.getModelObject()); this.info("Barcode label: " + containerForm.getModelObject().getName() + " was updated successfully."); } } target.add(feedBackPanel); onSavePostProcess(target); }
From source file:com.netflix.spinnaker.halyard.deploy.spinnaker.v1.profile.SpinnakerProfile.java
/** * @param node is the node to find required files in. * @return the list of files required by the node to function. *//* ww w . java 2 s.c o m*/ List<String> processRequiredFiles(Node node) { List<String> files = new ArrayList<>(); Consumer<Node> fileFinder = n -> files.addAll(n.localFiles().stream().map(f -> { try { f.setAccessible(true); String fPath = (String) f.get(n); if (fPath == null) { return null; } File fFile = new File(fPath); String fName = fFile.getName(); // Hash the path to uniquely flatten all files into the output directory Path newName = Paths.get(spinnakerOutputDependencyPath, Math.abs(fPath.hashCode()) + "-" + fName); File parent = newName.toFile().getParentFile(); if (!parent.exists()) { parent.mkdirs(); } else if (fFile.getParent().equals(parent.toString())) { // Don't move paths that are already in the right folder return fPath; } Files.copy(Paths.get(fPath), newName, REPLACE_EXISTING); f.set(n, newName.toString()); return newName.toString(); } catch (IllegalAccessException e) { throw new RuntimeException("Failed to get local files for node " + n.getNodeName(), e); } catch (IOException e) { throw new HalException( new ProblemBuilder(FATAL, "Failed to backup user file: " + e.getMessage()).build()); } finally { f.setAccessible(false); } }).filter(Objects::nonNull).collect(Collectors.toList())); node.recursiveConsume(fileFinder); return files; }