Scarab commit: svn commit: r10755 - trunk/src/java/org/tigris/scarab: pipeline tools
Hussayn Dabbous <[email protected]>
| Newsgroups | gmane.comp.java.scarab.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: dabbous
Date: 2009-06-08 13:54:28-0700
New Revision: 10755
Modified:
trunk/src/java/org/tigris/scarab/pipeline/DetermineTargetValve.java
trunk/src/java/org/tigris/scarab/tools/ScarabRequestTool.java
Log:
SCB2974: First try to implement shortlinks for queries
Modified: trunk/src/java/org/tigris/scarab/pipeline/DetermineTargetValve.java
Url: http://scarab.tigris.org/source/browse/scarab/trunk/src/java/org/tigris/scarab/pipeline/DetermineTargetValve.java?view=diff&pathrev=10755&r1=10754&r2=10755
==============================================================================
--- trunk/src/java/org/tigris/scarab/pipeline/DetermineTargetValve.java (original)
+++ trunk/src/java/org/tigris/scarab/pipeline/DetermineTargetValve.java 2009-06-08 13:54:28-0700
@@ -57,7 +57,6 @@
import org.apache.turbine.modules.Module;
import org.apache.turbine.pipeline.AbstractValve;
import org.tigris.scarab.om.ScarabUser;
-import org.tigris.scarab.tools.ScarabGlobalTool;
import org.tigris.scarab.tools.ScarabRequestTool;
import org.tigris.scarab.util.Log;
import org.tigris.scarab.util.ScarabConstants;
@@ -89,8 +88,16 @@
}
else if (parameters.getString("id") != null)
{
+ // Allows short link to issue
+ // $scarabRoot/issues/id/<issueId>
data.setTarget("ViewIssue.vm");
}
+ else if (parameters.getString("query") != null)
+ {
+ // Allows short link to public/personal queries
+ // $scarabRoot/issues/query/<queryId>/curmodule/<moduleId>
+ data.setTarget("IssueList.vm");
+ }
else
{
//data.getResponse().sendError(404);
Modified: trunk/src/java/org/tigris/scarab/tools/ScarabRequestTool.java
Url: http://scarab.tigris.org/source/browse/scarab/trunk/src/java/org/tigris/scarab/tools/ScarabRequestTool.java?view=diff&pathrev=10755&r1=10754&r2=10755
==============================================================================
--- trunk/src/java/org/tigris/scarab/tools/ScarabRequestTool.java (original)
+++ trunk/src/java/org/tigris/scarab/tools/ScarabRequestTool.java 2009-06-08 13:54:28-0700
@@ -116,7 +116,6 @@
import org.tigris.scarab.om.RModuleAttributeManager;
import org.tigris.scarab.om.RModuleIssueType;
import org.tigris.scarab.om.RModuleIssueTypePeer;
-import org.tigris.scarab.om.RModuleUserAttribute;
import org.tigris.scarab.om.ROptionOption;
import org.tigris.scarab.om.ReportManager;
import org.tigris.scarab.om.ScarabUser;
@@ -736,10 +735,11 @@
*/
public List getRModuleUserAttributes()
{
- ScarabUser user = (ScarabUser)data.getUser();
+ ScarabUser user = (ScarabUser)data.getUser();
+ IssueType theIssueType = this.getIssueType();
if(issueListColumns == null){
- issueListColumns= getRModuleUserAttributes(user, user.getCurrentModule(), issueType);
+ issueListColumns= getRModuleUserAttributes(user, user.getCurrentModule(), theIssueType);
if (issueListColumns == null)
{
issueListColumns = Collections.EMPTY_LIST;
@@ -796,33 +796,47 @@
/**
* A Query object for use within the Scarab API.
*/
- public Query getQuery()
- throws Exception
+ public Query getQuery() throws TorqueException
+ {
+ if (query == null)
+ {
+ String queryId = data.getParameters().getString("queryId");
+ query = getQuery(queryId);
+ }
+ return query;
+ }
+
+
+ /**
+ * A Query object for use within the Scarab API.
+ * Used for shortlink to query (similar to short URL to issueId)
+ */
+ private Query getQuery(String queryId) throws TorqueException
{
try
{
- if (query == null)
+ if (queryId == null || queryId.length() == 0)
{
- String queryId = data.getParameters()
- .getString("queryId");
- if (queryId == null || queryId.length() == 0)
- {
- query = Query.getInstance();
- }
- else
- {
- query = QueryManager
- .getInstance(new NumberKey(queryId), false);
- }
+ query = Query.getInstance();
+ }
+ else
+ {
+ query = QueryManager
+ .getInstance(new NumberKey(queryId), false);
}
}
- catch (Exception e)
+ catch (TorqueException e)
{
e.printStackTrace();
+ throw e;
}
return query;
}
+
+
+
+
/**
* A IssueTemplateInfo object for use within the Scarab API.
*/
@@ -982,15 +996,16 @@
return attachment;
}
+
/**
* A AttributeGroup object for use within the Scarab API.
*/
public AttributeGroup getAttributeGroup()
throws Exception
{
- AttributeGroup group = null;
-try
-{
+ AttributeGroup group = null;
+ try
+ {
String attGroupId = getIntakeTool()
.get("AttributeGroup", IntakeTool.DEFAULT_KEY)
.get("AttributeGroupId").toString();
@@ -1000,17 +1015,16 @@
}
else
{
- group = AttributeGroupManager
- .getInstance(new NumberKey(attGroupId), false);
+ group = AttributeGroupManager.getInstance(new NumberKey(attGroupId), false);
}
-}
-catch(Exception e)
-{
-e.printStackTrace();
-}
+ }
+ catch(Exception e)
+ {
+ e.printStackTrace();
+ }
return group;
+ }
- }
/**
* Get a AttributeGroup object.
*/
@@ -1055,7 +1069,6 @@
* Get an issue type object.
*/
public IssueType getIssueType()
- throws Exception
{
if (issueType == null)
{
@@ -1102,8 +1115,8 @@
throws Exception
{
RModuleAttribute rma = null;
-try
-{
+ try
+ {
ComboKey rModAttId = (ComboKey)getIntakeTool()
.get("RModuleAttribute", IntakeTool.DEFAULT_KEY)
.get("Id").getValue();
@@ -1131,11 +1144,11 @@
{
rma = RModuleAttributeManager.getInstance(rModAttId, false);
}
-}
-catch(Exception e)
-{
-e.printStackTrace();
-}
+ }
+ catch(Exception e)
+ {
+ e.printStackTrace();
+ }
return rma;
}
@@ -1155,23 +1168,23 @@
public Module getModule()
throws Exception
{
-try
-{
- String modId = getIntakeTool()
- .get("Module", IntakeTool.DEFAULT_KEY).get("Id").toString();
- if (modId == null || modId.length() == 0)
+ try
{
- module = ModuleManager.getInstance();
+ String modId = getIntakeTool()
+ .get("Module", IntakeTool.DEFAULT_KEY).get("Id").toString();
+ if (modId == null || modId.length() == 0)
+ {
+ module = ModuleManager.getInstance();
+ }
+ else
+ {
+ module = ModuleManager.getInstance(new Integer(modId));
+ }
}
- else
+ catch(Exception e)
{
- module = ModuleManager.getInstance(new Integer(modId));
+ e.printStackTrace();
}
-}
-catch(Exception e)
-{
-e.printStackTrace();
-}
return module;
}
@@ -1221,7 +1234,7 @@
* Gets the IssueType associated with the information
* passed around in the query string.
*/
- public IssueType getCurrentIssueType() throws Exception
+ public IssueType getCurrentIssueType()throws TorqueException
{
ScarabUser user = (ScarabUser)data.getUser();
IssueType curit = user.getCurrentIssueType();
@@ -1654,7 +1667,7 @@
/**
* Generates link to Issue List page, re-running stored query.
*/
- public String getExecuteLink(String link, Query query)
+ public static String getExecuteLink(String link, Query query)
{
// query.getValue() begins with a &
link = link
@@ -1676,7 +1689,7 @@
/**
* Generates link to the Query Detail page.
*/
- public String getEditLink(String link, Query query)
+ public static String getEditLink(String link, Query query)
{
// query.getValue() begins with a &
link = link + "?queryId=" + query.getQueryId()
@@ -1909,7 +1922,48 @@
private List getUnprotectedCurrentSearchResults()
throws Exception
{
- String currentQueryString = ((ScarabUser)data.getUser()).getMostRecentQuery();
+ ScarabUser user = (ScarabUser)data.getUser();
+
+ // [HD] Very experimental: The following code allows to create a shortLink
+ // to a public or private query similar to what has been implemented
+ // as shortLink for Issues. The URL-syntax is:
+ //
+ // <scarabHost>/scarab/issues/query/<queryId>
+ //
+ // The queryId should be sufficient to setup the full query.
+ // But i have seen a problem, when the user has only limitted
+ // module read permissions. In that case the LoginValve
+ // forces a login before the query can be perfromed.
+ // Workaround: Also add the moduleId to the URL:
+ //
+ // <scarabHost>/scarab/issues/query/<queryId>/curmodule/<moduleId>
+ //
+ // The current solution always uses the default MITList, hence it will
+ // not take care of user customized resultsets.
+ // I am not sure, where to place this code and how to actually
+ // control the search-Subsystem so that it will perfrom the correct
+ // search. Any help and advice for a better solution is heavily welcome!!!
+
+ String currentQueryString;
+ String queryId = data.getParameters().get("query");
+ if(queryId != null && queryId.length() > 0)
+ {
+ // ===================================================================
+ // Query has been entered via shortLink:
+ // <scarabHost>/scarab/issues/query/<queryId>/curmodule/<moduleId>/...
+ // ===================================================================
+ query = getQuery(queryId);
+ currentQueryString = query.getValue();
+ MITList queryMitList = query.getMITList(); //use the query default mitlist
+ user.setCurrentMITList(queryMitList);
+ user.removeTemp("queryResult");
+ }
+ else
+ {
+ currentQueryString = user.getMostRecentQuery();
+ }
+
+ assert currentQueryString != null;
String sortColumn = data.getParameters().getString("sortColumn");
String sortInternal=data.getParameters().getString("sortInternal");
String sortPolarity = data.getParameters().getString("sortPolarity");
@@ -1918,7 +1972,6 @@
if(currentQueryAddition.equals("nullnullnull"))
currentQueryAddition = cachedQueryAddition;
-
List queryResult = (List)data.getUser().getTemp("queryResult");
if (cachedQueryAddition==null || !cachedQueryAddition.equals(currentQueryAddition) || queryResult==null)
------------------------------------------------------
http://scarab.tigris.org/ds/viewMessage.do?dsForumId=3577&dsMessageId=2360451