You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@roller.apache.org by gm...@apache.org on 2014/08/05 04:41:31 UTC

svn commit: r1615852 - in /roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor: EntryBase.java EntryEdit.java EntryRemove.java

Author: gmazza
Date: Tue Aug  5 02:41:31 2014
New Revision: 1615852

URL: http://svn.apache.org/r1615852
Log:
EntryEdit and EntryRemove now subclassing UIAction instead of EntryBase, which has been removed.

Removed:
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/EntryBase.java
Modified:
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/EntryEdit.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/EntryRemove.java

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/EntryEdit.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/EntryEdit.java?rev=1615852&r1=1615851&r2=1615852&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/EntryEdit.java (original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/EntryEdit.java Tue Aug  5 02:41:31 2014
@@ -19,11 +19,14 @@
 package org.apache.roller.weblogger.ui.struts2.editor;
 
 import java.sql.Timestamp;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.Date;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
+
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -32,11 +35,19 @@ import org.apache.roller.util.RollerCons
 import org.apache.roller.weblogger.WebloggerException;
 import org.apache.roller.weblogger.business.WebloggerFactory;
 import org.apache.roller.weblogger.business.WeblogEntryManager;
+import org.apache.roller.weblogger.business.plugins.PluginManager;
+import org.apache.roller.weblogger.business.plugins.entry.WeblogEntryPlugin;
+import org.apache.roller.weblogger.business.search.IndexManager;
 import org.apache.roller.weblogger.pojos.GlobalPermission;
 import org.apache.roller.weblogger.pojos.WeblogCategory;
 import org.apache.roller.weblogger.pojos.WeblogEntry;
 import org.apache.roller.weblogger.pojos.WeblogEntry.PubStatus;
+import org.apache.roller.weblogger.pojos.WeblogEntrySearchCriteria;
 import org.apache.roller.weblogger.pojos.WeblogPermission;
+import org.apache.roller.weblogger.ui.core.RollerContext;
+import org.apache.roller.weblogger.ui.core.plugins.UIPluginManager;
+import org.apache.roller.weblogger.ui.core.plugins.WeblogEntryEditor;
+import org.apache.roller.weblogger.ui.struts2.util.UIAction;
 import org.apache.roller.weblogger.util.cache.CacheManager;
 import org.apache.roller.weblogger.util.MailUtil;
 import org.apache.roller.weblogger.util.MediacastException;
@@ -51,7 +62,7 @@ import org.apache.struts2.interceptor.va
 /**
  * Edit a new or existing entry.
  */
-public final class EntryEdit extends EntryBase {
+public final class EntryEdit extends UIAction {
 
     private static Log log = LogFactory.getLog(EntryEdit.class);
 
@@ -156,6 +167,9 @@ public final class EntryEdit extends Ent
                 WeblogEntryManager weblogMgr = WebloggerFactory.getWeblogger()
                         .getWeblogEntryManager();
 
+                IndexManager indexMgr = WebloggerFactory.getWeblogger()
+                        .getIndexManager();
+
                 WeblogEntry weblogEntry = getEntry();
 
                 // set updatetime & pubtime
@@ -227,9 +241,9 @@ public final class EntryEdit extends Ent
 
                 // notify search of the new entry
                 if (weblogEntry.isPublished()) {
-                    reindexEntry(weblogEntry);
+                    indexMgr.addEntryReIndexOperation(entry);
                 } else if ("entryEdit".equals(actionName)) {
-                    removeEntryIndex(weblogEntry);
+                    indexMgr.removeEntryIndexOperation(entry);
                 }
 
                 // notify caches
@@ -396,4 +410,87 @@ public final class EntryEdit extends Ent
         }
     }
 
+    public List<WeblogEntryPlugin> getEntryPlugins() {
+        List<WeblogEntryPlugin> availablePlugins = Collections.emptyList();
+        try {
+            PluginManager ppmgr = WebloggerFactory.getWeblogger()
+                    .getPluginManager();
+            Map<String, WeblogEntryPlugin> plugins = ppmgr
+                    .getWeblogEntryPlugins(getActionWeblog());
+
+            if (plugins.size() > 0) {
+                availablePlugins = new ArrayList<WeblogEntryPlugin>();
+                for (WeblogEntryPlugin plugin : plugins.values()) {
+                    availablePlugins.add(plugin);
+                }
+            }
+        } catch (Exception ex) {
+            log.error("Error getting plugins list", ex);
+        }
+        return availablePlugins;
+    }
+
+    public WeblogEntryEditor getEditor() {
+        UIPluginManager pmgr = RollerContext.getUIPluginManager();
+        return pmgr.getWeblogEntryEditor(getActionWeblog().getEditorPage());
+    }
+
+    public boolean isUserAnAuthor() {
+        return getActionWeblog().hasUserPermission(getAuthenticatedUser(),
+                WeblogPermission.POST);
+    }
+
+    public String getJsonAutocompleteUrl() {
+        return WebloggerFactory.getWeblogger().getUrlStrategy()
+                .getWeblogTagsJsonURL(getActionWeblog(), false, 0);
+    }
+
+    /**
+     * Get recent published weblog entries
+     * @return List of published WeblogEntry objects sorted by publication time.
+     */
+    public List<WeblogEntry> getRecentPublishedEntries() {
+        return getRecentEntries(PubStatus.PUBLISHED, WeblogEntrySearchCriteria.SortBy.PUBLICATION_TIME);
+    }
+
+    /**
+     * Get recent scheduled weblog entries
+     * @return List of scheduled WeblogEntry objects sorted by publication time.
+     */
+    public List<WeblogEntry> getRecentScheduledEntries() {
+        return getRecentEntries(PubStatus.SCHEDULED, WeblogEntrySearchCriteria.SortBy.PUBLICATION_TIME);
+    }
+
+    /**
+     * Get recent draft weblog entries
+     * @return List of draft WeblogEntry objects sorted by update time.
+     */
+    public List<WeblogEntry> getRecentDraftEntries() {
+        return getRecentEntries(PubStatus.DRAFT, WeblogEntrySearchCriteria.SortBy.UPDATE_TIME);
+    }
+
+    /**
+     * Get recent pending weblog entries
+     * @return List of pending WeblogEntry objects sorted by update time.
+     */
+    public List<WeblogEntry> getRecentPendingEntries() {
+        return getRecentEntries(PubStatus.PENDING, WeblogEntrySearchCriteria.SortBy.UPDATE_TIME);
+    }
+
+    private List<WeblogEntry> getRecentEntries(PubStatus pubStatus, WeblogEntrySearchCriteria.SortBy sortBy) {
+        List<WeblogEntry> entries = Collections.emptyList();
+        try {
+            WeblogEntrySearchCriteria wesc = new WeblogEntrySearchCriteria();
+            wesc.setWeblog(getActionWeblog());
+            wesc.setMaxResults(20);
+            wesc.setStatus(pubStatus);
+            wesc.setSortBy(sortBy);
+            entries = WebloggerFactory.getWeblogger().getWeblogEntryManager()
+                    .getWeblogEntries(wesc);
+        } catch (WebloggerException ex) {
+            log.error("Error getting entries list", ex);
+        }
+        return entries;
+    }
+
 }

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/EntryRemove.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/EntryRemove.java?rev=1615852&r1=1615851&r2=1615852&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/EntryRemove.java (original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/EntryRemove.java Tue Aug  5 02:41:31 2014
@@ -26,6 +26,7 @@ import org.apache.roller.weblogger.busin
 import org.apache.roller.weblogger.business.search.IndexManager;
 import org.apache.roller.weblogger.pojos.WeblogEntry;
 import org.apache.roller.weblogger.pojos.WeblogPermission;
+import org.apache.roller.weblogger.ui.struts2.util.UIAction;
 import org.apache.roller.weblogger.util.cache.CacheManager;
 
 import java.util.Collections;
@@ -34,7 +35,7 @@ import java.util.List;
 /**
  * Remove a weblog entry.
  */
-public class EntryRemove extends EntryBase {
+public class EntryRemove extends UIAction {
 
 	private static Log log = LogFactory.getLog(EntryRemove.class);
 
@@ -70,16 +71,14 @@ public class EntryRemove extends EntryBa
 
 		if (getRemoveEntry() != null) {
 			try {
-
 				WeblogEntry entry = getRemoveEntry();
+                IndexManager manager = WebloggerFactory.getWeblogger().getIndexManager();
 
 				try {
 					// remove the entry from the search index
 					// TODO: can we do this in a better way?
 					WeblogEntry.PubStatus originalStatus = entry.getStatus();
 					entry.setStatus(WeblogEntry.PubStatus.DRAFT);
-					IndexManager manager = WebloggerFactory.getWeblogger()
-							.getIndexManager();
 					manager.addEntryReIndexOperation(entry);
 					entry.setStatus(originalStatus);
 				} catch (WebloggerException ex) {
@@ -88,7 +87,7 @@ public class EntryRemove extends EntryBa
 
 				// remove from search index
 				if (entry.isPublished()) {
-					removeEntryIndex(entry);
+                    manager.removeEntryIndexOperation(entry);
 				}
 
 				// flush caches
@@ -116,7 +115,7 @@ public class EntryRemove extends EntryBa
 
 		return INPUT;
 	}
-	
+
 	public String getRemoveId() {
 		return removeId;
 	}