001: /**********************************************************************************
002: * $URL: https://source.sakaiproject.org/svn/search/tags/sakai_2-4-1/search-impl/impl/src/java/org/sakaiproject/search/component/adapter/contenthosting/BaseContentDigester.java $
003: * $Id: BaseContentDigester.java 29315 2007-04-20 14:28:12Z ajpoland@iupui.edu $
004: ***********************************************************************************
005: *
006: * Copyright (c) 2003, 2004, 2005, 2006 The Sakai Foundation.
007: *
008: * Licensed under the Educational Community License, Version 1.0 (the "License");
009: * you may not use this file except in compliance with the License.
010: * You may obtain a copy of the License at
011: *
012: * http://www.opensource.org/licenses/ecl1.php
013: *
014: * Unless required by applicable law or agreed to in writing, software
015: * distributed under the License is distributed on an "AS IS" BASIS,
016: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: * See the License for the specific language governing permissions and
018: * limitations under the License.
019: *
020: **********************************************************************************/package org.sakaiproject.search.component.adapter.contenthosting;
021:
022: import java.util.HashMap;
023:
024: import org.apache.commons.logging.Log;
025: import org.apache.commons.logging.LogFactory;
026:
027: /**
028: * @author ieb
029: */
030: public abstract class BaseContentDigester implements ContentDigester {
031:
032: private static Log log = LogFactory
033: .getLog(BaseContentDigester.class);
034:
035: private ContentHostingContentProducer contentProducer = null;
036:
037: protected int maxDigestSize = 1024 * 1024 * 5; // 10M
038:
039: public void init() {
040: try {
041: contentProducer.addDigester(this );
042: } catch (Throwable t) {
043: log.error("Failed to init", t);
044: }
045: }
046:
047: public void destroy() {
048: contentProducer.removeDigester(this );
049: }
050:
051: private HashMap mimeTypes = null;
052:
053: /*
054: * (non-Javadoc)
055: *
056: * @see org.sakaiproject.search.component.adapter.contenthosting.ContentDigester#accept(java.lang.String)
057: */
058: public boolean accept(String mimeType) {
059: return (mimeTypes.get(mimeType) != null);
060: }
061:
062: /**
063: * @return Returns the mimeTypes.
064: */
065: public HashMap getMimeTypes() {
066: return mimeTypes;
067: }
068:
069: /**
070: * @param mimeTypes
071: * The mimeTypes to set.
072: */
073: public void setMimeTypes(HashMap mimeTypes) {
074: this .mimeTypes = mimeTypes;
075: }
076:
077: /**
078: * @return Returns the contentProducer.
079: */
080: public ContentHostingContentProducer getContentProducer() {
081: return contentProducer;
082: }
083:
084: /**
085: * @param contentProducer
086: * The contentProducer to set.
087: */
088: public void setContentProducer(
089: ContentHostingContentProducer contentProducer) {
090: this .contentProducer = contentProducer;
091: }
092:
093: /**
094: * @return Returns the maxDigestSize.
095: */
096: public int getMaxDigestSize() {
097: return maxDigestSize;
098: }
099:
100: /**
101: * @param maxDigestSize The maxDigestSize to set.
102: */
103: public void setMaxDigestSize(int maxDigestSize) {
104: this.maxDigestSize = maxDigestSize;
105: }
106:
107: }
|