Java Code Examples for org.apache.commons.lang.StringUtils#isNumeric()

The following examples show how to use org.apache.commons.lang.StringUtils#isNumeric() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: mapr-music   File: SlugService.java    License: Apache License 2.0 6 votes vote down vote up
private Pair<String, Long> getSlugPostfixPair(String slug) {

        if (!slug.contains(SLUG_POSTFIX_DELIMITER)) {
            return new Pair<>(slug, null);
        }

        int indexOfPossiblePostfix = slug.lastIndexOf(SLUG_POSTFIX_DELIMITER);
        String possiblePostfixAsString = slug.substring(indexOfPossiblePostfix + 1, slug.length());

        if (!StringUtils.isNumeric(possiblePostfixAsString)) {
            return new Pair<>(slug, null);
        }

        // slug name has numeric postfix
        String slugNameWithoutNumericPostfix = slug.substring(0, indexOfPossiblePostfix);
        Long postfix = Long.parseLong(possiblePostfixAsString);

        return new Pair<>(slugNameWithoutNumericPostfix, postfix);
    }
 
Example 2
/**
 * Anonymize a user
 * 
 * @param request
 *            The request
 * @return The Jsp URL of the process result
 * @throws AccessDeniedException
 *             in case of invalid security token
 */
public String doAnonymizeAdminUser( HttpServletRequest request ) throws AccessDeniedException
{
    String strAdminUserId = request.getParameter( PARAMETER_USER_ID );

    if ( !StringUtils.isNumeric( strAdminUserId ) || strAdminUserId.isEmpty( ) )
    {
        return AdminMessageService.getMessageUrl( request, PROPERTY_MESSAGE_NO_ADMIN_USER_SELECTED, AdminMessage.TYPE_STOP );
    }

    int nUserId = Integer.parseInt( strAdminUserId );
    AdminUser user = AdminUserHome.findByPrimaryKey( nUserId );

    if ( user == null )
    {
        return AdminMessageService.getMessageUrl( request, PROPERTY_MESSAGE_USER_ERROR_SESSION, AdminMessage.TYPE_ERROR );
    }
    if ( !SecurityTokenService.getInstance( ).validate( request, JSP_URL_ANONYMIZE_ADMIN_USER ) )
    {
        throw new AccessDeniedException( ERROR_INVALID_TOKEN );
    }

    AdminUserService.anonymizeUser( nUserId, getLocale( ) );

    return JSP_MANAGE_USER;
}
 
Example 3
private int getLevel( String strLevelUser, String strLastName, String strFirstName, int nLineNumber, List<CSVMessageDescriptor> listMessages,
        Locale locale )
{
    int nLevelUser = 3;

    if ( StringUtils.isNotEmpty( strLevelUser ) && StringUtils.isNumeric( strLevelUser ) )
    {
        nLevelUser = Integer.parseInt( strLevelUser );
    }
    else
    {
        Object [ ] args = {
                strLastName, strFirstName, nLevelUser
        };
        String strMessage = I18nService.getLocalizedString( MESSAGE_NO_LEVEL, args, locale );
        CSVMessageDescriptor message = new CSVMessageDescriptor( CSVMessageLevel.INFO, nLineNumber, strMessage );
        listMessages.add( message );
    }
    return nLevelUser;
}
 
Example 4
Source Project: cloudstack   File: CreateNetworkACLCmd.java    License: Apache License 2.0 5 votes vote down vote up
public String getProtocol() {
    String p = protocol.trim();
    // Deal with ICMP(protocol number 1) specially because it need to be paired with icmp type and code
    if (StringUtils.isNumeric(p)) {
        int protoNumber = Integer.parseInt(p);
        if (protoNumber == 1) {
            p = "icmp";
        }
    }
    return p;
}
 
Example 5
Source Project: gocd   File: PipelineService.java    License: Apache License 2.0 5 votes vote down vote up
public Optional<Integer> resolvePipelineCounter(String pipelineName, String pipelineCounter) {
    if (JobIdentifier.LATEST.equalsIgnoreCase(pipelineCounter)) {
        PipelineIdentifier pipelineIdentifier = mostRecentPipelineIdentifier(pipelineName);
        return Optional.of(pipelineIdentifier.getCounter());
    } else if (!StringUtils.isNumeric(pipelineCounter)) {
        return Optional.empty();
    } else {
        return Optional.of(Integer.parseInt(pipelineCounter));
    }
}
 
Example 6
/**
 * Creates a hashmap with pagination vars added.
 * @return Returns a new hashmap containing the parameters
 */
// TODO Write unit tests for makeParamMapWithPagination()
public Map<String, Object> makeParamMapWithPagination() {
    Map<String, Object> params = new HashMap<String, Object>();
    String lower = processPagination();

    if (lower != null && lower.length() > 0 && StringUtils.isNumeric(lower)) {
        params.put("lower", lower);
    }

    return params;
}
 
Example 7
private String mapId(String id) {
    if (id == null || id.startsWith(CoverArtController.ALBUM_COVERART_PREFIX) ||
            id.startsWith(CoverArtController.ARTIST_COVERART_PREFIX) || StringUtils.isNumeric(id)) {
        return id;
    }

    try {
        String path = StringUtil.utf8HexDecode(id);
        MediaFile mediaFile = mediaFileService.getMediaFile(path);
        return String.valueOf(mediaFile.getId());
    } catch (Exception x) {
        return id;
    }
}
 
Example 8
/**
 * This method is used to load the policies declared in the configuration.
 *
 * @param properties    Loaded properties
 * @param extensionType Type of extension
 */
private void loadPolicyExtensions(Properties properties, String extensionType) {

    Set<Integer> count = new HashSet();
    Iterator<String> keyValues = properties.stringPropertyNames().iterator();
    while (keyValues.hasNext()) {
        String currentProp = keyValues.next();
        if (currentProp.startsWith(extensionType)) {
            String extensionNumber = currentProp.replaceFirst(extensionType + ".", "");
            if (StringUtils.isNumeric(extensionNumber)) {
                count.add(Integer.parseInt(extensionNumber));
            }
        }
    }
    //setting the number of extensionTypes as the upper bound as there can be many extension policy numbers,
    //eg: Password.policy.extensions.1, Password.policy.extensions.4, Password.policy.extensions.15
    Iterator<Integer> countIterator = count.iterator();
    while (countIterator.hasNext()) {
        Integer extensionIndex = countIterator.next();
        String className = properties.getProperty(extensionType + "." + extensionIndex);
        if (className == null) {
            continue;
        }
        try {
            Class clazz = Thread.currentThread().getContextClassLoader().loadClass(className);

            PolicyEnforcer policy = (PolicyEnforcer) clazz.newInstance();
            policy.init(getParameters(properties, extensionType, extensionIndex));

            this.policyRegistry.addPolicy(policy);
        } catch (ClassNotFoundException | IllegalAccessException | InstantiationException | SecurityException e) {
            log.error("Error while loading password policies " + className, e);
        }
    }

}
 
Example 9
/**
 * Get the server synchronization tolerance value in seconds
 *
 * @return clock skew in seconds
 */
public static int getClockSkewInSeconds() {

    String clockSkewConfigValue = IdentityUtil.getProperty(IdentityConstants.ServerConfig.CLOCK_SKEW);
    if (StringUtils.isBlank(clockSkewConfigValue) || !StringUtils.isNumeric(clockSkewConfigValue)) {
        clockSkewConfigValue = IdentityConstants.ServerConfig.CLOCK_SKEW_DEFAULT;
    }
    return Integer.parseInt(clockSkewConfigValue);
}
 
Example 10
Source Project: DataLink   File: JobScheduleController.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void run() {
    try {
        for(String fillDataStr : list) {
            Map<String, String> map = new HashMap<>();
            JobCommand command = new JobCommand();
            command.setJobId(new Long(id));
            command.setJobName(name);
            command.setType(JobCommand.Type.Start);
            map.put(FlinkerJobConfigConstant.DATAX_FILL_DATA, fillDataStr);
            Map<String, String> dyncParaMap =  FlinkerJobUtil.replaceDyncParaTofillDate(info, map);
            if (dyncParaMap != null && dyncParaMap.size() > 0) {
                command.setDynamicParam(true);
                command.setMapParam(dyncParaMap);
            }
            String msg = jobControlService.start(command, info.getTiming_target_worker());

            //等待10秒,再查询job运行结果,如果成功就继续执行,否则退出
            Thread.sleep(10 * 1000);
            if (StringUtils.isNumeric(msg)) {
                long executeId = Long.parseLong(msg);
                JobExecutionInfo executionInfo = jobService.getJobExecutionById(executeId);
                if (StringUtils.equals(executionInfo.getState(), "SUCCESSED")) {
                    //如果成功就继续
                    continue;
                }
            } else {
                //失败,退出
                break;
            }
        }
    } catch (InterruptedException e) {
        logger.error(e.getMessage(),e);
    } catch(Exception ex) {
        logger.error(ex.getMessage(),ex);
    } finally {
         fillDataSet.remove(name);
    }
}
 
Example 11
/**
 * Get the mailinglist modify page.
 * 
 * @param request
 *            the http request
 * @return the html code for the mailinglist modify page
 */
public String getModifyMailinglist( HttpServletRequest request )
{
    setPageTitleProperty( PROPERTY_MODIFY_MAILINGLIST_PAGETITLE );

    ReferenceList listWorkgroups = AdminWorkgroupService.getUserWorkgroups( getUser( ), getLocale( ) );

    String strMailingListId = request.getParameter( PARAMETER_MAILINGLIST_ID );

    if ( !StringUtils.isNumeric( strMailingListId ) )
    {
        AppLogService.error( SecurityUtil.logForgingProtect( strMailingListId ) + " is not a valid mailing list id." );

        return getManageMailinglists( request );
    }

    int nMailingListId = Integer.parseInt( strMailingListId );
    MailingList mailinglist = MailingListHome.findByPrimaryKey( nMailingListId );

    if ( mailinglist == null )
    {
        AppLogService.error( SecurityUtil.logForgingProtect( strMailingListId ) + " is not a valid mailing list id." );

        return getManageMailinglists( request );
    }

    Map<String, Object> model = new HashMap<>( );
    model.put( MARK_WORKGROUPS_LIST, listWorkgroups );
    model.put( MARK_MAILINGLIST, mailinglist );
    model.put( SecurityTokenService.MARK_TOKEN, SecurityTokenService.getInstance( ).getToken( request, TEMPLATE_MODIFY_MAILINGLIST ) );

    HtmlTemplate template = AppTemplateService.getTemplate( TEMPLATE_MODIFY_MAILINGLIST, getLocale( ), model );

    return getAdminPage( template.getHtml( ) );
}
 
Example 12
/**
 * get the timing of when the aging email notification should be sent
 */
protected Integer getCustomerAgingNotificationOnDays() {
    String daysAsString = this.getParameterService().getParameterValueAsString(CustomerAgingReportNotificationStep.class, ArParameterKeyConstants.NOTIFICATION_DAYS_PARAM_NM);
    if (!StringUtils.isNumeric(daysAsString)) {
        daysAsString = this.getParameterService().getParameterValueAsString(CustomerAgingReportDetail.class, ArConstants.CUSTOMER_INVOICE_AGE);
    }

    return Integer.parseInt(daysAsString);
}
 
Example 13
@Override
public String getUuid(final String resourceId, final ResourceObjectType resourceType) {
    if (!StringUtils.isNumeric(resourceId)) {
        return resourceId;
    }

    final Class<?> clazz = s_typeMap.get(resourceType);

    final Object entity = _entityMgr.findById(clazz, resourceId);
    if (entity != null && entity instanceof Identity) {
        return ((Identity) entity).getUuid();
    }

    return resourceId;
}
 
Example 14
Source Project: blog_demos   File: StudentServiceImpl.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * 根据结果构造一个student对象
 * @param cellArray
 * @return
 */
private static Student buildStudent(Cell[] cellArray){
    if(null==cellArray || cellArray.length<1){
        LOGGER.error("invalid cell array for build student");
        return null;
    }

    LOGGER.error("start buildStudent");

    Student student = null;

    for(Cell cell : cellArray){
        String row = new String(CellUtil.cloneRow(cell));
        String family = new String(CellUtil.cloneFamily(cell));
        String qualifier = new String(CellUtil.cloneQualifier(cell));
        String value = new String(CellUtil.cloneValue(cell));

        LOGGER.info("row [{}], family [{}], qualifier [{}], value [{}]", row, family, qualifier, value);

        if(!StringUtils.isNumeric(row)){
            LOGGER.error("invalid row for build student");
            return null;
        }

        if(null==student){
            student = new Student();
            student.setId(Long.valueOf(row));
        }

        if("info".equals(family)){
            if("age".equals(qualifier)){
                student.setAge(Integer.valueOf(value));
            } else if("name".equals(qualifier)){
                student.setName(value);
            }
        }
    }

    LOGGER.info("build : " + JSON.toJSONString(student));

    return student;
}
 
Example 15
public static String validateAndBuildTaskConfig(TaskDTO taskDTO) throws Exception {

        FlinkTaskConfigDTO flinkTaskConfigDTO = new FlinkTaskConfigDTO();
        flinkTaskConfigDTO.setTaskName(taskDTO.getTaskName());

        if(taskDTO.getIsCql() == YesOrNoEnum.NO.getValue()){
            if(StringUtils.isBlank(taskDTO.getClassPath())){
                throw new Exception("任务的类路径不能为空!");
            }
            if(StringUtils.isBlank(taskDTO.getArchiveId())){
                throw new Exception("请选择任务运行文件!");
            }
            TaskArchivePO taskArchivePO = flinkEngineService.taskArchiveDao.getTaskArchiveById(Integer.valueOf(taskDTO.getArchiveId()));
            if(taskArchivePO == null ){
                throw new Exception("任务运行文件不存在,或已经被删除!");
            }
            if(taskDTO.getArchiveVersionId()== null){
                throw new Exception("请选择任务运行文件版本!");
            }
            TaskArchiveVersionPO taskArchiveVersionPO = flinkEngineService.taskArchiveVersionDao.getTaskArchiveVersionById(Integer.valueOf(taskDTO.getArchiveVersionId()));
            if(taskArchiveVersionPO == null ){
                throw new Exception("任务运行文件包不存在,或已经被删除!");
            }
            flinkTaskConfigDTO.setProjectJarPath(taskArchiveVersionPO.getTaskArchiveVersionUrl());
            flinkTaskConfigDTO.setClassPath(taskDTO.getClassPath());
        }
        //cql 的情况
        else{
            if(StringUtils.isBlank(taskDTO.getTaskCqlId())|| Integer.valueOf(taskDTO.getTaskCqlId())<=0){
                throw new Exception("请选择CQL脚本!");
            }
            CqlPO cqlPO = flinkEngineService.cqlDao.getCqlById( Integer.valueOf(taskDTO.getTaskCqlId()));
            if(cqlPO == null){
                throw new Exception("选择的CQL脚本不存在或已经被删除!");
            }
            flinkTaskConfigDTO.setClassPath(EngineContant.FLINK_SQL_MAIN_CLASS);
            flinkTaskConfigDTO.setTaskCqlId(cqlPO.getId());
            flinkTaskConfigDTO.setTaskCql(cqlPO.getCqlText());
        }

        //处理其他参数
        if(taskDTO.getWorkerNum()==null||Integer.valueOf(taskDTO.getWorkerNum())<=0){
            throw new Exception("TaskManger 个数不能为空,并且只能为正整数!");
        }
        if(taskDTO.getWorkerMem()==null||Integer.valueOf(taskDTO.getWorkerMem())<=0){
            throw new Exception("每个 TaskManger 分配内存数不能为空,并且只能为正整数!");
        }
        if(Integer.valueOf(taskDTO.getWorkerMem()).intValue() > Integer.valueOf(YarnClientProxy.getConatinerMaxMem())){
            throw new Exception("填写的TaskManger内存数,超过container最大内存数!");
        }
        if(Integer.valueOf(taskDTO.getWorkerMem()).intValue()  < Integer.valueOf(YarnClientProxy.getConatinerMinMem())){
            throw new Exception("填写的TaskManger内存数,小于container最小内存数!");
        }

        flinkTaskConfigDTO.setCustomParams(taskDTO.getCustomParams());
        flinkTaskConfigDTO.setTaskMangerMem(Long.valueOf(taskDTO.getWorkerMem()));
        flinkTaskConfigDTO.setTaskMangerNum(Integer.valueOf(taskDTO.getWorkerNum()));
        flinkTaskConfigDTO.setSlots(Integer.valueOf(taskDTO.getSlots()));
        if(StringUtils.isNumeric(taskDTO.getParallelism())){
            flinkTaskConfigDTO.setParallelism(Integer.valueOf(taskDTO.getParallelism()));
        }
        return JSONObject.toJSONString(flinkTaskConfigDTO);
    }
 
Example 16
@Override
  protected void map(ImmutableBytesWritable key, Result value, Context context)
      throws IOException, InterruptedException {
    this.inputRecords++;
    String platform = this.getPlatform(value);
    String serverTime = this.getServerTime(value);
    String referrerUrl = this.getReferrerUrl(value);
    String sid = this.getSessionId(value);

    if (StringUtils.isBlank(platform) || StringUtils
        .isBlank(serverTime) || StringUtils
        .isBlank(referrerUrl) || StringUtils.isBlank(sid) || !StringUtils
        .isNumeric(serverTime.trim())) {
      System.out.println(Bytes.toString(value.getRow()));
      logger.warn("平台&前一个页面的会话id&servertime&referrerUrl不能为空,而且serverTime必须为时间戳");
      this.filterRecords++;
      return;
    }

    //构建inbound; 转换url为外链id
    int inboundId = 0;
    try {
      inboundId = this.getInboundIdByHost(UrlUtil.getHost(referrerUrl));
    } catch (Throwable e) {
      logger.warn("获取referrer url对应的inbound id异常: " + referrerUrl);
      inboundId = 0;
    }

    long longOfTime = Long.valueOf(serverTime.trim());
    if (longOfTime == -1) {
      //没有传s_time参数
      longOfTime = new Date().getTime();
    }

    //时间纬度创建
    DateDimension dateDimension = DateDimension.buildDate(longOfTime, DateEnum.DAY);
//
    //平台维度创建
    List<PlatformDimension> platformDimensions = PlatformDimension.buildList(platform);

    //进行输出定义
    this.outputValue.set(inboundId);
    StatsCommonDimension statsCommonDimension = this.outputKey.getStatsCommon();
    statsCommonDimension.setDate(dateDimension);
    statsCommonDimension.setKpi(this.inboundBounceKpi);

    this.outputKey.setSid(sid);
    this.outputKey.setServerTime(longOfTime);

    //输出
    for (PlatformDimension pf : platformDimensions) {
      //设置platform dimension
      statsCommonDimension.setPlatform(pf);
      context.write(this.outputKey, this.outputValue);
      this.outputRecords++;
    }

  }
 
Example 17
@Override
protected void map(ImmutableBytesWritable key, Result value, Context context)
    throws IOException, InterruptedException {
  String memberId = Bytes
      .toString(value.getValue(family, Bytes.toBytes(EventLogConstants.LOG_COLUMN_NAME_MEMBER_ID)));
  String platform = Bytes.toString(
      value.getValue(family, Bytes.toBytes(EventLogConstants.LOG_COLUMN_NAME_PLATFORM)));
  String serverTime = Bytes.toString(
      value.getValue(family, Bytes.toBytes(EventLogConstants.LOG_COLUMN_NAME_SERVER_TIME)));
  if (StringUtils.isBlank(memberId) || StringUtils.isBlank(serverTime) || StringUtils
      .isBlank(platform) || !StringUtils.isNumeric(serverTime.trim())) {
    System.out.println(Bytes.toString(value.getRow()));
    logger.warn("memberId&servertime&platform不能为空,而且serverTime必须为时间戳");
    return;
  }
  long longOfTime = Long.valueOf(serverTime.trim());
  if (longOfTime == -1) {
    //没有传s_time参数
    longOfTime = new Date().getTime();
  }
  DateDimension dateDimension = DateDimension.buildDate(longOfTime, DateEnum.DAY);
  outputValue.setId(memberId);
  List<PlatformDimension> platformDimensions = PlatformDimension.buildList(platform);
  //写browser相关的数据
  String browserName = Bytes.toString(
      value.getValue(family, Bytes.toBytes(EventLogConstants.LOG_COLUMN_NAME_BROWSER_NAME)));
  String browserVersion = Bytes.toString(
      value.getValue(family, Bytes.toBytes(EventLogConstants.LOG_COLUMN_NAME_BROWSER_VERSION)));
  List<BrowserDimension> browserDimensions = BrowserDimension
      .buildList(browserName, browserVersion);

  //开始进行输出
  StatsCommonDimension statsCommonDimension = this.outputKey.getStatsCommon();
  statsCommonDimension.setDate(dateDimension);

  for (PlatformDimension pf : platformDimensions) {
    //清空BrowserDimenson的内容
    outputKey.setBrowser(defaultBrowser);
    //设置platform dimension
    statsCommonDimension.setPlatform(pf);
    //设置kpi dimension
    statsCommonDimension.setKpi(activeMemberKpi);
    context.write(this.outputKey, this.outputValue);
    for (BrowserDimension br : browserDimensions) {
      statsCommonDimension.setKpi(activeMemberOfBrowserKpi);
      this.outputKey.setBrowser(br);
      context.write(this.outputKey, this.outputValue);
    }
  }

}
 
Example 18
public ActionForward transfer(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws FenixServiceException, FenixActionException {
    DynaActionForm dynaActionForm = (DynaActionForm) form;

    String executionCourseId = RequestUtils.getAndSetStringToRequest(request, "executionCourseId");
    String destinationExecutionCourseIdString = (String) dynaActionForm.get("destinationExecutionCourseId");
    String originExecutionDegreeId = RequestUtils.getAndSetStringToRequest(request, "originExecutionDegreeId");
    String curricularYearId = (String) dynaActionForm.get("curricularYearId");
    String[] shiftIdsToTransfer = (String[]) dynaActionForm.get("shiftIdsToTransfer");
    String[] curricularCourseIdsToTransfer = (String[]) dynaActionForm.get("curricularCourseIdsToTransfer");
    ExecutionDegree originExecutionDegree = FenixFramework.getDomainObject(originExecutionDegreeId);
    ExecutionCourse originExecutionCourse = FenixFramework.getDomainObject(executionCourseId);
    String originExecutionDegreesString = originExecutionCourse.getDegreePresentationString();
    String destinationExecutionCourseId = null;

    try {

        if (!StringUtils.isEmpty(destinationExecutionCourseIdString)
                && StringUtils.isNumeric(destinationExecutionCourseIdString)) {
            destinationExecutionCourseId = destinationExecutionCourseIdString;
        } else {
            throw new DomainException("error.selection.noDestinationExecutionCourse");
        }

        ExecutionCourse destinationExecutionCourse =
                SeperateExecutionCourse.run(executionCourseId, destinationExecutionCourseId, shiftIdsToTransfer,
                        curricularCourseIdsToTransfer);

        String destinationExecutionCourseName = destinationExecutionCourse.getNameI18N().getContent();
        if (StringUtils.isEmpty(destinationExecutionCourseName)) {
            destinationExecutionCourseName = destinationExecutionCourse.getName();
        }
        String destinationExecutionCourseCode = destinationExecutionCourse.getSigla();
        String destinationDegreeName = destinationExecutionCourse.getDegreePresentationString();
        String transferedCurricularCourses = makeObjectStringFromArray(curricularCourseIdsToTransfer, CurricularCourse.class);
        String transferedShifts;

        String successKey;
        if (shiftIdsToTransfer.length == 0) {
            successKey = "message.manager.executionCourseManagement.transferCourse.success.many.noShifts";
            transferedShifts = "";
        } else {
            successKey = "message.manager.executionCourseManagement.transferCourse.success.many";
            transferedShifts = makeObjectStringFromArray(shiftIdsToTransfer, Shift.class);
        }
        addActionMessage("success", request, successKey, transferedCurricularCourses, transferedShifts,
                destinationExecutionCourseName, destinationDegreeName, destinationExecutionCourseCode);

        // check if degree context has changed
        if (!originExecutionCourse.getExecutionDegrees().contains(originExecutionDegree)) {
            // origin execution course degree has changed (no longer on original degree)
            String originCourseName = originExecutionCourse.getNameI18N().getContent();
            if (StringUtils.isEmpty(originCourseName)) {
                originCourseName = originExecutionCourse.getName();
            }
            addActionMessage("info", request,
                    "message.manager.executionCourseManagement.transferCourse.success.switchContext", originCourseName,
                    originExecutionDegreesString, originExecutionCourse.getDegreePresentationString(),
                    destinationExecutionCourseName, destinationExecutionCourse.getDegreePresentationString(),
                    originExecutionDegree.getDegree().getSigla());
            request.setAttribute("executionCourseId", destinationExecutionCourse.getExternalId().toString());
        }

    } catch (DomainException e) {
        addActionMessage("error", request, e.getMessage(), e.getArgs());
        if (request.getAttribute("destinationExecutionDegreeId") != null) {
            request.setAttribute("destinationExecutionDegreeId", request.getAttribute("destinationExecutionDegreeId"));
        }
        if (curricularYearId != null) {
            request.setAttribute("destinationCurricularYear", curricularYearId);
        }
        if (request.getAttribute("executionCourses") != null) {
            request.setAttribute("executionCourses", request.getAttribute("executionCourses"));
        }
        if (destinationExecutionCourseId != null) {
            request.setAttribute("destinationExecutionCourseId", destinationExecutionCourseId.toString());
        }
        return changeDestinationContext(mapping, dynaActionForm, request, response);
    }

    return manageCurricularSeparation(mapping, dynaActionForm, request, response);
}
 
Example 19
@Override
protected void map(ImmutableBytesWritable key, Result value, Context context) throws IOException, InterruptedException {
    this.inputRecords++;
    // 获取platform, servertime, referrer url,sid
    String platform = this.getPlatform(value);
    String serverTime = this.getServerTime(value);
    String referrerUrl = this.getReferrerUrl(value);
    String sid = this.getSessionId(value);

    // 过滤
    if (StringUtils.isBlank(platform) || StringUtils.isBlank(serverTime) || StringUtils.isBlank(referrerUrl) || StringUtils.isBlank(sid) || !StringUtils.isNumeric(serverTime.trim())) {
        this.filterRecords++;
        logger.warn("平台&服务器时间&前一个页面的url&会话id不能为空,而且服务器时间必须为时间戳形式");
        return;
    }

    // 创建polatform
    List<PlatformDimension> platforms = PlatformDimension.buildList(platform);

    // 创建date
    long longOfTime = Long.valueOf(serverTime.trim());
    DateDimension dayOfDimension = DateDimension.buildDate(longOfTime, DateEnum.DAY);

    // 构建inbound;转换url为外链id
    int inboundId = DEFAULT_INBOUND_ID;
    try {
        inboundId = this.getInboundIdByHost(UrlUtil.getHost(referrerUrl));
    } catch (Throwable e) {
        logger.warn("获取referrer url对应的inbound id异常", e);
        inboundId = DEFAULT_INBOUND_ID;
    }

    // 输出定义
    this.outputValue.set(inboundId);
    StatsCommonDimension statsCommon = this.statsInboundBounceDimension.getStatsCommon();
    statsCommon.setDate(dayOfDimension);
    statsCommon.setKpi(this.inboundBounceKpi);
    this.statsInboundBounceDimension.setSid(sid);
    this.statsInboundBounceDimension.setServerTime(longOfTime);
    for (PlatformDimension pf : platforms) {
        statsCommon.setPlatform(pf);
        context.write(this.statsInboundBounceDimension, this.outputValue);
        this.outputRecords++;
    }
}
 
Example 20
private boolean isSet(String parameter) {
    return !StringUtils.isEmpty(parameter) && StringUtils.isNumeric(parameter);
}