The below code helps you to get the field values from the custom document type of Liferay.
import com.liferay.portlet.documentlibrary.model.DLFileEntry;
import com.liferay.portlet.documentlibrary.model.DLFileEntryMetadata;
import com.liferay.portlet.documentlibrary.model.DLFileEntryType;
import com.liferay.portlet.documentlibrary.model.DLFileVersion;
import com.liferay.portlet.documentlibrary.model.DLFolder;
import com.liferay.portlet.documentlibrary.model.DLFolderConstants;
import com.liferay.portlet.documentlibrary.model.DLFileEntry;
import com.liferay.portlet.documentlibrary.model.DLFileEntryMetadata;
import com.liferay.portlet.documentlibrary.model.DLFileEntryType;
import com.liferay.portlet.documentlibrary.model.DLFileVersion;
import com.liferay.portlet.documentlibrary.model.DLFolder;
import com.liferay.portlet.documentlibrary.model.DLFolderConstants;
public static String getFieldValue(DLFileEntry fileEntry,String name){
String feildValue = StringPool.BLANK;
try {
DLFileEntryType dlFileEntryType = DLFileEntryTypeLocalServiceUtil.getFileEntryType(fileEntry.getFileEntryTypeId());
List ddmStructures = dlFileEntryType.getDDMStructures();
if(Validator.isNotNull(ddmStructures)){
DDMStructure ddmStructure = ddmStructures.get(0);
DLFileVersion dlFileVersion = fileEntry.getFileVersion();
DLFileEntryMetadata dlFileEntryMetadata = DLFileEntryMetadataLocalServiceUtil.getFileEntryMetadata(ddmStructure.getStructureId(), dlFileVersion.getFileVersionId());
Fields fields = StorageEngineUtil.getFields(dlFileEntryMetadata.getDDMStorageId());
if(Validator.isNotNull(fields.get(name))){
feildValue= GetterUtil.getString(fields.get(name).getValue());
}
}
} catch (PortalException | SystemException e) {
_log.error(e.getMessage(), e);
}
return feildValue;
}
import com.liferay.portlet.documentlibrary.model.DLFileEntry;
import com.liferay.portlet.documentlibrary.model.DLFileEntryMetadata;
import com.liferay.portlet.documentlibrary.model.DLFileEntryType;
import com.liferay.portlet.documentlibrary.model.DLFileVersion;
import com.liferay.portlet.documentlibrary.model.DLFolder;
import com.liferay.portlet.documentlibrary.model.DLFolderConstants;
import com.liferay.portlet.documentlibrary.model.DLFileEntry;
import com.liferay.portlet.documentlibrary.model.DLFileEntryMetadata;
import com.liferay.portlet.documentlibrary.model.DLFileEntryType;
import com.liferay.portlet.documentlibrary.model.DLFileVersion;
import com.liferay.portlet.documentlibrary.model.DLFolder;
import com.liferay.portlet.documentlibrary.model.DLFolderConstants;
public static String getFieldValue(DLFileEntry fileEntry,String name){
String feildValue = StringPool.BLANK;
try {
DLFileEntryType dlFileEntryType = DLFileEntryTypeLocalServiceUtil.getFileEntryType(fileEntry.getFileEntryTypeId());
List
if(Validator.isNotNull(ddmStructures)){
DDMStructure ddmStructure = ddmStructures.get(0);
DLFileVersion dlFileVersion = fileEntry.getFileVersion();
DLFileEntryMetadata dlFileEntryMetadata = DLFileEntryMetadataLocalServiceUtil.getFileEntryMetadata(ddmStructure.getStructureId(), dlFileVersion.getFileVersionId());
Fields fields = StorageEngineUtil.getFields(dlFileEntryMetadata.getDDMStorageId());
if(Validator.isNotNull(fields.get(name))){
feildValue= GetterUtil.getString(fields.get(name).getValue());
}
}
} catch (PortalException | SystemException e) {
_log.error(e.getMessage(), e);
}
return feildValue;
}