1
22
23 package com.liferay.documentlibrary.util;
24
25 import com.liferay.documentlibrary.service.jms.IndexProducer;
26 import com.liferay.portal.kernel.search.Document;
27 import com.liferay.portal.kernel.search.DocumentSummary;
28 import com.liferay.portal.kernel.search.SearchException;
29 import com.liferay.portal.kernel.util.LongWrapper;
30 import com.liferay.portal.kernel.util.MethodWrapper;
31
32 import java.io.IOException;
33
34 import javax.portlet.PortletURL;
35
36 import org.apache.commons.logging.Log;
37 import org.apache.commons.logging.LogFactory;
38
39
45 public class Indexer implements com.liferay.portal.kernel.search.Indexer {
46
47 public static void addFile(
48 long companyId, String portletId, long groupId, long repositoryId,
49 String fileName)
50 throws IOException {
51
52 try {
53 MethodWrapper methodWrapper = new MethodWrapper(
54 IndexerImpl.class.getName(), "addFile",
55 new Object[] {
56 new LongWrapper(companyId), portletId,
57 new LongWrapper(groupId), new LongWrapper(repositoryId),
58 fileName
59 });
60
61 IndexProducer.produce(methodWrapper);
62 }
63 catch (Exception e) {
64 if (e instanceof IOException) {
65 throw (IOException)e;
66 }
67 else {
68 _log.error(e);
69 }
70 }
71 }
72
73 public static void addFile(
74 long companyId, String portletId, long groupId, long repositoryId,
75 String fileName, String properties)
76 throws IOException {
77
78 try {
79 MethodWrapper methodWrapper = new MethodWrapper(
80 IndexerImpl.class.getName(), "addFile",
81 new Object[] {
82 new LongWrapper(companyId), portletId,
83 new LongWrapper(groupId), new LongWrapper(repositoryId),
84 fileName, properties
85 });
86
87 IndexProducer.produce(methodWrapper);
88 }
89 catch (Exception e) {
90 if (e instanceof IOException) {
91 throw (IOException)e;
92 }
93 else {
94 _log.error(e);
95 }
96 }
97 }
98
99 public static void deleteFile(
100 long companyId, String portletId, long repositoryId,
101 String fileName)
102 throws IOException {
103
104 try {
105 MethodWrapper methodWrapper = new MethodWrapper(
106 IndexerImpl.class.getName(), "deleteFile",
107 new Object[] {
108 new LongWrapper(companyId), portletId,
109 new LongWrapper(repositoryId), fileName
110 });
111
112 IndexProducer.produce(methodWrapper);
113 }
114 catch (Exception e) {
115 if (e instanceof IOException) {
116 throw (IOException)e;
117 }
118 else {
119 _log.error(e);
120 }
121 }
122 }
123
124 public static void updateFile(
125 long companyId, String portletId, long groupId, long repositoryId,
126 String fileName, String properties)
127 throws IOException {
128
129 try {
130 MethodWrapper methodWrapper = new MethodWrapper(
131 IndexerImpl.class.getName(), "updateFile",
132 new Object[] {
133 new LongWrapper(companyId), portletId,
134 new LongWrapper(groupId), new LongWrapper(repositoryId),
135 fileName, properties
136 });
137
138 IndexProducer.produce(methodWrapper);
139 }
140 catch (Exception e) {
141 if (e instanceof IOException) {
142 throw (IOException)e;
143 }
144 else {
145 _log.error(e);
146 }
147 }
148 }
149
150 public DocumentSummary getDocumentSummary(
151 Document doc, PortletURL portletURL) {
152
153 return null;
154 }
155
156 public void reIndex(String[] ids) throws SearchException {
157 IndexerImpl.reIndex(ids);
158 }
159
160 private static Log _log = LogFactory.getLog(Indexer.class);
161
162 }