Example usage for com.liferay.portal.kernel.util Validator isBlank

List of usage examples for com.liferay.portal.kernel.util Validator isBlank

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util Validator isBlank.

Prototype

public static boolean isBlank(String s) 

Source Link

Usage

From source file:com.bemis.portal.fileuploader.service.impl.FileUploaderLocalServiceImpl.java

License:Open Source License

protected FileEntry addFileEntry(long userId, long groupId, long folderId, String sourceFileName,
        String mimeType, String title, String fileDescription, String changeLog, File inputFile,
        ServiceContext serviceContext) throws PortalException {

    long repositoryId = groupId;

    if (_log.isDebugEnabled()) {
        _log.debug(">>> File does not exist. Adding File Entry for : " + title);
    }//from ww  w.  ja  v a  2s.co m

    if (Validator.isBlank(fileDescription)) {
        fileDescription = title;
    }

    FileEntry fileEntry = _dlAppLocalService.addFileEntry(userId, repositoryId, folderId, sourceFileName,
            mimeType, title, fileDescription, changeLog, inputFile, serviceContext);

    if (_log.isWarnEnabled()) {
        _log.warn(String.format(">>> File with name '%s' added successfully with id : '%s'", title,
                fileEntry.getFileEntryId()));
    }

    return fileEntry;
}

From source file:com.bemis.portal.fileuploader.service.impl.FileUploaderLocalServiceImpl.java

License:Open Source License

protected FileEntry updateFileEntry(long userId, DLFileEntry dlFileEntry, String sourceFileName,
        String mimeType, String title, String fileDescription, String changeLog, boolean majorVersion,
        File file, ServiceContext serviceContext) throws PortalException {

    long dlFileEntryId = dlFileEntry.getFileEntryId();

    if (_log.isDebugEnabled()) {
        _log.debug(">>> File already exists, updating fileEntry with id :" + dlFileEntryId);
    }//from w  ww .  j  a  va 2 s .  com

    if (Validator.isBlank(changeLog)) {
        long currentFileSize = file.length();

        if (currentFileSize != dlFileEntry.getSize()) {
            changeLog = FileUploaderConstants.DEFAULT_CHANGE_LOG;
        }
    }

    FileEntry fileEntry = _dlAppLocalService.updateFileEntry(userId, dlFileEntryId, sourceFileName, mimeType,
            title, fileDescription, changeLog, majorVersion, file, serviceContext);

    if (_log.isWarnEnabled()) {
        _log.warn(String.format(
                ">>> File with name '%s' updated with change : '%s'" + "successfully with id : '%s'", title,
                changeLog, fileEntry.getFileEntryId()));
    }

    return fileEntry;
}

From source file:com.idetronic.subur.service.impl.AuthorLocalServiceImpl.java

License:Open Source License

/**
 * // w w  w .ja v a 2  s.  co m
 */
public int getSearchCount(String keyword, long companyId, long groupId) throws SystemException {

    if (Validator.isNotNull(keyword) || Validator.isBlank(keyword))
        return authorPersistence.countByCompanyGroup(companyId, groupId);//, companyId);//
    else
        return AuthorFinderUtil.getTotalByName(keyword, companyId, groupId);
}

From source file:com.idetronic.subur.service.impl.AuthorLocalServiceImpl.java

License:Open Source License

public List<Author> search(String keyword, long companyId, long groupId, String firstName, String lastName,
        boolean isAdvancedSearch, boolean isAndOperator, int start, int end, OrderByComparator obc)
        throws SystemException {
    String[] keywords = null;//w  ww  .j  ava 2  s  .  co m

    boolean matchAll;
    if (isAdvancedSearch) {
        return advanceSearch(keyword, companyId, groupId, firstName, lastName, isAndOperator, start, end, obc);

    } else {

        if (Validator.isNotNull(keyword) && !Validator.isBlank(keyword))
            keywords = CustomSQLUtil.keywords(keyword);
        else {
            return authorPersistence.findAll(start, end, obc);
        }

        try {
            return AuthorFinderUtil.findByName(keyword, companyId, groupId, start, end, obc);
            //return AuthorFinderUtil.findByFirstName(keywords,new LinkedHashMap<String, Object>(), start, end, obc);
        } catch (SystemException e) {

            throw new SystemException(e);
        }
    }
}

From source file:com.idetronic.subur.service.impl.AuthorLocalServiceImpl.java

License:Open Source License

/**
 * /*from   w ww .  j  av a2s  .  c  o  m*/
 */

public List<Author> search(String keyword, long companyId, long groupId, int start, int end,
        OrderByComparator obc) throws SystemException {
    String[] keywords = null;
    if (Validator.isNotNull(keyword) && !Validator.isBlank(keyword))
        keywords = CustomSQLUtil.keywords(keyword);
    else {
        return authorPersistence.findAll(start, end, obc);
    }

    try {
        return AuthorFinderUtil.findByName(keyword, companyId, groupId, start, end, obc);
        //return AuthorFinderUtil.findByFirstName(keywords,new LinkedHashMap<String, Object>(), start, end, obc);
    } catch (SystemException e) {

        throw new SystemException(e);
    }

}

From source file:com.labimo.portlet.LicenseManage.java

@Override
public void doView(RenderRequest renderRequest, RenderResponse renderResponse)
        throws PortletException, IOException {

    String action = (String) renderRequest.getAttribute("action");
    System.out.println("action" + action);

    String screenName = (String) renderRequest.getAttribute("screenName");
    System.out.println("screenName" + screenName);

    Boolean flag = false;//from  w w w .j  ava  2 s.  com
    try {

        ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest
                .getAttribute(com.liferay.portal.kernel.util.WebKeys.THEME_DISPLAY);
        User currentUser = PortalUtil.getUser(renderRequest);
        if (currentUser != null) {
            List<UserGroup> userGroups = UserGroupLocalServiceUtil.getUserUserGroups(themeDisplay.getUserId());
            for (UserGroup group : userGroups) {
                System.out.println(group.getName());
                if (manageGroup.equals(group.getName())) {
                    flag = true;
                }
            }

            List<License> licenseList = new ArrayList<License>();
            if (flag) {
                if (Validator.isBlank(screenName)) {
                    licenseList = LicenseLocalServiceUtil.getLicenses(0, queryMax);
                } else {
                    screenName = "%" + screenName + "%";
                    DynamicQuery userQuery = DynamicQueryFactoryUtil.forClass(User.class)
                            .add(PropertyFactoryUtil.forName("screenName").like(screenName));
                    userQuery.setLimit(0, queryMax);
                    List<User> userList = UserLocalServiceUtil.dynamicQuery(userQuery);
                    List<Long> userIdList = new ArrayList<Long>();
                    for (User user : userList) {
                        userIdList.add(user.getUserId());
                    }
                    DynamicQuery query = DynamicQueryFactoryUtil.forClass(License.class)
                            .add(PropertyFactoryUtil.forName("userId").in(userIdList));

                    licenseList = LicenseLocalServiceUtil.dynamicQuery(query);
                }

            } else {
                DynamicQuery query = DynamicQueryFactoryUtil.forClass(License.class)
                        .add(PropertyFactoryUtil.forName("userId").eq(currentUser.getUserId()));

                licenseList = LicenseLocalServiceUtil.dynamicQuery(query);

            }

            System.out.println(licenseList.size());
            renderRequest.setAttribute("licenseList", licenseList);
        }

        renderRequest.setAttribute("flag", flag);

    } catch (Exception e) {
        e.printStackTrace();
    }

    System.out.println("flag" + flag);
    if (flag) {
        super.doView(renderRequest, renderResponse);
    } else {
        include("/userView.jsp", renderRequest, renderResponse);
    }

}

From source file:com.liferay.application.list.user.personal.site.permissions.internal.UserPersonalSitePermissions.java

License:Open Source License

protected void initPermissions(long companyId, long powerUserRoleId, String rootPortletId,
        long userPersonalSiteGroupId) throws PortalException {

    String primaryKey = String.valueOf(userPersonalSiteGroupId);

    if (_resourcePermissionLocalService.getResourcePermissionsCount(companyId, rootPortletId,
            ResourceConstants.SCOPE_GROUP, primaryKey) == 0) {

        List<String> portletActionIds = ResourceActionsUtil.getPortletResourceActions(rootPortletId);

        _resourcePermissionLocalService.setResourcePermissions(companyId, rootPortletId,
                ResourceConstants.SCOPE_GROUP, String.valueOf(userPersonalSiteGroupId), powerUserRoleId,
                portletActionIds.toArray(new String[0]));
    }/*  ww  w  .  j av a 2s.com*/

    String modelName = ResourceActionsUtil.getPortletRootModelResource(rootPortletId);

    if (Validator.isBlank(modelName)) {
        return;
    }

    if (_resourcePermissionLocalService.getResourcePermissionsCount(companyId, modelName,
            ResourceConstants.SCOPE_GROUP, primaryKey) == 0) {

        List<String> modelActionIds = ResourceActionsUtil.getModelResourceActions(modelName);

        _resourcePermissionLocalService.setResourcePermissions(companyId, modelName,
                ResourceConstants.SCOPE_GROUP, String.valueOf(userPersonalSiteGroupId), powerUserRoleId,
                modelActionIds.toArray(new String[0]));
    }
}

From source file:com.liferay.asset.internal.util.AssetServiceUtil.java

License:Open Source License

public static boolean isValidWord(String word) {
    if (Validator.isBlank(word)) {
        return false;
    }//  w  w w . j a v a 2 s .  co m

    char[] wordCharArray = word.toCharArray();

    for (char c : wordCharArray) {
        for (char invalidChar : AssetHelper.INVALID_CHARACTERS) {
            if (c == invalidChar) {
                if (_log.isDebugEnabled()) {
                    _log.debug(StringBundler.concat("Word ", word, " is not valid because ", String.valueOf(c),
                            " is not allowed"));
                }

                return false;
            }
        }
    }

    return true;
}

From source file:com.liferay.customsql.CustomSQL.java

License:Open Source License

public String get(String id, QueryDefinition queryDefinition, String tableName) {

    String sql = get(id);/*from  w w w.j  ava 2 s.com*/

    if (!Validator.isBlank(tableName) && !tableName.endsWith(StringPool.PERIOD)) {

        tableName = tableName.concat(StringPool.PERIOD);
    }

    if (queryDefinition.getStatus() == WorkflowConstants.STATUS_ANY) {
        sql = sql.replace(_STATUS_KEYWORD, _STATUS_CONDITION_EMPTY);
    } else {
        if (queryDefinition.isExcludeStatus()) {
            sql = sql.replace(_STATUS_KEYWORD, tableName.concat(_STATUS_CONDITION_INVERSE));
        } else {
            sql = sql.replace(_STATUS_KEYWORD, tableName.concat(_STATUS_CONDITION_DEFAULT));
        }
    }

    return sql;
}

From source file:com.liferay.document.library.document.conversion.internal.security.auth.verifier.ImageRequestAuthVerifier.java

License:Open Source License

@Override
public AuthVerifierResult verify(AccessControlContext accessControlContext, Properties properties)
        throws AuthException {

    AuthVerifierResult authVerifierResult = new AuthVerifierResult();

    HttpServletRequest request = accessControlContext.getRequest();

    try {//from w w  w .  ja v a  2 s  .  c  om
        String token = ParamUtil.getString(request, "auth_token");

        if (Validator.isBlank(token)) {
            return authVerifierResult;
        }

        long userId = ImageRequestTokenUtil.getUserId(token);

        if (userId != 0) {
            authVerifierResult.setState(AuthVerifierResult.State.SUCCESS);
            authVerifierResult.setUserId(userId);
        } else {
            authVerifierResult.setState(AuthVerifierResult.State.INVALID_CREDENTIALS);
        }

        return authVerifierResult;
    } catch (Exception e) {
        throw new AuthException(e);
    }
}