@RequestMapping("/UserDetailInfo")
  public ModelAndView userDetailInfo(HttpServletRequest request) throws Exception {
    ModelAndView mav = new ModelAndView("business/common/userDetailInfo");

    UserDto userDto = new UserDto();

    String userId = request.getParameter("userId");
    userDto = user.getUserInfo(userId);

    String userTypeName = null;
    CodeDto cdoeDto = code.getCodeInfo("SYSTEM", "USER_TYPE", userDto.getUserType());
    if (cdoeDto != null) userTypeName = cdoeDto.getCodeName();

    String birthDt = userDto.getBirthDt();
    if (!StringUtils.isEmpty(birthDt) && StringUtils.length(birthDt) == 8) {
      birthDt =
          StringUtils.substring(birthDt, 0, 2)
              + "/"
              + StringUtils.substring(birthDt, 2, 4)
              + "/"
              + StringUtils.substring(birthDt, 4);
    }
    userDto.setBirthDt(birthDt);
    userDto.setUserTypeName(userTypeName);

    mav.addObject("userPhoto", user.getProfilePhoto(userId));
    mav.addObject("userDto", userDto);

    return mav;
  }
Example #2
0
  /**
   * @param filterName 比较属性字符串,含待比较的比较类型、属性值类型及属性列表. eg. LIKES_NAME_OR_LOGIN_NAME
   * @param value 待比较的值.
   */
  public PropertyFilter(final String filterName, final Object value) {
    String firstPart = StringUtils.upperCase(StringUtils.substringBefore(filterName, "_"));
    String matchTypeCode = StringUtils.substring(firstPart, 0, firstPart.length() - 1);
    String propertyTypeCode =
        StringUtils.substring(firstPart, firstPart.length() - 1, firstPart.length());

    try {
      matchType = Enum.valueOf(MatchType.class, matchTypeCode);
    } catch (RuntimeException e) {
      throw new IllegalArgumentException("filter名称" + filterName + "没有按规则编写,无法得到属性比较类型.", e);
    }

    try {
      propertyClass = Enum.valueOf(PropertyType.class, propertyTypeCode).getValue();
    } catch (RuntimeException e) {
      throw new IllegalArgumentException("filter名称" + filterName + "没有按规则编写,无法得到属性值类型.", e);
    }

    String propertyNameStr = StringUtils.substringAfter(filterName, "_");
    //		AssertUtils.isTrue(StringUtils.isNotBlank(propertyNameStr), "filter名称" + filterName +
    // "没有按规则编写,无法得到属性名称.");
    propertyNames = StringUtils.splitByWholeSeparator(propertyNameStr, PropertyFilter.OR_SEPARATOR);
    this.matchValue = value;
    if (null == value || !String.class.equals(value.getClass())) {
      return;
    }
    if (!String.class.equals(propertyClass)) {
      this.matchValue = ConvertUtils.convert((String) value, propertyClass);
    }
  }
 @Override
 public String logicalCollectionTableName(
     String tableName,
     String ownerEntityTable,
     String associatedEntityTable,
     String propertyName) {
   if (isAddUnderscores) {
     return StringUtils.substring(
         tablePrefix
             + super.logicalCollectionTableName(
                 addUnderscores(tableName),
                 addUnderscores(ownerEntityTable),
                 addUnderscores(associatedEntityTable),
                 addUnderscores(propertyName)),
         0,
         maxLength);
   } else {
     return StringUtils.substring(
         tablePrefix
             + super.logicalCollectionTableName(
                 tableName, ownerEntityTable, associatedEntityTable, propertyName),
         0,
         maxLength);
   }
 }
Example #4
0
 public static Map decrypt(String encryptPassword) {
   int length = encryptPassword.length();
   if (length < 36 || (length - 32) % 4 != 0) {
     return new HashMap();
   }
   int count = (length - 32) / 4;
   StringBuffer md5 = new StringBuffer();
   StringBuffer base64Encode = new StringBuffer();
   for (int i = 0; i < (length / (8 + count)); i++) {
     md5.append(
         StringUtils.substring(encryptPassword, i * (8 + count), (i + 1) * (8 + count) - count));
     base64Encode.append(
         StringUtils.substring(encryptPassword, i * (8 + count) + 8, (i + 1) * (8 + count)));
   }
   byte[] base64decode = Base64.decodeBase64(base64Encode.toString());
   String password = new String(base64decode);
   //		System.out.println(password);
   //		System.out.println(md5.toString());
   //		System.out.println(base64Encode.toString());
   Map map = new HashMap();
   map.put("password", password);
   map.put("md5", md5.toString().toUpperCase());
   map.put("base64Encode", base64Encode.toString());
   return map;
 }
Example #5
0
  /**
   * Parses a {@link SimpleConcept} from a String
   *
   * @param concept
   * @return
   * @author jmayaalv
   */
  public static SimpleConcept parse(String concept) {
    if (StringUtils.isBlank(concept)) {
      return null;
    }

    concept = StringUtils.trim(concept);
    if ((StringUtils.countMatches(concept, "(") == (StringUtils.countMatches(concept, ")")))
        && StringUtils.startsWith(concept, "(")
        && StringUtils.endsWith(concept, ")")) {
      concept = StringUtils.substring(concept, 1, concept.length() - 1);
    }

    boolean negated = false;
    if (concept.startsWith(".NO")) {
      negated = true;
      concept = StringUtils.remove(concept, ".NO");
      concept = StringUtils.trim(concept);
    }

    if (StringUtils.isBlank(concept)) {
      throw new RuntimeException("Concept can't be parsed: " + concept);
    }

    if ((StringUtils.countMatches(concept, "(") == (StringUtils.countMatches(concept, ")")))
        && StringUtils.startsWith(concept, "(")
        && StringUtils.endsWith(concept, ")")) {
      concept = StringUtils.substring(concept, 1, concept.length() - 1);
    }

    if (StringUtils.contains(concept, " ")) {
      return null; // not a SimpleConcep
    }

    return new SimpleConcept(Integer.parseInt(concept), negated);
  }
  /**
   * 转换成骆驼命名法返回
   *
   * @param name
   * @return
   */
  public static String getCamelName(String name) {
    if (StringUtils.isBlank(name)) {
      return null;
    }
    name = StringUtils.lowerCase(name);
    // 去掉前面的_
    while (StringUtils.startsWith(name, "_")) {
      name = StringUtils.substring(name, 1);
    }
    // 去掉后面的_
    while (StringUtils.endsWith(name, "_")) {
      name = StringUtils.substring(name, 0, name.length() - 1);
    }

    StringBuilder sb = new StringBuilder();

    for (int i = 0; i < name.length(); i++) {

      char c = name.charAt(i);

      if (c == '_') {
        i++;
        sb.append(Character.toUpperCase(name.charAt(i)));
        continue;
      }
      sb.append(c);
    }

    return sb.toString();
  }
 /**
  * 首字母小写
  *
  * @param name
  * @return
  */
 public static String getFirstLowerName(String name) {
   if (StringUtils.isBlank(name)) {
     return null;
   }
   String firstChar = StringUtils.substring(name, 0, 1).toLowerCase();
   return firstChar + StringUtils.substring(name, 1);
 }
Example #8
0
 public static boolean validarSinDigitosChequeo(String cuentaEntrada, String cuentaSalida) {
   String ctaEntradaParte1 = StringUtils.substring(cuentaEntrada, 0, 8);
   String ctaEntradaParte2 = StringUtils.substring(cuentaEntrada, 10, 20);
   String ctaSalidaParte1 = StringUtils.substring(cuentaSalida, 0, 8);
   String ctaSalidaParte2 = StringUtils.substring(cuentaSalida, 10, 20);
   return ctaEntradaParte1.equalsIgnoreCase(ctaSalidaParte1)
       && ctaEntradaParte2.equalsIgnoreCase(ctaSalidaParte2);
 }
Example #9
0
 private void registrarConcepto(final CargoAbono pago) {
   String forma = pago.getFormaDePago().name();
   forma = StringUtils.substring(forma, 0, 2);
   String pattern = "{0} {1} {2}";
   String ms = MessageFormat.format(pattern, forma, pago.getReferencia(), pago.getAFavor());
   ms = StringUtils.substring(ms, 0, 120);
   setConcepto(ms);
 }
 @Override
 public String propertyToColumnName(String propertyName) {
   if (isAddUnderscores) {
     return StringUtils.substring(
         super.propertyToColumnName(addUnderscores(propertyName)), 0, maxLength);
   } else {
     return StringUtils.substring(super.propertyToColumnName(propertyName), 0, maxLength);
   }
 }
 @Override
 public String classToTableName(String className) {
   if (isAddUnderscores) {
     return StringUtils.substring(
         tablePrefix + super.classToTableName(addUnderscores(className)), 0, maxLength);
   } else {
     return StringUtils.substring(tablePrefix + super.classToTableName(className), 0, maxLength);
   }
 }
 @Override
 public String logicalColumnName(String columnName, String propertyName) {
   if (isAddUnderscores) {
     return StringUtils.substring(
         super.logicalColumnName(addUnderscores(columnName), addUnderscores(propertyName)),
         0,
         maxLength);
   } else {
     return StringUtils.substring(super.logicalColumnName(columnName, propertyName), 0, maxLength);
   }
 }
 @Override
 public String joinKeyColumnName(String joinedColumn, String joinedTable) {
   if (isAddUnderscores) {
     return StringUtils.substring(
         super.joinKeyColumnName(addUnderscores(joinedColumn), addUnderscores(joinedTable)),
         0,
         maxLength);
   } else {
     return StringUtils.substring(
         super.joinKeyColumnName(joinedColumn, joinedTable), 0, maxLength);
   }
 }
Example #14
0
 private void afectarBancos(final CargoAbono pago) {
   AsientoDeGasto a1 = new AsientoDeGasto();
   a1.setCuenta(pago.getCuenta().getCuentaContable());
   String c =
       MessageFormat.format(
           "{0} {1}", pago.getCuenta().getDescripcion(), pago.getCuenta().getNumero());
   c = StringUtils.substring(c, 0, 28);
   a1.setConcepto(c);
   a1.setHaber(pago.getImporteMN().abs());
   a1.setDescripcion(StringUtils.substring(getConcepto(), 0, 28));
   registros.add(a1);
 }
Example #15
0
  /**
   * Turn SOLR date range into year range. E.g. [1940-01-01T00:00:00Z TO 1949-12-31T00:00:00Z] to
   * 1940-1949
   *
   * @param fieldValue
   * @return
   */
  private String substituteYearsForDates(String fieldValue) {
    String dateRange = URLDecoder.decode(fieldValue);
    String formattedDate = StringUtils.replaceChars(dateRange, "[]", "");
    String[] dates = formattedDate.split(" TO ");

    if (dates != null && dates.length > 1) {
      // grab just the year portions
      dateRange =
          StringUtils.substring(dates[0], 0, 4) + "-" + StringUtils.substring(dates[1], 0, 4);
    }

    return dateRange;
  }
  private static String formatWWN(String wwn) {
    if (StringUtils.isBlank(wwn)) {
      return null;
    }
    // Left pad with zeros to make 16 chars, trim any excess
    wwn = StringUtils.substring(StringUtils.leftPad(wwn, 16, '0'), 0, 16);

    StrBuilder sb = new StrBuilder();
    for (int i = 0; i < wwn.length(); i += 2) {
      sb.appendSeparator(':');
      sb.append(StringUtils.substring(wwn, i, i + 2));
    }
    return sb.toString();
  }
Example #17
0
  @Test
  public void testExtractNameEmail1() {

    String s = "Alex Okunevich <*****@*****.**>";

    int ind1 = StringUtils.indexOf(s, "<");
    int ind2 = StringUtils.indexOf(s, ">");

    String name = StringUtils.substring(s, 0, ind1);
    String email = StringUtils.substring(s, ind1 + 1, ind2);

    System.out.println(name);
    System.out.println(email);
  }
Example #18
0
  /**
   * Creates the field parsing the parameter value into fields' components
   *
   * @param value
   */
  public Field109(String value) {
    this();

    if (value != null) {
      if (value.length() >= 6) {
        setComponent1(org.apache.commons.lang.StringUtils.substring(value, 0, 6));
      }
      if (value.length() >= 12) {
        setComponent2(org.apache.commons.lang.StringUtils.substring(value, 6, 12));
      }
      if (value.length() > 12) {
        setComponent3(org.apache.commons.lang.StringUtils.substring(value, 12));
      }
    }
  }
  /**
   * 保留原文件后缀生成唯一文件名
   *
   * @param fileName
   * @return
   */
  public static String createUniqueFileName(String fileName) {

    int index = StringUtils.lastIndexOf(fileName, ".");
    String suffix = StringUtils.substring(fileName, index);
    String uqName = UUIDUtils.getUUID16() + suffix;
    return uqName;
  }
Example #20
0
  /**
   * Creates the field parsing the parameter value into fields' components
   *
   * @param value
   */
  public Field69D(String value) {
    this();

    setComponent1(SwiftParseUtils.getTokenFirst(value, ":", "//"));
    String toparse = SwiftParseUtils.getTokenSecondLast(value, "//");
    String toparse2 = SwiftParseUtils.getTokenFirst(toparse, "/");
    setComponent4(SwiftParseUtils.getTokenSecondLast(toparse, "/"));
    if (toparse2 != null) {
      if (toparse2.length() >= 8) {
        setComponent2(org.apache.commons.lang.StringUtils.substring(toparse2, 0, 8));
      }
      if (toparse2.length() > 8) {
        setComponent3(org.apache.commons.lang.StringUtils.substring(toparse2, 8));
      }
    }
  }
  /**
   * @param dets
   * @param registros
   */
  public void registrarGasto(
      final List<GCompraDet> dets, final Poliza poliza, final String factura) {
    GCompraDet det = dets.get(0);
    PolizaDet asiento = poliza.agregarPartida();
    asiento.setCuenta(getCuenta("600"));
    asiento.setDescripcion("");

    String pattern = "F-{0} {1}";
    String descripcion2 =
        MessageFormat.format(pattern, det.getFactura(), det.getProducto().getDescripcion());
    descripcion2 = StringUtils.substring(descripcion2, 0, 50);
    asiento.setDescripcion2(descripcion2);

    if ((det.getRubro() != null) || (det.getRubro().getRubroCuentaOrigen() != null)) {
      ConceptoDeGasto concepto = det.getRubro().getRubroCuentaOrigen();
      String cc = concepto != null ? concepto.getDescripcion() : "NA";
      asiento.setDescripcion2(cc);
    }

    CantidadMonetaria debe = CantidadMonetaria.pesos(0);
    for (GCompraDet part : dets) {
      debe = debe.add(part.getImporteMN());
    }

    asiento.setDebe(debe.amount());
    asiento.setReferencia(dets.get(0).getCompra().getProveedor().getNombreRazon());
    asiento.setReferencia2(det.getSucursal().getNombre());
  }
  /** @see java.beans.PropertyEditorSupport#getAsText() */
  @Override
  public String getAsText() {
    Object obj = this.getValue();

    if (obj == null) {
      return null;
    }

    String displayValue = obj.toString();
    if (displayValue.length() > 3) {
      displayValue =
          StringUtils.substring(displayValue, 0, 3) + "-" + StringUtils.substring(displayValue, 3);
    }

    return displayValue;
  }
  private void doObjects(Session hSession) throws HibernateException {
    MetadataTable tObject = getMetadataTable(MetadataTable.OBJECT);

    Iterator i = mResources.values().iterator();
    while (i.hasNext()) {
      Resource resource = (Resource) i.next();
      Set hObjects = new HashSet();
      List objects = tObject.getDataRows(resource.getPath());
      if (objects != null) {
        Iterator j = objects.iterator();
        while (j.hasNext()) {
          Metadata md = (Metadata) j.next();
          MObject hObject = new MObject();

          hObject.setResource(resource);

          hObject.setObjectType(ObjectTypeEnum.fromString(md.getAttribute("ObjectType")));
          hObject.setMimeType(md.getAttribute("MimeType"));
          hObject.setVisibleName(md.getAttribute("VisibleName"));
          hObject.setDescription(StringUtils.substring(md.getAttribute("Description"), 0, 64));

          // Should we have an updateLevel?

          hSession.save(hObject);
          hObjects.add(hObject);
        }
      }

      resource.setObjects(hObjects);
      hSession.saveOrUpdate(resource);
    }
  }
Example #24
0
  private ClassLoader addToClassPath(ClassLoader classLoader, String[] newPaths)
      throws ExecutorException {
    URLClassLoader loader = (URLClassLoader) classLoader;
    List<URL> curPath = Arrays.asList(loader.getURLs());
    List<URL> newPath = Lists.newArrayList();

    for (URL onePath : curPath) {
      newPath.add(onePath);
    }
    curPath = newPath;
    if (newPaths != null) {
      for (String onestr : newPaths) {
        if (StringUtils.indexOf(onestr, FILE_PREFIX) == 0) {
          onestr = StringUtils.substring(onestr, CQLConst.I_7);
        }

        URL oneurl = getFileURL(onestr);

        if (!curPath.contains(oneurl)) {
          curPath.add(oneurl);
        }
      }
    }

    return new URLClassLoader(curPath.toArray(new URL[0]), loader);
  }
Example #25
0
  /**
   * Loads the jamm.properties file and uses it to initalize the Globals object.
   *
   * @see jamm.webapp.Globals
   * @param config The configuration from the servlet container.
   * @throws ServletException when their is an IOException loading the properties file
   */
  private void loadProperties(ServletConfig config) throws ServletException {
    String path;
    Properties properties;

    try {
      path = config.getServletContext().getRealPath("WEB-INF/" + "jamm.properties");
      properties = new Properties();
      properties.load(new FileInputStream(path));

      Globals.setLdapHost(getStringProperty(properties, "ldap.host", "localhost"));
      Globals.setLdapPort(getIntProperty(properties, "ldap.port", 389));
      Globals.setLdapSearchBase(getStringProperty(properties, "ldap.search_base", ""));
      LdapPassword.setRandomClass(
          getStringProperty(properties, "random_class", "java.security.SecureRandom"));

      // Strip out leading and trailing quotes (common problem)
      String rootDn = getStringProperty(properties, "ldap.root_dn", "");
      if (rootDn.startsWith("\"") && rootDn.endsWith("\"")) {
        rootDn = StringUtils.substring(rootDn, 1, -1);
      }
      Globals.setRootDn(rootDn);
      Globals.setRootLogin(getStringProperty(properties, "ldap.root_login", "root"));
      MailManagerOptions.setUsePasswordExOp(getBooleanProperty(properties, "password.exop", true));
      MailManagerOptions.setVmailHomedir(
          getStringProperty(properties, "vmail.homedir", "/home/vmail/domains"));
    } catch (IOException e) {
      throw new ServletException(e);
    }
  }
Example #26
0
 /**
  * 密码加密。加密规则,密码先进行base64(4的整数倍)和md5(32),base64后的字符串分成四段md5后的数据分成四段,进行md5[0]+base64[0]+...+md5[4]+base64[4]
  *
  * @param password
  * @return加密后的密码
  * @throws UnsupportedEncodingException
  */
 public static String encrypt(String password) throws UnsupportedEncodingException {
   if (StringUtils.trimToNull(password) == null) {
     return "";
   } else {
     password = password.trim();
   }
   String base64Encode = Base64.encodeBase64String(password.getBytes("UTF-8"));
   String md5Encode = md5Encrypt(password);
   int count = base64Encode.length() / 4;
   StringBuffer encryptPassword = new StringBuffer();
   for (int i = 0; i < 4; i++) {
     encryptPassword.append(StringUtils.substring(md5Encode, i * 8, (i + 1) * 8));
     encryptPassword.append(StringUtils.substring(base64Encode, i * count, (i + 1) * count));
   }
   return encryptPassword.toString();
 }
Example #27
0
  /**
   * Creates the field parsing the parameter value into fields' components
   *
   * @param value
   */
  public Field37F(String value) {
    this();

    setComponent1(SwiftParseUtils.getTokenFirst(value, "//"));
    String toparse = SwiftParseUtils.getTokenSecond(value, "//");
    if (toparse != null && toparse.length() >= 6) {
      setComponent2(org.apache.commons.lang.StringUtils.substring(toparse, 0, 6));
    }
    if (toparse != null && toparse.length() >= 7) {
      setComponent3(org.apache.commons.lang.StringUtils.substring(toparse, 6, 7));
    }
    if (toparse != null && toparse.length() > 7) {
      String toparse2 = org.apache.commons.lang.StringUtils.substring(toparse, 7);
      setComponent4(SwiftParseUtils.getTokenFirst(toparse2, "/"));
      setComponent5(SwiftParseUtils.getTokenSecondLast(toparse2, "/"));
    }
  }
Example #28
0
 private void abonoAGastos(final CargoAbono pago) {
   AsientoDeGasto a1 = new AsientoDeGasto();
   a1.setConcepto("GASTOS");
   a1.setCuenta("901-0002-000");
   a1.setDescripcion(StringUtils.substring(getConcepto(), 0, 28));
   a1.setHaber(pago.getImporteMNSinIva().abs());
   registros.add(a1);
 }
Example #29
0
  /** 获取上级编号 */
  public static final String findParentNo(String no) {
    int length = StringUtils.length(no);
    if (length <= ITEM_LENGTH) {
      return StringUtils.EMPTY;
    }

    return StringUtils.substring(no, 0, (length - ITEM_LENGTH));
  }
 /**
  * Get the amino acid sequence (translate) for a spliced nucleotide sequence
  *
  * @param nuclSequence
  * @return amino acid sequence
  */
 public static String translate(String nuclSequence) {
   String aaSequence = "";
   for (int i = 0; i < nuclSequence.length() - 1; i = i + 3) {
     String codon = StringUtils.substring(nuclSequence, i, i + 3);
     aaSequence = aaSequence + SequenceUtils.getAminoAcid3(codon);
   }
   return aaSequence;
 }