Example usage for com.liferay.portal.kernel.util GetterUtil get

List of usage examples for com.liferay.portal.kernel.util GetterUtil get

Introduction

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

Prototype

public static String get(String value, String defaultValue) 

Source Link

Document

Returns the String value as a String.

Usage

From source file:au.com.permeance.liferay.portal.kernel.servlet.BaseFilter.java

License:Open Source License

public void init(FilterConfig filterConfig) {
    _filterConfig = filterConfig;/* www .j a  v a2s  .co  m*/

    if (_TCK_URL) {
        ServletContext servletContext = _filterConfig.getServletContext();

        _invokerEnabled = GetterUtil.get(servletContext.getInitParameter("liferay-invoker-enabled"), true);

        if (!_invokerEnabled) {
            _filterMapping = new FilterMapping(this, filterConfig, new ArrayList<String>(0),
                    new ArrayList<String>(0));
        }
    }

    LiferayFilterTracker.addLiferayFilter(this);
}

From source file:br.gov.camara.edemocracia.liferay.parsers.CDHtmlBBCodeTranslatorImpl.java

License:Open Source License

protected void handleVideo(StringBundler sb, List<BBCodeItem> bbCodeItems, IntegerWrapper marker) {
    int videoHeight = GetterUtil.get(PropsUtil.get("forum.video.height"), 349);
    int videoWidth = GetterUtil.get(PropsUtil.get("forum.video.width"), 560);

    String videoId = extractData(bbCodeItems, marker, "video", BBCodeParser.TYPE_DATA, true);

    if (videoId != null && videoId.trim().length() > 0) {
        // Extrai o identificador do video, parar criar o embbed
        for (Pattern p : _youtube_patterns) {
            Matcher m = p.matcher(videoId.trim());
            if (m.find()) {
                sb.append("<iframe ");
                sb.append("width=\"").append(videoWidth).append("\" ");
                sb.append("height=\"").append(videoHeight).append("\" ");
                sb.append("src=\"http://www.youtube.com/embed/");
                sb.append(m.group(1));/*from   ww  w.j  av  a2s. c om*/
                sb.append("\" frameborder=\"0\" allowfullscreen></iframe>");
                break;
            }
        }
    }
}

From source file:com.liferay.compat.hook.webdav.CompatDLWebDAVStorageImpl.java

License:Open Source License

public Status lockResource(WebDAVRequest webDAVRequest, String owner, long timeout) throws WebDAVException {

    Resource resource = getResource(webDAVRequest);

    Lock lock = null;//from   w ww .j a v  a 2  s.  c  o m
    int status = HttpServletResponse.SC_OK;

    try {
        if (resource == null) {
            status = HttpServletResponse.SC_CREATED;

            HttpServletRequest request = webDAVRequest.getHttpServletRequest();

            String[] pathArray = webDAVRequest.getPathArray();

            long companyId = webDAVRequest.getCompanyId();
            long groupId = webDAVRequest.getGroupId();
            long parentFolderId = getParentFolderId(companyId, pathArray);
            String title = WebDAVUtil.getResourceName(pathArray);

            String contentType = GetterUtil.get(request.getHeader(HttpHeaders.CONTENT_TYPE),
                    ContentTypes.APPLICATION_OCTET_STREAM);

            if (contentType.equals(ContentTypes.APPLICATION_OCTET_STREAM)) {
                contentType = MimeTypesUtil.getContentType(request.getInputStream(), title);
            }

            String description = StringPool.BLANK;
            String changeLog = StringPool.BLANK;

            File file = FileUtil.createTempFile(FileUtil.getExtension(title));

            file.createNewFile();

            ServiceContext serviceContext = new ServiceContext();

            serviceContext.setAddGroupPermissions(isAddGroupPermissions(groupId));
            serviceContext.setAddGuestPermissions(true);

            FileEntry fileEntry = DLAppServiceUtil.addFileEntry(groupId, parentFolderId, title, contentType,
                    title, description, changeLog, file, serviceContext);

            resource = toResource(webDAVRequest, fileEntry, false);
        }

        if (isInstanceOfDLFileEntryResourceImpl(super.getResource(webDAVRequest))) {

            FileEntry fileEntry = (FileEntry) resource.getModel();

            ServiceContext serviceContext = new ServiceContext();

            serviceContext.setAttribute(DLUtil.MANUAL_CHECK_IN_REQUIRED,
                    CompatWebDAVThreadLocal.isManualCheckInRequired());

            DLAppServiceUtil.checkOutFileEntry(fileEntry.getFileEntryId(), owner, timeout, serviceContext);

            lock = fileEntry.getLock();
        } else {
            boolean inheritable = false;

            long depth = WebDAVUtil.getDepth(webDAVRequest.getHttpServletRequest());

            if (depth != 0) {
                inheritable = true;
            }

            Folder folder = (Folder) resource.getModel();

            lock = DLAppServiceUtil.lockFolder(folder.getRepositoryId(), folder.getFolderId(), owner,
                    inheritable, timeout);
        }
    } catch (Exception e) {

        // DuplicateLock is 423 not 501

        if (!(e instanceof DuplicateLockException)) {
            throw new WebDAVException(e);
        }

        status = WebDAVUtil.SC_LOCKED;
    }

    return new Status(lock, status);
}

From source file:com.liferay.configuration.admin.web.internal.model.ConfigurationModel.java

License:Open Source License

public String getCategory() {
    Map<String, String> extensionAttributes = _extendedObjectClassDefinition
            .getExtensionAttributes(XML_NAMESPACE);

    return GetterUtil.get(extensionAttributes.get("category"), "other");
}

From source file:com.liferay.configuration.admin.web.internal.model.ConfigurationModel.java

License:Open Source License

public String getLabelAttribute() {
    Map<String, String> extensionAttributes = _extendedObjectClassDefinition
            .getExtensionAttributes(XML_NAMESPACE);

    return GetterUtil.get(extensionAttributes.get("factoryInstanceLabelAttribute"), StringPool.BLANK);
}

From source file:com.liferay.document.library.jaxrs.FileResource.java

License:Open Source License

@Path("/content")
@PUT//from   ww w  . j  a v  a  2  s. co m
public FileRepr updateFile(@Context HttpServletRequest httpServletRequest, byte[] bytes,
        @QueryParam("changelog") String changelog, @QueryParam("majorVersion") boolean majorVersion)
        throws PortalException {

    changelog = GetterUtil.get(changelog, StringPool.BLANK);

    return FileRepr
            .fromFileEntry(
                    _dlAppService.updateFileEntry(_fileEntry.getFileEntryId(), _fileEntry.getFileName(),
                            httpServletRequest.getContentType(), _fileEntry.getTitle(),
                            _fileEntry.getDescription(), changelog, majorVersion, bytes, new ServiceContext()),
                    _fileUriBuilder);
}

From source file:com.liferay.portlet.documentlibrary.sharepoint.DLSharepointStorageImpl.java

License:Open Source License

@Override
public void putDocument(SharepointRequest sharepointRequest) throws Exception {

    HttpServletRequest request = sharepointRequest.getHttpServletRequest();

    String documentPath = sharepointRequest.getRootPath();
    String parentFolderPath = getParentFolderPath(documentPath);

    long groupId = SharepointUtil.getGroupId(parentFolderPath);
    long parentFolderId = getLastFolderId(groupId, parentFolderPath,
            DLFolderConstants.DEFAULT_PARENT_FOLDER_ID);
    String title = getResourceName(documentPath);
    String description = StringPool.BLANK;
    String changeLog = StringPool.BLANK;

    ServiceContext serviceContext = new ServiceContext();

    serviceContext.setAddGroupPermissions(true);
    serviceContext.setAddGuestPermissions(true);

    String contentType = GetterUtil.get(request.getHeader(HttpHeaders.CONTENT_TYPE),
            ContentTypes.APPLICATION_OCTET_STREAM);

    String extension = FileUtil.getExtension(title);

    File file = null;/*  w  ww .java 2  s.  c o  m*/

    try {
        file = FileUtil.createTempFile(extension);

        FileUtil.write(file, request.getInputStream());

        if (contentType.equals(ContentTypes.APPLICATION_OCTET_STREAM)) {
            contentType = MimeTypesUtil.getContentType(file, title);
        }

        try {
            FileEntry fileEntry = getFileEntry(sharepointRequest);

            long fileEntryId = fileEntry.getFileEntryId();

            description = fileEntry.getDescription();

            String[] assetTagNames = AssetTagLocalServiceUtil.getTagNames(FileEntry.class.getName(),
                    fileEntry.getFileEntryId());

            serviceContext.setAssetTagNames(assetTagNames);

            DLAppServiceUtil.updateFileEntry(fileEntryId, title, contentType, title, description, changeLog,
                    false, file, serviceContext);
        } catch (NoSuchFileEntryException nsfee) {
            DLAppServiceUtil.addFileEntry(groupId, parentFolderId, title, contentType, title, description,
                    changeLog, file, serviceContext);
        }
    } finally {
        FileUtil.delete(file);
    }
}

From source file:com.liferay.portlet.documentlibrary.webdav.DLWebDAVStorageImpl.java

License:Open Source License

@Override
public Status lockResource(WebDAVRequest webDavRequest, String owner, long timeout) throws WebDAVException {

    Resource resource = getResource(webDavRequest);

    Lock lock = null;/*w  ww.jav a2 s.  com*/
    int status = HttpServletResponse.SC_OK;

    try {
        if (resource == null) {
            status = HttpServletResponse.SC_CREATED;

            HttpServletRequest request = webDavRequest.getHttpServletRequest();

            String[] pathArray = webDavRequest.getPathArray();

            long companyId = webDavRequest.getCompanyId();
            long groupId = webDavRequest.getGroupId();
            long parentFolderId = getParentFolderId(companyId, pathArray);
            String title = WebDAVUtil.getResourceName(pathArray);

            String contentType = GetterUtil.get(request.getHeader(HttpHeaders.CONTENT_TYPE),
                    ContentTypes.APPLICATION_OCTET_STREAM);

            if (contentType.equals(ContentTypes.APPLICATION_OCTET_STREAM)) {
                contentType = MimeTypesUtil.getContentType(request.getInputStream(), title);
            }

            String description = StringPool.BLANK;
            String changeLog = StringPool.BLANK;

            File file = FileUtil.createTempFile(FileUtil.getExtension(title));

            file.createNewFile();

            ServiceContext serviceContext = new ServiceContext();

            serviceContext.setAddGroupPermissions(isAddGroupPermissions(groupId));
            serviceContext.setAddGuestPermissions(true);

            FileEntry fileEntry = DLAppServiceUtil.addFileEntry(groupId, parentFolderId, title, contentType,
                    title, description, changeLog, file, serviceContext);

            resource = toResource(webDavRequest, fileEntry, false);
        }

        if (resource instanceof DLFileEntryResourceImpl) {
            FileEntry fileEntry = (FileEntry) resource.getModel();

            lock = DLAppServiceUtil.lockFileEntry(fileEntry.getFileEntryId(), owner, timeout);
        } else {
            boolean inheritable = false;

            long depth = WebDAVUtil.getDepth(webDavRequest.getHttpServletRequest());

            if (depth != 0) {
                inheritable = true;
            }

            Folder folder = (Folder) resource.getModel();

            lock = DLAppServiceUtil.lockFolder(folder.getRepositoryId(), folder.getFolderId(), owner,
                    inheritable, timeout);
        }
    } catch (Exception e) {

        // DuplicateLock is 423 not 501

        if (!(e instanceof DuplicateLockException)) {
            throw new WebDAVException(e);
        }

        status = WebDAVUtil.SC_LOCKED;
    }

    return new Status(lock, status);
}

From source file:com.liferay.portlet.documentlibrary.webdav.DLWebDAVStorageImpl.java

License:Open Source License

@Override
public int putResource(WebDAVRequest webDavRequest) throws WebDAVException {
    File file = null;//from ww  w .  j a  va 2  s .  c o m

    try {
        HttpServletRequest request = webDavRequest.getHttpServletRequest();

        String[] pathArray = webDavRequest.getPathArray();

        long companyId = webDavRequest.getCompanyId();
        long groupId = webDavRequest.getGroupId();
        long parentFolderId = getParentFolderId(companyId, pathArray);
        String title = WebDAVUtil.getResourceName(pathArray);
        String description = StringPool.BLANK;
        String changeLog = StringPool.BLANK;

        ServiceContext serviceContext = ServiceContextFactory.getInstance(request);

        serviceContext.setAddGroupPermissions(isAddGroupPermissions(groupId));
        serviceContext.setAddGuestPermissions(true);

        String contentType = GetterUtil.get(request.getHeader(HttpHeaders.CONTENT_TYPE),
                ContentTypes.APPLICATION_OCTET_STREAM);

        String extension = FileUtil.getExtension(title);

        file = FileUtil.createTempFile(extension);

        FileUtil.write(file, request.getInputStream());

        if (contentType.equals(ContentTypes.APPLICATION_OCTET_STREAM)) {
            contentType = MimeTypesUtil.getContentType(file, title);
        }

        try {
            FileEntry fileEntry = DLAppServiceUtil.getFileEntry(groupId, parentFolderId, title);

            if (!hasLock(fileEntry, webDavRequest.getLockUuid()) && (fileEntry.getLock() != null)) {

                return WebDAVUtil.SC_LOCKED;
            }

            long fileEntryId = fileEntry.getFileEntryId();

            description = fileEntry.getDescription();

            String[] assetTagNames = AssetTagLocalServiceUtil.getTagNames(FileEntry.class.getName(),
                    fileEntry.getFileEntryId());

            serviceContext.setAssetTagNames(assetTagNames);

            DLAppServiceUtil.updateFileEntry(fileEntryId, title, contentType, title, description, changeLog,
                    false, file, serviceContext);
        } catch (NoSuchFileEntryException nsfee) {
            if (file.length() == 0) {
                serviceContext.setWorkflowAction(WorkflowConstants.ACTION_SAVE_DRAFT);
            }

            DLAppServiceUtil.addFileEntry(groupId, parentFolderId, title, contentType, title, description,
                    changeLog, file, serviceContext);
        }

        if (_log.isInfoEnabled()) {
            _log.info("Added " + StringUtil.merge(pathArray, StringPool.SLASH));
        }

        return HttpServletResponse.SC_CREATED;
    } catch (PrincipalException pe) {
        return HttpServletResponse.SC_FORBIDDEN;
    } catch (NoSuchFolderException nsfe) {
        return HttpServletResponse.SC_CONFLICT;
    } catch (PortalException pe) {
        if (_log.isWarnEnabled()) {
            _log.warn(pe, pe);
        }

        return HttpServletResponse.SC_CONFLICT;
    } catch (Exception e) {
        throw new WebDAVException(e);
    } finally {
        FileUtil.delete(file);
    }
}

From source file:com.liferay.wsrp.consumer.portlet.ConsumerFriendlyURLMapper.java

License:Open Source License

protected void addPathElement(StringBuilder sb, String value) {
    sb.append(StringPool.SLASH);
    sb.append(GetterUtil.get(HttpUtil.encodeURL(value), StringPool.DASH));
}