You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@roller.apache.org by sn...@apache.org on 2006/05/25 21:06:37 UTC
svn commit: r409435 [2/3] - in /incubator/roller/branches/roller_3.0:
src/org/apache/roller/business/ src/org/apache/roller/business/hibernate/
src/org/apache/roller/business/search/
src/org/apache/roller/business/search/operations/ src/org/apache/roll...
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/business/search/operations/RebuildWebsiteIndexOperation.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/business/search/operations/RebuildWebsiteIndexOperation.java?rev=409435&r1=409434&r2=409435&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/business/search/operations/RebuildWebsiteIndexOperation.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/business/search/operations/RebuildWebsiteIndexOperation.java Thu May 25 12:06:35 2006
@@ -1,25 +1,21 @@
/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. The ASF licenses this file to You
-* under the Apache License, Version 2.0 (the "License"); you may not
-* use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License. For additional information regarding
-* copyright in this work, please see the NOTICE file in the top level
-* directory of this distribution.
-*/
-/*
- * Created on Jul 16, 2003
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * Authored by: Mindaugas Idzelis (min@idzelis.com)
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
*/
+/* Created on Jul 16, 2003 */
package org.apache.roller.business.search.operations;
import java.io.IOException;
@@ -43,131 +39,104 @@
import org.apache.roller.pojos.WeblogEntryData;
import org.apache.roller.pojos.WebsiteData;
-
/**
- * @author aim4min
- *
- * An index operation that rebuilds a given users index (or all indexes.)
+ * An index operation that rebuilds a given users index (or all indexes).
+ * @author Mindaugas Idzelis (min@idzelis.com)
*/
-public class RebuildWebsiteIndexOperation extends WriteToIndexOperation
-{
+public class RebuildWebsiteIndexOperation extends WriteToIndexOperation {
+
//~ Static fields/initializers =============================================
-
+
private static Log mLogger =
LogFactory.getFactory().getInstance(RebuildWebsiteIndexOperation.class);
-
+
//~ Instance fields ========================================================
-
+
private WebsiteData website;
-
+
//~ Constructors ===========================================================
-
+
/**
* Create a new operation that will recreate an index.
*
* @param website The website to rebuild the index for, or null for all users.
*/
- public RebuildWebsiteIndexOperation(IndexManagerImpl mgr, WebsiteData website)
- {
+ public RebuildWebsiteIndexOperation(IndexManagerImpl mgr, WebsiteData website) {
super(mgr);
this.website = website;
}
-
+
//~ Methods ================================================================
-
- /* (non-Javadoc)
- * @see java.lang.Runnable#run()
- */
- public void doRun()
- {
+
+ public void doRun() {
Date start = new Date();
-
+
IndexReader reader = beginDeleting();
-
- try
- {
- if (reader != null)
- {
+
+ try {
+ if (reader != null) {
Term tWebsite = null;
- if (website != null)
- {
+ if (website != null) {
tWebsite = IndexUtil.getTerm(
- FieldConstants.WEBSITE_HANDLE, website.getHandle());
+ FieldConstants.WEBSITE_HANDLE, website.getHandle());
}
- if (tWebsite != null)
- {
+ if (tWebsite != null) {
reader.delete(tWebsite);
- }
- else
- {
+ } else {
Term all =
- IndexUtil.getTerm(FieldConstants.CONSTANT,
- FieldConstants.CONSTANT_V);
+ IndexUtil.getTerm(FieldConstants.CONSTANT,
+ FieldConstants.CONSTANT_V);
reader.delete(all);
}
}
- }
- catch (IOException e)
- {
+ } catch (IOException e) {
mLogger.info("Problems deleting doc from index", e);
- }
- finally
- {
+ } finally {
endDeleting();
}
-
+
IndexWriter writer = beginWriting();
-
+
Roller roller = RollerFactory.getRoller();
- try
- {
- if (writer != null)
- {
+ try {
+ if (writer != null) {
WeblogManager weblogManager = roller.getWeblogManager();
-
+
List entries = weblogManager .getWeblogEntries(
- website, // userName
- null, // startDate
- new Date(), // endDate (don't index 'future' entries)
- null, // catName
- WeblogEntryData.PUBLISHED, // status
- null, // sortby (null mean pubTime)
- null); // maxEntries (null to get 'em all)
-
- for (Iterator wbItr = entries.iterator(); wbItr.hasNext();)
- {
+ website, // userName
+ null, // startDate
+ new Date(), // endDate (don't index 'future' entries)
+ null, // catName
+ WeblogEntryData.PUBLISHED, // status
+ null, // sortby (null mean pubTime)
+ null); // maxEntries (null to get 'em all)
+
+ for (Iterator wbItr = entries.iterator(); wbItr.hasNext();) {
WeblogEntryData entry = (WeblogEntryData) wbItr.next();
writer.addDocument(getDocument(entry));
mLogger.debug(
- MessageFormat.format("Indexed entry {0}: {1}",
- new Object[] {entry.getPubTime(), entry.getAnchor()}));
+ MessageFormat.format("Indexed entry {0}: {1}",
+ new Object[] {entry.getPubTime(), entry.getAnchor()}));
}
// release the database connection
roller.release();
}
- }
- catch (Exception e)
- {
+ } catch (Exception e) {
mLogger.error("ERROR adding doc to index", e);
- }
- finally
- {
+ } finally {
endWriting();
if (roller != null) roller.release();
}
-
+
Date end = new Date();
double length = (end.getTime() - start.getTime()) / (double) 1000;
-
- if (website == null)
- {
+
+ if (website == null) {
mLogger.info(
- "Completed rebuilding index for all users in '" + length + "' secs");
- }
- else
- {
+ "Completed rebuilding index for all users in '" + length + "' secs");
+ } else {
mLogger.info("Completed rebuilding index for website handle: '" +
- website.getHandle() + "' in '" + length + "' seconds");
+ website.getHandle() + "' in '" + length + "' seconds");
}
}
}
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/business/search/operations/RemoveEntryOperation.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/business/search/operations/RemoveEntryOperation.java?rev=409435&r1=409434&r2=409435&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/business/search/operations/RemoveEntryOperation.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/business/search/operations/RemoveEntryOperation.java Thu May 25 12:06:35 2006
@@ -1,25 +1,21 @@
/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. The ASF licenses this file to You
-* under the Apache License, Version 2.0 (the "License"); you may not
-* use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License. For additional information regarding
-* copyright in this work, please see the NOTICE file in the top level
-* directory of this distribution.
-*/
-/*
- * Created on Jul 16, 2003
- * Authored by: Mindaugas Idzelis (min@idzelis.com)
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
*/
+/* Created on Jul 16, 2003 */
package org.apache.roller.business.search.operations;
import java.io.IOException;
@@ -34,57 +30,42 @@
/**
- * @author aim4min
- *
* An operation that removes the weblog from the index.
+ * @author Mindaugas Idzelis (min@idzelis.com)
*/
-public class RemoveEntryOperation extends WriteToIndexOperation
-{
+public class RemoveEntryOperation extends WriteToIndexOperation {
+
//~ Static fields/initializers =============================================
-
+
private static Log mLogger =
- LogFactory.getFactory().getInstance(RemoveEntryOperation.class);
-
+ LogFactory.getFactory().getInstance(RemoveEntryOperation.class);
+
//~ Instance fields ========================================================
-
+
private WeblogEntryData data;
-
+
//~ Constructors ===========================================================
-
- /**
- *
- */
- public RemoveEntryOperation(IndexManagerImpl mgr, WeblogEntryData data)
- {
+
+ public RemoveEntryOperation(IndexManagerImpl mgr, WeblogEntryData data) {
super(mgr);
this.data = data;
}
-
+
//~ Methods ================================================================
-
- /* (non-Javadoc)
- * @see java.lang.Runnable#run()
- */
- public void doRun()
- {
+
+ public void doRun() {
IndexReader reader = beginDeleting();
- try
- {
- if (reader != null)
- {
+ try {
+ if (reader != null) {
Term term = new Term(FieldConstants.ID, data.getId());
reader.delete(term);
}
- }
- catch (IOException e)
- {
+ } catch (IOException e) {
mLogger.error("Error deleting doc from index", e);
- }
- finally
- {
+ } finally {
endDeleting();
}
}
-
-
+
+
}
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/business/search/operations/RemoveWebsiteIndexOperation.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/business/search/operations/RemoveWebsiteIndexOperation.java?rev=409435&r1=409434&r2=409435&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/business/search/operations/RemoveWebsiteIndexOperation.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/business/search/operations/RemoveWebsiteIndexOperation.java Thu May 25 12:06:35 2006
@@ -1,25 +1,21 @@
/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. The ASF licenses this file to You
-* under the Apache License, Version 2.0 (the "License"); you may not
-* use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License. For additional information regarding
-* copyright in this work, please see the NOTICE file in the top level
-* directory of this distribution.
-*/
-/*
- * Created on Jul 16, 2003
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * Authored by: Mindaugas Idzelis (min@idzelis.com)
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
*/
+/* Created on Jul 16, 2003 */
package org.apache.roller.business.search.operations;
import java.io.IOException;
@@ -36,75 +32,59 @@
/**
- * @author aim4min
- *
- * An index operation that rebuilds a given users index (or all indexes.)
+ * An index operation that rebuilds a given users index (or all indexes).
+ * @author Mindaugas Idzelis (min@idzelis.com)
*/
-public class RemoveWebsiteIndexOperation extends WriteToIndexOperation
-{
+public class RemoveWebsiteIndexOperation extends WriteToIndexOperation {
+
//~ Static fields/initializers =============================================
-
+
private static Log mLogger =
- LogFactory.getFactory().getInstance(RemoveWebsiteIndexOperation.class);
-
+ LogFactory.getFactory().getInstance(RemoveWebsiteIndexOperation.class);
+
//~ Instance fields ========================================================
-
+
private WebsiteData website;
-
+
//~ Constructors ===========================================================
-
+
/**
* Create a new operation that will recreate an index.
- *
* @param website The website to rebuild the index for, or null for all sites.
*/
- public RemoveWebsiteIndexOperation(IndexManagerImpl mgr, WebsiteData website)
- {
+ public RemoveWebsiteIndexOperation(IndexManagerImpl mgr, WebsiteData website) {
super(mgr);
this.website = website;
}
-
+
//~ Methods ================================================================
-
- /* (non-Javadoc)
- * @see java.lang.Runnable#run()
- */
- public void doRun()
- {
+
+ public void doRun() {
Date start = new Date();
IndexReader reader = beginDeleting();
- try
- {
- if (reader != null)
- {
+ try {
+ if (reader != null) {
String handle = null;
- if (website != null)
- {
+ if (website != null) {
handle = website.getHandle();
}
Term tHandle =
- IndexUtil.getTerm(FieldConstants.WEBSITE_HANDLE, handle);
-
- if (tHandle != null)
- {
+ IndexUtil.getTerm(FieldConstants.WEBSITE_HANDLE, handle);
+
+ if (tHandle != null) {
reader.delete(tHandle);
}
}
- }
- catch (IOException e)
- {
+ } catch (IOException e) {
mLogger.info("Problems deleting doc from index", e);
- }
- finally
- {
+ } finally {
endDeleting();
}
-
+
Date end = new Date();
double length = (end.getTime() - start.getTime()) / (double) 1000;
-
- if (website != null)
- {
+
+ if (website != null) {
mLogger.info("Completed deleting indices for website '" +
website.getName() + "' in '" + length + "' seconds");
}
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/business/search/operations/SearchOperation.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/business/search/operations/SearchOperation.java?rev=409435&r1=409434&r2=409435&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/business/search/operations/SearchOperation.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/business/search/operations/SearchOperation.java Thu May 25 12:06:35 2006
@@ -1,24 +1,21 @@
/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. The ASF licenses this file to You
-* under the Apache License, Version 2.0 (the "License"); you may not
-* use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License. For additional information regarding
-* copyright in this work, please see the NOTICE file in the top level
-* directory of this distribution.
-*/
-/*
- * Created on Jul 18, 2003
- * Authored by: Mindaugas Idzelis (min@idzelis.com)
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
*/
+/* Created on Jul 18, 2003 */
package org.apache.roller.business.search.operations;
import java.io.IOException;
@@ -44,74 +41,67 @@
/**
- * @author aim4min
- *
* An operation that searches the index.
+ * @author Mindaugas Idzelis (min@idzelis.com)
*/
-public class SearchOperation extends ReadFromIndexOperation
-{
+public class SearchOperation extends ReadFromIndexOperation {
//~ Static fields/initializers =============================================
-
+
private static Log mLogger =
- LogFactory.getFactory().getInstance(SearchOperation.class);
-
+ LogFactory.getFactory().getInstance(SearchOperation.class);
+
private static String[] SEARCH_FIELDS = new String[]{
- FieldConstants.CONTENT, FieldConstants.TITLE,
+ FieldConstants.CONTENT, FieldConstants.TITLE,
FieldConstants.C_CONTENT, FieldConstants.CATEGORY
};
private static Sort SORTER = new Sort( new SortField(
- FieldConstants.PUBLISHED, SortField.STRING, true) );
-
+ FieldConstants.PUBLISHED, SortField.STRING, true) );
+
//~ Instance fields ========================================================
-
+
private String term;
private String websiteHandle;
private String category;
private Hits searchresults;
private String parseError;
-
+
//~ Constructors ===========================================================
-
+
/**
* Create a new operation that searches the index.
*/
- public SearchOperation(IndexManager mgr)
- {
+ public SearchOperation(IndexManager mgr) {
// TODO: finish moving IndexManager to backend, so this cast is not needed
- super((IndexManagerImpl)mgr);
+ super((IndexManagerImpl)mgr);
}
-
+
//~ Methods ================================================================
-
- public void setTerm(String term)
- {
+
+ public void setTerm(String term) {
this.term = term;
}
-
+
/* (non-Javadoc)
* @see java.lang.Runnable#run()
*/
- public void doRun()
- {
+ public void doRun() {
searchresults = null;
-
+
IndexSearcher searcher = null;
-
- try
- {
+
+ try {
IndexReader reader = manager.getSharedIndexReader();
searcher = new IndexSearcher(reader);
-
+
Query query =
- MultiFieldQueryParser.parse(
+ MultiFieldQueryParser.parse(
term, SEARCH_FIELDS, new StandardAnalyzer());
-
+
Term tUsername =
- IndexUtil.getTerm(FieldConstants.WEBSITE_HANDLE, websiteHandle);
-
- if (tUsername != null)
- {
+ IndexUtil.getTerm(FieldConstants.WEBSITE_HANDLE, websiteHandle);
+
+ if (tUsername != null) {
BooleanQuery bQuery = new BooleanQuery();
bQuery.add(query, true, false);
bQuery.add(new TermQuery(tUsername), true, false);
@@ -119,61 +109,51 @@
}
Term tCategory =
- IndexUtil.getTerm(FieldConstants.CATEGORY, category);
-
- if (tCategory != null)
- {
+ IndexUtil.getTerm(FieldConstants.CATEGORY, category);
+
+ if (tCategory != null) {
BooleanQuery bQuery = new BooleanQuery();
bQuery.add(query, true, false);
bQuery.add(new TermQuery(tCategory), true, false);
query = bQuery;
}
searchresults = searcher.search(query, null/*Filter*/, SORTER);
- }
- catch (IOException e)
- {
+ } catch (IOException e) {
mLogger.error("Error searching index", e);
parseError = e.getMessage();
- }
- catch (ParseException e)
- {
+ } catch (ParseException e) {
// who cares?
parseError = e.getMessage();
}
// don't need to close the reader, since we didn't do any writing!
}
-
- public Hits getResults()
- {
+
+ public Hits getResults() {
return searchresults;
}
- public int getResultsCount()
- {
+ public int getResultsCount() {
if (searchresults == null) return -1;
return searchresults.length();
}
- public String getParseError()
- {
+ public String getParseError() {
return parseError;
}
-
+
/**
* @param string
*/
- public void setWebsiteHandle(String websiteHandle)
- {
+ public void setWebsiteHandle(String websiteHandle) {
this.websiteHandle = websiteHandle;
}
-
+
/**
* @param parameter
*/
- public void setCategory(String category)
- {
+ public void setCategory(String category) {
this.category = category;
}
-
+
}
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/business/search/operations/WriteToIndexOperation.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/business/search/operations/WriteToIndexOperation.java?rev=409435&r1=409434&r2=409435&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/business/search/operations/WriteToIndexOperation.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/business/search/operations/WriteToIndexOperation.java Thu May 25 12:06:35 2006
@@ -1,26 +1,21 @@
/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. The ASF licenses this file to You
-* under the Apache License, Version 2.0 (the "License"); you may not
-* use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License. For additional information regarding
-* copyright in this work, please see the NOTICE file in the top level
-* directory of this distribution.
-*/
-/*
- * Created on Aug 12, 2003
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * To change the template for this generated file go to
- * Window>Preferences>Java>Code Generation>Code and Comments
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
*/
+/* Created on Aug 12, 2003 */
package org.apache.roller.business.search.operations;
import org.apache.commons.logging.Log;
@@ -28,44 +23,29 @@
import org.apache.roller.business.IndexManagerImpl;
/**
- * @author aim4min
- *
- * To change the template for this generated type comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
+ * An operation that writes to index.
+ * @author Mindaugas Idzelis (min@idzelis.com)
*/
public abstract class WriteToIndexOperation extends IndexOperation {
-
- /**
- * @param manager
- */
- public WriteToIndexOperation(IndexManagerImpl mgr)
- {
+
+ public WriteToIndexOperation(IndexManagerImpl mgr) {
super(mgr);
}
-
+
private static Log mLogger =
- LogFactory.getFactory().getInstance(WriteToIndexOperation.class);
-
- /* (non-Javadoc)
- * @see java.lang.Runnable#run()
- */
- public void run()
- {
- try
- {
+ LogFactory.getFactory().getInstance(WriteToIndexOperation.class);
+
+ public void run() {
+ try {
manager.getReadWriteLock().writeLock().acquire();
mLogger.info("Starting search index operation");
doRun();
mLogger.info("Search index operation complete");
- }
- catch (InterruptedException e)
- {
- mLogger.error("Error acquiring write lock on index", e);
- }
- finally
- {
- manager.getReadWriteLock().writeLock().release();
- }
+ } catch (InterruptedException e) {
+ mLogger.error("Error acquiring write lock on index", e);
+ } finally {
+ manager.getReadWriteLock().writeLock().release();
+ }
manager.resetSharedReader();
- }
+ }
}
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/model/PlanetManager.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/model/PlanetManager.java?rev=409435&r1=409434&r2=409435&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/model/PlanetManager.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/model/PlanetManager.java Thu May 25 12:06:35 2006
@@ -110,31 +110,38 @@
/**
* Get top X subscriptions.
*/
- public List getTopSubscriptions(int max) throws RollerException;
+ public List getTopSubscriptions(int offset, int len) throws RollerException;
/**
* Get top X subscriptions, restricted by group.
*/
public List getTopSubscriptions(
- PlanetGroupData group, int max) throws RollerException;
+ PlanetGroupData group, int offset, int len) throws RollerException;
+
+ /**
+ * Get entries in a single feed as list of PlanetEntryData objects.
+ */
+ public List getFeedEntries(
+ String feedUrl, int offset, int len) throws RollerException;
//------------------------------------------------------------ aggregations
/**
- * Get agggration for group from cache, enries in
- * reverse chonological order.
+ * Get agggration for group from cache, enries in reverse chonological order.
* Respects category constraints of group.
- * @param group
- * @param maxEntries Maximum number of entries to return.
+ * @param group Restrict to entries from one subscription group.
+ * @param offset Offset into results (for paging)
+ * @param len Maximum number of results to return (for paging)
*/
public List getAggregation(
- PlanetGroupData group, int maxEntries) throws RollerException;
+ PlanetGroupData group, int offset, int len) throws RollerException;
/**
* Get agggration from cache, enries in reverse chonological order.
- * @param maxEntries Maximum number of entries to return.
+ * @param offset Offset into results (for paging)
+ * @param len Maximum number of results to return (for paging)
*/
- public List getAggregation(int maxEntries) throws RollerException;
+ public List getAggregation(int offset, int len) throws RollerException;
//------------------------------------------------------------------ update
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/model/RefererManager.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/model/RefererManager.java?rev=409435&r1=409434&r2=409435&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/model/RefererManager.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/model/RefererManager.java Thu May 25 12:06:35 2006
@@ -23,60 +23,49 @@
import org.apache.roller.pojos.RefererData;
import org.apache.roller.pojos.WebsiteData;
-
/**
* Interface to Referer management.
*/
-public interface RefererManager {
-
+public interface RefererManager {
/**
* Store the referer.
*/
- public void saveReferer(RefererData referer) throws RollerException;
-
+ public void saveReferer(RefererData referer) throws RollerException;
/**
* Remove a single referer.
*/
- public void removeReferer(RefererData referer) throws RollerException;
-
+ public void removeReferer(RefererData referer) throws RollerException;
/**
* Clear referrer dayhits and remove referrers without excerpts.
*/
- public void clearReferrers() throws RollerException;
-
+ public void clearReferrers() throws RollerException;
/**
* Clear referrer dayhits and remove referrers without excerpts.
*/
- public void clearReferrers(WebsiteData website) throws RollerException;
-
+ public void clearReferrers(WebsiteData website) throws RollerException;
/**
- * Retrieve referer by ID.
+ * Retrieve referer by id.
*/
- public RefererData getReferer(String id) throws RollerException;
-
+ public RefererData getReferer(String id) throws RollerException;
/**
* Get all referers for specified weblog.
* @param weblog
* @return List of type RefererData
- * @throws RollerException
*/
- public List getReferers(WebsiteData weblog) throws RollerException;
-
+ public List getReferers(WebsiteData weblog) throws RollerException;
/**
* Get all referers for specified user that were made today.
* @param userName Name of user.
* @return List of type RefererData
- * @throws RollerException
*/
- public List getTodaysReferers(WebsiteData website) throws RollerException;
-
+ public List getTodaysReferers(WebsiteData website) throws RollerException;
/**
* Get referers for a specified date.
@@ -85,15 +74,18 @@
* @return List of type RefererData.
* @throws RollerException
*/
- public List getReferersToDate(WebsiteData website, String date) throws RollerException;
-
+ public List getReferersToDate(WebsiteData website, String date)
+ throws RollerException;
/**
* Get most popular websites based on referer day hits.
+ * @param sinceDays Restrict to last X days (or -1 for all)
+ * @param offset Offset into results (for paging)
+ * @param len Maximum number of results to return (for paging)
* @return List of WebsiteDisplayData objects.
*/
- public List getDaysPopularWebsites(int max) throws RollerException;
-
+ public List getDaysPopularWebsites(int sinceDays, int offset, int len)
+ throws RollerException;
/**
* Get referers that refer to a specific weblog entry.
@@ -101,32 +93,27 @@
* @return List of RefererData objects.
* @throws RollerException
*/
- public List getReferersToEntry(String entryid) throws RollerException;
-
+ public List getReferersToEntry(String entryid) throws RollerException;
/**
* Get user's day hits
*/
- public int getDayHits(WebsiteData website) throws RollerException;
-
+ public int getDayHits(WebsiteData website) throws RollerException;
/**
* Get user's all-time total hits
*/
- public int getTotalHits(WebsiteData website) throws RollerException;
-
+ public int getTotalHits(WebsiteData website) throws RollerException;
/**
* Apply ignoreWord/spam filters to all referers in system.
*/
- public void applyRefererFilters() throws RollerException;
-
+ public void applyRefererFilters() throws RollerException;
/**
* Apply ignoreWord/spam filters to all referers in website.
*/
- public void applyRefererFilters(WebsiteData website) throws RollerException;
-
+ public void applyRefererFilters(WebsiteData website) throws RollerException;
/**
* Process an incoming referer.
@@ -136,13 +123,11 @@
String referrerUrl,
String weblogHandle,
String weblogAnchor,
- String weblogDateString);
-
+ String weblogDateString);
/**
- * Release all resources associated with Roller session.
+ * Release all resources held by manager.
*/
- public void release();
-
+ public void release();
}
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/model/UserManager.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/model/UserManager.java?rev=409435&r1=409434&r2=409435&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/model/UserManager.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/model/UserManager.java Thu May 25 12:06:35 2006
@@ -19,13 +19,13 @@
package org.apache.roller.model;
import java.util.List;
+import java.util.Map;
import org.apache.roller.RollerException;
import org.apache.roller.pojos.WeblogTemplate;
import org.apache.roller.pojos.PermissionsData;
import org.apache.roller.pojos.UserData;
import org.apache.roller.pojos.WebsiteData;
-
/**
* Manages users, weblogs, permissions, and weblog pages.
*/
@@ -34,50 +34,48 @@
/**
* Add new user object to Roller. User will be given the global editor role,
* unless it's the first user, who will get the global admin role.
- *
* @param user User object to be added, initialized with name, password, etc.
- * @throws RollerException
*/
public void addUser(UserData newUser) throws RollerException;
-
-
+
/**
* Store a single user.
*/
public void saveUser(UserData data) throws RollerException;
-
+ /**
+ * Remove user.
+ */
public void removeUser(UserData user) throws RollerException;
-
- public UserData getUser(String id)throws RollerException;
+ /**
+ * Get user by id.
+ */
+ public UserData getUser(String id) throws RollerException;
/**
* Get user object by user name (only enabled users)
*/
- public UserData getUserByUsername(String userName) throws RollerException;
-
+ public UserData getUserByUsername(String userName) throws RollerException;
/**
* Get user object by user name, optionally include dis-enabled users
*/
- public UserData getUserByUsername(String userName, Boolean enabled) throws RollerException;
-
+ public UserData getUserByUsername(String userName, Boolean enabled)
+ throws RollerException;
/**
* Get all enabled users
*/
- public List getUsers() throws RollerException;
-
+ public List getUsers() throws RollerException;
/**
* Get all users, optionally include dis-enabled users.
*
* @param enabled True for enabled only, false for disabled only, null for all
*/
- public List getUsers(Boolean enabled) throws RollerException;
-
+ public List getUsers(Boolean enabled) throws RollerException;
/**
* Get all users or a website.
@@ -86,8 +84,7 @@
* @returns List of UserData objects.
*/
public List getUsers(WebsiteData website, Boolean enabled) throws RollerException;
-
-
+
/**
* Returns users whose usernames or email addresses start with a string.
* @param startsWith String to match userNames and emailAddresses against
@@ -97,162 +94,191 @@
* @return List of (up to length) users that match startsWith string
*/
public List getUsersStartingWith(String startsWith,
- int offset, int length, Boolean enabled) throws RollerException;
+ int offset, int length, Boolean enabled) throws RollerException;
+
+ /**
+ * Get map with 26 entries, one for each letter A-Z and
+ * containing integers reflecting the number of users whose
+ * names start with each letter.
+ */
+ public Map getUsernameLetterMap();
+ /** Get collection of users whose names begin with specified letter */
+ public List getUsersByLetter(char letter);
- public void addWebsite(WebsiteData newWebsite) throws RollerException;
+ /**
+ * Get map with 26 entries, one for each letter A-Z and
+ * containing integers reflecting the number of weblogs whose
+ * names start with each letter.
+ */
+ public Map getWeblogHandleLetterMap();
+ /** Get collection of weblogs whose handles begin with specified letter */
+ public List getWeblogsByLetter(char letter);
+
+ /**
+ * Add new website, give creator admin permission, creates blogroll,
+ * creates categories and other objects required for new website.
+ * @param newWebsite New website to be created, must have creator.
+ */
+ public void addWebsite(WebsiteData newWebsite) throws RollerException;
/**
* Store a single weblog.
*/
public void saveWebsite(WebsiteData data) throws RollerException;
-
+ /**
+ * Remove website object.
+ */
public void removeWebsite(WebsiteData website) throws RollerException;
-
+ /**
+ * Get website object by name.
+ */
public WebsiteData getWebsite(String id) throws RollerException;
-
-
+
/**
* Get website specified by handle (or null if enabled website not found).
- *
* @param handle Handle of website
*/
- public WebsiteData getWebsiteByHandle(String handle) throws RollerException;
-
+ public WebsiteData getWebsiteByHandle(String handle) throws RollerException;
/**
* Get website specified by handle with option to return only enabled websites.
- *
* @param handle Handle of website
*/
- public WebsiteData getWebsiteByHandle(String handle, Boolean enabled) throws RollerException;
-
-
+ public WebsiteData getWebsiteByHandle(String handle, Boolean enabled)
+ throws RollerException;
+
/**
- * Get all websites of which user is a member
- *
+ * Get websites optionally restricted by user, enabled and active status.
* @param user Get all websites for this user (or null for all)
+ * @param offset Offset into results (for paging)
+ * @param len Maximum number of results to return (for paging)
* @param enabled Get all with this enabled state (or null or all)
* @param active Get all with this active state (or null or all)
* @returns List of WebsiteData objects.
*/
- public List getWebsites(UserData user, Boolean enabled, Boolean active) throws RollerException;
+ public List getWebsites(
+ UserData user, Boolean enabled, Boolean active, int offset, int len)
+ throws RollerException;
+ /**
+ * Get websites ordered by descending number of comments.
+ * @param sinceDays Restrict to last X days (or -1 for all)
+ * @param offset Offset into results (for paging)
+ * @param len Maximum number of results to return (for paging)
+ * @returns List of WebsiteData objects.
+ */
+ public List getMostCommentedWebsites(int sinceDays, int offset, int len)
+ throws RollerException;
+ /**
+ * Save permissions object.
+ */
public void savePermissions(PermissionsData perms) throws RollerException;
-
+ /**
+ * Remove permissions object.
+ */
public void removePermissions(PermissionsData perms) throws RollerException;
-
- public PermissionsData getPermissions(String id) throws RollerException;
-
+ /**
+ * Get permissions object by id.
+ */
+ public PermissionsData getPermissions(String id) throws RollerException;
/**
- * Get pending permissions for user
- *
+ * Get pending permissions for user.
* @param user User (not null)
* @returns List of PermissionsData objects.
*/
- public List getPendingPermissions(UserData user) throws RollerException;
-
+ public List getPendingPermissions(UserData user) throws RollerException;
/**
- * Get pending permissions for website
- *
+ * Get pending permissions for website.
* @param website Website (not null)
* @returns List of PermissionsData objects.
*/
- public List getPendingPermissions(WebsiteData user) throws RollerException;
-
+ public List getPendingPermissions(WebsiteData user) throws RollerException;
/**
- * Get permissions of user in website
- *
+ * Get permissions of user in website.
* @param website Website (not null)
* @param user User (not null)
* @return PermissionsData object
*/
- public PermissionsData getPermissions(WebsiteData website, UserData user) throws RollerException;
-
+ public PermissionsData getPermissions(WebsiteData website, UserData user)
+ throws RollerException;
/**
* Get all permissions in website
- *
* @param website Website (not null)
* @return PermissionsData object
*/
- public List getAllPermissions(WebsiteData website) throws RollerException;
-
+ public List getAllPermissions(WebsiteData website) throws RollerException;
/**
* Get all permissions of user
- *
* @param user User (not null)
* @return PermissionsData object
*/
- public List getAllPermissions(UserData user) throws RollerException;
-
+ public List getAllPermissions(UserData user) throws RollerException;
/**
* Invite user to join a website with specific permissions
- *
* @param website Website to be joined (persistent instance)
* @param user User to be invited (persistent instance)
* @param perms Permissions mask (see statics in PermissionsData)
* @return New PermissionsData object, with pending=true
*/
- public PermissionsData inviteUser(WebsiteData website, UserData user, short perms) throws RollerException;
-
-
+ public PermissionsData inviteUser(
+ WebsiteData website, UserData user, short perms)
+ throws RollerException;
+
/**
* Retire user from a website
- *
* @param website Website to be retired from (persistent instance)
* @param user User to be retired (persistent instance)
*/
- public void retireUser(WebsiteData website, UserData user) throws RollerException;
-
-
+ public void retireUser(WebsiteData website, UserData user)
+ throws RollerException;
+
/**
- * Store page
+ * Store page.
*/
- public void savePage(WeblogTemplate data) throws RollerException;
-
+ public void savePage(WeblogTemplate data) throws RollerException;
/**
- * Remove page
+ * Remove page.
*/
- public void removePage(WeblogTemplate page) throws RollerException;
-
+ public void removePage(WeblogTemplate page) throws RollerException;
/**
- * Get page by ID
+ * Get page by id.
*/
- public WeblogTemplate getPage(String id) throws RollerException;
-
+ public WeblogTemplate getPage(String id) throws RollerException;
/**
- * Get user's page by name
+ * Get user's page by name.
*/
public WeblogTemplate getPageByName(WebsiteData w, String p) throws RollerException;
-
/**
- * Get user's page by link
+ * Get website's page by link.
*/
- public WeblogTemplate getPageByLink(WebsiteData w, String p) throws RollerException;
-
+ public WeblogTemplate getPageByLink(WebsiteData w, String p)
+ throws RollerException;
/**
- * Get users pages
+ * Get website's pages
*/
public List getPages(WebsiteData w) throws RollerException;
-
+ /**
+ * Release any resources held by manager.
+ */
public void release();
}
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/model/WeblogManager.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/model/WeblogManager.java?rev=409435&r1=409434&r2=409435&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/model/WeblogManager.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/model/WeblogManager.java Thu May 25 12:06:35 2006
@@ -30,7 +30,6 @@
import org.apache.roller.pojos.WeblogEntryData;
import org.apache.roller.pojos.WebsiteData;
-
/**
* Interface to weblog entry, category and comment management.
*/
@@ -38,24 +37,27 @@
public static final String CATEGORY_ATT = "category.att";
+ /**
+ * Save weblog entry.
+ */
public void saveWeblogEntry(WeblogEntryData entry) throws RollerException;
-
- public void removeWeblogEntry(WeblogEntryData entry) throws RollerException;
-
+
+ /**
+ * Remove weblog entry.
+ */
+ public void removeWeblogEntry(WeblogEntryData entry) throws RollerException;
/**
- * Get weblog entry by ID
+ * Get weblog entry by id.
*/
public WeblogEntryData getWeblogEntry(String id) throws RollerException;
-
/**
* Get weblog entry by anchor.
*/
public WeblogEntryData getWeblogEntryByAnchor(WebsiteData website, String anchor)
throws RollerException;
-
-
+
/**
* Get WeblogEntries by offset/length as list in reverse chronological order.
* The range offset and list arguments enable paging through query results.
@@ -80,8 +82,7 @@
int offset,
int range)
throws RollerException;
-
-
+
/**
* Get WeblogEntries up to limit as list in reverse chronological order.
* The range offset and list arguments enable paging through query results.
@@ -105,8 +106,7 @@
String sortBy,
Integer maxEntries)
throws RollerException;
-
-
+
/**
* Get Weblog Entries grouped by day. This method returns a Map that
* contains Lists, each List contains WeblogEntryData objects, and the
@@ -128,8 +128,7 @@
String status,
Integer maxEntries)
throws RollerException;
-
-
+
/**
* Get Weblog Entry date strings grouped by day. This method returns a Map
* that contains Lists, each List contains YYYYMMDD date strings objects,
@@ -150,44 +149,47 @@
String catName,
String status,
Integer maxEntries)
- throws RollerException;
-
+ throws RollerException;
/**
* Get weblog entries with given category or, optionally, any sub-category
* of that category.
- * @param cat Category.
- * @param subcats True if sub-categories are to be fetched.
- * @return List of weblog entries in category.
+ * @param cat Category
+ * @param subcats True if sub-categories are to be fetched
+ * @return List of weblog entries in category
*/
public List getWeblogEntries(WeblogCategoryData cat, boolean subcats)
- throws RollerException;
+ throws RollerException;
+ /**
+ * Get weblog enties ordered by descending number of comments.
+ * @param website Restrict to only this website (or null for all)
+ * @param sinceDays Restrict to last X days (or -1 for all)
+ * @param len Maximum number of results to return (for paging)
+ * @returns List of WeblogEntryData objects.
+ */
+ public List getMostCommentedWeblogEntries(
+ WebsiteData website, int sinceDays, int offset, int len)
+ throws RollerException;
/**
* Get the WeblogEntry following, chronologically, the current entry.
* Restrict by the Category, if named.
- *
- * @param current The "current" WeblogEntryData.
- * @param catName The value of the requested Category Name.
- * @return
+ * @param current The "current" WeblogEntryData
+ * @param catName The value of the requested Category Name
*/
public WeblogEntryData getNextEntry(WeblogEntryData current, String catName)
- throws RollerException;
-
+ throws RollerException;
/**
* Get the WeblogEntry prior to, chronologically, the current entry.
* Restrict by the Category, if named.
- *
* @param current The "current" WeblogEntryData.
* @param catName The value of the requested Category Name.
- * @return
*/
public WeblogEntryData getPreviousEntry(WeblogEntryData current,
String catName) throws RollerException;
-
-
+
/**
* Get entries next after current entry.
* @param entry Current entry.
@@ -196,8 +198,7 @@
*/
public List getNextEntries(WeblogEntryData entry,
String catName, int maxEntries) throws RollerException;
-
-
+
/**
* Get entries previous to current entry.
* @param entry Current entry.
@@ -205,53 +206,47 @@
* @param maxEntries Maximum number of entries to return.
*/
public List getPreviousEntries(WeblogEntryData entry,
- String catName, int maxEntries) throws RollerException;
-
+ String catName, int maxEntries) throws RollerException;
/**
* Get specified number of most recent pinned and published Weblog Entries.
* @param max Maximum number to return.
* @return Collection of WeblogEntryData objects.
*/
- public List getWeblogEntriesPinnedToMain(Integer max) throws RollerException;
-
+ public List getWeblogEntriesPinnedToMain(Integer max) throws RollerException;
/** Get time of last update for a weblog specified by username */
- public Date getWeblogLastPublishTime(WebsiteData website) throws RollerException;
-
+ public Date getWeblogLastPublishTime(WebsiteData website) throws RollerException;
/**
* Gets returns most recent pubTime, optionally restricted by category.
* @param handle Handle of website or null for all users
* @param catName Category name of posts or null for all categories
* @return Date Of last publish time
- * @throws RollerException
*/
public Date getWeblogLastPublishTime(WebsiteData website, String catName )
throws RollerException;
-
+ /**
+ * Save weblog category.
+ */
public void saveWeblogCategory(WeblogCategoryData cat) throws RollerException;
-
/**
- * Recategorize all entries with one category to another.
- * @param srcId
- * @param destId
- * @throws org.apache.roller.RollerException
+ * Remove weblog category.
*/
- public void moveWeblogCategoryContents(String srcId, String destId)
- throws RollerException;
-
-
public void removeWeblogCategory(WeblogCategoryData cat) throws RollerException;
-
-
+
/**
- * Get category by ID
+ * Get category by id.
*/
public WeblogCategoryData getWeblogCategory(String id) throws RollerException;
+ /**
+ * Recategorize all entries with one category to another.
+ */
+ public void moveWeblogCategoryContents(String srcId, String destId)
+ throws RollerException;
/**
* Get top level categories for a website.
@@ -276,18 +271,19 @@
* @return Category specified by path or null if not found.
*/
public WeblogCategoryData getWeblogCategoryByPath(WebsiteData wd,
- WeblogCategoryData category, String string) throws RollerException;
-
-
- /** Get WebLogCategory objects for a website. */
- public List getWeblogCategories(WebsiteData website) throws RollerException;
+ WeblogCategoryData category, String string) throws RollerException;
+ /**
+ * Get WebLogCategory objects for a website.
+ */
+ public List getWeblogCategories(WebsiteData website) throws RollerException;
- /** Get WebLogCategory objects for a website. */
+ /**
+ * Get WebLogCategory objects for a website.
+ */
public List getWeblogCategories(WebsiteData website, boolean includeRoot)
throws RollerException;
-
-
+
/**
* Get absolute path to category, appropriate for use by getWeblogCategoryByPath().
* @param category WeblogCategoryData.
@@ -295,30 +291,43 @@
*/
public String getPath(WeblogCategoryData category) throws RollerException;
-
+ /**
+ * Get parent association for a category.
+ */
public Assoc getWeblogCategoryParentAssoc(WeblogCategoryData data) throws RollerException;
+ /**
+ * Get child associations for a category.
+ */
public List getWeblogCategoryChildAssocs(WeblogCategoryData data) throws RollerException;
+ /**
+ * Get all descendent associations for a category.
+ */
public List getAllWeblogCategoryDecscendentAssocs(WeblogCategoryData data) throws RollerException;
+ /**
+ * Get all ancestor associates for a category.
+ */
public List getWeblogCategoryAncestorAssocs(WeblogCategoryData data) throws RollerException;
-
+ /**
+ * Save comment.
+ */
public void saveComment(CommentData comment) throws RollerException;
-
+ /**
+ * Remove comment.
+ */
public void removeComment(CommentData comment) throws RollerException;
-
-
+
/**
- * Get comment by ID
+ * Get comment by id.
*/
public CommentData getComment(String id) throws RollerException;
-
-
+
/**
- * Generic comments query method
+ * Generic comments query method.
* @param website Website or null for all comments on site
* @param entry Entry or null to include all comments
* @param startDate Start date or null for no restriction
@@ -343,52 +352,48 @@
int offset,
int length
) throws RollerException;
-
-
+
/**
* Create unique anchor for weblog entry.
*/
- public String createAnchor(WeblogEntryData data) throws RollerException;
-
+ public String createAnchor(WeblogEntryData data) throws RollerException;
/**
* Check for duplicate category name.
*/
public boolean isDuplicateWeblogCategoryName(WeblogCategoryData data)
- throws RollerException;
-
+ throws RollerException;
/**
* Check if weblog category is in use.
*/
public boolean isWeblogCategoryInUse(WeblogCategoryData data)
- throws RollerException;
-
+ throws RollerException;
/**
* Returns true if ancestor is truly an ancestor of child.
*/
public boolean isDescendentOf(WeblogCategoryData child,
- WeblogCategoryData ancestor) throws RollerException;
-
+ WeblogCategoryData ancestor) throws RollerException;
/**
* Get the URL of a website.
- * @param website The website
+ * @param website The website object
* @param contextUrl The context url, this is prepended and can be absolute
* or relative depending on what is desired.
* @return The url of the user's weblog
*/
- public String getUrl(WebsiteData website, String contextUrl) throws RollerException;
+ public String getUrl(WebsiteData website, String contextUrl)
+ throws RollerException;
/**
* Apply comment default settings from website to all of website's entries.
*/
- public void applyCommentDefaultsToEntries(WebsiteData website) throws RollerException;
+ public void applyCommentDefaultsToEntries(WebsiteData website)
+ throws RollerException;
/**
- * Release all resources associated with Roller session.
+ * Release all resources held by manager.
*/
- public void release();
-
+ public void release();
}
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/pojos/PlanetEntryData.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/pojos/PlanetEntryData.java?rev=409435&r1=409434&r2=409435&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/pojos/PlanetEntryData.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/pojos/PlanetEntryData.java Thu May 25 12:06:35 2006
@@ -1,8 +1,8 @@
/*
- * Copyright 2005 Sun Microsystems, Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
@@ -11,13 +11,15 @@
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
- * limitations under the License.
+ * limitations under the License. For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
*/
package org.apache.roller.pojos;
import java.io.Serializable;
+import java.sql.Timestamp;
import java.util.ArrayList;
-import java.util.Date;
import java.util.Iterator;
import java.util.List;
@@ -32,9 +34,6 @@
import com.sun.syndication.feed.synd.SyndEntry;
import com.sun.syndication.feed.synd.SyndFeed;
-// this will be needed for ROME v0.8
-//import com.sun.syndication.feed.synd.SyndPerson;
-
import java.util.Map;
import org.apache.roller.RollerException;
import org.apache.roller.model.PagePluginManager;
@@ -42,24 +41,26 @@
import org.apache.roller.model.RollerFactory;
/**
- * A syndication feed entry intended for use in an in-memory or database cache to
- * speed the creation of aggregations in Planet Roller implementations.
+ * Represents a planet entry, i.e. an entry that was parsed out of an RSS or
+ * Atom newsfeed by Roller's built-in planet aggregator.
+ * <p>
+ * The model coded in this class simple, perhaps too simple, and in the future
+ * it should be replaced by more complete model that can fully represent all
+ * forms of RSS and Atom.
*
* @hibernate.class lazy="false" table="rag_entry"
- * @author Dave Johnson
*/
-public class PlanetEntryData extends PersistentObject
- implements Serializable, Comparable
-{
- protected String id;
- protected String handle;
- protected String title;
- protected String guid;
- protected String permalink;
- protected String author;
- protected String content = "";
- protected Date published;
- protected Date updated;
+public class PlanetEntryData extends PersistentObject
+ implements WeblogEntry, Serializable, Comparable {
+ protected String id;
+ protected String handle;
+ protected String title;
+ protected String guid;
+ protected String permalink;
+ protected String author;
+ protected String text = "";
+ protected Timestamp published;
+ protected Timestamp updated;
private String categoriesString;
protected PlanetSubscriptionData subscription = null;
@@ -67,16 +68,14 @@
/**
* Construct empty entry.
*/
- public PlanetEntryData()
- {
+ public PlanetEntryData() {
}
-
+
/**
* Create entry from Rome entry.
*/
public PlanetEntryData(
- SyndFeed romeFeed, SyndEntry romeEntry, PlanetSubscriptionData sub)
- {
+ SyndFeed romeFeed, SyndEntry romeEntry, PlanetSubscriptionData sub) {
setSubscription(sub);
initFromRomeEntry(romeFeed, romeEntry);
}
@@ -85,88 +84,68 @@
* Create entry from Rome entry.
*/
public PlanetEntryData(
- WeblogEntryData rollerEntry,
- PlanetSubscriptionData sub,
- Map pagePlugins) throws RollerException
- {
+ WeblogEntryData rollerEntry,
+ PlanetSubscriptionData sub,
+ Map pagePlugins) throws RollerException {
setSubscription(sub);
initFromRollerEntry(rollerEntry, pagePlugins);
}
- /**
- * Init entry from Rome entry
+ /**
+ * Init entry from Rome entry
*/
- private void initFromRomeEntry(SyndFeed romeFeed, SyndEntry romeEntry)
- {
+ private void initFromRomeEntry(SyndFeed romeFeed, SyndEntry romeEntry) {
setAuthor(romeEntry.getAuthor());
- // this will be needed (instead of the previous line) for ROME v0.8
- //List authors = romeEntry.getAuthors();
- //if (authors!=null && authors.size() > 0) {
- //SyndPerson person = (SyndPerson)authors.get(0);
- //setAuthor(person.getName());
- //}
setTitle(romeEntry.getTitle());
- setPermalink(romeEntry.getLink());
+ setPermaLink(romeEntry.getLink());
- // Play some games to get the date
+ // Play some games to get the date
DCModule entrydc = (DCModule)romeEntry.getModule(DCModule.URI);
DCModule feeddc = (DCModule)romeFeed.getModule(DCModule.URI);
- if (romeEntry.getPublishedDate() != null)
- {
- setPublished(romeEntry.getPublishedDate()); // use <pubDate>
+ if (romeEntry.getPublishedDate() != null) {
+ setPubTime(new Timestamp(romeEntry.getPublishedDate().getTime())); // use <pubDate>
+ } else if (entrydc != null) {
+ setPubTime(new Timestamp(entrydc.getDate().getTime())); // use <dc:date>
}
- else if (entrydc != null)
- {
- setPublished(entrydc.getDate()); // use <dc:date>
- }
- // get content and unescape if it is 'text/plain'
- if (romeEntry.getContents().size() > 0)
- {
+ // get content and unescape if it is 'text/plain'
+ if (romeEntry.getContents().size() > 0) {
SyndContent content= (SyndContent)romeEntry.getContents().get(0);
- if (content != null && content.getType().equals("text/plain"))
- {
- setContent(Utilities.unescapeHTML(content.getValue()));
- }
- else if (content != null)
- {
- setContent(content.getValue());
+ if (content != null && content.getType().equals("text/plain")) {
+ setText(Utilities.unescapeHTML(content.getValue()));
+ } else if (content != null) {
+ setText(content.getValue());
}
}
- // no content, then try <content:encoded>
- if (getContent() == null || getContent().trim().length() == 0)
- {
+ // no content, then try <content:encoded>
+ if (getText() == null || getText().trim().length() == 0) {
ContentModule cm = (ContentModule)romeEntry.getModule(ContentModule.URI);
- if (cm != null)
- {
- setContent(Utilities.unescapeHTML(cm.getEncoded()));
+ if (cm != null) {
+ setText(Utilities.unescapeHTML(cm.getEncoded()));
}
}
// copy categories
- if (romeEntry.getCategories().size() > 0)
- {
+ if (romeEntry.getCategories().size() > 0) {
List list = new ArrayList();
Iterator cats = romeEntry.getCategories().iterator();
- while (cats.hasNext())
- {
+ while (cats.hasNext()) {
SyndCategory cat = (SyndCategory)cats.next();
list.add(cat.getName());
}
- setCategories(list);
+ setCategoriesString(list);
}
}
- /**
- * Init entry from Roller entry
+ /**
+ * Init entry from Roller entry
*/
- private void initFromRollerEntry(WeblogEntryData rollerEntry, Map pagePlugins)
- throws RollerException
- {
+ private void initFromRollerEntry(WeblogEntryData rollerEntry, Map pagePlugins)
+ throws RollerException {
Roller roller = RollerFactory.getRoller();
PagePluginManager ppmgr = roller.getPagePluginManager();
-
+
String content = "";
if (!StringUtils.isEmpty(rollerEntry.getText())) {
content = rollerEntry.getText();
@@ -177,183 +156,173 @@
setAuthor( rollerEntry.getCreator().getFullName());
setTitle( rollerEntry.getTitle());
- setPermalink( rollerEntry.getLink());
- setPublished( rollerEntry.getPubTime());
- setContent( content);
+ setPermaLink( rollerEntry.getLink());
+ setPubTime( rollerEntry.getPubTime());
+ setText( content);
- setPermalink(RollerRuntimeConfig.getProperty("site.absoluteurl")
- + rollerEntry.getPermaLink());
+ setPermaLink(RollerRuntimeConfig.getProperty("site.absoluteurl")
+ + rollerEntry.getPermaLink());
List cats = new ArrayList();
cats.add(rollerEntry.getCategory().getPath());
- setCategories(cats);
+ setCategoriesString(cats);
}
//----------------------------------------------------------- persistent fields
-
- /**
- * @hibernate.id column="id"
+
+ /**
+ * @hibernate.id column="id"
* generator-class="uuid.hex" unsaved-value="null"
*/
- public String getId()
- {
+ public String getId() {
return id;
}
- public void setId(String id)
- {
+ public void setId(String id) {
this.id = id;
}
- /**
+ /**
* @hibernate.property column="categories" non-null="false" unique="false"
*/
- public String getCategoriesString()
- {
+ public String getCategoriesString() {
return categoriesString;
}
- public void setCategoriesString(String categoriesString)
- {
+ public void setCategoriesString(String categoriesString) {
this.categoriesString = categoriesString;
}
- /**
+ /**
* @hibernate.many-to-one column="subscription_id" cascade="none" not-null="true"
*/
- public PlanetSubscriptionData getSubscription()
- {
+ public PlanetSubscriptionData getSubscription() {
return subscription;
}
- public void setSubscription(PlanetSubscriptionData subscription)
- {
+ public void setSubscription(PlanetSubscriptionData subscription) {
this.subscription = subscription;
}
- /**
+ /**
* @hibernate.property column="author" non-null="false" unique="false"
*/
- public String getAuthor()
- {
+ public String getAuthor() {
return author;
}
- public void setAuthor(String author)
- {
+ public void setAuthor(String author) {
this.author = author;
}
- /**
+ /**
* @hibernate.property column="content" non-null="false" unique="false"
*/
- public String getContent()
- {
- return content;
- }
- public void setContent(String content)
- {
- this.content = content;
+ public String getText() {
+ return text;
}
- /**
+ public void setText(String content) {
+ this.text = content;
+ }
+ /**
* @hibernate.property column="guid" non-null="false" unique="true"
*/
- public String getGuid()
- {
+ public String getGuid() {
return guid;
}
- public void setGuid(String guid)
- {
+ public void setGuid(String guid) {
this.guid = guid;
}
- /**
+ /**
* @hibernate.property column="handle" non-null="false" unique="false"
*/
- public String getHandle()
- {
+ public String getHandle() {
return handle;
}
- public void setHandle(String handle)
- {
+ public void setHandle(String handle) {
this.handle = handle;
}
- /**
+ /**
* @hibernate.property column="published" non-null="true" unique="false"
*/
- public Date getPublished()
- {
+ public Timestamp getPubTime() {
return published;
}
- public void setPublished(Date published)
- {
+ public void setPubTime(Timestamp published) {
this.published = published;
}
- /**
+ /**
* @hibernate.property column="permalink" non-null="true" unique="false"
*/
- public String getPermalink()
- {
+ public String getPermaLink() {
return permalink;
}
- public void setPermalink(String permalink)
- {
+ public void setPermaLink(String permalink) {
this.permalink = permalink;
}
- /**
+ /**
* @hibernate.property column="title" non-null="false" unique="false"
*/
- public String getTitle()
- {
+ public String getTitle() {
return title;
}
- public void setTitle(String title)
- {
+ public void setTitle(String title) {
this.title = title;
}
- /**
+ /**
* @hibernate.property column="updated" non-null="false" unique="false"
*/
- public Date getUpdated()
- {
+ public Timestamp getUpdateTime() {
return updated;
}
- public void setUpdated(Date updated)
- {
+ public void setUpdateTime(Timestamp updated) {
this.updated = updated;
}
-
+
//----------------------------------------------------------------- convenience
-
+
/**
- * Returns true if any of entry's categories contain a specific string
+ * Returns true if any of entry's categories contain a specific string
* (case-insensitive comparison).
*/
- public boolean inCategory(String category)
- {
+ public boolean inCategory(String category) {
Iterator cats = getCategories().iterator();
- while (cats.hasNext())
- {
+ while (cats.hasNext()) {
String catName = ((String)cats.next()).toLowerCase();
- if (catName.indexOf(category.toLowerCase()) != -1)
- {
+ if (catName.indexOf(category.toLowerCase()) != -1) {
return true;
}
}
return false;
}
-
+
//------------------------------------------------------------- implemenatation
- public List getCategories()
- {
+
+ /**
+ * Returns categories as list of WeblogCategoryData objects.
+ */
+ public List getCategories() {
List list = new ArrayList();
- if (categoriesString != null)
- {
+ if (categoriesString != null) {
String[] catArray = Utilities.stringToStringArray(categoriesString,",");
- for (int i=0; i<catArray.length; i++)
- {
- list.add(catArray[i]);
+ for (int i=0; i<catArray.length; i++) {
+ WeblogCategoryData cat = new WeblogCategoryData();
+ cat.setName(catArray[i]);
+ cat.setPath(catArray[i]);
+ list.add(cat);
}
}
return list;
}
- public void setCategories(List categories)
- {
+
+ /**
+ * Return first entry in category collection.
+ */
+ public WeblogCategoryData getCategory() {
+ WeblogCategoryData cat = null;
+ List cats = getCategories();
+ if (cats.size() > 0) {
+ cat = (WeblogCategoryData)cats.get(0);
+ }
+ return cat;
+ }
+
+ private void setCategoriesString(List categories) {
StringBuffer sb = new StringBuffer();
Iterator cats = categories.iterator();
- while (cats.hasNext())
- {
+ while (cats.hasNext()) {
String cat = (String)cats.next();
sb.append(cat);
if (cats.hasNext()) sb.append(",");
@@ -362,42 +331,56 @@
}
/**
- * Return category names as a string, separated by delimeters.
+ * Returns creator as a UserData object.
+ * TODO: make planet model entry author name, email, and uri
*/
- public String getCategoriesAsString(String delim)
- {
- StringBuffer sb = new StringBuffer();
- Iterator cats = getCategories().iterator();
- while (cats.hasNext())
- {
- String catName = ((String)cats.next()).toLowerCase();
- sb.append(catName);
- if (cats.hasNext()) sb.append(delim);
+ public UserData getCreator() {
+ UserData user = null;
+ if (author != null) {
+ user = new UserData();
+ user.setFullName(author);
+ user.setUserName(author);
}
- return sb.toString();
- }
+ return user;
+ }
+
+ /**
+ * Returns summary (always null for planet entry)
+ * TODO: make planet model entry.summary
+ */
+ public String getSummary() {
+ return null;
+ }
- public int compareTo(Object o)
- {
+ /**
+ * Compare planet entries by comparing permalinks.
+ */
+ public int compareTo(Object o) {
PlanetEntryData other = (PlanetEntryData)o;
- return getPermalink().compareTo(other.getPermalink());
+ return getPermaLink().compareTo(other.getPermaLink());
}
- public boolean equals(Object other) {
-
+ /**
+ * Compare planet entries by comparing permalinks.
+ */
+ public boolean equals(Object other) {
if(this == other) return true;
- if(!(other instanceof PlanetEntryData)) return false;
-
+ if(!(other instanceof PlanetEntryData)) return false;
final PlanetEntryData that = (PlanetEntryData) other;
- return this.permalink.equals(that.getPermalink());
+ return this.permalink.equals(that.getPermaLink());
}
+ /**
+ * Generate hash code based on permalink.
+ */
public int hashCode() {
return this.permalink.hashCode();
}
- public void setData(PersistentObject vo)
- {
- }
+ public void setData(PersistentObject vo) {}
+
+
}
+
+
Added: incubator/roller/branches/roller_3.0/src/org/apache/roller/pojos/WeblogEntry.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/pojos/WeblogEntry.java?rev=409435&view=auto
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/pojos/WeblogEntry.java (added)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/pojos/WeblogEntry.java Thu May 25 12:06:35 2006
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.roller.pojos;
+
+import java.sql.Timestamp;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Common weblog entry interface supported by both WeblogEntryData and
+ * PlanetEntryData, meant primarily as documentation -- to help Roller template
+ * author's write template code that works with both blog and planet entries.
+ */
+public interface WeblogEntry {
+
+ /**
+ * Returns raw title of entry, which you should treat as escaped HTML
+ * content, but since titles are not required by all feed formats so this
+ * method may return null.
+ */
+ public String getTitle();
+
+ /**
+ * Returns the fully qualified permalink for the entry.
+ */
+ public String getPermaLink();
+
+ /**
+ * Returns published time for entry, will not be null (both planet and
+ * Roller itself require a published timestamp).
+ */
+ public Timestamp getPubTime();
+
+ /**
+ * Returns updated time for entry, will not be null (planet entries do
+ * not alays have update times).
+ */
+ public Timestamp getUpdateTime();
+
+ /**
+ * Returns the summary of the entry, but since summary is not a required
+ * field, this may be null.
+ */
+ public String getSummary();
+
+ /**
+ * Returns the entry content, which you should treat as escaped HTML content.
+ */
+ public String getText();
+
+ /**
+ * Returns the entry's category object but since feed formats do require
+ * category information, this may be null. If there are multiple categories
+ * then the first category found is returned.
+ */
+ public WeblogCategoryData getCategory();
+
+ /**
+ * Returns collection of WeblogCategoryData objects for entry.
+ */
+ public List getCategories();
+
+ /**
+ * Returns user object of author who created post but since titles are not
+ * required by all feed formats so this method may return null.
+ */
+ public UserData getCreator();
+}
+
+