示例#1
0
  private MessageBundle createMessageBundle(
      final ApplicationKey applicationKey, final Locale locale) {
    final Properties props = new Properties();

    if (locale == null) {
      props.putAll(loadBundle(applicationKey, ""));
      return new MessageBundleImpl(props);
    }

    String lang = locale.getLanguage();
    String country = locale.getCountry();
    String variant = locale.getVariant();

    props.putAll(loadBundle(applicationKey, ""));

    if (StringUtils.isNotEmpty(lang)) {
      lang = lang.toLowerCase();
      props.putAll(loadBundle(applicationKey, DELIMITER + lang));
    }

    if (StringUtils.isNotEmpty(country)) {
      props.putAll(loadBundle(applicationKey, DELIMITER + lang + DELIMITER + country));
    }

    if (StringUtils.isNotEmpty(variant)) {
      variant = variant.toLowerCase();
      props.putAll(
          loadBundle(applicationKey, DELIMITER + lang + DELIMITER + country + DELIMITER + variant));
    }

    return new MessageBundleImpl(props);
  }
示例#2
0
  /**
   * Returns true if a script with the specified type and language attributes is actually
   * JavaScript. According to <a href="http://www.w3.org/TR/REC-html40/types.html#h-6.7">W3C
   * recommendation</a> are content types case insensitive.<b> IE supports only a limited number of
   * values for the type attribute. For testing you can use
   * http://www.robinlionheart.com/stds/html4/scripts.
   *
   * @param typeAttribute the type attribute specified in the script tag
   * @param languageAttribute the language attribute specified in the script tag
   * @return true if the script is JavaScript
   */
  boolean isJavaScript(final String typeAttribute, final String languageAttribute) {
    if (StringUtils.isNotEmpty(typeAttribute)) {
      if ("text/javascript".equalsIgnoreCase(typeAttribute)
          || "text/ecmascript".equalsIgnoreCase(typeAttribute)) {
        return true;
      }

      final boolean appJavascriptSupported =
          getPage()
              .getWebClient()
              .getBrowserVersion()
              .hasFeature(BrowserVersionFeatures.HTMLSCRIPT_APPLICATION_JAVASCRIPT);
      if (appJavascriptSupported
          && ("application/javascript".equalsIgnoreCase(typeAttribute)
              || "application/ecmascript".equalsIgnoreCase(typeAttribute)
              || "application/x-javascript".equalsIgnoreCase(typeAttribute))) {
        return true;
      }
      return false;
    }

    if (StringUtils.isNotEmpty(languageAttribute)) {
      return StringUtils.startsWithIgnoreCase(languageAttribute, "javascript");
    }
    return true;
  }
示例#3
0
  @RequestMapping(value = "/searchActs")
  public String searchActs(HttpServletRequest request, Model model, SearchActForm form) {
    if (null != form
        && StringUtils.isNotEmpty(form.getStartDate())
        && StringUtils.isNotEmpty(form.getEndDate())) {
      try {
        Date startDate = DateUtils.parseDate(form.getStartDate(), new String[] {"yyyy-MM-dd"});
        Date endDate = DateUtils.parseDate(form.getEndDate(), new String[] {"yyyy-MM-dd"});

        PagerManager pager =
            new PagerManager(form.getPageId(), 10, actService.countNewActs(startDate, endDate));
        List<Act> actList =
            actService.searchNewActs(
                startDate, endDate, form.getOrder(), pager.getFirstResult(), pager.getMaxResult());
        List<CmsActView> viewList = new ArrayList<CmsActView>(actList.size());
        for (Act act : actList) {
          viewList.add(
              new CmsActView(
                  act,
                  actService.listSynonymActs(act.getId()),
                  actService.isShieldAct(act.getId())));
        }
        model.addAttribute("cmsActViewList", viewList);
        model.addAttribute("pager", pager);
      } catch (ParseException e) {
        log.error("parse search date error.", e);
      }
      model.addAttribute("searchActForm", form);
    }
    return "cms/act_list";
  }
  /** {@inheritDoc} */
  @Override
  public void transform(final Criteria criteria, final SearchCriteria searchCrit) {
    final PatientSearchCriteria crit = (PatientSearchCriteria) searchCrit;

    // Nom
    if (StringUtils.isNotEmpty(crit.getNom())) {
      CriteriaMakerUtils.addSqlCritere(criteria, "this_.nom", crit.getNom());
    }

    // Prénom
    if (StringUtils.isNotEmpty(crit.getPrenom())) {
      CriteriaMakerUtils.addSqlCritere(criteria, "this_.prenom", crit.getPrenom());
    }

    // Prénom
    if (StringUtils.isNotEmpty(crit.getInitiales())) {
      CriteriaMakerUtils.addSqlCritere(criteria, "this_.initiales", crit.getInitiales());
    }

    // Numéro IPP
    if (StringUtils.isNotEmpty(crit.getNumeroIpp())) {
      CriteriaMakerUtils.addSqlCritere(criteria, "this_.numeroIpp", crit.getNumeroIpp());
    }

    // Numéro IPP
    if (StringUtils.isNotEmpty(crit.getNumeroIppExact())) {
      CriteriaMakerUtils.addCritere(criteria, "numeroIpp", crit.getNumeroIppExact());
    }

    this.handleCriteriaEssai(criteria, crit);

    this.handleCriteriaByTypeInclusion(criteria, crit);

    this.handleCriteriaNumeroIppOrNomOrPrenom(criteria, crit);
  }
  private void addJsonParameters(
      String propertyName, List<IOParameter> parameterList, ObjectNode propertiesNode) {
    ObjectNode parametersNode = objectMapper.createObjectNode();
    ArrayNode itemsNode = objectMapper.createArrayNode();
    for (IOParameter parameter : parameterList) {
      ObjectNode parameterItemNode = objectMapper.createObjectNode();
      if (StringUtils.isNotEmpty(parameter.getSource())) {
        parameterItemNode.put(PROPERTY_IOPARAMETER_SOURCE, parameter.getSource());
      } else {
        parameterItemNode.putNull(PROPERTY_IOPARAMETER_SOURCE);
      }
      if (StringUtils.isNotEmpty(parameter.getTarget())) {
        parameterItemNode.put(PROPERTY_IOPARAMETER_TARGET, parameter.getTarget());
      } else {
        parameterItemNode.putNull(PROPERTY_IOPARAMETER_TARGET);
      }
      if (StringUtils.isNotEmpty(parameter.getSourceExpression())) {
        parameterItemNode.put(
            PROPERTY_IOPARAMETER_SOURCE_EXPRESSION, parameter.getSourceExpression());
      } else {
        parameterItemNode.putNull(PROPERTY_IOPARAMETER_SOURCE_EXPRESSION);
      }

      itemsNode.add(parameterItemNode);
    }

    parametersNode.put("totalCount", itemsNode.size());
    parametersNode.put(EDITOR_PROPERTIES_GENERAL_ITEMS, itemsNode);
    propertiesNode.put(propertyName, parametersNode);
  }
示例#6
0
  @Override
  public void close() {
    if (mbean != null) {
      String srvName = regionName + "-" + indexName;
      String oname = MBeanHelper.createMBeanName("index", srvName);
      GemliteNode.getInstance().unRegisterBean(oname);
      mbean = null;
    }

    if (StringUtils.isNotEmpty(indexName)) indexName = null;
    if (StringUtils.isNotEmpty(indexDef)) indexDef = null;
    if (StringUtils.isNotEmpty(regionName)) regionName = null;

    if (loader != null) {
      loader.clean();
      loader = null;
    }
    if (indexTool != null) {
      IndexTool tool = (IndexTool) indexTool;
      tool.clear();
      indexTool = null;
      indexData = null;
    }

    if (testIndexTool != null) testIndexTool = null;
    if (testIndexData != null) {
      ((Map<?, ?>) testIndexData).clear();
      testIndexData = null;
    }
  }
  public LocationLevel createLocationLevel(String locationName, String locationLevelName) {
    LocationLevel locationLevel = null;
    if (StringUtils.isNotEmpty(locationName) && StringUtils.isNotEmpty(locationLevelName)) {
      String[] locations = locationName.split("/");
      String[] locationLevels = locationLevelName.split("/");
      String locName = "";
      String levelName = "";
      if (locations.length > 0) {
        locName = locations[0];
        levelName = locationLevels[0];
        if (locationName.contains("/")) {
          locationName = locationName.replaceFirst(locations[0] + "/", "");
        } else {
          locationName = locationName.replace(locations[0], "");
        }

        if (locationLevelName.contains("/")) {
          locationLevelName = locationLevelName.replaceFirst(locationLevels[0] + "/", "");
        } else {
          locationLevelName = locationLevelName.replace(locationLevels[0], "");
        }
        if (locName != null && locations.length != 0) {
          locationLevel = new LocationLevel();
          locationLevel.setLevel(levelName);
          locationLevel.setName(locName);
          locationLevel.setLocationLevel(createLocationLevel(locationName, locationLevelName));
        }
      }
    }
    return locationLevel;
  }
示例#8
0
  /**
   * Adding valves with imposing implicit valves ordering makes sure that adding a new valve with
   * before and after constrainst can *never* reshuffle existing valves. Thus for example, if you
   * already have the valves a,b,c,d,e in that order, then, adding a valve 'f' before c and after a
   * can never change the relative order of the already present valves
   */
  private void addValvesIntoObjectOrdererWithImposingImplicitOrdering(
      ObjectOrderer<Valve> valveOrderer, final Valve[] valves) {
    String prevOrderableValveName = null;

    for (Valve valve : valves) {
      final String valveName;
      String afterValves = null;
      String beforeValves = null;

      if (valve instanceof OrderableValve) {
        OrderableValve orderableValve = (OrderableValve) valve;
        valveName = StringUtils.defaultIfEmpty(orderableValve.getValveName(), valve.toString());

        if (StringUtils.isNotEmpty(orderableValve.getAfterValves())) {
          afterValves = orderableValve.getAfterValves();
        }

        if (StringUtils.isNotEmpty(orderableValve.getBeforeValves())) {
          beforeValves = orderableValve.getBeforeValves();
        }
      } else {
        valveName = valve.toString();
      }

      if (prevOrderableValveName != null && afterValves == null && beforeValves == null) {
        // imply implicit ordering
        afterValves = prevOrderableValveName;
      }

      valveOrderer.add(valve, valveName, afterValves, beforeValves);

      prevOrderableValveName = valveName;
    }
  }
示例#9
0
  // 产品搜索
  @WebMethod
  public ModelAndView searchGoods(Page<Map> page, String name, Integer uid) {
    ModelAndView mv = new ModelAndView();
    StringBuilder sql =
        new StringBuilder(
            "select goods.id as id , goods.title as title , img.path as img , goods.spec as spec , goods.vender as vender , goods.price as price from Goods goods , Image img  where goods.imgId=img.id ");
    List<Object> params = new ArrayList<Object>();
    if (StringUtils.isNotEmpty(name)) {
      System.out.println(name);
      sql.append(" and title like ?");
      params.add("%" + name + "%");
    }
    page.order = "desc";
    page.orderBy = "addtime";
    page.setPageSize(10);
    page = dao.findPage(page, sql.toString(), true, params.toArray());

    if (StringUtils.isNotEmpty(name)) {
      SearchHistory search = new SearchHistory();
      search.uid = uid;
      search.text = name;
      dao.saveOrUpdate(search);
    }

    mv.data.put("page", JSONHelper.toJSON(page));
    mv.data.put(
        "imgUrl", "http://" + ConfigCache.get("image_host", "localhost") + "/article_image_path");
    mv.data.put(
        "goodsDetailUrl",
        "https://" + ConfigCache.get("app_host", "localhost") + "/goods/view.jsp");
    return mv;
  }
示例#10
0
  public boolean check(String action, String method) {
    if (!StringUtil.isBlank(action)) {
      PatternMatcher matcher = new Perl5Matcher();
      Iterator<ActionPatternHolder> iter = actionPatternList.iterator();
      while (iter.hasNext()) {
        ActionPatternHolder holder = (ActionPatternHolder) iter.next();
        if (StringUtils.isNotEmpty(action)
            && matcher.matches(action, holder.getActionPattern())
            && StringUtils.isNotEmpty(method)
            && matcher.matches(method, holder.getMethodPattern())) {
          if (logger.isDebugEnabled()) {
            logger.debug(
                "Candidate is: '"
                    + action
                    + "|"
                    + method
                    + "'; pattern is "
                    + holder.getActionName()
                    + "|"
                    + holder.getMethodName()
                    + "; matched=true");
          }
          return true;
        }
      }
    }

    return false;
  }
示例#11
0
  private void handleShowProteinDomain(Tuple request) throws Exception {
    if (StringUtils.isNotEmpty(request.getString("domain_id")))
      this.getModel().getMutationSearchCriteriaVO().setProteinDomainId(request.getInt("domain_id"));
    if (StringUtils.isNotEmpty(request.getString("snpbool")))
      if (request.getString("snpbool").equals("hide"))
        this.getModel().getMutationSearchCriteriaVO().setReportedAsSNP(false);

    SearchService searchService = ServiceLocator.instance().getSearchService();

    this.getModel()
        .setProteinDomainDTO(searchService.findProteinDomain(request.getInt("domain_id"), false));
    this.getModel()
        .setMutationSummaryDTOList(
            searchService.findMutationsByDomainId(request.getInt("domain_id")));
    ((HttpServletRequestTuple) request)
        .getRequest()
        .setAttribute("mutationSummaryVOList", this.getModel().getMutationSummaryDTOList());
    this.getModel().setRawOutput(this.include(request, this.getModel().getMutationPager()));

    this.getModel().setHeader((this.getModel().getProteinDomainDTO() == null) ? "Unknown id." : "");

    this.getModel().getMbrowse().setProteinDomainDTO(this.getModel().getProteinDomainDTO());

    if (this.getModel().getMbrowse().getExonDTOList() == null)
      this.getModel().getMbrowse().setExonDTOList(searchService.findAllExons());

    this.setView(new FreemarkerView("proteindomain.ftl", getModel()));
  }
  protected Submission.Builder submissionBuilder(
      ProcessInstance instance,
      SubmissionTemplate template,
      Entity principal,
      Submission rawSubmission) {
    String principalId = principal != null ? principal.getEntityId() : "anonymous";

    String submitterId = principalId;
    if (principal != null
        && principal.getEntityType() == Entity.EntityType.SYSTEM
        && StringUtils.isNotEmpty(template.getActAsUser())) submitterId = template.getActAsUser();
    else if (rawSubmission != null && StringUtils.isNotEmpty(rawSubmission.getSubmitterId()))
      submitterId = sanitizer.sanitize(rawSubmission.getSubmitterId());

    Submission.Builder submissionBuilder;

    if (rawSubmission != null)
      submissionBuilder = new Submission.Builder(rawSubmission, sanitizer, true);
    else
      submissionBuilder =
          new Submission.Builder()
              .actionType(instance == null ? ActionType.COMPLETE : ActionType.SAVE);

    submissionBuilder
        .processDefinitionKey(template.getProcess().getProcessDefinitionKey())
        .requestId(template.getRequestId())
        .taskId(template.getTaskId())
        .submissionDate(new Date())
        .submitter(identityService.getUser(submitterId));

    return submissionBuilder;
  }
    public void parseChildElement(XMLStreamReader xtr, BaseElement parentElement) throws Exception {
      String resourceElement = XMLStreamReaderUtil.moveDown(xtr);
      if (StringUtils.isNotEmpty(resourceElement)
          && "resourceAssignmentExpression".equals(resourceElement)) {
        String expression = XMLStreamReaderUtil.moveDown(xtr);
        if (StringUtils.isNotEmpty(expression) && "formalExpression".equals(expression)) {
          List<String> assignmentList = new ArrayList<String>();
          String assignmentText = xtr.getElementText();
          if (assignmentText.contains(",")) {
            String[] assignmentArray = assignmentText.split(",");
            assignmentList = Arrays.asList(assignmentArray);
          } else {
            assignmentList.add(assignmentText);
          }
          for (String assignmentValue : assignmentList) {
            if (assignmentValue == null) continue;
            assignmentValue = assignmentValue.trim();
            if (assignmentValue.length() == 0) continue;

            if (assignmentValue.trim().startsWith("user(")) {
              ((UserTask) parentElement).getCandidateUsers().add(assignmentValue);

            } else {
              ((UserTask) parentElement).getCandidateGroups().add(assignmentValue);
            }
          }
        }
      }
    }
示例#14
0
  /**
   * Attempts to get the text value of the first text node under <code>Element</code> that matches
   * the nodeName/subNodeName path.
   *
   * @param element Parent <code>Element</code> object
   * @param nodeName Name of the node that will be searched among element's children
   * @param subNodeName Name of the node that will be searched among nodeName's children, if a node
   *     with name=nodeName is identified under element
   * @return String value of the first text child that matches
   */
  public static String getSubNodeValue(
      final Element element, final String nodeName, final String subNodeName) {
    String subNodeValue = "";

    if (element != null
        && StringUtils.isNotEmpty(nodeName)
        && StringUtils.isNotEmpty(subNodeName)) {
      try {
        subNodeValue =
            (String)
                XPATH.evaluate(
                    new StringBuilder(nodeName)
                        .append("[1]/")
                        .append(subNodeName)
                        .append("[1]/text()[1]")
                        .toString(),
                    element,
                    XPathConstants.STRING);
      } catch (final XPathExpressionException e) {
        subNodeValue = "";
      }
    }

    return subNodeValue;
  }
  protected B2BPermissionData populateB2BPermissionDataFromForm(
      final B2BPermissionForm b2BPermissionForm) throws ParseException {
    final B2BPermissionData b2BPermissionData = new B2BPermissionData();
    b2BPermissionData.setOriginalCode(b2BPermissionForm.getOriginalCode());
    final String permissionCode = b2BPermissionForm.getCode();
    if (StringUtils.isNotEmpty(permissionCode)) {
      b2BPermissionData.setCode(permissionCode);
    } else {
      b2BPermissionData.setCode(assignPermissionName(b2BPermissionForm));
    }
    final B2BPermissionTypeData b2BPermissionTypeData =
        b2BPermissionForm.getB2BPermissionTypeData();
    b2BPermissionData.setB2BPermissionTypeData(b2BPermissionTypeData);
    final CurrencyData currencyData = new CurrencyData();
    currencyData.setIsocode(b2BPermissionForm.getCurrency());
    b2BPermissionData.setCurrency(currencyData);

    b2BPermissionData.setUnit(
        companyB2BCommerceFacade.getUnitForUid(b2BPermissionForm.getParentUnitName()));
    final String permissionTimespan = b2BPermissionForm.getTimeSpan();
    if (StringUtils.isNotEmpty(permissionTimespan)) {
      b2BPermissionData.setPeriodRange(B2BPeriodRange.valueOf(b2BPermissionForm.getTimeSpan()));
    }
    final String monetaryValue = b2BPermissionForm.getValue();
    if (StringUtils.isNotEmpty(monetaryValue)) {
      b2BPermissionData.setValue(
          Double.valueOf(formatFactory.createNumberFormat().parse(monetaryValue).doubleValue()));
    }
    return b2BPermissionData;
  }
示例#16
0
  @Inject
  public SeyrenMailSender(SeyrenConfig seyrenConfig) {

    int port = seyrenConfig.getSmtpPort();
    String host = seyrenConfig.getSmtpHost();
    String username = seyrenConfig.getSmtpUsername();
    String password = seyrenConfig.getSmtpPassword();
    String protocol = seyrenConfig.getSmtpProtocol();

    setPort(port);
    setHost(host);

    Properties props = new Properties();
    if (StringUtils.isNotEmpty(username) && StringUtils.isNotEmpty(password)) {
      props.setProperty("mail.smtp.auth", "true");
      setUsername(username);
      setPassword(password);
    }

    if (getPort() == 587) {
      props.put("mail.smtp.starttls.enable", "true");
    }

    if (props.size() > 0) {
      setJavaMailProperties(props);
    }

    setProtocol(protocol);

    LOGGER.info("{}:{}@{}", username, password, host);
  }
示例#17
0
 @SuppressWarnings("unchecked")
 @Transactional(readOnly = true)
 @Cacheable("shipping")
 public Map<String, Object> query(Shipping shipping) {
   Setting setting = SettingUtils.get();
   Map<String, Object> data = new HashMap<String, Object>();
   if (shipping != null
       && StringUtils.isNotEmpty(setting.getKuaidi100Key())
       && StringUtils.isNotEmpty(shipping.getDeliveryCorpCode())
       && StringUtils.isNotEmpty(shipping.getTrackingNo())) {
     try {
       ObjectMapper mapper = new ObjectMapper();
       URL url =
           new URL(
               "http://api.kuaidi100.com/api?id="
                   + setting.getKuaidi100Key()
                   + "&com="
                   + shipping.getDeliveryCorpCode()
                   + "&nu="
                   + shipping.getTrackingNo()
                   + "&show=0&muti=1&order=asc");
       data = mapper.readValue(url, Map.class);
     } catch (Exception e) {
       e.printStackTrace();
     }
   }
   return data;
 }
示例#18
0
 /**
  * 我发起的签到记录
  *
  * @return
  */
 @RequestMapping(
     value = "getMyLaunchSignRecord",
     method = {RequestMethod.GET, RequestMethod.POST})
 public @ResponseBody DataResult getMyLaunchSignRecord() {
   String spageIndex = HttpRequestUtil.getInstance().getString("pageIndex");
   String spageSize = HttpRequestUtil.getInstance().getString("pageSize");
   String type = HttpRequestUtil.getInstance().getString("type");
   int pageIndex = -1;
   int pageSize = -1;
   if (StringUtils.isNotEmpty(spageIndex)) {
     pageIndex = Integer.valueOf(spageIndex);
   }
   if (StringUtils.isNotEmpty(spageSize)) {
     pageSize = Integer.valueOf(spageSize);
   }
   Sign sign = new Sign();
   Map<String, Object> params = new HashMap<String, Object>();
   // params.put("userId",
   // SystemCacheUtil.getInstance().getCurrentUser().getUserid());
   sign.setUserId(SystemCacheUtil.getInstance().getCurrentUser().getUserid());
   if ("0".equals(type)) {
     params.put("isNoEnd", true);
   } else if ("1".equals(type)) {
     params.put("isEnd", true);
   }
   return signService.querySignRecord(sign, params, pageIndex, pageSize);
 }
示例#19
0
  public QueryFilter(HttpServletRequest request) {
    this.request = request;
    Enumeration<?> paramEnu = request.getParameterNames();
    while (paramEnu.hasMoreElements()) {
      String paramName = (String) paramEnu.nextElement();

      if (paramName.startsWith("Q_")) {
        String paramValue = request.getParameter(paramName);
        addFilter(paramName, paramValue);
      }
    }

    Integer start = Integer.valueOf(0);
    Integer limit = PagingBean.DEFAULT_PAGE_SIZE;

    String s_start = request.getParameter("start");
    String s_limit = request.getParameter("limit");
    if (StringUtils.isNotEmpty(s_start)) {
      start = new Integer(s_start);
    }
    if (StringUtils.isNotEmpty(s_limit)) {
      limit = new Integer(s_limit);
    }

    String sort = request.getParameter("sort");
    String dir = request.getParameter("dir");

    if ((StringUtils.isNotEmpty(sort)) && (StringUtils.isNotEmpty(dir))) {
      addSorted(sort, dir);
    }

    this.pagingBean = new PagingBean(start.intValue(), limit.intValue());
  }
示例#20
0
 /**
  * 添加cookie
  *
  * @param request HttpServletRequest
  * @param response HttpServletResponse
  * @param name cookie名称
  * @param value cookie�?
  * @param maxAge 有效�?单位: �?
  * @param path 路径
  * @param domain �?
  * @param secure 是否启用加密
  */
 public static void addCookie(
     HttpServletRequest request,
     HttpServletResponse response,
     String name,
     String value,
     Integer maxAge,
     String path,
     String domain,
     Boolean secure) {
   Assert.notNull(request);
   Assert.notNull(response);
   Assert.hasText(name);
   try {
     name = URLEncoder.encode(name, "UTF-8");
     value = URLEncoder.encode(value, "UTF-8");
     Cookie cookie = new Cookie(name, value);
     if (maxAge != null) {
       cookie.setMaxAge(maxAge);
     }
     if (StringUtils.isNotEmpty(path)) {
       cookie.setPath(path);
     }
     if (StringUtils.isNotEmpty(domain)) {
       cookie.setDomain(domain);
     }
     if (secure != null) {
       cookie.setSecure(secure);
     }
     response.addCookie(cookie);
   } catch (UnsupportedEncodingException e) {
     e.printStackTrace();
   }
 }
  public static String getViewPathsRegexp(String[] loadRules, boolean isUnix) {
    // Note - the logic here to do ORing to match against *any* of the load rules is, quite frankly,
    // hackishly ugly. I'm embarassed by it. But it's what I've got for right now.
    String filterRegexp = "";
    if (loadRules != null) {
      String tempFilterRules = "";
      for (String loadRule : loadRules) {
        if (StringUtils.isNotEmpty(loadRule)) {
          if (loadRule.endsWith("/") || loadRule.endsWith("\\")) {
            loadRule = loadRule.substring(0, loadRule.length() - 1);
          }
          loadRule = PathUtil.convertPathForOS(loadRule, isUnix);
          tempFilterRules += "|" + Pattern.quote(loadRule + PathUtil.fileSepForOS(isUnix));
          tempFilterRules += "|" + Pattern.quote(loadRule) + "$";
        }
      }

      // Adding tweak for ignoring leading slashes or Windows drives in case of strange situations
      // using setview.
      if (StringUtils.isNotEmpty(tempFilterRules)) {
        filterRegexp = tempFilterRules.substring(1);
      }
    }
    return filterRegexp;
  }
  @Override
  protected void writeAdditionalAttributes(BaseElement element, XMLStreamWriter xtw)
      throws Exception {

    ServiceTask serviceTask = (ServiceTask) element;

    if (ImplementationType.IMPLEMENTATION_TYPE_CLASS.equals(serviceTask.getImplementationType())) {
      writeQualifiedAttribute(ATTRIBUTE_TASK_SERVICE_CLASS, serviceTask.getImplementation(), xtw);
    } else if (ImplementationType.IMPLEMENTATION_TYPE_EXPRESSION.equals(
        serviceTask.getImplementationType())) {
      writeQualifiedAttribute(
          ATTRIBUTE_TASK_SERVICE_EXPRESSION, serviceTask.getImplementation(), xtw);
    } else if (ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION.equals(
        serviceTask.getImplementationType())) {
      writeQualifiedAttribute(
          ATTRIBUTE_TASK_SERVICE_DELEGATEEXPRESSION, serviceTask.getImplementation(), xtw);
    }

    if (StringUtils.isNotEmpty(serviceTask.getResultVariableName())) {
      writeQualifiedAttribute(
          ATTRIBUTE_TASK_SERVICE_RESULTVARIABLE, serviceTask.getResultVariableName(), xtw);
    }
    if (StringUtils.isNotEmpty(serviceTask.getType())) {
      writeQualifiedAttribute(ATTRIBUTE_TYPE, serviceTask.getType(), xtw);
    }
    if (StringUtils.isNotEmpty(serviceTask.getExtensionId())) {
      writeQualifiedAttribute(
          ATTRIBUTE_TASK_SERVICE_EXTENSIONID, serviceTask.getExtensionId(), xtw);
    }
  }
  private List<IOParameter> convertToIOParameters(String propertyName, JsonNode elementNode) {
    List<IOParameter> ioParameters = new ArrayList<IOParameter>();
    JsonNode parametersNode = getProperty(propertyName, elementNode);
    if (parametersNode != null) {
      JsonNode itemsArrayNode = parametersNode.get(EDITOR_PROPERTIES_GENERAL_ITEMS);
      if (itemsArrayNode != null) {
        for (JsonNode itemNode : itemsArrayNode) {
          JsonNode sourceNode = itemNode.get(PROPERTY_IOPARAMETER_SOURCE);
          JsonNode sourceExpressionNode = itemNode.get(PROPERTY_IOPARAMETER_SOURCE_EXPRESSION);
          if ((sourceNode != null && StringUtils.isNotEmpty(sourceNode.asText()))
              || (sourceExpressionNode != null
                  && StringUtils.isNotEmpty(sourceExpressionNode.asText()))) {

            IOParameter parameter = new IOParameter();
            if (StringUtils.isNotEmpty(getValueAsString(PROPERTY_IOPARAMETER_SOURCE, itemNode))) {
              parameter.setSource(getValueAsString(PROPERTY_IOPARAMETER_SOURCE, itemNode));
            }
            if (StringUtils.isNotEmpty(
                getValueAsString(PROPERTY_IOPARAMETER_SOURCE_EXPRESSION, itemNode))) {
              parameter.setSourceExpression(
                  getValueAsString(PROPERTY_IOPARAMETER_SOURCE_EXPRESSION, itemNode));
            }
            if (StringUtils.isNotEmpty(getValueAsString(PROPERTY_IOPARAMETER_TARGET, itemNode))) {
              parameter.setTarget(getValueAsString(PROPERTY_IOPARAMETER_TARGET, itemNode));
            }
            ioParameters.add(parameter);
          }
        }
      }
    }
    return ioParameters;
  }
示例#24
0
  /**
   * Parses a new Version object from a String.
   *
   * @param toParse The String object to parse.
   * @return A new Version object.
   * @throws Exception When there is an error parsing the String.
   */
  public static DotNetVersion parse(String toParse) throws Exception {
    Matcher m = STD_VERSION_PATT.matcher(toParse);

    if (!m.find()) {
      throw new Exception(String.format("Error parsing version from '%s'", toParse));
    }

    DotNetVersion v = new DotNetVersion();
    v.rawVersion = toParse;
    v.prefix = m.group(1);

    if (StringUtils.isNotEmpty(m.group(2))) {
      v.setMajor(m.group(2));
    }

    if (StringUtils.isNotEmpty(m.group(3))) {
      v.setMinor(m.group(3));
    }

    if (StringUtils.isNotEmpty(m.group(4))) {
      v.setBuild(m.group(4));
    }

    if (StringUtils.isNotEmpty(m.group(5))) {
      v.setRevision(m.group(5));
    }

    v.suffix = m.group(6);

    return v;
  }
  // 更新
  @Validations(
      requiredFields = {
        @RequiredFieldValidator(fieldName = "instantMessagingTitle", message = "在线客服标题不允许为空!"),
        @RequiredFieldValidator(fieldName = "instantMessagingPosition", message = "在线客服位置不允许为空!")
      })
  @InputConfig(resultName = "error")
  public String update() {
    List<InstantMessaging> allInstantMessagingList = instantMessagingService.getAllList();
    if (allInstantMessagingList != null) {
      for (InstantMessaging instantMessaging : allInstantMessagingList) {
        instantMessagingService.delete(instantMessaging);
      }
    }
    if (instantMessagingList != null) {
      for (InstantMessaging instantMessaging : instantMessagingList) {
        if (instantMessaging != null
            && StringUtils.isNotEmpty(instantMessaging.getTitle())
            && StringUtils.isNotEmpty(instantMessaging.getValue())) {
          instantMessagingService.save(instantMessaging);
        }
      }
    }

    Setting setting = SettingUtil.getSetting();
    setting.setInstantMessagingTitle(instantMessagingTitle);
    setting.setInstantMessagingPosition(instantMessagingPosition);
    setting.setIsInstantMessagingEnabled(isInstantMessagingEnabled);
    SettingUtil.updateSetting(setting);

    jobService.buildShopJs();

    redirectUrl = "instant_messaging!edit.action";
    return SUCCESS;
  }
 private void retrieveConnParameters(
     Map<String, Map<String, String>> initParams, Map<String, String> paramsMap) {
   if (paramsMap == null) {
     return;
   }
   Map<String, String> params = initParams.get(getTypeName());
   if (params != null) {
     String server = params.get(EHadoopConfProperties.HBASE_ZOOKEEPER_QUORUM.getName());
     if (StringUtils.isNotEmpty(server)) {
       paramsMap.put(ConnParameterKeys.CONN_PARA_KEY_DB_SERVER, server);
     }
     String port = params.get(EHadoopConfProperties.HBASE_ZOOKEEPER_PROPERTY_CLIENTPORT.getName());
     if (StringUtils.isNotEmpty(port)) {
       paramsMap.put(ConnParameterKeys.CONN_PARA_KEY_DB_PORT, port);
     }
     String masterPrincipal =
         params.get(EHadoopConfProperties.HBASE_MASTER_KERBEROS_PRINCIPAL.getName());
     if (StringUtils.isNotEmpty(masterPrincipal)) {
       paramsMap.put(
           ConnParameterKeys.CONN_PARA_KEY_HBASE_AUTHENTICATION_MASTERPRINCIPAL, masterPrincipal);
     }
     String regionServerPrincipal =
         params.get(EHadoopConfProperties.HBASE_REGIONSERVER_KERBEROS_PRINCIPAL.getName());
     if (StringUtils.isNotEmpty(regionServerPrincipal)) {
       paramsMap.put(
           ConnParameterKeys.CONN_PARA_KEY_HBASE_AUTHENTICATION_REGIONSERVERPRINCIPAL,
           regionServerPrincipal);
     }
   }
 }
  /**
   * Creates a new Cluster based on the specified configuration.
   *
   * @param stormConf the storm configuration.
   * @return a new a new {@link Cluster} instance.
   */
  @Override
  protected Cluster make(Map<String, Object> stormConf) {
    CassandraConf cassandraConf = new CassandraConf(stormConf);

    Cluster.Builder cluster =
        Cluster.builder()
            .withoutJMXReporting()
            .withoutMetrics()
            .addContactPoints(cassandraConf.getNodes())
            .withPort(cassandraConf.getPort())
            .withRetryPolicy(DowngradingConsistencyRetryPolicy.INSTANCE)
            .withReconnectionPolicy(
                new ExponentialReconnectionPolicy(100L, TimeUnit.MINUTES.toMillis(1)))
            .withLoadBalancingPolicy(new TokenAwarePolicy(new RoundRobinPolicy()));

    final String username = cassandraConf.getUsername();
    final String password = cassandraConf.getPassword();

    if (StringUtils.isNotEmpty(username) && StringUtils.isNotEmpty(password)) {
      cluster.withAuthProvider(new PlainTextAuthProvider(username, password));
    }

    QueryOptions options =
        new QueryOptions().setConsistencyLevel(cassandraConf.getConsistencyLevel());
    cluster.withQueryOptions(options);

    return cluster.build();
  }
  /**
   * Changes from/to dates into the range operators the lookupable dao expects ("..",">" etc) this
   * method modifies the passed in map and returns an updated search criteria map
   *
   * @param searchCriteria - map of criteria currently set for which the date criteria will be
   *     adjusted
   * @return map updated search criteria
   */
  public static Map<String, String> preprocessDateFields(Map<String, String> searchCriteria) {
    Map<String, String> fieldsToUpdate = new HashMap<String, String>();
    Map<String, String> searchCriteriaUpdated = new HashMap<String, String>(searchCriteria);
    Set<String> fieldsForLookup = searchCriteria.keySet();
    for (String propName : fieldsForLookup) {
      if (propName.startsWith(KRADConstants.LOOKUP_RANGE_LOWER_BOUND_PROPERTY_PREFIX)) {
        String from_DateValue = searchCriteria.get(propName);
        String dateFieldName =
            StringUtils.remove(propName, KRADConstants.LOOKUP_RANGE_LOWER_BOUND_PROPERTY_PREFIX);
        String to_DateValue = searchCriteria.get(dateFieldName);
        String newPropValue = to_DateValue; // maybe clean above with
        // ObjectUtils.clean(propertyValue)
        if (StringUtils.isNotEmpty(from_DateValue) && StringUtils.isNotEmpty(to_DateValue)) {
          newPropValue = from_DateValue + SearchOperator.BETWEEN + to_DateValue;
        } else if (StringUtils.isNotEmpty(from_DateValue) && StringUtils.isEmpty(to_DateValue)) {
          newPropValue = SearchOperator.GREATER_THAN_EQUAL.op() + from_DateValue;
        } else if (StringUtils.isNotEmpty(to_DateValue) && StringUtils.isEmpty(from_DateValue)) {
          newPropValue = SearchOperator.LESS_THAN_EQUAL.op() + to_DateValue;
        } // could optionally continue on else here

        fieldsToUpdate.put(dateFieldName, newPropValue);
      }
    }

    // update lookup values from found date values to update
    Set<String> keysToUpdate = fieldsToUpdate.keySet();
    for (String updateKey : keysToUpdate) {
      searchCriteriaUpdated.put(updateKey, fieldsToUpdate.get(updateKey));
    }

    return searchCriteriaUpdated;
  }
示例#29
0
  protected void drawHtmlPostSubsButtons(Writer out) throws IOException {
    Messages msgs = MessagesManager.getMessages();

    out.write(
        "<div class=\""
            + CssConstants.CSSCLASS_TABSETSAVEBAR
            + "\">\n"); //$NON-NLS-1$ //$NON-NLS-2$

    Button save = new Button();
    String saveOnclick = this.getConfigValue("saveOnclick", "mgnlDialogFormSubmit();");
    String saveLabel = this.getConfigValue("saveLabel", msgs.get("buttons.save"));
    if (StringUtils.isNotEmpty(saveOnclick) && StringUtils.isNotEmpty("saveLabel")) {
      save.setOnclick(saveOnclick); // $NON-NLS-1$ //$NON-NLS-2$
      save.setLabel(saveLabel); // $NON-NLS-1$ //$NON-NLS-2$
      out.write(save.getHtml());
    }
    Button cancel = new Button();
    cancel.setOnclick(
        this.getConfigValue("cancelOnclick", "window.close();")); // $NON-NLS-1$ //$NON-NLS-2$
    cancel.setLabel(
        this.getConfigValue(
            "cancelLabel", msgs.get("buttons.cancel"))); // $NON-NLS-1$ //$NON-NLS-2$
    out.write(cancel.getHtml());

    out.write("</div>\n"); // $NON-NLS-1$
  }
  public static ClassLoader getClassLoader(IMetadataConnection metadataConnection) {
    ClassLoader loader = null;
    if (metadataConnection != null) {
      String clusterId =
          (String)
              metadataConnection.getParameter(ConnParameterKeys.CONN_PARA_KEY_HADOOP_CLUSTER_ID);
      String distribution =
          (String)
              metadataConnection.getParameter(ConnParameterKeys.CONN_PARA_KEY_HBASE_DISTRIBUTION);
      if (EHBaseDistributions.CUSTOM.getName().equals(distribution)) {
        return getCustomClassLoader(metadataConnection);
      }
      String version =
          (String) metadataConnection.getParameter(ConnParameterKeys.CONN_PARA_KEY_HBASE_VERSION);
      if (StringUtils.isNotEmpty(distribution) && StringUtils.isNotEmpty(version)) {
        boolean useKrb =
            Boolean.valueOf(
                (String) metadataConnection.getParameter(ConnParameterKeys.CONN_PARA_KEY_USE_KRB));
        loader =
            HadoopClassLoaderFactory2.getHBaseClassLoader(clusterId, distribution, version, useKrb);
      }
    }
    if (loader == null) {
      loader = HBaseClassLoaderFactory.class.getClassLoader();
    }

    return loader;
  }