Example usage for com.liferay.portal.kernel.util WebKeys DOCUMENT_LIBRARY_FILE_ENTRY_TYPE

List of usage examples for com.liferay.portal.kernel.util WebKeys DOCUMENT_LIBRARY_FILE_ENTRY_TYPE

Introduction

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

Prototype

String DOCUMENT_LIBRARY_FILE_ENTRY_TYPE

To view the source code for com.liferay.portal.kernel.util WebKeys DOCUMENT_LIBRARY_FILE_ENTRY_TYPE.

Click Source Link

Usage

From source file:com.liferay.document.library.web.internal.portlet.action.EditFileEntryTypeMVCRenderCommand.java

License:Open Source License

@Override
public String render(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException {

    DLFileEntryType dlFileEntryType = null;

    try {//from   ww  w.  jav a2s.co  m
        long fileEntryTypeId = ParamUtil.getLong(renderRequest, "fileEntryTypeId");

        if (fileEntryTypeId > 0) {
            dlFileEntryType = _dlFileEntryTypeService.getFileEntryType(fileEntryTypeId);

            renderRequest.setAttribute(WebKeys.DOCUMENT_LIBRARY_FILE_ENTRY_TYPE, dlFileEntryType);

            DDMStructure ddmStructure = DDMStructureManagerUtil.fetchStructure(dlFileEntryType.getGroupId(),
                    _portal.getClassNameId(DLFileEntryMetadata.class),
                    DLUtil.getDDMStructureKey(dlFileEntryType));

            if (ddmStructure == null) {
                ddmStructure = DDMStructureManagerUtil.fetchStructure(dlFileEntryType.getGroupId(),
                        _portal.getClassNameId(DLFileEntryMetadata.class),
                        DLUtil.getDeprecatedDDMStructureKey(dlFileEntryType));
            }

            renderRequest.setAttribute(WebKeys.DOCUMENT_LIBRARY_DYNAMIC_DATA_MAPPING_STRUCTURE, ddmStructure);
        }
    } catch (Exception e) {
        if (e instanceof NoSuchFileEntryTypeException || e instanceof PrincipalException) {

            SessionErrors.add(renderRequest, e.getClass());

            return "/document_library/error.jsp";
        } else {
            throw new PortletException(e);
        }
    }

    return "/document_library/edit_file_entry_type.jsp";
}