forked from sakaiproject/sakai
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
STAT-253: Added API method + webservice for processing past site events
git-svn-id: https://source.sakaiproject.org/svn/sitestats/trunk@82272 66ffb92e-73f9-0310-93c1-f5514f145a0a
- Loading branch information
Showing
5 changed files
with
221 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
Site Stats WebServices | ||
============================================ | ||
|
||
1. About | ||
2. Installation instructions | ||
3. Call SiteStats webservice | ||
4. Contact | ||
|
||
|
||
|
||
1. About | ||
============================================ | ||
Site Stats WebServices offer the ability to invoke some SiteStats API calls through webservices. | ||
|
||
|
||
2. Installation instructions | ||
============================================ | ||
From now on, we will assume that: | ||
- Tomcat folder is located at [TOMCAT_HOME] | ||
- Sakai source folder is located at [SAKAI_SRC] | ||
- SiteStats source folder is located at [SITESTATS_SRC] | ||
|
||
2.1 Adding the *.jws files | ||
* cp [SITESTATS_SRC]/util/webservices/*.jws [SAKAI_SRC]/webservices/axis/src/webapp | ||
|
||
2.2 Compile & deploy webservices | ||
Webservices compilation and deployment can be made *live* (without stopping Sakai tomcats), | ||
as long as there are no webservices running/processing data (these will be aborted). | ||
* go to [SAKAI_SRC]/webservices | ||
* run: mvn -Dmaven.tomcat.home=[TOMCAT_HOME] clean install sakai:deploy | ||
|
||
2.3 Configure Sakai webservices (if not already done) | ||
You can read the following article from Steve Swinsburg about Sakai webservices: | ||
http://steve-on-sakai.blogspot.com/2009/05/enabling-web-services-in-sakai-and.html | ||
|
||
|
||
3. Call SiteStats webservice | ||
============================================ | ||
You can use a custom SOAP client (java code, shell script, ...) to invoke | ||
the SiteStats webservices calls. Alternativelly, you can use 3rd Party tools: | ||
- SOAP Client (Mac): http://ditchnet.org/soapclient/ | ||
- SoapUI (Windows): http://www.soapui.org/ | ||
- WebServiceStudio (Windows): http://webservicestudio.codeplex.com/ | ||
|
||
|
||
4. Contact | ||
============================================ | ||
SiteStats is written by Nuno Fernandes at Universidade Fernando Pessoa. | ||
If you wish, feel free to submit patches or any other contributions. | ||
You may contact us at [email protected]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import java.util.Date; | ||
|
||
import org.apache.axis.AxisFault; | ||
import org.apache.commons.logging.Log; | ||
import org.apache.commons.logging.LogFactory; | ||
import org.sakaiproject.authz.api.SecurityService; | ||
import org.sakaiproject.component.cover.ComponentManager; | ||
import org.sakaiproject.sitestats.api.StatsUpdateManager; | ||
import org.sakaiproject.tool.api.Session; | ||
import org.sakaiproject.tool.api.SessionManager; | ||
|
||
/** | ||
* SiteStats.jws | ||
* | ||
* Webservice for the SiteStats API. | ||
* | ||
*/ | ||
public class SiteStats { | ||
private static final Log LOG = LogFactory.getLog("org.sakaiproject.axis.SiteStats"); | ||
|
||
private SessionManager sessionManager; | ||
private SecurityService securityService; | ||
private StatsUpdateManager statsUpdateManager; | ||
|
||
public SiteStats() { | ||
sessionManager = (SessionManager) ComponentManager.get(SessionManager.class.getName()); | ||
securityService = (SecurityService) ComponentManager.get(SecurityService.class.getName()); | ||
statsUpdateManager = (StatsUpdateManager) ComponentManager.get(StatsUpdateManager.class.getName()); | ||
} | ||
|
||
/** Collect site events from SAKAI_EVENT table for a specific site, between specified dates. */ | ||
public long collectPastSiteEvents(String sessionid, String siteId, Date initialDate, Date finalDate) throws AxisFault { | ||
Session session = establishSession(sessionid); | ||
if(!securityService.isSuperUser()) { | ||
LOG.warn("NonSuperUser trying to collect past site events: " + session.getUserId()); | ||
throw new AxisFault("NonSuperUser trying to collect past site events: " + session.getUserId()); | ||
} | ||
|
||
return statsUpdateManager.collectPastSiteEvents(siteId, initialDate, finalDate); | ||
} | ||
|
||
|
||
/** | ||
* Get the Session related to the given sessionid | ||
* @param sessionid the id of the session to retrieve | ||
* @return the session, if it is active | ||
* @throws AxisFault if session is inactive | ||
*/ | ||
private Session establishSession(String sessionid) throws AxisFault | ||
{ | ||
Session s = sessionManager.getSession(sessionid); | ||
if (s == null) { | ||
throw new AxisFault("Session \""+sessionid+"\" is not active"); | ||
} | ||
s.setActive(); | ||
sessionManager.setCurrentSession(s); | ||
return s; | ||
} | ||
|
||
} | ||
|