001
014
015 package com.liferay.portlet.documentlibrary.util;
016
017 import com.liferay.portal.kernel.exception.PortalException;
018 import com.liferay.portal.kernel.exception.SystemException;
019 import com.liferay.portal.kernel.repository.model.FileEntry;
020 import com.liferay.portal.kernel.repository.model.FileVersion;
021 import com.liferay.portlet.documentlibrary.model.DLProcessorConstants;
022
023
038 public class RawMetadataProcessorUtil {
039
040 public static void cleanUp(FileEntry fileEntry) {
041 RawMetadataProcessor rawMetadataProcessor = getRawMetadataProcessor();
042
043 if (rawMetadataProcessor != null) {
044 rawMetadataProcessor.cleanUp(fileEntry);
045 }
046 }
047
048 public static void cleanUp(FileVersion fileVersion) {
049 RawMetadataProcessor rawMetadataProcessor = getRawMetadataProcessor();
050
051 if (rawMetadataProcessor != null) {
052 rawMetadataProcessor.cleanUp(fileVersion);
053 }
054 }
055
056
064 public static void generateMetadata(FileVersion fileVersion)
065 throws PortalException, SystemException {
066
067 RawMetadataProcessor rawMetadataProcessor = getRawMetadataProcessor();
068
069 if (rawMetadataProcessor != null) {
070 rawMetadataProcessor.generateMetadata(fileVersion);
071 }
072 }
073
074 public static RawMetadataProcessor getRawMetadataProcessor() {
075 return (RawMetadataProcessor)DLProcessorRegistryUtil.getDLProcessor(
076 DLProcessorConstants.RAW_METADATA_PROCESSOR);
077 }
078
079 public static boolean isSupported(FileVersion fileVersion) {
080 RawMetadataProcessor rawMetadataProcessor = getRawMetadataProcessor();
081
082 if (rawMetadataProcessor == null) {
083 return false;
084 }
085
086 return rawMetadataProcessor.isSupported(fileVersion);
087 }
088
089 public static boolean isSupported(String mimeType) {
090 RawMetadataProcessor rawMetadataProcessor = getRawMetadataProcessor();
091
092 if (rawMetadataProcessor == null) {
093 return false;
094 }
095
096 return rawMetadataProcessor.isSupported(mimeType);
097 }
098
099
112 public static void saveMetadata(FileVersion fileVersion)
113 throws PortalException, SystemException {
114
115 RawMetadataProcessor rawMetadataProcessor = getRawMetadataProcessor();
116
117 if (rawMetadataProcessor != null) {
118 rawMetadataProcessor.saveMetadata(fileVersion);
119 }
120 }
121
122
132 public static void trigger(FileVersion fileVersion) {
133 RawMetadataProcessor rawMetadataProcessor = getRawMetadataProcessor();
134
135 if (rawMetadataProcessor != null) {
136 rawMetadataProcessor.trigger(fileVersion);
137 }
138 }
139
140
143 public void setRawMetadataProcessor(
144 RawMetadataProcessor rawMetadataProcessor) {
145 }
146
147 }