本文整理匯總了Java中com.liferay.portal.kernel.util.Validator.isNull方法的典型用法代碼示例。如果您正苦於以下問題:Java Validator.isNull方法的具體用法?Java Validator.isNull怎麽用?Java Validator.isNull使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.liferay.portal.kernel.util.Validator
的用法示例。
在下文中一共展示了Validator.isNull方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getDossier
import com.liferay.portal.kernel.util.Validator; //導入方法依賴的package包/類
protected Dossier getDossier(String id, long groupId) throws PortalException {
// TODO update logic here
long dossierId = GetterUtil.getLong(id);
Dossier dossier = null;
if (dossierId != 0) {
dossier = DossierLocalServiceUtil.fetchDossier(dossierId);
}
if (Validator.isNull(dossier)) {
dossier = DossierLocalServiceUtil.getByRef(groupId, id);
}
return dossier;
}
示例2: getTitlePattern
import com.liferay.portal.kernel.util.Validator; //導入方法依賴的package包/類
@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;
}
示例3: convertStringToLongArray
import com.liferay.portal.kernel.util.Validator; //導入方法依賴的package包/類
/**
* 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();
}
示例4: saveGlobalSettings
import com.liferay.portal.kernel.util.Validator; //導入方法依賴的package包/類
@Override
public void saveGlobalSettings(String adtUuid, boolean doSearchOnStartup, String doSearchOnStartupKeywords, PortletPreferences preferences) throws ReadOnlyException, ValidatorException, IOException {
if(Validator.isNull(doSearchOnStartupKeywords)) {
doSearchOnStartupKeywords = FlashlightSearchService.CONFIGURATION_DEFAULT_SEARCH_KEYWORDS;
}
preferences.setValue(CONF_KEY_ADT_UUID, adtUuid);
preferences.setValue(CONF_KEY_DO_SEARCH_ON_STARTUP, Boolean.toString(doSearchOnStartup));
preferences.setValue(CONF_KEY_DO_SEARCH_ON_STARTUP_KEYWORDS, doSearchOnStartupKeywords);
preferences.store();
}
示例5: convertStringToDate
import com.liferay.portal.kernel.util.Validator; //導入方法依賴的package包/類
public static Date convertStringToDate(String source, String pattern) {
if (Validator.isNull(source) || Validator.isNull(pattern)) {
return null;
}
SimpleDateFormat sdf = new SimpleDateFormat(pattern);
try {
return sdf.parse(source);
} catch (Exception e) {
return null;
}
}
示例6: removeDeliverableType
import com.liferay.portal.kernel.util.Validator; //導入方法依賴的package包/類
public DeliverableType removeDeliverableType(long groupId, String deliverableTypeId) throws PortalException {
// TODO remove DeliverableType
validateRemoveDeliverableType(groupId, deliverableTypeId);
DeliverableType deliverableTypeObj = null;
long id = Long.valueOf(deliverableTypeId);
deliverableTypeObj = deliverableTypePersistence.fetchByPrimaryKey(id);
if (Validator.isNull(deliverableTypeObj)) {
deliverableTypeObj = deliverableTypePersistence.fetchByG_DLT(groupId, deliverableTypeId);
}
return deliverableTypePersistence.remove(deliverableTypeObj);
}
示例7: getDossier
import com.liferay.portal.kernel.util.Validator; //導入方法依賴的package包/類
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;
}
示例8: updateDictItemListener
import com.liferay.portal.kernel.util.Validator; //導入方法依賴的package包/類
@Indexable(type = IndexableType.REINDEX)
public DictItem updateDictItemListener(long userId, long dictItemId, long dictCollectionId, String itemCode,
String itemName, String itemNameEN, String itemDescription, long parentItemId, String sibling, int level,
String metaData, ServiceContext serviceContext)
throws DuplicateCategoryException, UnauthenticationException, UnauthorizationException, NoSuchUserException,
NotFoundException, PortalException {
Date now = new Date();
User user = userPersistence.findByPrimaryKey(userId);
DictItem dictItem = dictItemPersistence.fetchByPrimaryKey(dictItemId);
DictItem dictColl = dictItemPersistence.fetchByF_dictItemCode(itemCode, dictItem.getGroupId());
if (Validator.isNotNull(dictColl) && dictColl.getDictItemId() != dictItemId) {
throw new DuplicateCategoryException();
}
if (Validator.isNull(dictItem)) {
throw new NotFoundException();
}
// Audit fields
dictItem.setUserId(user.getUserId());
dictItem.setUserName(user.getFullName());
dictItem.setModifiedDate(serviceContext.getCreateDate(now));
// Other fields
dictItem.setDictCollectionId(dictCollectionId);
dictItem.setItemCode(itemCode);
dictItem.setItemName(itemName);
dictItem.setItemNameEN(itemNameEN);
dictItem.setItemDescription(itemDescription);
dictItem.setParentItemId(parentItemId);
dictItem.setSibling(sibling);
dictItem.setMetaData(metaData);
String treeIndex = getTreeIndex(dictItemId, parentItemId, sibling);
dictItem.setTreeIndex(treeIndex);
dictItem.setLevel(StringUtil.count(treeIndex, StringPool.PERIOD));
// referent dictcollection
BaseModel<?> baseModel = DictCollectionLocalServiceUtil.fetchDictCollection(dictCollectionId);
dictItem.setExpandoBridgeAttributes(baseModel);
// dictItem.setExpandoBridgeAttributes(serviceContext);
dictItemPersistence.update(dictItem);
return dictItem;
}
示例9: convertDateToString
import com.liferay.portal.kernel.util.Validator; //導入方法依賴的package包/類
public static String convertDateToString(Date date, String pattern) {
DateFormat dateFormat = DateFormatFactoryUtil.getSimpleDateFormat(
pattern);
if (Validator.isNull(date) || Validator.isNull(pattern)) {
return StringPool.BLANK;
}
dateFormat.setTimeZone(TimeZoneUtil.getTimeZone("Asia/Ho_Chi_Minh"));
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
return dateFormat.format(calendar.getTime());
}
示例10: getProcessAction
import com.liferay.portal.kernel.util.Validator; //導入方法依賴的package包/類
protected ProcessAction getProcessAction(long groupId, long dossierId, String refId, String actionCode,
long serviceProcessId) throws PortalException {
ProcessAction action = null;
try {
List<ProcessAction> actions = ProcessActionLocalServiceUtil.getByActionCode(groupId, actionCode,
serviceProcessId);
_log.info("actionCode" + actionCode);
_log.info("serviceProcessId" + serviceProcessId);
Dossier dossier = getDossier(groupId, dossierId, refId);
String dossierStatus = dossier.getDossierStatus();
String dossierSubStatus = Validator.isNull(dossier.getDossierSubStatus()) ? StringPool.BLANK
: dossier.getDossierSubStatus();
_log.info("GROUPID_" + groupId);
_log.info("dossierId" + dossierId);
_log.info("refId" + refId);
_log.info("DOSSIER_STATUS_" + dossierStatus);
_log.info("DOSSIER_SUB_STATUS_" + dossierSubStatus);
_log.info("ACTION_SIZE" + actions.size());
for (ProcessAction act : actions) {
String preStepCode = act.getPreStepCode();
_log.info(JSONFactoryUtil.looseSerialize(act));
ProcessStep step = ProcessStepLocalServiceUtil.fetchBySC_GID(preStepCode, groupId, serviceProcessId);
String subStepStatus = StringPool.BLANK;
if (Validator.isNotNull(step)) {
subStepStatus = Validator.isNull(step.getDossierSubStatus()) ? StringPool.BLANK
: step.getDossierSubStatus();
}
_log.info(JSONFactoryUtil.looseSerialize(step));
if (Validator.isNull(step)) {
action = act;
break;
} else {
if (step.getDossierStatus().contentEquals(dossierStatus)
&& subStepStatus.contentEquals(dossierSubStatus)) {
action = act;
break;
}
}
}
} catch (Exception e) {
_log.error(e);
throw new NotFoundException("ProcessActionNotFoundException with actionCode= " + actionCode
+ "|serviceProcessId= " + serviceProcessId + "|referenceUid= " + refId + "|groupId= " + groupId);
}
return action;
}
示例11: updateResourceRole
import com.liferay.portal.kernel.util.Validator; //導入方法依賴的package包/類
@Indexable(type = IndexableType.REINDEX)
@Override
public ResourceRole updateResourceRole(long userId, long resourceRoleId, String className, String classPK,
long roleId, ServiceContext serviceContext)
throws UnauthenticationException, UnauthorizationException, NotFoundException, NoSuchUserException {
// authen
BackendAuthImpl authImpl = new BackendAuthImpl();
boolean isAuth = authImpl.isAuth(serviceContext, StringPool.BLANK, StringPool.BLANK);
if (!isAuth) {
throw new UnauthenticationException();
}
boolean hasPermission = authImpl.hasResource(serviceContext, ModelNameKeys.WORKINGUNIT_MGT_CENTER,
ActionKeys.EDIT_DATA);
if (!hasPermission) {
throw new UnauthorizationException();
}
Role role = RoleLocalServiceUtil.fetchRole(roleId);
if(Validator.isNull(role)){
throw new NotFoundException();
}
Date now = new Date();
User user = userPersistence.findByPrimaryKey(userId);
ResourceRole resourceRole = resourceRolePersistence.fetchByPrimaryKey(resourceRoleId);
if (Validator.isNull(resourceRole)) {
throw new NotFoundException();
}
// Audit fields
resourceRole.setUserId(user.getUserId());
resourceRole.setUserName(user.getFullName());
resourceRole.setModifiedDate(serviceContext.getCreateDate(now));
// Other fields
resourceRole.setClassName(className);
resourceRole.setClassPK(classPK);
resourceRole.setRoleId(roleId);
resourceRole.setExpandoBridgeAttributes(serviceContext);
resourceRolePersistence.update(resourceRole);
return resourceRole;
}
示例12: updateResourceUser
import com.liferay.portal.kernel.util.Validator; //導入方法依賴的package包/類
@Indexable(type = IndexableType.REINDEX)
@Override
public ResourceUser updateResourceUser(long userId, long resourceUserId, String className, String classPK,
long toUserId, String fullname, String email, boolean readonly, ServiceContext serviceContext)
throws UnauthenticationException, UnauthorizationException, NotFoundException, NoSuchUserException {
// authen
BackendAuthImpl authImpl = new BackendAuthImpl();
boolean isAuth = authImpl.isAuth(serviceContext, StringPool.BLANK, StringPool.BLANK);
if (!isAuth) {
throw new UnauthenticationException();
}
boolean hasPermission = authImpl.hasResource(serviceContext, ModelNameKeys.WORKINGUNIT_MGT_CENTER,
ActionKeys.EDIT_DATA);
if (!hasPermission) {
throw new UnauthorizationException();
}
User toUser = userPersistence.fetchByPrimaryKey(toUserId);
if (Validator.isNull(toUser)) {
throw new NotFoundException();
}
Date now = new Date();
User user = userPersistence.findByPrimaryKey(userId);
ResourceUser resourceUser = resourceUserPersistence.fetchByPrimaryKey(resourceUserId);
if (Validator.isNull(resourceUser)) {
throw new NotFoundException();
}
// Audit fields
resourceUser.setUserId(user.getUserId());
resourceUser.setUserName(user.getFullName());
resourceUser.setModifiedDate(serviceContext.getCreateDate(now));
// Other fields
resourceUser.setClassName(className);
resourceUser.setClassPK(classPK);
resourceUser.setToUserId(toUserId);
resourceUser.setFullname(fullname);
resourceUser.setEmail(email);
resourceUser.setReadonly(readonly);
resourceUser.setExpandoBridgeAttributes(serviceContext);
resourceUserPersistence.update(resourceUser);
return resourceUser;
}
示例13: deleteDictCollection
import com.liferay.portal.kernel.util.Validator; //導入方法依賴的package包/類
/**
* @author binhth
* @param code
* ( collectionCode unique )
* @param groupId
* @param serviceContext
* @throws NotFoundException,
* UnauthenticationException, UnauthorizationException
* @return boolean
*/
public boolean deleteDictCollection(String code, long groupId, ServiceContext serviceContext)
throws NotFoundException, UnauthenticationException, UnauthorizationException {
boolean flag = false;
DictCollection dictColl = DictCollectionLocalServiceUtil.fetchByF_dictCollectionCode(code,
groupId);
if (Validator.isNull(dictColl)) {
flag = false;
} else {
DictCollectionLocalServiceUtil.deleteDictCollection(dictColl.getDictCollectionId(), serviceContext);
flag = true;
}
return flag;
}
示例14: getApplicantProfile
import com.liferay.portal.kernel.util.Validator; //導入方法依賴的package包/類
@Override
public Response getApplicantProfile(HttpServletRequest request, HttpHeaders header, Company company, Locale locale,
User user, ServiceContext serviceContext, long id) {
ApplicantActions actions = new ApplicantActionsImpl();
BackendAuth auth = new BackendAuthImpl();
Applicant applicant = null;
try {
if (!auth.isAuth(serviceContext)) {
throw new UnauthenticationException();
}
User requestUser = ApplicantUtils.getUser(id);
boolean isAllowed = false;
if (auth.hasResource(serviceContext, Applicant.class.getName(), ActionKeys.ADD_ENTRY)) {
isAllowed = true;
} else {
if (Validator.isNull(requestUser)) {
throw new NoSuchUserException();
} else {
// check userLogin is equal userRequest get detail
if (requestUser.getUserId() == user.getUserId()) {
isAllowed = true;
}
}
}
if (isAllowed) {
applicant = actions.getApplicantDetail (serviceContext, id);
JSONObject result = JSONFactoryUtil.createJSONObject(applicant.getProfile());
return Response.status(200).entity(JSONFactoryUtil.looseSerialize(result)).build();
} else {
throw new UnauthorizationException();
}
} catch (Exception e) {
ErrorMsg error = new ErrorMsg();
if (e instanceof UnauthenticationException) {
error.setMessage("Non-Authoritative Information.");
error.setCode(HttpURLConnection.HTTP_NOT_AUTHORITATIVE);
error.setDescription("Non-Authoritative Information.");
return Response.status(HttpURLConnection.HTTP_NOT_AUTHORITATIVE).entity(error).build();
} else {
if (e instanceof UnauthorizationException) {
error.setMessage("Unauthorized.");
error.setCode(HttpURLConnection.HTTP_NOT_AUTHORITATIVE);
error.setDescription("Unauthorized.");
return Response.status(HttpURLConnection.HTTP_UNAUTHORIZED).entity(error).build();
} else {
if (e instanceof NoSuchUserException) {
error.setMessage("Not Found");
error.setCode(HttpURLConnection.HTTP_NOT_FOUND);
error.setDescription("Not Found");
return Response.status(HttpURLConnection.HTTP_NOT_FOUND).entity(error).build();
} else {
error.setMessage("Internal Server Error");
error.setCode(HttpURLConnection.HTTP_INTERNAL_ERROR);
error.setDescription(e.getMessage());
return Response.status(HttpURLConnection.HTTP_INTERNAL_ERROR).entity(error).build();
}
}
}
}
}
示例15: updateHoliday
import com.liferay.portal.kernel.util.Validator; //導入方法依賴的package包/類
@Indexable(type = IndexableType.REINDEX)
@Override
public Holiday updateHoliday(long userId, long holidayId, Date holidayDate, String description,
ServiceContext serviceContext)
throws UnauthenticationException, UnauthorizationException, NotFoundException, NoSuchUserException {
// 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();
}
Date now = new Date();
User user = userPersistence.findByPrimaryKey(userId);
Holiday holiday = holidayPersistence.fetchByPrimaryKey(holidayId);
if (Validator.isNull(holiday)) {
throw new NotFoundException();
}
// Audit fields
holiday.setUserId(user.getUserId());
holiday.setUserName(user.getFullName());
holiday.setModifiedDate(serviceContext.getCreateDate(now));
// Other fields
holiday.setHolidayDate(holidayDate);
holiday.setDescription(description);
holiday.setExpandoBridgeAttributes(serviceContext);
holidayPersistence.update(holiday);
return holiday;
}