List of usage examples for org.apache.commons.beanutils PropertyUtils isReadable
public static boolean isReadable(Object bean, String name)
Return true
if the specified property name identifies a readable property on the specified bean; otherwise, return false
.
For more details see PropertyUtilsBean
.
From source file:org.kuali.rice.kns.web.struts.form.KualiTableRenderFormMetadata.java
/** * Sorts a list on the form according to the form metadata (sortColumName, previouslySortedColumnName) * * @param memberTableMetadata//w w w . j a va 2s. c om * @param items * @param maxRowsPerPage * @throws org.kuali.rice.kew.api.exception.WorkflowException */ public void sort(List<?> items, int maxRowsPerPage) { // Don't bother to sort null, empty or singleton lists if (items == null || items.size() <= 1) return; String columnToSortOn = getColumnToSortName(); // Don't bother to sort if no column to sort on is provided if (StringUtils.isEmpty(columnToSortOn)) return; String previouslySortedColumnName = getPreviouslySortedColumnName(); // We know members isn't null or empty from the check above Object firstItem = items.get(0); // Need to decide if the comparator is for a bean property or a mapped key on the qualififer attribute set Comparator comparator = null; Comparator subComparator = new Comparator<Object>() { public int compare(Object o1, Object o2) { if (o1 == null) return -1; if (o2 == null) return 1; if (o1 instanceof java.util.Date && o2 instanceof java.util.Date) { Date d1 = (Date) o1; Date d2 = (Date) o2; return d1.compareTo(d2); } String s1 = o1.toString(); String s2 = o2.toString(); int n1 = s1.length(), n2 = s2.length(); for (int i1 = 0, i2 = 0; i1 < n1 && i2 < n2; i1++, i2++) { char c1 = s1.charAt(i1); char c2 = s2.charAt(i2); if (c1 != c2) { c1 = Character.toUpperCase(c1); c2 = Character.toUpperCase(c2); if (c1 != c2) { c1 = Character.toLowerCase(c1); c2 = Character.toLowerCase(c2); if (c1 != c2) { return c1 - c2; } } } } return n1 - n2; } }; // If the columnName is a readable bean property on the first member, then it's safe to say we need a simple bean property comparator, // otherwise it's a mapped property -- syntax for BeanComparator is "name" and "name(key)", respectively if (PropertyUtils.isReadable(firstItem, columnToSortOn)) comparator = new BeanComparator(columnToSortOn, subComparator); else comparator = new BeanComparator( new StringBuilder().append("qualifierAsMap(").append(columnToSortOn).append(")").toString(), subComparator); // If the user has decided to resort by the same column that the list is currently sorted by, then assume that s/he wants to reverse the order of the sort if (!StringUtils.isEmpty(columnToSortOn) && !StringUtils.isEmpty(previouslySortedColumnName) && columnToSortOn.equals(previouslySortedColumnName)) { // we're already sorted on the same column that the user clicked on, so we reverse the list if (isSortDescending()) comparator = Collections.reverseOrder(comparator); setSortDescending(!isSortDescending()); } else { // Track which column we're currently sorting, so that the above logic will work on the next sort setPreviouslySortedColumnName(columnToSortOn); setSortDescending(true); } //if the user is just going between pages no need to sort if (getSwitchToPageNumber() == getViewedPageNumber()) { Collections.sort(items, comparator); } jumpToFirstPage(items.size(), maxRowsPerPage); }
From source file:org.kuali.rice.krad.service.impl.KRADLegacyDataAdapterImpl.java
@Override public void setObjectPropertyDeep(Object bo, String propertyName, Class type, Object propertyValue) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { DataObjectWrapper<Object> dataObjectWrapper = dataObjectService.wrap(bo); // Base return cases to avoid null pointers & infinite loops if (KRADUtils.isNull(bo) || !PropertyUtils.isReadable(bo, propertyName) || (propertyValue != null//from ww w . j a va2 s . co m && propertyValue.equals(dataObjectWrapper.getPropertyValueNullSafe(propertyName))) || (type != null && !type.equals(KRADUtils.easyGetPropertyType(bo, propertyName)))) { return; } // Set the property in the BO KRADUtils.setObjectProperty(bo, propertyName, type, propertyValue); // Now drill down and check nested BOs and BO lists PropertyDescriptor[] propertyDescriptors = PropertyUtils.getPropertyDescriptors(bo.getClass()); for (int i = 0; i < propertyDescriptors.length; i++) { PropertyDescriptor propertyDescriptor = propertyDescriptors[i]; // Business Objects if (propertyDescriptor.getPropertyType() != null && (BusinessObject.class).isAssignableFrom(propertyDescriptor.getPropertyType()) && PropertyUtils.isReadable(bo, propertyDescriptor.getName())) { Object nestedBo = dataObjectWrapper.getPropertyValueNullSafe(propertyDescriptor.getName()); if (nestedBo instanceof BusinessObject) { setObjectPropertyDeep(nestedBo, propertyName, type, propertyValue); } } // Lists else if (propertyDescriptor.getPropertyType() != null && (List.class).isAssignableFrom(propertyDescriptor.getPropertyType()) && dataObjectWrapper.getPropertyValueNullSafe(propertyDescriptor.getName()) != null) { List propertyList = (List) dataObjectWrapper.getPropertyValueNullSafe(propertyDescriptor.getName()); for (Object listedBo : propertyList) { if (listedBo != null && listedBo instanceof BusinessObject) { setObjectPropertyDeep(listedBo, propertyName, type, propertyValue); } } // end for } } // end for }
From source file:org.kuali.rice.krad.util.ObjectUtils.java
/** * Recursive; sets all occurences of the property in the object, its nested objects and its object lists with the * given value.//w ww. j av a2 s . c o m * * @param bo * @param propertyName * @param type * @param propertyValue * @throws NoSuchMethodException * @throws InvocationTargetException * @throws IllegalAccessException */ public static void setObjectPropertyDeep(Object bo, String propertyName, Class type, Object propertyValue) throws FormatException, IllegalAccessException, InvocationTargetException, NoSuchMethodException { // Base return cases to avoid null pointers & infinite loops if (isNull(bo) || !PropertyUtils.isReadable(bo, propertyName) || (propertyValue != null && propertyValue.equals(getPropertyValue(bo, propertyName))) || (type != null && !type.equals(easyGetPropertyType(bo, propertyName)))) { return; } // need to materialize the updateable collections before resetting the property, because it may be used in the retrieval materializeUpdateableCollections(bo); // Set the property in the BO setObjectProperty(bo, propertyName, type, propertyValue); // Now drill down and check nested BOs and BO lists PropertyDescriptor[] propertyDescriptors = PropertyUtils.getPropertyDescriptors(bo.getClass()); for (int i = 0; i < propertyDescriptors.length; i++) { PropertyDescriptor propertyDescriptor = propertyDescriptors[i]; // Business Objects if (propertyDescriptor.getPropertyType() != null && (BusinessObject.class).isAssignableFrom(propertyDescriptor.getPropertyType()) && PropertyUtils.isReadable(bo, propertyDescriptor.getName())) { Object nestedBo = getPropertyValue(bo, propertyDescriptor.getName()); if (nestedBo instanceof BusinessObject) { setObjectPropertyDeep(nestedBo, propertyName, type, propertyValue); } } // Lists else if (propertyDescriptor.getPropertyType() != null && (List.class).isAssignableFrom(propertyDescriptor.getPropertyType()) && getPropertyValue(bo, propertyDescriptor.getName()) != null) { List propertyList = (List) getPropertyValue(bo, propertyDescriptor.getName()); for (Object listedBo : propertyList) { if (listedBo != null && listedBo instanceof BusinessObject) { setObjectPropertyDeep(listedBo, propertyName, type, propertyValue); } } // end for } } // end for }
From source file:org.kuali.rice.krad.util.ObjectUtils.java
public static void setObjectPropertyDeep(Object bo, String propertyName, Class type, Object propertyValue, int depth) throws FormatException, IllegalAccessException, InvocationTargetException, NoSuchMethodException { // Base return cases to avoid null pointers & infinite loops if (depth == 0 || isNull(bo) || !PropertyUtils.isReadable(bo, propertyName)) { return;/*from ww w. j av a2 s .c o m*/ } // need to materialize the updateable collections before resetting the property, because it may be used in the retrieval try { materializeUpdateableCollections(bo); } catch (ClassNotPersistableException ex) { //Not all classes will be persistable in a collection. For e.g. externalizable business objects. LOG.info("Not persistable dataObjectClass: " + bo.getClass().getName() + ", field: " + propertyName); } // Set the property in the BO setObjectProperty(bo, propertyName, type, propertyValue); // Now drill down and check nested BOs and BO lists PropertyDescriptor[] propertyDescriptors = PropertyUtils.getPropertyDescriptors(bo.getClass()); for (int i = 0; i < propertyDescriptors.length; i++) { PropertyDescriptor propertyDescriptor = propertyDescriptors[i]; // Business Objects if (propertyDescriptor.getPropertyType() != null && (BusinessObject.class).isAssignableFrom(propertyDescriptor.getPropertyType()) && PropertyUtils.isReadable(bo, propertyDescriptor.getName())) { Object nestedBo = getPropertyValue(bo, propertyDescriptor.getName()); if (nestedBo instanceof BusinessObject) { setObjectPropertyDeep(nestedBo, propertyName, type, propertyValue, depth - 1); } } // Lists else if (propertyDescriptor.getPropertyType() != null && (List.class).isAssignableFrom(propertyDescriptor.getPropertyType()) && getPropertyValue(bo, propertyDescriptor.getName()) != null) { List propertyList = (List) getPropertyValue(bo, propertyDescriptor.getName()); // Complete Hibernate Hack - fetches the proxied List into the PersistenceContext and sets it on the BO Copy. // if (propertyList instanceof PersistentBag) { // try { // PersistentBag bag = (PersistentBag) propertyList; // PersistableBusinessObject pbo = // (PersistableBusinessObject) KRADServiceLocator.getEntityManagerFactory() // .createEntityManager().find(bo.getClass(), bag.getKey()); // Field field1 = pbo.getClass().getDeclaredField(propertyDescriptor.getName()); // Field field2 = bo.getClass().getDeclaredField(propertyDescriptor.getName()); // field1.setAccessible(true); // field2.setAccessible(true); // field2.set(bo, field1.get(pbo)); // propertyList = (List) getPropertyValue(bo, propertyDescriptor.getName()); // ; // } catch (Exception e) { // LOG.error(e.getMessage(), e); // } // } // End Complete Hibernate Hack for (Object listedBo : propertyList) { if (listedBo != null && listedBo instanceof BusinessObject) { setObjectPropertyDeep(listedBo, propertyName, type, propertyValue, depth - 1); } } // end for } } // end for }
From source file:org.malaguna.cmdit.service.reflection.HibernateProxyUtils.java
private void deepLoadDomainObject(AbstractObject<?> object, Object guideObj) { PropertyDescriptor[] properties = PropertyUtils.getPropertyDescriptors(unproxy(object)); for (PropertyDescriptor property : properties) { String pName = property.getName(); if (PropertyUtils.isWriteable(object, pName) && PropertyUtils.isReadable(object, pName)) { try { Object propGuideObject = property.getReadMethod().invoke(guideObj); if (null != propGuideObject) { Object unproxied = deepLoad(property.getReadMethod().invoke(object), propGuideObject); property.getWriteMethod().invoke(object, unproxied); }/* w w w. jav a2s. c o m*/ } catch (IllegalAccessException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } } } }
From source file:org.molasdin.wbase.collections.list.ExtendedListDecorator.java
@SuppressWarnings("unchecked") public void sort(final String property, Order order) { if (decorated().isEmpty()) { return;// w ww. j a v a 2 s .c o m } T item = decorated().get(0); Comparator<T> tmp = null; if (ReflectionHelper.hasFunction(property, item)) { final Transformer<T, Object> transformer = new Transformer<T, Object>() { @Override public Object transform(T o) { return ReflectionHelper.functionValue(property, o); } }; Object val = transformer.transform(item); final boolean isNatural = ReflectionHelper.supportsNaturalOrdering(val); tmp = new Comparator<T>() { @Override public int compare(T o1, T o2) { Object firstResult = transformer.transform(o1); Object secondResult = transformer.transform(o2); if (isNatural) { Comparable f = (Comparable) firstResult; Comparable s = (Comparable) secondResult; return f.compareTo(s); } String f = ConvertUtils.convert(firstResult); String s = ConvertUtils.convert(secondResult); return f.compareTo(s); } }; } else if (PropertyUtils.isReadable(item, property)) { tmp = new BeanComparator(property); } else { throw new RuntimeException("No property"); } Collections.sort(decorated(), tmp); }
From source file:org.ms123.common.data.JdoLayerImpl.java
public Map query(SessionContext sessionContext, Map params, StoreDesc sdesc, String entityName, String idParent, String entityNameDetails) { debug("query:" + params + ",entityName:" + entityName + ",entityNameDetails:" + entityNameDetails + ",idParent:" + idParent); String config = sessionContext.getConfigName(); PersistenceManager pm = sessionContext.getPM(); long start = new Date().getTime(); List<String> joinFields = new ArrayList<String>(); entityName = m_inflector.getEntityName(entityName); String detailFieldName = entityNameDetails; if (entityNameDetails != null) { joinFields.add(entityNameDetails); entityNameDetails = getEntityNameFromProperty(sdesc, entityName, entityNameDetails); } else {//from ww w .j a v a 2 s . c om entityNameDetails = null; } Map retMap = new HashMap(); try { Map fieldSets = m_settingService.getFieldSets(config, sdesc.getNamespace(), entityName); boolean hasTeamSecurity = hasTeamSecurity(sessionContext, entityName, entityNameDetails); boolean hasStateSelect = hasStateSelect(sdesc, entityName, entityNameDetails); System.out.println("hasStateSelect:" + hasStateSelect + "," + params.get("state")); String orderBy = getOrderBy(params, entityName, detailFieldName); Map filtersMap = null; if (params.get("filters") != null && "".equals(params.get("filters")) == false) { filtersMap = (Map) m_ds.deserialize((String) params.get("filters")); } if (params.get("filter") != null) { filtersMap = (Map) params.get("filter"); } /*if (params.get("luceneQuery") != null && "".equals(params.get("luceneQuery")) == false) { filtersMap = createFiltersMapFromLuceneQuery(sessionContext, entityName, (String) params.get("luceneQuery")); if (filtersMap == null) { Map ret = new HashMap(); ret.put("rows", new ArrayList()); return ret; } }*/ QueryBuilder qb = new QueryBuilder("pg", sdesc, entityName, hasTeamSecurity, sessionContext.getConfigName(), sessionContext, joinFields, filtersMap, (Map) params, fieldSets); qb.addSelector(entityName); List<String> fieldsArray = null; boolean fullyQualified = false; if (params.get("fields") != null) { if (params.get("fields") instanceof List) { fieldsArray = (List) params.get("fields"); } else { if (((String) params.get("fields")).length() > 0) { fieldsArray = (List) m_ds.deserialize((String) params.get("fields")); } } if (fieldsArray != null) { for (String field : fieldsArray) { int dot = field.indexOf("."); if (dot != -1) { qb.addSelector(field); fullyQualified = true; String[] name = field.split("\\."); String selector = name[0]; } } } } String andStr = ""; String whereClause = "where"; if (params.get("whereVal") != null && ((String) params.get("whereVal")).trim() != "") { whereClause += " " + params.get("whereVal"); andStr = " and"; } String w = qb.getWhere(); if (w != null) { whereClause += andStr + " " + w; andStr = " and"; } String jointype = null; if (entityNameDetails != null) { jointype = "join"; Class mainClass = sessionContext.getClass(entityName); Map permittedFields = sessionContext.getPermittedFields(entityName); String pk = getPrimaryKey(mainClass); Map c = (Map) permittedFields.get(pk); if (c != null && c.get("datatype") != null && "string".equals(c.get("datatype"))) { whereClause += andStr + " (" + getAlias(entityName) + "." + pk + " = '" + idParent + "')"; } else if (c != null && c.get("datatype") != null && "number".equals(c.get("datatype"))) { whereClause += andStr + " (" + getAlias(entityName) + "." + pk + " = " + idParent + ")"; } else { //Default id = string whereClause += andStr + " (" + getAlias(entityName) + "." + pk + " = '" + idParent + "')"; } andStr = " and"; if (fieldsArray == null) { String alias = entityNameDetails; if (joinFields.size() > 0) { alias = joinFields.get(0); } boolean isMap = TypeUtils.isMap(mainClass, detailFieldName); if (isMap) { Class childClass = TypeUtils.getTypeForField(mainClass, detailFieldName); String varName = "v_" + childClass.getSimpleName().toLowerCase(); qb.addVariable(childClass.getName() + " " + varName); fieldsArray = qb.getProjectionListEntity(entityNameDetails, varName); whereClause += andStr + " (" + getAlias(entityName) + "." + detailFieldName + ".containsValue(" + varName + "))"; } else { qb.addSelector(entityName); fieldsArray = qb.getProjectionListEntity(entityNameDetails, entityName + "$" + alias); } } } if ("where".equals(whereClause)) { andStr = ""; whereClause = ""; } List<String> projList = null; if (fieldsArray != null) { projList = fieldsArray; String pk = null; if (entityNameDetails != null) { pk = getPrimaryKey(sessionContext.getClass(entityNameDetails)); } else { pk = getPrimaryKey(sessionContext.getClass(entityName)); } if (!Utils.containsId(projList, pk)) { projList.add(pk); } qb.addSelectors(fieldsArray); } else { if (entityNameDetails != null) { projList = qb.getProjectionListAll(entityNameDetails); } else { projList = qb.getProjectionListAll(entityName); } } String projection = getProjectionString(projList); String from = qb.getFrom(jointype); if (hasTeamSecurity) { if (entityNameDetails != null) { projection = projection + "," + entityName + "$" + detailFieldName; } else { projection = projection + "," + entityName; } projList.add("_team_list"); } List<String> involvedModule = qb.getInvolvedEntity(); Map<String, Class> involvedClasses = getInvolvedClasses(sdesc, involvedModule); String teamUserWhere = qb.getTeamUserWhere(); if (teamUserWhere != null) { teamUserWhere = andStr + " " + teamUserWhere; andStr = " and"; } else { teamUserWhere = ""; } String teamSecurityWhere = qb.getTeamSecurityWhere(); if (teamSecurityWhere != null) { teamSecurityWhere = andStr + " " + teamSecurityWhere; } else { teamSecurityWhere = ""; } String stateWhere = ""; if (hasStateSelect && !Utils.getBoolean(params, DISABLE_STATESELECT, false)) { String state = qb.getRequestedState(); String qualifier = null; if (entityNameDetails != null) { qualifier = entityName + "$" + detailFieldName; } else { qualifier = entityName; } stateWhere = andStr + " " + getStateWhere(qualifier, state); andStr = " and"; } boolean noResultSetCount = noResultSetCount(sdesc, entityName, entityNameDetails); String sql = "Select distinct " + projection + " from " + from + " " + whereClause + " " + stateWhere + " " + teamUserWhere + " " + teamSecurityWhere + " " + orderBy; info("========================================================================================="); info("sql:" + sql); info("========================================================================================="); info("Imports:" + sdesc.getImports()); Query q = pm.newQuery("javax.jdo.query.JPQL", sql); q.declareImports(sdesc.getImports()); int offset = getInt(params, "offset", 0); int pageSize = getInt(params, "pageSize", 30); if (noResultSetCount && pageSize > 0) { q.setRange(offset, offset + pageSize); } String vars = qb.getVariables(); if (vars != null) q.declareVariables(vars); List results = (List) q.executeWithMap(qb.getQueryParams()); Iterator itr = results.iterator(); int count = 0; boolean first = true; Field fields[] = null; String colNames[] = null; boolean isRelatedTo[] = null; int total = 0; List dataList = new ArrayList(); String defaultClassName = m_inflector .getClassName(entityNameDetails != null ? entityNameDetails : entityName); Map<Class, String> primKeyNameMap = new HashMap(); while (itr.hasNext()) { Object[] row = null; Object no = itr.next(); if (!(no instanceof Object[])) { row = new Object[1]; row[0] = no; } else { row = (Object[]) no; } if (noResultSetCount || pageSize == 0 || (total >= offset && count < pageSize)) { Map<String, Object> rowMap = new HashMap<String, Object>(); if (first) { colNames = new String[row.length]; isRelatedTo = new boolean[row.length]; for (int col = 0; col < row.length; col++) { debug("\tColumn:" + row[col]); String colName = projList.get(col); Field field = getFieldForColName(sdesc, colName, defaultClassName); isRelatedTo[col] = field != null ? field.isAnnotationPresent(RelatedTo.class) : false; if (fullyQualified == false) { int dot = colName.indexOf("."); if (dot != -1) { colName = colName.substring(dot + 1); } } boolean isPermitted = true; if (field != null) { String clazz = getLastElement(field.getDeclaringClass().getName()); String name = field.getName(); isPermitted = sessionContext.isFieldPermitted(name, clazz); debug("\tisPermitted(" + clazz + "," + name + "):" + isPermitted); } if (colName.equals("id") || isPermitted) { colNames[col] = colName; } else { colNames[col] = null; } } first = false; } for (int col = 0; col < row.length; col++) { String colName = colNames[col]; if (colName == null) { continue; } if (isRelatedTo[col]) { if (row[col] != null) { Class clazz = row[col].getClass(); if (primKeyNameMap.get(clazz) == null) { primKeyNameMap.put(clazz, getPrimaryKey(clazz)); } Object id = PropertyUtils.getProperty(row[col], primKeyNameMap.get(clazz)); rowMap.put(colName, id + ""); //rowMap.put(colName,getTitle(sessionContext, m_inflector.getEntityName(clazz.getSimpleName()),new BeanMap(row[col]), id)); } else { rowMap.put(colName, ""); } } else if (row[col] instanceof byte[]) { debug("Bytearray"); } else if (row[col] instanceof java.util.Date) { rowMap.put(colName, String.valueOf(((Date) row[col]).getTime())); } else { rowMap.put(colName, row[col]); } } String _entityName = entityNameDetails != null ? entityNameDetails : entityName; evaluteFormulas(sessionContext, _entityName, rowMap, "out", involvedClasses, pm); if (hasTeamSecurity) { Object x = rowMap.get("_team_list"); if (x != null) { Set<Object> _teams = null; if (PropertyUtils.isReadable(x, "_team_list")) { _teams = (Set<Object>) PropertyUtils.getProperty(x, "_team_list"); } rowMap.remove("_team_list"); if (_teams != null && _teams.size() > 0) { debug("NOT Checking"); /*if (hasTeamSecurity && !m_teamService.checkTeams(sessionContext.getStoreDesc().getNamespace(), sessionContext.getUserName(), sessionContext.getUserProperties(), _teams)) { debug("No teampermission:" + rowMap); continue; }*/ } } } dataList.add(rowMap); count++; } total++; } long pagesTotal = (total == 0 || pageSize == 0) ? 0 : Math.round((total / pageSize) + 0.4999); if (noResultSetCount) { pagesTotal = total == pageSize ? -1 : 0; total = total == pageSize || offset > 0 ? -1 : total; } info("<== getTable.rows:" + dataList.size()); info("<== getTable.recordsTotal:" + total); debug("getTable.pagesTotal:" + pagesTotal); debug("getTable.page:" + getInt(params, "page", 0)); Map ret = new HashMap(); ret.put("records", total); ret.put("page", params.get("page")); ret.put("total", pagesTotal); ret.put("rows", dataList); retMap = ret; long end = new Date().getTime(); info("Dauer_query(rows:" + total + "):" + (end - start)); } catch (Exception e) { throw new RuntimeException(e); } return retMap; }
From source file:org.ms123.common.data.JdoLayerImpl.java
private void getBinary(SessionContext sessionContext, Object obj, boolean hasTeamSecurity, Map permittedFields, HttpServletResponse resp) throws Exception { Map<String, Object> map = new HashMap(); BeanMap beanMap = new BeanMap(obj); if (beanMap.getType("_team_list") != null) { Set<Object> _teams = (Set<Object>) beanMap.get("_team_list"); if (hasTeamSecurity && !m_teamService.checkTeams(sessionContext.getStoreDesc().getNamespace(), sessionContext.getUserName(), sessionContext.getUserProperties(), _teams)) { info("getPropertyMap.notAllowed:" + _teams); resp.setStatus(HttpServletResponse.SC_NOT_FOUND); return; }//w ww . j a v a 2 s . co m } if (PropertyUtils.isReadable(obj, "content")) { byte[] c = (byte[]) PropertyUtils.getProperty(obj, "content"); if (PropertyUtils.isReadable(obj, "type")) { String t = (String) PropertyUtils.getProperty(obj, "type"); resp.setContentType(t); } if (PropertyUtils.isReadable(obj, "filename")) { String t = (String) PropertyUtils.getProperty(obj, "filename"); resp.addHeader("Content-Disposition", "inline;filename=" + t); } if (c != null) { debug("getBinary:length:" + c.length); IOUtils.write(c, resp.getOutputStream()); } resp.setStatus(HttpServletResponse.SC_OK); resp.getOutputStream().close(); } }
From source file:org.ms123.common.data.SessionContextImpl.java
public boolean hasTeamPermission(Object o) { long startTime = new Date().getTime(); Object teams = null;/*from w w w . j a va2 s. c o m*/ try { if (!(o instanceof Collection)) { if (PropertyUtils.isReadable(o, "_team_list")) { teams = PropertyUtils.getProperty(o, "_team_list"); } } if (teams != null) { boolean b = m_teamService.checkTeams(getStoreDesc().getNamespace(), getUserName(), getUserProperties(), (Collection<Object>) teams); long endTime = new Date().getTime(); System.err.println("hasTeamPermission.time:" + (endTime - startTime) + "/allowed:" + b); return b; } } catch (Exception e) { throw new RuntimeException("SessionContext.hasTeamPermission:", e); } return true; }
From source file:org.ms123.common.data.TriggerServiceImpl.java
public Map applyDeleteRules(SessionContext sessionContext, String entityName, Object insert) throws Exception { // Map preUpdate = new HashMap(new BeanMap(insert)); Map preUpdate = UtilsServiceImpl.copyObject(insert); if (PropertyUtils.isReadable(insert, "_team_list")) { PropertyUtils.setProperty(insert, "_team_list", new HashSet()); }// w w w. j av a2 s .c o m return applyRules(sessionContext, entityName, insert, preUpdate, DELETE); }