예제 #1
1
 public void testIsNotEmpty() {
   assertEquals(false, StringUtils.isNotEmpty(null));
   assertEquals(false, StringUtils.isNotEmpty(""));
   assertEquals(true, StringUtils.isNotEmpty(" "));
   assertEquals(true, StringUtils.isNotEmpty("foo"));
   assertEquals(true, StringUtils.isNotEmpty("  foo  "));
 }
예제 #2
0
 /**
  * Determines whether or not all the Strings in an array are empty or not.
  *
  * @param strings String[] whose elements are being checked for emptiness
  * @return whether or not the String is empty
  */
 private static boolean deepEmpty(final String[] strings) {
   if (strings != null) {
     for (final String s : strings) {
       if (StringUtils.isNotEmpty(s)) {
         return false;
       }
     }
   }
   return true;
 }
예제 #3
0
 public static <T> T newInstance(String className, Object... parameters) {
   Class<T> clazz = null;
   try {
     if (StringUtils.isNotEmpty(className)) {
       clazz = forName(className);
     }
   } catch (Exception e) {
     logger.error(e.getMessage(), e);
   }
   return newInstance(clazz, parameters);
 }
예제 #4
0
 public static Intent getTabIntent(Context context, Tab tab, String s, String s1) {
   context = new Intent(context, ActivitySelector.getActivityClass(tab.getViewController()));
   if (StringUtils.isNotEmpty(tab.getUrl())) {
     context.putExtra("URL", tab.getUrl());
   }
   context.putExtra("TAB_UNIQUE_ID", tab.getId());
   context.putExtra("TAB_LABEL", tab.getLabel());
   context.putExtra("TAB_SPECIAL_ID", tab.getTabId());
   if (StringUtils.isNotEmpty(s1) && !s1.equalsIgnoreCase("0")) {
     context.putExtra("ITEM_ID", s1);
   } else {
     context.putExtra("ITEM_ID", tab.getItemId());
   }
   if (StringUtils.isNotEmpty(s) && !s.equalsIgnoreCase("0")) {
     context.putExtra("SECTION_ID", s);
   } else {
     context.putExtra("SECTION_ID", tab.getSectionId());
   }
   context.putExtra("USE_NATIVE_BROWSER", tab.isOpenInSafari());
   context.putExtra("TAB_FRAGMENT", tab.getViewController());
   return context;
 }
예제 #5
0
 @Test
 public void testIsNotEmpty() {
   assertTrue(StringUtils.isNotEmpty("test!"));
   assertTrue(StringUtils.isNotEmpty("t !"));
   assertTrue(StringUtils.isNotEmpty(" test!"));
   assertFalse(StringUtils.isNotEmpty(" "));
   assertFalse(StringUtils.isNotEmpty(null));
   assertFalse(StringUtils.isNotEmpty("     "));
 }
예제 #6
0
 public static <T> T newInstance(Class<T> clazz, Object... parameters) {
   T objetc = null;
   try {
     if (StringUtils.isNotEmpty(clazz)) {
       if (parameters != null && parameters.length > 0) {
         Class<?>[] classs = new Class<?>[parameters.length];
         for (int i = 0; i < classs.length; i++) {
           classs[i] = parameters[i].getClass();
         }
         Constructor<T> constructor = clazz.getConstructor(classs);
         objetc = constructor.newInstance(parameters);
       } else {
         objetc = clazz.newInstance();
       }
     }
   } catch (Exception e) {
     logger.error(e.getMessage(), e);
   }
   return objetc;
 }
예제 #7
0
  /**
   * 添加会议网站基本信息
   *
   * @param mapping
   * @param form
   * @param request
   * @param response
   * @return
   * @throws Exception
   */
  protected ActionForward doSiteSetting(
      final ActionMapping mapping,
      final ActionForm form,
      final HttpServletRequest request,
      final HttpServletResponse response)
      throws Exception {
    LangForm lform = (LangForm) form;
    LangBean lbean = null;
    ActionMessages msgs = new ActionMessages();
    // 判断用户是否登录
    UserBean loginUser = super.getLoginUser(request, response);
    if (loginUser == null) msgs.add("err", new ActionMessage("error.need_login"));
    else if (loginUser.getIsAdmin() != UserBean.TRUE)
      msgs.add("err", new ActionMessage("error.can_not_access"));
    else {
      try {
        Timestamp ts = new Timestamp(System.currentTimeMillis());

        int id = 1;
        String languange = StringUtils.exportString(request.getParameter("languange"));
        if (languange.equals("zh_cn")) {
          id = LangBean.LANG_ZH_CN;
        }
        if (languange.equals("zh_tw")) {
          id = LangBean.LANG_ZH_TW;
        }
        if (languange.equals("english")) {
          id = LangBean.LANG_ENGLISH;
        }
        boolean isSave = false;
        // 从数据库中读取设置信息
        lbean = LangDAO.getLangByID(id);
        if (lbean == null) {
          lbean = new LangBean();
          lbean.setId(id);
          isSave = true;
        }

        // 利用表单数据修改数据对象

        String publishId = StringUtils.exportString(request.getParameter("publishId")); // 获取是否发布
        String template = StringUtils.exportString(request.getParameter("template")); // 获得所选模板
        String isdefault = request.getParameter("isdefault");
        if (StringUtils.exportString(isdefault).equals("")) {
          isdefault = LangBean.LANG_PUBLISHED_NOT + "";
        }
        if (StringUtils.isNotEmpty(languange)) lbean.setLanguange(languange);
        lbean.setIsDefault(Integer.parseInt(isdefault));
        if (StringUtils.isNotEmpty(lform.getConfname())) lbean.setConfName(lform.getConfname());
        if (StringUtils.isNotEmpty(lform.getShortname())) lbean.setShortName(lform.getShortname());
        if (StringUtils.isNotEmpty(lform.getCopyright())) lbean.setCopyright(lform.getCopyright());
        if (StringUtils.isNotEmpty(lform.getEmail())) lbean.setEmail(lform.getEmail());
        if (lform.getShow1() != 0 || lform.getShow1() != 1) lbean.setShow1(lform.getShow1());
        if (lform.getShow2() != 0 || lform.getShow2() != 1) lbean.setShow2(lform.getShow2());
        lbean.setCreateTime(ts);
        lbean.setUpdateTime(ts);
        if (StringUtils.isNotEmpty(publishId))
          lbean.setPublished(LangBean.LANG_PUBLISHED); // 如果取值不为空,则发布
        if (StringUtils.isNotEmpty(template)) lbean.setTemplate(template);
        // 保存入数据库
        if (isSave) {
          LangDAO.createLang(lbean);
        } else {
          LangDAO.updateLang(lbean);
        }

      } catch (Exception e) {
        msgs.add("err", new ActionMessage("error.db"));
        log.error("database error when save site_setting", e);
      }
    }
    if (!msgs.isEmpty()) {
      saveMessages(request, msgs);
      return mapping.findForward("error");
    }

    request.setAttribute("lang", lbean);
    String fromPage = lform.getFromPage();
    if (StringUtils.isNotEmpty(fromPage)) return new ActionForward(fromPage);

    return mapping.findForward("home.site");
  }
예제 #8
0
  private void customizeNodes(ConfigProcessor processor, CIJob job)
      throws JDOMException, PhrescoException {

    // SVN url customization
    if (SVN.equals(job.getRepoType())) {
      S_LOGGER.debug("This is svn type project!!!!!");
      processor.changeNodeValue(SCM_LOCATIONS_REMOTE, job.getSvnUrl());
    } else if (GIT.equals(job.getRepoType())) {
      S_LOGGER.debug("This is git type project!!!!!");
      processor.changeNodeValue(SCM_USER_REMOTE_CONFIGS_URL, job.getSvnUrl());
      processor.changeNodeValue(SCM_BRANCHES_NAME, job.getBranch());
      // cloned workspace
    } else if (CLONED_WORKSPACE.equals(job.getRepoType())) {
      S_LOGGER.debug("Clonned workspace selected!!!!!!!!!!");
      processor.useClonedScm(job.getUsedClonnedWorkspace(), SUCCESSFUL);
    }

    // Schedule expression customization
    processor.changeNodeValue(TRIGGERS_SPEC, job.getScheduleExpression());

    // Triggers Implementation
    List<String> triggers = job.getTriggers();

    processor.createTriggers(TRIGGERS, triggers, job.getScheduleExpression());

    // if the technology is java stanalone and functional test , goal have to specified in post
    // build step only
    if (job.isEnablePostBuildStep() && FUNCTIONAL_TEST.equals(job.getOperation())) {
      // Maven command customization
      processor.changeNodeValue(GOALS, CI_FUNCTIONAL_ADAPT.trim());
    } else {
      // Maven command customization
      processor.changeNodeValue(GOALS, job.getMvnCommand());
    }

    // Recipients customization
    Map<String, String> email = job.getEmail();

    // Failure Reception list
    processor.changeNodeValue(
        TRIGGER_FAILURE_EMAIL_RECIPIENT_LIST, (String) email.get(FAILURE_EMAILS));

    // Success Reception list
    processor.changeNodeValue(
        TRIGGER_SUCCESS__EMAIL_RECIPIENT_LIST, (String) email.get(SUCCESS_EMAILS));

    // enable collabnet file release plugin integration
    if (job.isEnableBuildRelease()) {
      S_LOGGER.debug("Enablebling collabnet file release plugin ");
      processor.enableCollabNetBuildReleasePlugin(job);
    }

    // use clonned scm
    if (CLONED_WORKSPACE.equals(job.getRepoType())) {
      S_LOGGER.debug("using cloned workspace ");
      processor.useClonedScm(job.getUsedClonnedWorkspace(), SUCCESSFUL);
    }

    // clone workspace for future use
    if (job.isCloneWorkspace()) {
      S_LOGGER.debug("Clonning the workspace ");
      processor.cloneWorkspace(ALL_FILES, SUCCESSFUL, TAR);
    }

    // Build Other projects
    if (StringUtils.isNotEmpty(job.getDownStreamProject())) {
      S_LOGGER.debug("Enabling downstream project!!!!!!");
      processor.buildOtherProjects(job.getDownStreamProject());
    }

    // pom location specifier
    if (StringUtils.isNotEmpty(job.getPomLocation())) {
      S_LOGGER.debug("POM location changing " + job.getPomLocation());
      processor.updatePOMLocation(job.getPomLocation());
    }

    if (job.isEnablePostBuildStep()) {
      System.out.println("java stanalone technology with functional test enabled!!!!!!!");
      String mvnCommand = job.getMvnCommand();
      String[] ciAdapted =
          mvnCommand.split(CI_FUNCTIONAL_ADAPT); // java stanalone functional test alone
      for (String ciCommand : ciAdapted) {
        S_LOGGER.debug("ciCommand...." + ciCommand);
      }
      // iterate over loop
      processor.enablePostBuildStep(job.getPomLocation(), ciAdapted[1]);
    }

    if (job.isEnablePreBuildStep()) {
      System.out.println("java stanalone technology with functional test enabled!!!!!!!");
      // iterate over loop
      List<String> prebuildStepCommands = job.getPrebuildStepCommands();
      for (String prebuildStepCommand : prebuildStepCommands) {
        processor.enablePreBuildStep(job.getPomLocation(), prebuildStepCommand);
      }
    }
  }