Java 类com.liferay.portal.kernel.util.Validator 实例源码

项目:ch-inofix-timetracker    文件:ExportTaskRecordsMVCActionCommand.java   
@Override
protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

    _log.info("doProcessAction()");

    String cmd = ParamUtil.getString(actionRequest, Constants.CMD);

    _log.info("cmd = " + cmd);

    if (cmd.equals(Constants.DELETE)) {
        deleteBackgroundTasks(actionRequest, actionResponse);
    } else if (cmd.equals(Constants.EXPORT)) {
        exportTaskRecords(actionRequest, actionResponse);
    }

    String redirect = ParamUtil.getString(actionRequest, "redirect");

    if (Validator.isNotNull(redirect)) {
        sendRedirect(actionRequest, actionResponse, redirect);
    }
}
项目:ch-inofix-timetracker    文件:ExportImportBackgroundTaskDisplay.java   
protected String getStatusMessageKey() {
    if (Validator.isNotNull(_messageKey)) {
        return _messageKey;
    }

    _messageKey = StringPool.BLANK;

    if (hasRemoteMessage()) {
        _messageKey = "please-wait-as-the-publication-processes-on-the-remote-site";
    } else if (hasStagedModelMessage()) {
        _messageKey = "exporting";

        if (Objects.equals(_cmd, Constants.IMPORT)) {
            _messageKey = "importing";
        } else if (Objects.equals(_cmd, Constants.PUBLISH_TO_LIVE)
                || Objects.equals(_cmd, Constants.PUBLISH_TO_REMOTE)) {

            _messageKey = "publishing";
        }
    }

    return _messageKey;
}
项目:ch-inofix-timetracker    文件:TaskRecordIndexer.java   
@Override
public void postProcessSearchQuery(BooleanQuery searchQuery, BooleanFilter fullQueryBooleanFilter,
        SearchContext searchContext) throws Exception {

    boolean advancedSearch = GetterUtil.getBoolean(searchContext.getAttribute("advancedSearch"), false);

    addSearchTerm(searchQuery, searchContext, "description", false);
    if (!advancedSearch) {
        addSearchTerm(searchQuery, searchContext, "workPackage", true);
    }

    // TODO: add ticketURL

    LinkedHashMap<String, Object> params = (LinkedHashMap<String, Object>) searchContext.getAttribute("params");

    if (params != null) {
        String expandoAttributes = (String) params.get("expandoAttributes");

        if (Validator.isNotNull(expandoAttributes)) {
            addSearchExpando(searchQuery, searchContext, expandoAttributes);
        }
    }
}
项目:opencps-v2    文件:ServiceProcessActionsImpl.java   
@Override
public ProcessStep updateProcessStep(long groupId, String oldStepCode, String newStepCode, String stepName,
        long serviceProcessId, String sequenceNo, String dossierStatus, String dossierSubStatus, int durationCount,
        String customProcessUrl, String stepInstruction, String briefNote, boolean editable, ServiceContext context)
        throws PortalException {

    ProcessStep step = ProcessStepLocalServiceUtil.fetchBySC_GID(oldStepCode, groupId, serviceProcessId);

    long processStepId = 0;

    if (Validator.isNotNull(step)) {
        processStepId = step.getProcessStepId();
    }

    return ProcessStepLocalServiceUtil.updateProcessStep(groupId, processStepId, newStepCode, stepName,
            serviceProcessId, sequenceNo, dossierStatus, dossierSubStatus, durationCount, customProcessUrl,
            stepInstruction, briefNote, editable, context);
}
项目:liferay-gsearch    文件:JournalArticleItemBuilder.java   
/**
 * {@inheritDoc}
 */
@Override
public String getLink()
    throws Exception {

    String link = null;

    link = getAssetRenderer().getURLViewInContext(
        (LiferayPortletRequest) _portletRequest,
        (LiferayPortletResponse) _portletResponse, null);

    if (Validator.isNull(link)) {
        link = getNotLayoutBoundJournalArticleUrl();
    }

    return link;
}
项目:opencps-v2    文件:ApplicantLocalServiceImpl.java   
/**
 * @param appicantName
 * @param applicantIdType
 * @param applicantIdNo
 * @param applicantIdDate
 * @throws PortalException
 */
private void validateAdd(String applicantName, String applicantIdType, String applicantIdNo, String applicantIdDate)
        throws PortalException {
    if (Validator.isNull(applicantName)) {
        throw new NoApplicantNameException("NoApplicantNameException");
    }

    if (Validator.isNull(applicantIdType))
        throw new NoApplicantIdTypeException("NoApplicantIdTypeException");

    if (Validator.isNull(applicantIdNo))
        throw new NoApplicantIdNoException("NoApplicantIdNoException");

    if (Validator.isNull(applicantIdDate))
        throw new NoApplicantIdDateException("NoApplicantIdDateException");
}
项目:opencps-v2    文件:ServiceProcessLocalServiceImpl.java   
@Deprecated
private void validateUpdate(long groupId, long serviceProcessId, String processNo, String processName,
        boolean generateDossierNo, String dossierNoPattern, boolean generateDueDate, String dueDatePattern,
        ServiceContext context) throws PortalException {

    ServiceProcess spUpdate = serviceProcessPersistence.fetchByPrimaryKey(serviceProcessId);

    if (!spUpdate.getProcessNo().equals(processNo) || !spUpdate.getProcessName().equals(processName)) {
        validateAdd(groupId, serviceProcessId, processNo, processName, generateDossierNo, dossierNoPattern,
                generateDueDate, dueDatePattern, context);
    }

    if (generateDossierNo && Validator.isNull(dossierNoPattern)) {
        throw new RequiredDossierNoPatternException("RequiredDossierNoPatternException");
    }

    if (generateDueDate && Validator.isNull(dueDatePattern)) {
        throw new RequiredDueDatePatternException("RequiredDueDatePatternException");
    }

}
项目:opencps-v2    文件:DictGroupIndexer.java   
@Override
protected Document doGetDocument(DictGroup dictGroup) throws Exception {
    Document document = getBaseModelDocument(CLASS_NAME, dictGroup);

    document.addKeywordSortable(Field.COMPANY_ID, String.valueOf(dictGroup.getCompanyId()));
    document.addDateSortable(Field.MODIFIED_DATE, dictGroup.getModifiedDate());
    document.addKeywordSortable(Field.USER_ID, String.valueOf(dictGroup.getUserId()));
    document.addKeywordSortable(Field.USER_NAME, String.valueOf(dictGroup.getUserName()));

    document.addNumberSortable(DictGroupTerm.GROUP_ID, dictGroup.getGroupId());
    document.addNumberSortable(DictGroupTerm.DICT_GROUPID, dictGroup.getDictGroupId());
    document.addNumberSortable(DictGroupTerm.DICT_COLLECTIONID, dictGroup.getDictCollectionId());
    document.addTextSortable(DictGroupTerm.GROUP_CODE, dictGroup.getGroupCode());
    document.addTextSortable(DictGroupTerm.GROUP_NAME, dictGroup.getGroupName());
    document.addTextSortable(DictGroupTerm.GROUP_NAME_EN, dictGroup.getGroupNameEN());
    document.addTextSortable(DictGroupTerm.GROUP_DESCRIPTION, dictGroup.getGroupDescription());

    DictCollection dictCollection = DictCollectionLocalServiceUtil.fetchDictCollection(dictGroup.getDictCollectionId());

    String dictCollectionCode = Validator.isNotNull(dictCollection)?dictCollection.getCollectionCode():StringPool.BLANK;

    document.addTextSortable(DictGroupTerm.DICT_COLLECTION_CODE, dictCollectionCode);

    return document;
}
项目:opencps-v2    文件:ProcessStepLocalServiceImpl.java   
@Deprecated
private void validateUpdate(long groupId, long processStepId, String stepCode, long serviceProcessId,
        String sequenceNo, String dossierStatus, String dossierSubStatus, String customProcessUrl)
        throws PortalException {

    ProcessStep processStep = processStepPersistence.findByPrimaryKey(processStepId);

    if (!processStep.getStepCode().toLowerCase().contentEquals(stepCode.toLowerCase())) {
        validateAdd(groupId, processStepId, stepCode, serviceProcessId, sequenceNo, dossierStatus, dossierSubStatus,
                customProcessUrl);
    }

    if (Validator.isNotNull(customProcessUrl) && !Validator.isUrl(customProcessUrl)) {
        throw new DossierURLException("InvalidCustomProcessURL");
    }
}
项目:opencps-v2    文件:UserUtils.java   
public static UserProfileModel mapperUserProfileModel(Document document) {

        UserProfileModel ett = new UserProfileModel();

        try {

            ett.setClassName(document.get("className"));
            ett.setClassPK(document.get("classPK"));
            ett.setScreenName(document.get("screenName"));
            ett.setEmail(document.get("email"));
            ett.setFullName(document.get("fullName"));
            ett.setContactEmail(document.get("contactEmail"));
            ett.setContactTelNo(document.get("contactTelNo"));
            ett.setGender(document.get("gender"));
            ett.setBirthdate(Validator.isNotNull(document.getDate("birthdate")) ? APIDateTimeUtils
                    .convertDateToString(document.getDate("birthdate"), APIDateTimeUtils._TIMESTAMP)
                    : StringPool.BLANK);

        } catch (Exception e) {
            _log.error(e);
        }

        return ett;
    }
项目:opencps-v2    文件:ProcessStepIndexer.java   
protected String getDictItemName(long groupId, String collectionCode, String itemCode) {

        DictCollection dc = DictCollectionLocalServiceUtil.fetchByF_dictCollectionCode(collectionCode, groupId);

        String itemName = StringPool.BLANK;

        if (Validator.isNotNull(dc)) {
            DictItem it = DictItemLocalServiceUtil.fetchByF_dictItemCode(itemCode, dc.getPrimaryKey(), groupId);
            if (Validator.isNotNull(it)) {
                itemName = it.getItemName();
            } else {
                itemName = StringPool.BLANK;
            }
        }

        return itemName;
    }
项目:opencps-v2    文件:ResourceUserActions.java   
@Override
public void clone(String className, String classPK, long userId, long companyId, long groupId, String sourcePK,
        ServiceContext serviceContext)
        throws NotFoundException, UnauthenticationException, UnauthorizationException, NoSuchUserException {
    List<ResourceUser> resourceUsers = new ArrayList<>(
            ResourceUserLocalServiceUtil.findByF_className_classPK(groupId, className, classPK));

    if (Validator.isNotNull(resourceUsers) && resourceUsers.size() > 0) {
        // Nothing to do here
    } else {

        List<ResourceUser> resourceUsersSourcePK = new ArrayList<>(
                ResourceUserLocalServiceUtil.findByF_className_classPK(groupId, className, sourcePK));

        for (ResourceUser resourceUser : resourceUsersSourcePK) {

            ResourceUserLocalServiceUtil.addResourceUser(userId, groupId, className, classPK,
                    resourceUser.getToUserId(), resourceUser.getFullname(), resourceUser.getEmail(),
                    resourceUser.getReadonly(), serviceContext);
        }

    }

}
项目:opencps-v2    文件:DossierPullScheduler.java   
private void pullFormData(long desGroupId, String fileRef, String dossierTemplateNo, long dossierId,
        String formData, DossierPart part, ServiceContext serviceContext) {
    try {
        DossierFile dossierFile = DossierFileLocalServiceUtil.getDossierFileByReferenceUid(dossierId, fileRef);

        if (Validator.isNull(dossierFile)) {
            // create dossierFile
            dossierFile = DossierFileLocalServiceUtil.addDossierFile(desGroupId, dossierId,
                    PortalUUIDUtil.generate(), dossierTemplateNo, part.getPartNo(), part.getFileTemplateNo(),
                    part.getPartName(), StringPool.BLANK, 0, null, StringPool.BLANK, StringPool.FALSE,
                    serviceContext);
        }

        dossierFile.setFormData(formData);

        DossierFileLocalServiceUtil.updateDossierFile(dossierFile);

    } catch (Exception e) {
        _log.error(e);
    }
}
项目:opencps-v2    文件:DataManagementUtils.java   
public static DictCollectionModel mapperDictCollectionModel(DictCollection dictCollection) {

        DictCollectionModel ett = new DictCollectionModel();

        try {

            ett.setDictCollectionId(dictCollection.getDictCollectionId());
            ett.setCollectionCode(dictCollection.getCollectionCode());
            ett.setCollectionName(dictCollection.getCollectionName());
            ett.setCollectionNameEN(dictCollection.getCollectionNameEN());
            ett.setDescription(dictCollection.getDescription());
            ett.setCreateDate(Validator.isNotNull(dictCollection.getCreateDate())
                    ? APIDateTimeUtils.convertDateToString(dictCollection.getCreateDate(), APIDateTimeUtils._TIMESTAMP)
                    : StringPool.BLANK);
            ett.setModifiedDate(
                    Validator.isNotNull(dictCollection.getModifiedDate()) ? APIDateTimeUtils.convertDateToString(
                            dictCollection.getModifiedDate(), APIDateTimeUtils._TIMESTAMP) : StringPool.BLANK);

        } catch (Exception e) {
            _log.error(e);
        }

        return ett;
    }
项目:opencps-v2    文件:DictItemLocalServiceImpl.java   
protected String getSibling(long groupId, long dictCollectionId, long parentItemId, String sibling, int level) {

        if (parentItemId == 0) {

        } else {

            DictItem parentItem = dictItemPersistence.fetchByPrimaryKey(parentItemId);

            level = Validator.isNotNull(parentItem) ? (parentItem.getLevel() + 1) : 0;
        }

        DictItem dictItem = dictItemPersistence.fetchByF_parentItemId_level_Last(groupId, dictCollectionId,
                parentItemId, level, null);
        if ((Validator.isNotNull(dictItem) && sibling.equals("0")) || sibling.equals("0")) {
            try {
                sibling = GetterUtil.getInteger(dictItem.getSibling(), 1) + 1 + StringPool.BLANK;
            } catch (Exception e) {
                sibling = String.valueOf(1);
            }
        }
        return sibling;

    }
项目:opencps-v2    文件:DossierPaymentUtils.java   
/**
 * @param pattern
 * @param content
 * @return
 */
private static boolean _checkcontains(String pattern, String content) {

    boolean isContains = false;

    String[] splitPattern = StringUtil.split(pattern, StringPool.SPACE);

    for (String element : splitPattern) {
        if (Validator.equals(element, content)) {
            isContains = true;
            break;

        }
    }

    return isContains;
}
项目:ch-inofix-timetracker    文件:TaskRecordActivityInterpreter.java   
@Override
protected String getTitlePattern(String groupName, SocialActivity activity) {

    _log.info("getTitlePattern");

    int activityType = activity.getType();

    if (activityType == TaskRecordActivityKeys.ADD_TASK_RECORD) {
        if (Validator.isNull(groupName)) {
            return "activity-task-record-add-task-record";
        } else {
            return "activity-task-record-add-task-record-in";
        }
    } else if (activityType == SocialActivityConstants.TYPE_MOVE_TO_TRASH) {
        if (Validator.isNull(groupName)) {
            return "activity-task-record-move-to-trash";
        } else {
            return "activity-task-record-move-to-trash-in";
        }
    } else if (activityType == SocialActivityConstants.TYPE_RESTORE_FROM_TRASH) {

        if (Validator.isNull(groupName)) {
            return "activity-task-record-restore-from-trash";
        } else {
            return "activity-task-record-restore-from-trash-in";
        }
    } else if (activityType == TaskRecordActivityKeys.UPDATE_TASK_RECORD) {
        if (Validator.isNull(groupName)) {
            return "activity-task-record-update-task-record";
        } else {
            return "activity-task-record-update-task-record-in";
        }
    }

    return StringPool.BLANK;
}
项目:opencps-v2    文件:ResourceUserIndexer.java   
@Override
protected Document doGetDocument(ResourceUser resourceUser) throws Exception {
    Document document = getBaseModelDocument(CLASS_NAME, resourceUser);

    document.addKeywordSortable(Field.COMPANY_ID, String.valueOf(resourceUser.getCompanyId()));
    document.addDateSortable(Field.MODIFIED_DATE, resourceUser.getModifiedDate());
    document.addKeywordSortable(Field.USER_ID, String.valueOf(resourceUser.getUserId()));
    document.addKeywordSortable(Field.USER_NAME, String.valueOf(resourceUser.getUserName()));

    document.addNumberSortable(ResourceUserTerm.GROUP_ID, resourceUser.getGroupId());
    document.addNumberSortable(ResourceUserTerm.RESOURCEUSER_ID, resourceUser.getResourceUserId());
    document.addTextSortable(ResourceUserTerm.CLASS_NAME, resourceUser.getClassName());
    document.addTextSortable(ResourceUserTerm.CLASS_PK, resourceUser.getClassPK());
    document.addNumberSortable(ResourceUserTerm.TO_USERID, resourceUser.getToUserId());
    document.addTextSortable("selected", Boolean.TRUE.toString());

    User user = UserLocalServiceUtil.fetchUser(resourceUser.getToUserId());

    String userName = StringPool.BLANK;
    String email = StringPool.BLANK;

    if(Validator.isNotNull(user)){

        userName = user.getFullName();
        email = user.getEmailAddress();

    }

    document.addTextSortable(ResourceUserTerm.TO_USERNAME, userName);
    document.addTextSortable(ResourceUserTerm.EMAIL, email);
    document.addTextSortable(ResourceUserTerm.USERCLASS, Employee.class.getName());

    return document;
}
项目:liferay-dummy-factory    文件:UserDataService.java   
/**
 * Set org roles
 * 
 * Filtering only organization roles out from role ids and asign
 * organization roles to a user.
 * 
 * @param userId
 * @param organizationIds
 * @param roleIds
 * @throws PortalException
 */
public void setOrgRoles(long userId, long[] organizationIds, long[] roleIds) throws PortalException {

    Map<Integer, List<Role>> roles = _commonUtil.filterRoles(roleIds);
    List<Role> orgRoles = roles.get(RoleConstants.TYPE_ORGANIZATION);

    if (Validator.isNull(orgRoles) || orgRoles.size() == 0) {
        return;
    }

    long[] orgIds = orgRoles.stream().mapToLong(Role::getRoleId).toArray();

    if (_log.isDebugEnabled()) {
        String orgids = orgRoles.stream().map(o -> String.valueOf(o.getPrimaryKey()))
                .collect(Collectors.joining(","));
        _log.debug("Organization ids : " + orgids);
    }

    if (0 == orgIds.length) {
        _log.debug("Organization didn't exist in the ids. exit");
        return;
    }

    List<Organization> orgs = _organizationLocalService.getOrganizations(organizationIds);
    long[] orgGroupdIds = orgs.stream().mapToLong(Organization::getGroupId).toArray();

    for (long orgGroupdId : orgGroupdIds) {
        _userGroupRoleLocalService.addUserGroupRoles(userId, orgGroupdId, orgIds);
    }
}
项目:opencps-v2    文件:DateTimeUtils.java   
public static Date convertStringToFullDate(String strDate) {
    DateFormat df = getDateTimeFormat(_VN_DATE_TIME_FORMAT);
    Date date = null;

    try {
        if (Validator.isNotNull(strDate)) {
            date = df.parse(strDate);
        }
    }
    catch (ParseException pe) {
        _log.error(pe);
    }

    return date;
}
项目:opencps-v2    文件:DossierManagementImpl.java   
protected Dossier getDossier(String id, long groupId) throws PortalException {
    // TODO update logic here
    long dossierId = GetterUtil.getLong(id);

    Dossier dossier = null;

    dossier = DossierLocalServiceUtil.fetchDossier(dossierId);

    if (Validator.isNull(dossier)) {
        dossier = DossierLocalServiceUtil.getByRef(groupId, id);
    }

    return dossier;
}
项目:opencps-v2    文件:ResourceUserIndexer.java   
@Override
public void postProcessSearchQuery(BooleanQuery searchQuery, BooleanFilter fullQueryBooleanFilter,
        SearchContext searchContext) throws Exception {

    @SuppressWarnings("unchecked")
    LinkedHashMap<String, Object> params = (LinkedHashMap<String, Object>) searchContext.getAttribute("params");

    if (params != null) {
        String expandoAttributes = (String) params.get("expandoAttributes");

        if (Validator.isNotNull(expandoAttributes)) {
            addSearchExpando(searchQuery, searchContext, expandoAttributes);
        }
    }
}
项目:ch-inofix-contact-manager    文件:ExportImportBackgroundTaskDisplay.java   
protected boolean hasStagedModelMessage() {
    if (Validator.isNotNull(_stagedModelName) && Validator.isNotNull(_stagedModelType)) {

        return true;
    }

    return false;
}
项目:ch-inofix-contact-manager    文件:ContactImpl.java   
@Override
public VCard getVCard() {

    String str = getCard();
    VCard vCard = null;

    if (Validator.isNotNull(str)) {
        vCard = Ezvcard.parse(str).first();
    } else {
        vCard = new VCard();
    }

    return vCard;

}
项目:opencps-v2    文件:EmployeeJobPosIndexer.java   
@Override
protected Document doGetDocument(EmployeeJobPos employeeJobPos) throws Exception {
    Document document = getBaseModelDocument(CLASS_NAME, employeeJobPos);

    document.addKeywordSortable(Field.COMPANY_ID, String.valueOf(employeeJobPos.getCompanyId()));
    document.addDateSortable(Field.MODIFIED_DATE, employeeJobPos.getModifiedDate());
    document.addKeywordSortable(Field.USER_ID, String.valueOf(employeeJobPos.getUserId()));
    document.addKeywordSortable(Field.USER_NAME, String.valueOf(employeeJobPos.getUserName()));

    document.addNumberSortable(EmployeeJobPosTerm.GROUP_ID, employeeJobPos.getGroupId());
    document.addNumberSortable(EmployeeJobPosTerm.EMPLOYEE_JOBPOST_ID, employeeJobPos.getEmployeeJobPosId());
    document.addNumberSortable(EmployeeJobPosTerm.EMPLOYEE_ID, employeeJobPos.getEmployeeId());
    document.addNumberSortable(EmployeeJobPosTerm.JOBPOST_ID, employeeJobPos.getJobPostId());
    document.addNumberSortable(EmployeeJobPosTerm.WORKING_UNIT_ID, employeeJobPos.getWorkingUnitId());

    WorkingUnit workingUnit = WorkingUnitLocalServiceUtil.fetchWorkingUnit(employeeJobPos.getWorkingUnitId());

    document.addTextSortable(EmployeeJobPosTerm.WORKING_UNIT_NAME, Validator.isNotNull(workingUnit)?workingUnit.getName():StringPool.BLANK);

    String title = StringPool.BLANK;
    int leader = 0;

    JobPos jobPos = JobPosLocalServiceUtil.fetchJobPos(employeeJobPos.getJobPostId());

    if(Validator.isNotNull(jobPos)){
        title = jobPos.getTitle();
        leader = jobPos.getLeader();
    }

    document.addTextSortable(EmployeeJobPosTerm.JOBPOST_TITLE, title);
    document.addNumberSortable(EmployeeJobPosTerm.LEADER, leader);

    return document;
}
项目:opencps-v2    文件:NotificationTemplateUtils.java   
public static NotificationQueueShortModel mapperNotificationQueueModel(NotificationQueue notificationQueue) {

        NotificationQueueShortModel ett = new NotificationQueueShortModel();

        try {

            ett.setNotificationQueueId(notificationQueue.getNotificationQueueId());
            ett.setNotificationType(notificationQueue.getNotificationType());
            ett.setClassName(notificationQueue.getClassName());
            ett.setClassPK(notificationQueue.getClassPK());
            ett.setPayload(notificationQueue.getPayload());
            ett.setFromUsername(notificationQueue.getFromUsername());
            ett.setToUsername(notificationQueue.getToUsername());
            ett.setToUserId(String.valueOf(notificationQueue.getToUserId()));
            ett.setToEmail(notificationQueue.getToEmail());
            ett.setToTelNo(notificationQueue.getToTelNo());
            ett.setExpireDate(Validator.isNotNull(notificationQueue.getExpireDate()) ? APIDateTimeUtils.convertDateToString(
                    notificationQueue.getExpireDate(), APIDateTimeUtils._TIMESTAMP) : StringPool.BLANK);
            ett.setPublicationDate(Validator.isNotNull(notificationQueue.getCreateDate()) ? APIDateTimeUtils.convertDateToString(
                    notificationQueue.getCreateDate(), APIDateTimeUtils._TIMESTAMP) : StringPool.BLANK);
//          ett.setEmailSubject(notificationQueue.get);
//          ett.setEmailBody(notificationQueue.get);
//          ett.setTextMessage(notificationQueue.get);
//          ett.setUrlLink(notificationQueue.get);
//          ett.setSendEmail(notificationQueue.get);
//          ett.setSendSMS(notificationQueue.get);

        } catch (Exception e) {
            _log.error(e);
        }

        return ett;
    }
项目:opencps-v2    文件:JobposUtils.java   
public static JobposModel mapperJobposModel(JobPos jobPos) {

        JobposModel ett = new JobposModel();

        try {

            ett.setJobPosId(jobPos.getJobPosId());
            ett.setCreateDate(Validator.isNotNull(jobPos.getCreateDate())
                    ? APIDateTimeUtils.convertDateToString(jobPos.getCreateDate(), APIDateTimeUtils._TIMESTAMP)
                    : StringPool.BLANK);
            ett.setModifiedDate(Validator.isNotNull(jobPos.getModifiedDate())
                    ? APIDateTimeUtils.convertDateToString(jobPos.getModifiedDate(), APIDateTimeUtils._TIMESTAMP)
                    : StringPool.BLANK);
            ett.setTitle(jobPos.getTitle());
            ett.setDescription(jobPos.getDescription());
            // ett.setWorkingUnitId(jobPos.getWorkingUnitId());

            // WorkingUnit workingUnit =
            // WorkingUnitLocalServiceUtil.fetchWorkingUnit(jobPos.getWorkingUnitId());
            //
            // String workingUnitName = StringPool.BLANK;
            //
            // if (Validator.isNotNull(workingUnit)) {
            //
            // workingUnitName = workingUnit.getName();
            //
            // }
            //
            // ett.setWorkingUnitName(workingUnitName);
            ett.setLeader(jobPos.getLeader());
            ett.setRoleId(jobPos.getMappingRoleId());

        } catch (Exception e) {
            _log.error(e);
        }

        return ett;
    }
项目:opencps-v2    文件:DeliverablesManagementImpl.java   
@Override
public Response getPreview(HttpServletRequest request, HttpHeaders header, Company company, Locale locale,
        User user, ServiceContext serviceContext, Long id) {
    // TODO Add Deliverable Type
    BackendAuth auth = new BackendAuthImpl();

    long groupId = GetterUtil.getLong(header.getHeaderString("groupId"));

    try {
        if (!auth.isAuth(serviceContext)) {
            throw new UnauthenticationException();
        }

        DeliverableActions actions = new DeliverableActionsImpl();
        String results = StringPool.BLANK;

        Deliverable deliverableInfo = actions.getDetailById(id, groupId);

        if (Validator.isNotNull(deliverableInfo)) {
            results = deliverableInfo.getFormReport();
        } else {
            throw new Exception();
        }

        return Response.status(200).entity(JSONFactoryUtil.looseSerialize(results)).build();

    } catch (Exception e) {
        ErrorMsg error = new ErrorMsg();

        error.setMessage("not found!");
        error.setCode(404);
        error.setDescription("not found!");

        return Response.status(404).entity(error).build();
    }
}
项目:opencps-v2    文件:DateTimeUtils.java   
public static Date convertStringToDateAPI(String strDate) {
    DateFormat df = getDateTimeFormat(_DATE_TIME_TO_NAME);
    Date date = null;

    try {
        if (Validator.isNotNull(strDate)) {
            date = df.parse(strDate);
        }
    }
    catch (ParseException pe) {
        _log.error(pe);
    }

    return date;
}
项目:opencps-v2    文件:ServiceInfoManagementImpl.java   
@Override
public Response getDetailServiceInfo(HttpServletRequest request, HttpHeaders header, Company company, Locale locale,
        User user, ServiceContext serviceContext, String id) {
    ServiceInfoActions actions = new ServiceInfoActionsImpl();

    ServiceInfoDetailModel results = new ServiceInfoDetailModel();

    try {
        long groupId = GetterUtil.getLong(header.getHeaderString("groupId"));

        ServiceInfo serviceInfo = null;

        serviceInfo = actions.getByCode(id, groupId);

        if (Validator.isNull(serviceInfo)) {
            serviceInfo = actions.getById(GetterUtil.getLong(id));
        }

        if (Validator.isNull(serviceInfo)) {
            throw new Exception();
        } else {
            results = ServiceInfoUtils.mappingToServiceInfoDetailModel(serviceInfo, serviceContext);
        }

        return Response.status(200).entity(results).build();

    } catch (Exception e) {
        ErrorMsg error = new ErrorMsg();

        error.setMessage("not found!");
        error.setCode(404);
        error.setDescription("not found!");

        return Response.status(404).entity(error).build();
    }
}
项目:liferay-dummy-factory    文件:CommonUtil.java   
/**
 * Convert string array to long array
 * 
 * @param source String array of ids
 * @return long array of ids
 */
static public long[] convertStringToLongArray(String[] source) {
    if (Validator.isNull(source) || source.length <= 0) {
        return null;
    }

    return Arrays.stream(source).distinct().mapToLong(Long::parseLong).toArray();
}
项目:opencps-v2    文件:ServiceInfoLocalServiceImpl.java   
private void valdiate(String serviceCode, String serviceName, String administrationCode, String domainCode,
        long groupId) throws PortalException {

    if (Validator.isNull(serviceCode)) {
        throw new RequiredServiceCodeException();
    }

    if (Validator.isNull(serviceName)) {
        throw new RequiredServiceNameException();
    }

    if (Validator.isNull(administrationCode)) {
        throw new RequiredAdministrationCodeException();
    }

    ServiceInfo si = null;

    try {
        si = serviceInfoPersistence.findBySC_GI(serviceCode, groupId);
    } catch (Exception e) {

    }

    if (Validator.isNotNull(si)) {
        throw new DuplicateServiceCodeException();
    }
}
项目:opencps-v2    文件:DossierFileLocalServiceImpl.java   
private Map<String, Object> jsonToMap(JSONObject json) {
    Map<String, Object> retMap = new HashMap<String, Object>();

    if (Validator.isNotNull(json)) {
        try {
            retMap = toMap(json);
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    return retMap;
}
项目:opencps-v2    文件:DateTimeUtils.java   
public static Date convertStringToDate(String strDate) {
    DateFormat df = getDateTimeFormat(_VN_DATE_FORMAT);
    Date date = null;

    try {
        if (Validator.isNotNull(strDate)) {
            date = df.parse(strDate);
        }
    }
    catch (ParseException pe) {
        _log.error(pe);
    }

    return date;
}
项目:opencps-v2    文件:DictItemLocalServiceImpl.java   
@Indexable(type = IndexableType.DELETE)
@Override
public DictItem deleteDictItem(long dictItemId, ServiceContext serviceContext)
        throws UnauthenticationException, UnauthorizationException, NotFoundException {
    // authen
    BackendAuthImpl authImpl = new BackendAuthImpl();

    boolean isAuth = authImpl.isAuth(serviceContext);

    if (!isAuth) {
        throw new UnauthenticationException();
    }

    boolean hasPermission = authImpl.hasResource(serviceContext, ModelNameKeys.WORKINGUNIT_MGT_CENTER,
            ActionKeys.EDIT_DATA);

    if (!hasPermission) {
        throw new UnauthorizationException();
    }
    DictItem dictItem;

    try {

        List<DictItem> listItem = dictItemPersistence.findByF_parentItemId(dictItemId);

        if (Validator.isNotNull(listItem) && listItem.size() > 0) {
            throw new UnauthorizationException();
        } else {

            dictItem = dictItemPersistence.remove(dictItemId);

        }

    } catch (NoSuchDictItemException e) {
        throw new NotFoundException();
    }

    return dictItem;
}
项目:opencps-v2    文件:DateTimeUtils.java   
public static DateFormat getDateTimeFormat(String pattern) {
    DateFormat dateFormat = DateFormatFactoryUtil.getSimpleDateFormat(
        pattern);

    if (Validator.isNotNull(pattern)) {
        pattern = _VN_DATE_TIME_FORMAT;
    }

    dateFormat.setTimeZone(TimeZoneUtil.getDefault());

    return dateFormat;
}
项目:opencps-v2    文件:OfficeSiteLocalServiceImpl.java   
public long countLuceneSearchEngine(LinkedHashMap<String, Object> params,
        SearchContext searchContext) throws ParseException, SearchException {
    // TODO
    MultiMatchQuery query = null;
    String keywords = (String) params.get("keywords");
    String groupId = (String) params.get("groupId");
    String userId = (String) params.get("userId");
    Indexer<OfficeSite> indexer = IndexerRegistryUtil.nullSafeGetIndexer(OfficeSite.class);

    searchContext.addFullQueryEntryClassName(OfficeSite.class.getName());
    searchContext.setEntryClassNames(new String[] { OfficeSite.class.getName() });
    searchContext.setAttribute("paginationType", "regular");
    searchContext.setLike(true);
    searchContext.setAndSearch(true);

    BooleanQuery booleanQuery = null;

    booleanQuery = Validator.isNotNull((String) keywords)
            ? BooleanQueryFactoryUtil.create((SearchContext) searchContext) : indexer.getFullQuery(searchContext);

    if (Validator.isNotNull(groupId)) {
        query = new MultiMatchQuery(groupId);

        query.addFields(OfficeSiteTerm.GROUP_ID);

        booleanQuery.add(query, BooleanClauseOccur.MUST);
    }

    if (Validator.isNotNull(userId)) {
        query = new MultiMatchQuery(userId);

        query.addFields(OfficeSiteTerm.USER_ID);

        booleanQuery.add(query, BooleanClauseOccur.MUST);
    }

    booleanQuery.addRequiredTerm(Field.ENTRY_CLASS_NAME, OfficeSite.class.getName());

    return IndexSearcherHelperUtil.searchCount(searchContext, booleanQuery);
}
项目:opencps-v2    文件:UserActions.java   
@Override
public String getPreference(long id, long groupId, ServiceContext serviceContext) {
    Preferences preferences = PreferencesLocalServiceUtil.fetchByF_userId(groupId, id);

    String result = Validator.isNotNull(preferences) ? preferences.getPreferences() : StringPool.BLANK;

    return result;
}
项目:opencps-v2    文件:DateTimeUtils.java   
public static DateFormat getDateTimeFormat(String pattern) {
    DateFormat dateFormat = DateFormatFactoryUtil.getSimpleDateFormat(
        pattern);

    if (Validator.isNotNull(pattern)) {
        pattern = _VN_DATE_TIME_FORMAT;
    }

    dateFormat.setTimeZone(TimeZoneUtil.getDefault());

    return dateFormat;
}
项目:opencps-v2    文件:NotificationTemplateIndexer.java   
@Override
public void postProcessSearchQuery(BooleanQuery searchQuery, BooleanFilter fullQueryBooleanFilter,
        SearchContext searchContext) throws Exception {

    addSearchTerm(searchQuery, searchContext, NotificationTemplateTerm.NOTIFICATIONTEMPLATE_ID, false);
    addSearchTerm(searchQuery, searchContext, NotificationTemplateTerm.GROUP_ID, false);
    addSearchTerm(searchQuery, searchContext, NotificationTemplateTerm.COMPANY_ID, false);
    addSearchTerm(searchQuery, searchContext, NotificationTemplateTerm.USER_NAME, false);
    addSearchTerm(searchQuery, searchContext, NotificationTemplateTerm.USER_ID, false);
    addSearchTerm(searchQuery, searchContext, NotificationTemplateTerm.CREATE_DATE, false);
    addSearchTerm(searchQuery, searchContext, NotificationTemplateTerm.MODIFIED_DATE, false);

    addSearchTerm(searchQuery, searchContext, NotificationTemplateTerm.NOTIFICATTION_TYPE, true);
    addSearchTerm(searchQuery, searchContext, NotificationTemplateTerm.NOTIFICATION_EMAIL_SUBJECT, true);
    addSearchTerm(searchQuery, searchContext, NotificationTemplateTerm.NOTIFICATION_EMAIL_BODY, true);
    addSearchTerm(searchQuery, searchContext, NotificationTemplateTerm.NOTIFICATION_TEXT_MESSAGE, true);
    addSearchTerm(searchQuery, searchContext, NotificationTemplateTerm.NOTIFICATION_SEND_SMS, true);

    LinkedHashMap<String, Object> params = (LinkedHashMap<String, Object>) searchContext.getAttribute("params");

    if (params != null) {
        String expandoAttributes = (String) params.get("expandoAttributes");

        if (Validator.isNotNull(expandoAttributes)) {
            addSearchExpando(searchQuery, searchContext, expandoAttributes);
        }
    }
}