/**
   * {@inheritDoc}
   *
   * @see
   *     org.kuali.kra.common.specialreview.service.SpecialReviewService#getProtocolIndex(java.lang.String)
   */
  public int getProtocolIndex(String prefix) {
    int index = -1;

    int lastLeftBracketIndex = StringUtils.lastIndexOf(prefix, '[');
    int lastRightBracketIndex = StringUtils.lastIndexOf(prefix, ']');
    if (lastLeftBracketIndex != -1 && lastRightBracketIndex != -1) {
      String lineNumber = prefix.substring(lastLeftBracketIndex + 1, lastRightBracketIndex);
      if (NumberUtils.isDigits(lineNumber)) {
        index = Integer.parseInt(lineNumber);
      }
    }

    return index;
  }
  /**
   * 保留原文件后缀生成唯一文件名
   *
   * @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;
  }
Exemple #3
0
 public String getFileName() {
   int index = StringUtils.lastIndexOf(getHref(), "/");
   String fileName = getHref();
   if (index > -1) {
     fileName = getHref().substring(index + 1);
   }
   return fileName;
 }
Exemple #4
0
 public Path getHrefAsPath() {
   int index = StringUtils.lastIndexOf(getHref(), "/");
   String path = "";
   if (index > -1) {
     path = getHref().substring(0, index);
   }
   return EpubFileSystem.INSTANCE.getPath("/" + path);
 }
Exemple #5
0
 @Override
 public void convertFromString(String string) {
   int index = StringUtils.lastIndexOf(getHref(), "/");
   String fileName = getHref();
   if (index > -1) {
     fileName = getHref().substring(index + 1);
   }
   setHref(getHref().replace(fileName, string));
 }
 /**
  * Given a <code>String</code> XML SockEntry, returns the <code>String</code> podUUID
  *
  * @param <code>String</code> s
  * @return <code>String</code>
  */
 public String podUUID(String s) {
   String headless = stripHead(s);
   return StringUtils.strip(
       headless.substring(
           StringUtils.indexOf(headless, '"') + 1, StringUtils.lastIndexOf(headless, '"')));
 }
 /**
  * Given a <code>String</code> XML SockEntry, returns a <code>String</code> with the XML header
  * info removed
  *
  * @param <code>String</code> s
  * @return <code>String</code>
  */
 private String stripHead(String s) {
   return StringUtils.strip(
       s.substring(StringUtils.indexOf(s, '>') + 1, StringUtils.lastIndexOf(s, '>')));
 }
 /**
  * 在文件名后加上指定后缀,不包括后缀名
  *
  * @param fileName
  * @param endSuffix
  * @return
  */
 public static String createEndSuffixFileName(String fileName, String endSuffix) {
   int index = StringUtils.lastIndexOf(fileName, ".");
   String preFileName = StringUtils.substring(fileName, 0, index);
   String suffix = StringUtils.substring(fileName, index);
   return preFileName + endSuffix + suffix;
 }
 @SuppressWarnings("unchecked")
 public String execute() throws Exception {
   try {
     String username = (String) ActionContext.getContext().getSession().get("LOGINUSERNAME");
     String password = (String) ActionContext.getContext().getSession().get("LOGINPASSWORD");
     if (username == null || password == null) {
       return LOGIN;
     }
     String filterResult = filterType(new String[] {"text/xml", "text/plain"});
     if (filterResult != null) {
       ActionContext.getContext().getSession().put("typeError", "您要上传的文件类型不正确,只允许上传jrxml格式的模板!");
       return filterResult;
     }
     if (logger.isDebugEnabled()) {
       logger.debug("uploadContentType:" + uploadContentType);
     }
   } catch (Exception e) {
     logger.error("" + e.getMessage(), e.getCause());
   }
   String filename = getUploadFileName();
   // 上传单个文件
   try {
     SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
     int pos = StringUtils.lastIndexOf(filename, ".");
     String suffix = filename.substring(pos + 1, filename.length());
     filename = sdf.format(new Timestamp(System.currentTimeMillis())) + "." + suffix;
     logger.debug("filename:" + filename);
     // 以服务器的文件保存地址和原文件名建立上传文件输出流
     FileOutputStream fos = new FileOutputStream(getSavePath() + "//" + filename);
     // 以上传文件建立一个<SPAN class=hilite2>文件上传</SPAN>流
     FileInputStream fis = new FileInputStream(getUpload());
     // 将上传文件的内容写入服务器
     byte[] buffer = new byte[1024];
     int len = 0;
     while ((len = fis.read(buffer)) > 0) {
       fos.write(buffer, 0, len);
     }
     fos.flush();
     fos.close();
     fis.close();
   } catch (Exception e) {
     logger.error("addRepartTemplate:" + e.getMessage(), e.getCause());
   }
   try {
     String isOK = (String) ActionContext.getContext().getSession().get("CLIENTINPUTADDISOK");
     if (isOK != null && "OK".equals(isOK)) {
       ReportTemplateInfo info =
           (ReportTemplateInfo) ActionContext.getContext().getSession().get("TEMPLATEEDIT");
       if (description != null) {
         info.setDescription(description);
       }
       if (getUploadFileName() != null) {
         info.setFileName(filename);
       }
       if (path != null) {
         info.setPath(path);
       }
       if (name != null) {
         info.setName(name);
       }
       if (type != null) {
         info.setType(type);
       }
       reportTemplateInfoService.updateReportTemplateInfo(info);
       ActionContext.getContext().getSession().put("CLIENTINPUTADDISOK", "NOT");
     }
   } catch (Exception e) {
     logger.error("" + e.getMessage(), e.getCause());
   }
   return SUCCESS;
 }