Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

docs, indenting

  • Loading branch information...
commit adb85ed446f8874cc5c2dfb8fa0ec4374a8f78f4 1 parent 294b87f
Benjamin Pick authored
View
49 plugin/src/de/uni_siegen/wineme/come_in/thumbnailer/plugin/ThumbnailerPlugin.java
@@ -57,22 +57,23 @@
* Integration of Thumbnailer into Regain
*
* In order to save ressources, the Thumbnail Library remains loaded only until the end of the crawling process.
+ *
* @author Benjamin
*/
public class ThumbnailerPlugin extends AbstractCrawlerPlugin implements ThumbnailerLuceneConstants, ThumbnailerConstants
{
/**
- * Logger instance
+ * @var Logger instance
*/
private static Logger mLog = Logger.getLogger(ThumbnailerPlugin.class);
/**
- * Thumbnailer Manager (can be null if deactivated)
+ * @var Thumbnailer Manager (can be null if deactivated)
*/
private ThumbnailerManager thumbnailer;
/**
- * If thumbnails should be generated.
+ * @var If thumbnails should be generated.
* This can be deactivated due to initialization errors, or via config.
*/
private boolean thumbnailGenerationDeactivated = false;
@@ -84,10 +85,14 @@
private int paramThumbnailHeight;
private File paramThumbnailFolder;
private String paramOpenOfficeHome;
-
private String paramOpenOfficeProfile;
-
+ /**
+ * Initializes the plugin.
+ *
+ * @param config The configuration for this plugin.
+ * @throws RegainException When the configuration has an error.
+ */
@Override
public void init(PreparatorConfig config) throws RegainException {
Map<String, String> thumbnailConfig = config.getSectionWithName("thumbnailing");
@@ -141,8 +146,14 @@ public void init(PreparatorConfig config) throws RegainException {
}
/**
+ * Called before the crawling process starts (Crawler::run()).
* Initialize Thumbnail Generation:
* load Config and configure Thumbnailer
+ *
+ * This may be called multiple times during the lifetime of a plugin instance,
+ * but CrawlerPlugin::onFinishCrawling() is always called in between.
+ *
+ * @param crawler The crawler instance that is about to begin crawling
*/
public void onStartCrawling(Crawler crawler) {
if (thumbnailGenerationDeactivated)
@@ -185,7 +196,12 @@ public void onStartCrawling(Crawler crawler) {
}
/**
+ * Called after the crawling process has finished or aborted (because of an exception):
* Close the Thumbnail Generator.
+ *
+ * This may be called multiple times during the lifetime of a plugin instance.
+ *
+ * @param crawler The crawler instance that is about to finish crawling
*/
public void onFinishCrawling(Crawler crawler) {
if (thumbnailer == null)
@@ -197,10 +213,14 @@ public void onFinishCrawling(Crawler crawler) {
}
/**
- * Called when a document is dropped from lucene index.
+ * Called when a document is deleted from the index:
+ * Delete the created thumbnail
*
- * We will need to:
- * <li>Delete the created thumbnail
+ * Note that when being replaced by another document ("update index"),
+ * the old document is added to index first, deleting is part of the cleaning-up-at-the-end-Phase.
+ *
+ * @param doc Document to read
+ * @param index Luce Index Reader
*/
public void onDeleteIndexEntry(Document doc, IndexReader index) {
String location = getLuceneField(doc, LUCENE_FIELD_NAME_FILE_LOCATION);
@@ -244,8 +264,11 @@ protected String getLuceneField(Document doc, String fieldname) {
}
/**
- * After the document was prepared, let's add a thumbnail.
- * (Create the thumbnail and add the information about its creation to the lucene entry.)
+ * Called after a document is being prepared to be added to the index:
+ * Create the thumbnail and add the information about its creation to the lucene entry.
+ *
+ * @param document Regain document that was analysed
+ * @param preparator Preparator that has analysed this document
*/
public void onAfterPrepare(RawDocument document, WriteablePreparator preparator) {
String thumbnailerStatus = "";
@@ -284,10 +307,4 @@ public void onAfterPrepare(RawDocument document, WriteablePreparator preparator)
preparator.addAdditionalField(LUCENE_FIELD_NAME_STATUS, thumbnailerStatus);
preparator.addAdditionalField(LUCENE_FIELD_NAME_FILE_LOCATION, thumbnailLocation);
}
-
-
-
-
-
-
}
View
73 plugin/src/de/uni_siegen/wineme/come_in/thumbnailer/plugin/sharedlib/ImgTag.java
@@ -43,6 +43,9 @@
* <p>
* Tag Parameters:
* <ul>
+ * <li>width: Width of the image (px)
+ * <li>height: Height of the image (px)
+ * <li>missing: Name of image to show when no image was generated
* </ul>
*
* @author b
@@ -58,42 +61,42 @@
* @param hitIndex The index of the hit.
* @throws RegainException If there was an exception.
*/
- protected void printEndTag(PageRequest request, PageResponse response,
- Document hit, int hitIndex)
- throws RegainException {
- //SearchResults results = SearchToolkit.getSearchResults(request);
+ protected void printEndTag(PageRequest request, PageResponse response,
+ Document hit, int hitIndex)
+ throws RegainException {
+ //SearchResults results = SearchToolkit.getSearchResults(request);
- int width = getParameterAsInt("width", THUMBNAIL_DEFAULT_WIDTH);
- if (width < 0)
- width = THUMBNAIL_DEFAULT_WIDTH;
-
- int height = getParameterAsInt("height", THUMBNAIL_DEFAULT_HEIGHT);
- if (height < 0)
- height = THUMBNAIL_DEFAULT_HEIGHT;
-
- String size = "width=\"" + width + "\" height=\"" + height + "\"";
+ int width = getParameterAsInt("width", THUMBNAIL_DEFAULT_WIDTH);
+ if (width < 0)
+ width = THUMBNAIL_DEFAULT_WIDTH;
- String status = SearchToolkit.getCompressedFieldValue(hit, LUCENE_FIELD_NAME_STATUS);
-
- String location = null;
- if (LUCENE_FIELD_VALUE_STATUS_OK.equals(status))
- location = SearchToolkit.getCompressedFieldValue(hit, LUCENE_FIELD_NAME_FILE_LOCATION);
-
- // New For Thumbnail Tag
- if (location != null) {
- response.print("<img src=\"");
- response.printNoHtml(rewrite(location));
- response.print("\" " + size + " />");
- }
- else {
- String img_missing = getParameter("missing", false);
- if (img_missing != null && !img_missing.isEmpty())
- response.print("<img src=\"" +img_missing + "\" " + size + " />");
- }
- }
+ int height = getParameterAsInt("height", THUMBNAIL_DEFAULT_HEIGHT);
+ if (height < 0)
+ height = THUMBNAIL_DEFAULT_HEIGHT;
-private String rewrite(String value) {
- // TODO: Config Rewrite Rule / Thumbnail Base Path
- return "thumbs/" + value;
-}
+ String size = "width=\"" + width + "\" height=\"" + height + "\"";
+
+ String status = SearchToolkit.getCompressedFieldValue(hit, LUCENE_FIELD_NAME_STATUS);
+
+ String location = null;
+ if (LUCENE_FIELD_VALUE_STATUS_OK.equals(status))
+ location = SearchToolkit.getCompressedFieldValue(hit, LUCENE_FIELD_NAME_FILE_LOCATION);
+
+ // New For Thumbnail Tag
+ if (location != null) {
+ response.print("<img src=\"");
+ response.printNoHtml(rewrite(location));
+ response.print("\" " + size + " />");
+ }
+ else {
+ String img_missing = getParameter("missing", false);
+ if (img_missing != null && !img_missing.isEmpty())
+ response.print("<img src=\"" +img_missing + "\" " + size + " />");
+ }
+ }
+
+ private String rewrite(String value) {
+ // TODO: Config Rewrite Rule / Thumbnail Base Path
+ return "thumbs/" + value;
+ }
}
View
25 src/de/uni_siegen/wineme/come_in/thumbnailer/ThumbnailerManager.java
@@ -36,7 +36,7 @@
/**
* This class manages all available Thumbnailers.
- * It's purpose is to delegate a File to the appropriate Thumbnailer in order to get a Thumbnail of it.
+ * Its purpose is to delegate a File to the appropriate Thumbnailer in order to get a Thumbnail of it.
* This is done in a fall-through manner: If several Thumbnailer can handle a specific filetype,
* all are tried until a Thumbnail could be created.
*
@@ -44,19 +44,36 @@
* Then call generateThumbnail().
*
* @author Benjamin
- *
-
*/
public class ThumbnailerManager implements Thumbnailer, ThumbnailerConstants {
+ /**
+ * @var Starting estimate of the number of mime types that the thumbnailer can manager
+ */
private static final int DEFAULT_NB_MIME_TYPES = 40;
+ /**
+ * @var Starting estimate of the number of thumbnailers per mime type
+ */
private static final int DEFAULT_NB_THUMBNAILERS_PER_MIME = 5;
- /** MIME Type for "all MIME" within thumbnailers Hash */
+ /**
+ * @var MIME Type for "all MIME" within thumbnailers Hash
+ */
private static final String ALL_MIME_WILDCARD = "*/*";
+ /**
+ * @var Width of thumbnail picture to create (in Pixel)
+ */
private int thumbWidth;
+
+ /**
+ * @var Height of thumbnail picture to create (in Pixel)
+ */
private int thumbHeight;
+
+ /**
+ * @var Options for image resizer (currently unused)
+ */
private int thumbOptions = 0;
/** Folder under which new thumbnails should be filed */
Please sign in to comment.
Something went wrong with that request. Please try again.