Index: lams_bb_integration/build.xml
===================================================================
diff -u -r6ea1989a0d2f9cb90fd256689eb0f673fbff120e -ra8f2859ee903c129921e653ce789dca19cc60f1f
--- lams_bb_integration/build.xml (.../build.xml) (revision 6ea1989a0d2f9cb90fd256689eb0f673fbff120e)
+++ lams_bb_integration/build.xml (.../build.xml) (revision a8f2859ee903c129921e653ce789dca19cc60f1f)
@@ -53,7 +53,6 @@
-
Fisheye: Tag a8f2859ee903c129921e653ce789dca19cc60f1f refers to a dead (removed) revision in file `lams_bb_integration/conf/main.properties'.
Fisheye: No comparison available. Pass `N' to diff?
Index: lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LamsPluginUtil.java
===================================================================
diff -u -r8ea6dac2e1f9e39a41030dd5907592bc2aa04d17 -ra8f2859ee903c129921e653ce789dca19cc60f1f
--- lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LamsPluginUtil.java (.../LamsPluginUtil.java) (revision 8ea6dac2e1f9e39a41030dd5907592bc2aa04d17)
+++ lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LamsPluginUtil.java (.../LamsPluginUtil.java) (revision a8f2859ee903c129921e653ce789dca19cc60f1f)
@@ -22,7 +22,6 @@
*/
package org.lamsfoundation.ld.integration.blackboard;
-
import java.util.Properties;
import java.io.File;
import java.io.FileInputStream;
@@ -32,31 +31,28 @@
import blackboard.platform.plugin.PlugInException;
import blackboard.platform.plugin.PlugInUtil;
-
-
/**
*
- * This class basically manages the lams.properties file on the BB server
- * This file contains the LAMS server URL, server ID and secret key
- * These values allow the communication between the two servers
+ * This class basically manages the lams.properties file on the BB server This file contains the LAMS server URL, server
+ * ID and secret key These values allow the communication between the two servers
*
* @author Luke Foxton
*/
public class LamsPluginUtil {
-
+
public static final String VENDOR_ID = "lams";
public static final String PLUGIN_HANDLE = "lamscontent";
public static final String CONTENT_HANDLE = "resource/x-lams-lamscontent";
public static final String FILE_PROPERTIES = "lams.properties";
-
+
public static final String PROP_LAMS_SECRET_KEY = "LAMS_SERVER_SKEY";
public static final String PROP_LAMS_SERVER_ID = "LAMS_SERVER_ID";
public static final String PROP_LAMS_URL = "LAMS_SERVER_URL";
public static final String PROP_REQ_SRC = "BB_REQ_SRC";
-
+ public static final String PROP_LAMS_SERVER_TIME_REFRESH_INTERVAL = "LAMS_SERVER_TIME_REFRESH_INTERVAL";
+
private static Properties lamsProperties = null;
-
-
+
/**
* Returns the properties file that contains the server name, key and connection URL
*
@@ -66,91 +62,99 @@
* @throws IOException
*/
public static Properties getProperties() {
- if(lamsProperties != null)
- return lamsProperties;
-
- //load LAMS Configuration File
- try{
- File configFile = new File(PlugInUtil.getConfigDirectory(VENDOR_ID, PLUGIN_HANDLE).getPath() + File.separator + FILE_PROPERTIES);
- Properties p = new Properties();
-
- if(configFile.exists())
- p.load(new FileInputStream(configFile));
- else{
- p.setProperty(PROP_LAMS_URL, "");
- p.setProperty(PROP_LAMS_SECRET_KEY, "");
- p.setProperty(PROP_LAMS_SERVER_ID, "");
- p.setProperty(PROP_REQ_SRC, "");
- }
-
- lamsProperties = p;
- return p;
- } catch(PlugInException e){
- throw new RuntimeException(e);
- } catch(FileNotFoundException e){
- throw new RuntimeException(e);
- } catch(IOException e){
- throw new RuntimeException(e);
- }
+ if (lamsProperties != null)
+ return lamsProperties;
+
+ // load LAMS Configuration File
+ try {
+ File configFile = new File(PlugInUtil.getConfigDirectory(VENDOR_ID, PLUGIN_HANDLE).getPath()
+ + File.separator + FILE_PROPERTIES);
+ Properties p = new Properties();
+
+ if (configFile.exists())
+ p.load(new FileInputStream(configFile));
+ else {
+ p.setProperty(PROP_LAMS_URL, "");
+ p.setProperty(PROP_LAMS_SECRET_KEY, "");
+ p.setProperty(PROP_LAMS_SERVER_ID, "");
+ p.setProperty(PROP_REQ_SRC, "");
+ p.setProperty(PROP_LAMS_SERVER_TIME_REFRESH_INTERVAL, "24");
+ }
+
+ lamsProperties = p;
+ return p;
+ } catch (PlugInException e) {
+ throw new RuntimeException(e);
+ } catch (FileNotFoundException e) {
+ throw new RuntimeException(e);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
}
-
+
/**
- * Save a Properties file as the LAMS properties file
+ * Save a Properties file as the LAMS properties file
*
* @param p
* @throws PlugInException
* @throws FileNotFoundException
* @throws IOException
*/
public static void setProperties(Properties p) {
- try{
- lamsProperties = p;
-
- FileOutputStream configFile =
- new FileOutputStream(PlugInUtil.getConfigDirectory(VENDOR_ID, PLUGIN_HANDLE).getPath() +
- File.separator + FILE_PROPERTIES);
- p.store(configFile, "LAMS configuration");
- configFile.close();
- } catch(PlugInException e){
- throw new RuntimeException(e);
- } catch(FileNotFoundException e){
- throw new RuntimeException(e);
- } catch(IOException e){
- throw new RuntimeException(e);
- }
+ try {
+ lamsProperties = p;
+
+ FileOutputStream configFile = new FileOutputStream(PlugInUtil.getConfigDirectory(VENDOR_ID, PLUGIN_HANDLE)
+ .getPath() + File.separator + FILE_PROPERTIES);
+ p.store(configFile, "LAMS configuration");
+ configFile.close();
+ } catch (PlugInException e) {
+ throw new RuntimeException(e);
+ } catch (FileNotFoundException e) {
+ throw new RuntimeException(e);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
}
-
+
/**
*
* @return the secret key from lams.properties
*/
- public static String getSecretKey(){
- return getProperties().getProperty(PROP_LAMS_SECRET_KEY);
+ public static String getSecretKey() {
+ return getProperties().getProperty(PROP_LAMS_SECRET_KEY);
}
-
+
/**
*
* @return the secret url from lams.properties
*/
- public static String getServerUrl(){
- return getProperties().getProperty(PROP_LAMS_URL);
+ public static String getServerUrl() {
+ return getProperties().getProperty(PROP_LAMS_URL);
}
-
+
/**
*
* @return the server id from lams.properties
*/
- public static String getServerId(){
- return getProperties().getProperty(PROP_LAMS_SERVER_ID);
+ public static String getServerId() {
+ return getProperties().getProperty(PROP_LAMS_SERVER_ID);
}
-
+
/**
*
* @return the request source from lams.properties
*/
- public static String getReqSrc(){
- return getProperties().getProperty(PROP_REQ_SRC);
+ public static String getReqSrc() {
+ return getProperties().getProperty(PROP_REQ_SRC);
}
+ /**
+ *
+ * @return the LAMS server time refresh interval from lams.properties
+ */
+ public static String getLamsServerTimeRefreshInterval() {
+ return getProperties().getProperty(PROP_LAMS_SERVER_TIME_REFRESH_INTERVAL);
+ }
}
Index: lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LamsSecurityUtil.java
===================================================================
diff -u -r6ea1989a0d2f9cb90fd256689eb0f673fbff120e -ra8f2859ee903c129921e653ce789dca19cc60f1f
--- lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LamsSecurityUtil.java (.../LamsSecurityUtil.java) (revision 6ea1989a0d2f9cb90fd256689eb0f673fbff120e)
+++ lams_bb_integration/src/org/lamsfoundation/ld/integration/blackboard/LamsSecurityUtil.java (.../LamsSecurityUtil.java) (revision a8f2859ee903c129921e653ce789dca19cc60f1f)
@@ -61,24 +61,6 @@
public class LamsSecurityUtil {
private static Logger logger = Logger.getLogger(LamsSecurityUtil.class);
-
- /**
- * How often it should refresh LAMS server time. Measured in hours.
- */
- private static long INTERVAL;
-
- static {
- //set default value
- INTERVAL = 24;
-
- Properties props = new Properties();
- try {
- props.load(LamsSecurityUtil.class.getResourceAsStream("/main.properties"));
- INTERVAL = Long.parseLong(props.getProperty("lams.server.time.refresh.interval"));
- } catch (IOException e) {
- logger.error("Error loading propertis from main.properties file due to " + e.getMessage());
- }
- }
/**
* Generates login requests to LAMS for author, monitor and learner
@@ -398,7 +380,8 @@
long lastUpdateTime = (lastUpdateTimeStr == null) ? -1 : Long.parseLong(lastUpdateTimeStr);
long lamsServerTime;
- if ((lamsServerTimeDeltaStr == null) || (lastUpdateTime + INTERVAL * 60 * 60 * 1000 < now)) {
+ long lamsServerTimeRefreshInterval = getLamsServerTimeRefreshInterval() * 60 * 60 * 1000;
+ if ((lamsServerTimeDeltaStr == null) || (lastUpdateTime + lamsServerTimeRefreshInterval < now)) {
// refresh time from LAMS server
String serverAddr = getServerAddress();
@@ -491,6 +474,25 @@
public static String getReqSrc() {
return LamsPluginUtil.getProperties().getProperty(LamsPluginUtil.PROP_REQ_SRC);
}
+
+ /**
+ *
+ * @return the LAMS server time refresh interval from lams.properties
+ */
+ public static long getLamsServerTimeRefreshInterval() {
+ //set default value
+ long lamsServerTimeRefreshInterval = 24;
+
+ try {
+ String lamsServerTimeRefreshIntervalStr = LamsPluginUtil.getProperties().getProperty(
+ LamsPluginUtil.PROP_LAMS_SERVER_TIME_REFRESH_INTERVAL);
+ lamsServerTimeRefreshInterval = Long.parseLong(lamsServerTimeRefreshIntervalStr);
+ } catch (NumberFormatException e) {
+ logger.warn("Wrong format of PROP_LAMS_SERVER_TIME_REFRESH_INTERVAL from lams.properties");
+ }
+
+ return lamsServerTimeRefreshInterval;
+ }
// generate authentication hash code to validate parameters
public static String generateAuthenticationHash(String datetime, String login, String serverId) {
Index: lams_bb_integration/web/admin/config.jsp
===================================================================
diff -u -rc259b06d6cd8117ee8750bd3300ac37729360846 -ra8f2859ee903c129921e653ce789dca19cc60f1f
--- lams_bb_integration/web/admin/config.jsp (.../config.jsp) (revision c259b06d6cd8117ee8750bd3300ac37729360846)
+++ lams_bb_integration/web/admin/config.jsp (.../config.jsp) (revision a8f2859ee903c129921e653ce789dca19cc60f1f)
@@ -32,6 +32,7 @@
String lamsServerId = p.getProperty("LAMS_SERVER_ID", "");
String SecretKey = p.getProperty("LAMS_SERVER_SKEY", "");
String ReqSrc = p.getProperty("BB_REQ_SRC");
+ String lamsServerTimeRefreshInterval = p.getProperty("LAMS_SERVER_TIME_REFRESH_INTERVAL");
//Add port to the url if the port is in the blackboard url
int bbport = request.getServerPort();
@@ -67,7 +68,10 @@
-
For further information on how to configure these settings, see this tutorial.
+
+
+
+ For further information on how to configure these settings, see this tutorial.
Index: lams_bb_integration/web/admin/config_proc.jsp
===================================================================
diff -u -re90547eeb5330fd68c424212233b1689f25c71ce -ra8f2859ee903c129921e653ce789dca19cc60f1f
--- lams_bb_integration/web/admin/config_proc.jsp (.../config_proc.jsp) (revision e90547eeb5330fd68c424212233b1689f25c71ce)
+++ lams_bb_integration/web/admin/config_proc.jsp (.../config_proc.jsp) (revision a8f2859ee903c129921e653ce789dca19cc60f1f)
@@ -36,12 +36,14 @@
String lamsServerSkey = request.getParameter("lams_server_skey");
String lamsServerId = request.getParameter("lams_server_id");
String bbReqSrc = request.getParameter("bb_req_src");
+ String lamsServerTimeRefreshInterval = request.getParameter("lams_server_time_refresh_interval");
// Save the properties to Blackboard
p.setProperty(LamsPluginUtil.PROP_LAMS_URL, lamsServerUrl);
p.setProperty(LamsPluginUtil.PROP_LAMS_SECRET_KEY, lamsServerSkey);
p.setProperty(LamsPluginUtil.PROP_LAMS_SERVER_ID, lamsServerId);
- p.setProperty("BB_REQ_SRC", bbReqSrc);
+ p.setProperty(LamsPluginUtil.PROP_REQ_SRC, bbReqSrc);
+ p.setProperty(LamsPluginUtil.PROP_LAMS_SERVER_TIME_REFRESH_INTERVAL, lamsServerTimeRefreshInterval);
// Persist the properties object
LamsPluginUtil.setProperties(p);
@@ -70,6 +72,7 @@
LAMS_SERVER_SKEY: <%= lamsServerSkey %>
LAMS_SERVER_ID: <%= lamsServerId %>
BB_REQ_SRC: <%= bbReqSrc %>
+ LAMS_SERVER_TIME_REFRESH_INTERVAL: <%= lamsServerTimeRefreshInterval %>
\ No newline at end of file