Compod isac-side finished; ugly calls from Session (additional to former ExampleDialog); last example in the list of test-examples doesnt call notifyObjectResult, probable reason: mutual recursive pointers between Session -- ExampleDialog -- UserLogger (see constructor of Session).
Redesign of respective Objects together with introduction DialogGuide necessary.
1.1 --- a/src/java/isac/browserdialog/BrowserDialog.java Wed Feb 11 16:19:39 2009 +0100
1.2 +++ b/src/java/isac/browserdialog/BrowserDialog.java Fri Feb 13 12:14:56 2009 +0100
1.3 @@ -204,7 +204,8 @@
1.4 UIActionOnHierarchy ui_action_on_hierarchy = new UIActionOnHierarchy(
1.5 EUIElement.UI_BROWSER_HIERARCHY,
1.6 EUIContext.UI_CONTEXT_HIERARCHY, user_language_, hierarchy_);
1.7 - System.out.println("registerBrowserFrame after 'new UIActionOnHierarchy'");
1.8 + System.out
1.9 + .println("registerBrowserFrame after 'new UIActionOnHierarchy'");
1.10 try {
1.11 browser_frame_rmi_.doUIAction(ui_action_on_hierarchy);
1.12 } catch (RemoteException e) {
1.13 @@ -284,7 +285,7 @@
1.14 String type = ""; // taken from here............^^^ (mustbe same^^^)
1.15 // filename and exp_key -- ".xxx" should be the same
1.16
1.17 - //WN080825 StringTokenizer better ?
1.18 + // WN080825 StringTokenizer better ?
1.19 link_array = to_interpret.split("#");
1.20 link = link_array[0];
1.21 if (link_array.length == 2) {
1.22 @@ -302,7 +303,7 @@
1.23 compod_.setScopeByTopic(session_.getUser().getUsername(),
1.24 argument);
1.25 compod_.startSession(session_.getUser().getUsername(),
1.26 - "course"); // the topic to be assessed
1.27 + "assessment");
1.28 } catch (Exception e) {
1.29 e.printStackTrace();
1.30 }
1.31 @@ -318,6 +319,27 @@
1.32 e.printStackTrace();
1.33 }
1.34 return;// --------------------------------------------->
1.35 + } else if (command.equals("COMMAND_START_COURSE")) {
1.36 + try {
1.37 + compod_.setScopeByTopic(session_.getUser().getUsername(),
1.38 + argument);
1.39 + compod_.startSession(session_.getUser().getUsername(),
1.40 + "course");
1.41 + } catch (Exception e) {
1.42 + e.printStackTrace();
1.43 + }
1.44 + // start the first example ...
1.45 + session_.getExampleDialog().notifyStartFirstExample();
1.46 + return;// --------------------------------------------->
1.47 + } else if (command.equals("COMMAND_STOP_COURSE")) {
1.48 + try {
1.49 + compod_
1.50 + .stopSession(session_.getUser().getUsername(),
1.51 + false /* FIXME.WN071010 */);
1.52 + } catch (Exception e) {
1.53 + e.printStackTrace();
1.54 + }
1.55 + return;// --------------------------------------------->
1.56 }
1.57 }
1.58 path_array = link.split("/");
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/src/java/isac/session/CompodDriver.java Fri Feb 13 12:14:56 2009 +0100
2.3 @@ -0,0 +1,338 @@
2.4 +/*********************************************************************
2.5 + * This file is part of the Compod project
2.6 + * Contact: Alexander Nussbaumer (AN, alnuss)
2.7 + * <alexander.nussbaumer@uni-graz.at>, <alnuss@gmx.net>
2.8 + *
2.9 + * modified: AN, 20070916
2.10 + *********************************************************************/
2.11 +
2.12 +package isac.session;
2.13 +
2.14 +import isac.util.ObjectManagerPaths;
2.15 +
2.16 +import java.net.MalformedURLException;
2.17 +import java.net.URL;
2.18 +
2.19 +/**
2.20 + * This is a dummy implementation of the ICompod interface. In contrast to a
2.21 + * "real" implemenatin, this class does not connect the Compod services.
2.22 + *
2.23 + * @author Alexander Nussbaumer (AN)
2.24 + */
2.25 +public class CompodDriver implements ICompod {
2.26 + // --- fields ---
2.27 +
2.28 + /**
2.29 + * The lmsid. this is not needed in the dummy, however, the dummy simulates
2.30 + * a 'real' compod interface, so it is neccessary to insist of it's usage
2.31 + * (exception if not set).
2.32 + */
2.33 + private String lmsid_ = null;
2.34 +
2.35 + /**
2.36 + * isac objects. real object IDs, but only a few in the dummy.
2.37 + */
2.38 + private String[] objects_ = { "exp_IsacCore_Tests_1a.xml",
2.39 + "exp_IsacCore_Tests_1b.xml", "exp_IsacCore_Tests_1c.xml" };
2.40 +
2.41 + /**
2.42 + * Index of the object which will be the next to be shown to the user. If
2.43 + * session is not active, than index is -1.
2.44 + */
2.45 + private int objectindex_ = -1;
2.46 +
2.47 + /**
2.48 + * Keeps inforamtion which type of session is currently running:
2.49 + * "assessment" or "course", or null if no session is active. Maybe enum
2.50 + * would be better than string.
2.51 + */
2.52 + private String sessiontype_ = null;
2.53 +
2.54 + /**
2.55 + * Keeps information about the session state.
2.56 + */
2.57 + private SessionState sessionstate_ = null;
2.58 +
2.59 + /**
2.60 + * Keeps availability information about knowledge and competence state.
2.61 + */
2.62 + private KnowledgeStateQuality knowledgestatequality_ = null;
2.63 +
2.64 + /**
2.65 + * is the compod service available ?
2.66 + */
2.67 + private boolean compod_enabled_ = false;
2.68 +
2.69 + private URL compod_path_ = null;
2.70 +
2.71 + // --- constructor ---
2.72 +
2.73 + /**
2.74 + * Constructor: initialisation
2.75 + */
2.76 + public CompodDriver() {
2.77 + // initialisation
2.78 + compod_enabled_ = ObjectManagerPaths.COMPOD_ENABLED;
2.79 + if (compod_enabled_) {
2.80 + try {
2.81 + compod_path_ = new URL(ObjectManagerPaths.COMPOD_PATH);
2.82 + } catch (MalformedURLException e) {
2.83 + System.out.println("COMPOD_PATH is no URL format");
2.84 + e.printStackTrace();
2.85 + }
2.86 + }
2.87 + // no session at the beginning
2.88 + sessionstate_ = SessionState.INACTIVE;
2.89 +
2.90 + // empty set at beginning, empty set is also a possible knowledge state
2.91 + knowledgestatequality_ = KnowledgeStateQuality.AVAILABLE;
2.92 + }
2.93 +
2.94 + /**
2.95 + * @see ICompod#setLMSID(java.lang.String)
2.96 + */
2.97 + public void setLMSID(String lmsid) throws Exception {
2.98 + lmsid_ = lmsid;
2.99 + }
2.100 +
2.101 + /**
2.102 + * @see isac.session.ICompod#setScopeByTopic(java.lang.String,
2.103 + * java.lang.String)
2.104 + */
2.105 + public void setScopeByTopic(String username, String topic) throws Exception {
2.106 + if (lmsid_ == null)
2.107 + throw new Exception("lmsid is not set");
2.108 +
2.109 + // not used in dummy
2.110 + }
2.111 +
2.112 + /**
2.113 + * @see ICompod#startSession(java.lang.String, java.lang.String)
2.114 + */
2.115 + public boolean startSession(String username, String sessiontype)
2.116 + throws Exception {
2.117 + if (lmsid_ == null)
2.118 + throw new Exception("lmsid is not set");
2.119 +
2.120 + // user is ignored in this dummy
2.121 +
2.122 + // if a session is already running then return
2.123 + if (sessionstate_ == SessionState.ACTIVE)
2.124 + return false;
2.125 +
2.126 + // activate and initialise session
2.127 + sessionstate_ = SessionState.ACTIVE;
2.128 + sessiontype_ = sessiontype;
2.129 + objectindex_ = 0;
2.130 + // during an assessment, the knowledge and competence state is not
2.131 + // available
2.132 + if (sessiontype_ == "assessment")
2.133 + knowledgestatequality_ = KnowledgeStateQuality.UNAVAILABLE;
2.134 +
2.135 + return true;
2.136 + }
2.137 +
2.138 + /**
2.139 + * @see ICompod#stopSession(java.lang.String, boolean)
2.140 + */
2.141 + public boolean stopSession(String username, boolean cancel)
2.142 + throws Exception {
2.143 + if (lmsid_ == null)
2.144 + throw new Exception("lmsid is not set");
2.145 +
2.146 + // user and cancel type is ignored in this dummy
2.147 +
2.148 + // if a session is not running then return
2.149 + if (sessionstate_ == SessionState.INACTIVE)
2.150 + return false;
2.151 +
2.152 + // stop session
2.153 + sessionstate_ = SessionState.INACTIVE;
2.154 + knowledgestatequality_ = KnowledgeStateQuality.PRELIMINARY;
2.155 + objectindex_ = -1;
2.156 +
2.157 + return true;
2.158 + }
2.159 +
2.160 + /**
2.161 + * @see ICompod#getSessionStatus(java.lang.String)
2.162 + */
2.163 + public SessionState getSessionState(String username) throws Exception {
2.164 + if (lmsid_ == null)
2.165 + throw new Exception("lmsid is not set");
2.166 +
2.167 + return sessionstate_;
2.168 + }
2.169 +
2.170 + /**
2.171 + * @see ICompod#getNextObjects(java.lang.String)
2.172 + */
2.173 + public String[] getNextObjects(String username) throws Exception {
2.174 + if (lmsid_ == null)
2.175 + throw new Exception("lmsid is not set");
2.176 +
2.177 + // return if no session is active
2.178 + if (sessionstate_ == SessionState.INACTIVE)
2.179 + return null;
2.180 +
2.181 + // system invariant: this case should not happen
2.182 + int objectnumber = objects_.length;
2.183 + if (objectindex_ < 0 || objectindex_ >= objectnumber)
2.184 + return null;
2.185 +
2.186 + // return next objects
2.187 + String[] nextobjects = new String[1];
2.188 + nextobjects[0] = objects_[objectindex_];
2.189 +
2.190 + // different behaviour if a course is conducted
2.191 + // in contrast to the assessment, there is no separate update,
2.192 + // therefore the update has to be done here.
2.193 + if (sessiontype_ == "course" || sessiontype_ == "assessment") {
2.194 + // update and prepare for getNextObjects
2.195 + objectindex_++;
2.196 +
2.197 + // stop if no more objects are available
2.198 + if (objectindex_ >= objectnumber) {
2.199 + sessionstate_ = SessionState.INACTIVE;
2.200 + objectindex_ = -1;
2.201 + }
2.202 + }
2.203 + return nextobjects;
2.204 + }
2.205 +
2.206 + /**
2.207 + * @see ICompod#notifyObjectResult(java.lang.String, java.lang.String,
2.208 + * boolean)
2.209 + */
2.210 + public void notifyObjectResult(String username, String objectid,
2.211 + boolean solved) throws Exception {
2.212 + if (lmsid_ == null)
2.213 + throw new Exception("lmsid is not set");
2.214 +
2.215 + // TODO write data in a file (or on the console)
2.216 +
2.217 + // update and prepare for getNextObjects
2.218 + // WN090111 objectindex_++; only in getNextObjects
2.219 +
2.220 + // stop if no more objects are available
2.221 + int objectnumber = objects_.length;
2.222 + if (objectindex_ >= objectnumber) {
2.223 + sessionstate_ = SessionState.INACTIVE;
2.224 + knowledgestatequality_ = KnowledgeStateQuality.AVAILABLE;
2.225 + objectindex_ = -1;
2.226 + }
2.227 + }
2.228 +
2.229 + /**
2.230 + * @see ICompod#notifyObjectMicroResult(java.lang.String, java.lang.String,
2.231 + * java.lang.String, java.lang.String, boolean)
2.232 + */
2.233 + public void notifyObjectMicroResult(String username, String objectid,
2.234 + String skillid, String masterylevel, boolean solved)
2.235 + throws Exception {
2.236 + if (lmsid_ == null)
2.237 + throw new Exception("lmsid is not set");
2.238 +
2.239 + // TODO write data in a file (or on the console)
2.240 + }
2.241 +
2.242 + /**
2.243 + * @see ICompod#getKnowledgeStateQuality(java.lang.String)
2.244 + */
2.245 + public KnowledgeStateQuality getKnowledgeStateQuality(String username)
2.246 + throws Exception {
2.247 + if (lmsid_ == null)
2.248 + throw new Exception("lmsid is not set");
2.249 +
2.250 + return knowledgestatequality_;
2.251 + }
2.252 +
2.253 + /**
2.254 + * @see ICompod#getKnowledgeState(java.lang.String)
2.255 + */
2.256 + public String[] getKnowledgeState(String username) throws Exception {
2.257 + if (lmsid_ == null)
2.258 + throw new Exception("lmsid is not set");
2.259 +
2.260 + String[] knowledgestate = null;
2.261 + if (knowledgestatequality_ != KnowledgeStateQuality.UNAVAILABLE)
2.262 + knowledgestate = new String[0];
2.263 +
2.264 + return knowledgestate;
2.265 + }
2.266 +
2.267 + /**
2.268 + * @see ICompod#getCompetenceState(java.lang.String)
2.269 + */
2.270 + public String[] getCompetenceState(String username) throws Exception {
2.271 + if (lmsid_ == null)
2.272 + throw new Exception("lmsid is not set");
2.273 +
2.274 + String[] competencestate = null;
2.275 + if (knowledgestatequality_ != KnowledgeStateQuality.UNAVAILABLE)
2.276 + competencestate = new String[0];
2.277 +
2.278 + return competencestate;
2.279 + }
2.280 +
2.281 + /**
2.282 + * This main method is used for 1) testing the dummy implementation and 2)
2.283 + * demonstrating the usage of the ICompod interface. This could also be
2.284 + * placed in an external class.
2.285 + *
2.286 + * @param args
2.287 + * (Command line arguments) not used
2.288 + */
2.289 + public static void main(String[] args) {
2.290 + CompodDriver compod = new CompodDriver();
2.291 +
2.292 + System.out.print("Compod Dummy.\n");
2.293 +
2.294 + // initialisation
2.295 + String lmsid = "isac-beta-xxx";
2.296 + String username = "some wired user";
2.297 +
2.298 + try {
2.299 + compod.setLMSID(lmsid);
2.300 + } catch (Exception e) {
2.301 + e.printStackTrace();
2.302 + return; // stop
2.303 + }
2.304 +
2.305 + // assessment
2.306 + try {
2.307 + System.out.print("- Assessment.\n");
2.308 + compod.startSession(username, "assessment");
2.309 + while (compod.getSessionState(username) == SessionState.ACTIVE) {
2.310 + String[] nextobjects = compod.getNextObjects(username);
2.311 +
2.312 + // output
2.313 + for (int i = 0; i < nextobjects.length; i++)
2.314 + System.out.print(nextobjects[i]);
2.315 + System.out.println("");
2.316 +
2.317 + compod.notifyObjectResult(username, nextobjects[0], true);
2.318 + }
2.319 + } catch (Exception e) {
2.320 + e.printStackTrace();
2.321 + }
2.322 +
2.323 + // course
2.324 + try {
2.325 + System.out.print("- Course.\n");
2.326 + compod.startSession(username, "course");
2.327 + while (compod.getSessionState(username) == SessionState.ACTIVE) {
2.328 + String[] nextobjects = compod.getNextObjects(username);
2.329 +
2.330 + // output
2.331 + for (int i = 0; i < nextobjects.length; i++)
2.332 + System.out.print(nextobjects[i]);
2.333 + System.out.println("");
2.334 + }
2.335 + } catch (Exception e) {
2.336 + e.printStackTrace();
2.337 + }
2.338 +
2.339 + }
2.340 +
2.341 +}
3.1 --- a/src/java/isac/session/CompodDummy.java Wed Feb 11 16:19:39 2009 +0100
3.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
3.3 @@ -1,357 +0,0 @@
3.4 -/*********************************************************************
3.5 - * This file is part of the Compod project
3.6 - * Contact: Alexander Nussbaumer (AN, alnuss)
3.7 - * <alexander.nussbaumer@uni-graz.at>, <alnuss@gmx.net>
3.8 - *
3.9 - * modified: AN, 20070916
3.10 - *********************************************************************/
3.11 -
3.12 -package isac.session;
3.13 -
3.14 -
3.15 -/**
3.16 - * This is a dummy implementation of the ICompod interface.
3.17 - * In contrast to a "real" implemenatin, this class does not
3.18 - * connect the Compod services.
3.19 - *
3.20 - * @author Alexander Nussbaumer (AN)
3.21 - */
3.22 -public class CompodDummy implements ICompod
3.23 -{
3.24 - // --- fields ---
3.25 -
3.26 - /**
3.27 - * The lmsid. this is not needed in the dummy, however, the dummy
3.28 - * simulates a 'real' compod interface, so it is neccessary to insist
3.29 - * of it's usage (exception if not set).
3.30 - */
3.31 - private String lmsid_ = null;
3.32 -
3.33 - /**
3.34 - * isac objects. real object IDs, but only a few in the dummy.
3.35 - */
3.36 - private String[] objects_ =
3.37 - { "exp_IsacCore_Tests_1a.xml", "exp_IsacCore_Tests_1b.xml", "exp_IsacCore_Tests_1c.xml" };
3.38 -
3.39 - /**
3.40 - * Index of the object which will be the next to be shown to the user.
3.41 - * If session is not active, than index is -1.
3.42 - */
3.43 - private int objectindex_ = -1;
3.44 -
3.45 - /**
3.46 - * Keeps inforamtion which type of session is currently running:
3.47 - * "assessment" or "course", or null if no session is active.
3.48 - * Maybe enum would be better than string.
3.49 - */
3.50 - private String sessiontype_ = null;
3.51 -
3.52 - /**
3.53 - * Keeps information about the session state.
3.54 - */
3.55 - private SessionState sessionstate_ = null;
3.56 -
3.57 - /**
3.58 - * Keeps availability information about knowledge and competence state.
3.59 - */
3.60 - private KnowledgeStateQuality knowledgestatequality_ = null;
3.61 -
3.62 -
3.63 - // --- constructor ---
3.64 -
3.65 - /**
3.66 - * Constructor: initialisation
3.67 - */
3.68 - public CompodDummy ()
3.69 - {
3.70 - // initialisation
3.71 -
3.72 - // no session at the beginning
3.73 - sessionstate_ = SessionState.INACTIVE;
3.74 -
3.75 - // empty set at beginning, empty set is also a possible knowledge state
3.76 - knowledgestatequality_ = KnowledgeStateQuality.AVAILABLE;
3.77 - }
3.78 -
3.79 - /**
3.80 - * @see ICompod#setLMSID(java.lang.String)
3.81 - */
3.82 - public void setLMSID(String lmsid) throws Exception
3.83 - {
3.84 - lmsid_ = lmsid;
3.85 - }
3.86 -
3.87 - /**
3.88 - * @see isac.session.ICompod#setScopeByTopic(java.lang.String, java.lang.String)
3.89 - */
3.90 - public void setScopeByTopic (String username, String topic) throws Exception
3.91 - {
3.92 - if (lmsid_ == null)
3.93 - throw new Exception ("lmsid is not set");
3.94 -
3.95 - // not used in dummy
3.96 - }
3.97 -
3.98 - /**
3.99 - * @see ICompod#startSession(java.lang.String, java.lang.String)
3.100 - */
3.101 - public boolean startSession(String username, String sessiontype) throws Exception
3.102 - {
3.103 - if (lmsid_ == null)
3.104 - throw new Exception ("lmsid is not set");
3.105 -
3.106 - // user is ignored in this dummy
3.107 -
3.108 - // if a session is already running then return
3.109 - if (sessionstate_ == SessionState.ACTIVE)
3.110 - return false;
3.111 -
3.112 - // activate and initialise session
3.113 - sessionstate_ = SessionState.ACTIVE;
3.114 - sessiontype_ = sessiontype;
3.115 - objectindex_ = 0;
3.116 - // during an assessment, the knowledge and competence state is not available
3.117 - if (sessiontype_ == "assessment")
3.118 - knowledgestatequality_ = KnowledgeStateQuality.UNAVAILABLE;
3.119 -
3.120 - return true;
3.121 - }
3.122 -
3.123 - /**
3.124 - * @see ICompod#stopSession(java.lang.String, boolean)
3.125 - */
3.126 - public boolean stopSession(String username, boolean cancel) throws Exception
3.127 - {
3.128 - if (lmsid_ == null)
3.129 - throw new Exception ("lmsid is not set");
3.130 -
3.131 - // user and cancel type is ignored in this dummy
3.132 -
3.133 - // if a session is not running then return
3.134 - if (sessionstate_ == SessionState.INACTIVE)
3.135 - return false;
3.136 -
3.137 - // stop session
3.138 - sessionstate_ = SessionState.INACTIVE;
3.139 - knowledgestatequality_ = KnowledgeStateQuality.PRELIMINARY;
3.140 - objectindex_ = -1;
3.141 -
3.142 - return true;
3.143 - }
3.144 -
3.145 -
3.146 - /**
3.147 - * @see ICompod#getSessionStatus(java.lang.String)
3.148 - */
3.149 - public SessionState getSessionState(String username) throws Exception
3.150 - {
3.151 - if (lmsid_ == null)
3.152 - throw new Exception ("lmsid is not set");
3.153 -
3.154 - return sessionstate_;
3.155 - }
3.156 -
3.157 -
3.158 - /**
3.159 - * @see ICompod#getNextObjects(java.lang.String)
3.160 - */
3.161 - public String[] getNextObjects(String username) throws Exception
3.162 - {
3.163 - if (lmsid_ == null)
3.164 - throw new Exception ("lmsid is not set");
3.165 -
3.166 - // return if no session is active
3.167 - if (sessionstate_ == SessionState.INACTIVE)
3.168 - return null;
3.169 -
3.170 - // system invariant: this case should not happen
3.171 - int objectnumber = objects_.length;
3.172 - if (objectindex_ < 0 || objectindex_ >= objectnumber)
3.173 - return null;
3.174 -
3.175 - // return next objects
3.176 - String[] nextobjects = new String[1];
3.177 - nextobjects[0] = objects_[objectindex_];
3.178 -
3.179 - // different behaviour if a course is conducted
3.180 - // in contrast to the assessment, there is no separate update,
3.181 - // therefore the update has to be done here.
3.182 - if (sessiontype_ == "course")
3.183 - {
3.184 - // update and prepare for getNextObjects
3.185 - objectindex_++;
3.186 -
3.187 - // stop if no more objects are available
3.188 - if (objectindex_ >= objectnumber)
3.189 - {
3.190 - sessionstate_ = SessionState.INACTIVE;
3.191 - objectindex_ = -1;
3.192 - }
3.193 - }
3.194 - return nextobjects;
3.195 - }
3.196 -
3.197 - /**
3.198 - * @see ICompod#notifyObjectResult(java.lang.String, java.lang.String, boolean)
3.199 - */
3.200 - public void notifyObjectResult(String username, String objectid,
3.201 - boolean solved) throws Exception
3.202 - {
3.203 - if (lmsid_ == null)
3.204 - throw new Exception ("lmsid is not set");
3.205 -
3.206 - // TODO write data in a file (or on the console)
3.207 -
3.208 - // update and prepare for getNextObjects
3.209 - // WN090111 objectindex_++; only in getNextObjects
3.210 -
3.211 - // stop if no more objects are available
3.212 - int objectnumber = objects_.length;
3.213 - if (objectindex_ >= objectnumber)
3.214 - {
3.215 - sessionstate_ = SessionState.INACTIVE;
3.216 - knowledgestatequality_ = KnowledgeStateQuality.AVAILABLE;
3.217 - objectindex_ = -1;
3.218 - }
3.219 - }
3.220 -
3.221 - /**
3.222 - * @see ICompod#notifyObjectMicroResult(java.lang.String, java.lang.String, java.lang.String, java.lang.String, boolean)
3.223 - */
3.224 - public void notifyObjectMicroResult(String username, String objectid,
3.225 - String skillid, String masterylevel, boolean solved) throws Exception
3.226 - {
3.227 - if (lmsid_ == null)
3.228 - throw new Exception ("lmsid is not set");
3.229 -
3.230 - // TODO write data in a file (or on the console)
3.231 - }
3.232 -
3.233 -
3.234 - /**
3.235 - * @see ICompod#getKnowledgeStateQuality(java.lang.String)
3.236 - */
3.237 - public KnowledgeStateQuality getKnowledgeStateQuality(String username) throws Exception
3.238 - {
3.239 - if (lmsid_ == null)
3.240 - throw new Exception ("lmsid is not set");
3.241 -
3.242 - return knowledgestatequality_;
3.243 - }
3.244 -
3.245 - /**
3.246 - * @see ICompod#getKnowledgeState(java.lang.String)
3.247 - */
3.248 - public String[] getKnowledgeState(String username) throws Exception
3.249 - {
3.250 - if (lmsid_ == null)
3.251 - throw new Exception ("lmsid is not set");
3.252 -
3.253 - String[] knowledgestate = null;
3.254 - if (knowledgestatequality_ != KnowledgeStateQuality.UNAVAILABLE)
3.255 - knowledgestate = new String[0];
3.256 -
3.257 - return knowledgestate;
3.258 - }
3.259 -
3.260 - /**
3.261 - * @see ICompod#getCompetenceState(java.lang.String)
3.262 - */
3.263 - public String[] getCompetenceState(String username) throws Exception
3.264 - {
3.265 - if (lmsid_ == null)
3.266 - throw new Exception ("lmsid is not set");
3.267 -
3.268 - String[] competencestate = null;
3.269 - if (knowledgestatequality_ != KnowledgeStateQuality.UNAVAILABLE)
3.270 - competencestate = new String[0];
3.271 -
3.272 - return competencestate;
3.273 - }
3.274 -
3.275 -
3.276 -
3.277 - /**
3.278 - * This main method is used for
3.279 - * 1) testing the dummy implementation and
3.280 - * 2) demonstrating the usage of the ICompod interface.
3.281 - * This could also be placed in an external class.
3.282 - *
3.283 - * @param args
3.284 - * (Command line arguments) not used
3.285 - */
3.286 - public static void main (String[] args)
3.287 - {
3.288 - CompodDummy compod = new CompodDummy ();
3.289 -
3.290 - System.out.print("Compod Dummy.\n");
3.291 -
3.292 - // initialisation
3.293 - String lmsid = "isac-beta-xxx";
3.294 - String username = "some wired user";
3.295 -
3.296 - try
3.297 - {
3.298 - compod.setLMSID (lmsid);
3.299 - }
3.300 - catch (Exception e)
3.301 - {
3.302 - e.printStackTrace();
3.303 - return; // stop
3.304 - }
3.305 -
3.306 - // assessment
3.307 - try
3.308 - {
3.309 - System.out.print("- Assessment.\n");
3.310 - compod.startSession (username, "assessment");
3.311 - while (compod.getSessionState (username) == SessionState.ACTIVE)
3.312 - {
3.313 - String[] nextobjects = compod.getNextObjects (username);
3.314 -
3.315 - // output
3.316 - for (int i = 0; i < nextobjects.length; i++)
3.317 - System.out.print (nextobjects[i]);
3.318 - System.out.println ("");
3.319 -
3.320 - compod.notifyObjectResult(username, nextobjects[0], true);
3.321 - }
3.322 - }
3.323 - catch (Exception e)
3.324 - {
3.325 - e.printStackTrace();
3.326 - }
3.327 -
3.328 - // course
3.329 - try
3.330 - {
3.331 - System.out.print("- Course.\n");
3.332 - compod.startSession (username, "course");
3.333 - while (compod.getSessionState (username) == SessionState.ACTIVE)
3.334 - {
3.335 - String[] nextobjects = compod.getNextObjects (username);
3.336 -
3.337 - // output
3.338 - for (int i = 0; i < nextobjects.length; i++)
3.339 - System.out.print (nextobjects[i]);
3.340 - System.out.println ("");
3.341 - }
3.342 - }
3.343 - catch (Exception e)
3.344 - {
3.345 - e.printStackTrace();
3.346 - }
3.347 -
3.348 -
3.349 - }
3.350 -
3.351 -
3.352 -
3.353 -
3.354 -
3.355 -
3.356 -
3.357 -
3.358 -
3.359 -
3.360 -}
4.1 --- a/src/java/isac/session/ObjectManager.java Wed Feb 11 16:19:39 2009 +0100
4.2 +++ b/src/java/isac/session/ObjectManager.java Fri Feb 13 12:14:56 2009 +0100
4.3 @@ -30,134 +30,132 @@
4.4 *
4.5 */
4.6 public class ObjectManager extends UnicastRemoteObject implements
4.7 - IObjectManager {
4.8 + IObjectManager {
4.9
4.10 - private static final Logger logger = Logger.getLogger(ObjectManager.class.getName());
4.11 + private static final Logger logger = Logger.getLogger(ObjectManager.class
4.12 + .getName());
4.13
4.14 - static final long serialVersionUID = -7823336348890642600L;
4.15 + static final long serialVersionUID = -7823336348890642600L;
4.16
4.17 - SessionManager sdialog_ = SessionManager.getInstance();
4.18 -
4.19 - UserManager user_manager_ = UserManager.getInstance();
4.20 -
4.21 - WatchdogThread watchdog_;
4.22 + SessionManager sdialog_ = SessionManager.getInstance();
4.23
4.24 - /**
4.25 - * fetch the UserManager of the system - multiple calls to this method
4.26 - * result in one and the same UserManager.
4.27 - */
4.28 - public IUserManager getUserManager() throws RemoteException {
4.29 - if (user_manager_ == null)
4.30 - user_manager_ = UserManager.getInstance();
4.31 - return user_manager_;
4.32 - }
4.33 + UserManager user_manager_ = UserManager.getInstance();
4.34
4.35 - /**
4.36 - * instantiates the Objectmanager which is used to simulate a function of
4.37 - * dinopolis The ObjectManager provides functions to fetch objects which are
4.38 - * used by other modules of the system using RMI
4.39 - *
4.40 - * @throws RemoteException
4.41 - */
4.42 - protected ObjectManager() throws RemoteException {
4.43 - super();
4.44 - rmiBind();
4.45 - //RK for RMI-problems 07htl: watchdog_ = new WatchdogThread();
4.46 - // watchdog_.start();
4.47 - }
4.48 + WatchdogThread watchdog_;
4.49
4.50 - /**
4.51 - * fetch the XBrowserDialog identified by <code>session</code>
4.52 - */
4.53 - public IBrowserDialog getBrowserDialog(String session) throws RemoteException {
4.54 - return (IBrowserDialog) sdialog_.getSessionByID(session).getExampleDialog();
4.55 - }
4.56 + /**
4.57 + * fetch the UserManager of the system - multiple calls to this method
4.58 + * result in one and the same UserManager.
4.59 + */
4.60 + public IUserManager getUserManager() throws RemoteException {
4.61 + if (user_manager_ == null)
4.62 + user_manager_ = UserManager.getInstance();
4.63 + return user_manager_;
4.64 + }
4.65
4.66 -
4.67 + /**
4.68 + * instantiates the Objectmanager which is used to simulate a function of
4.69 + * dinopolis The ObjectManager provides functions to fetch objects which are
4.70 + * used by other modules of the system using RMI
4.71 + *
4.72 + * @throws RemoteException
4.73 + */
4.74 + protected ObjectManager() throws RemoteException {
4.75 + super();
4.76 + rmiBind();
4.77 + // RK for RMI-problems 07htl: watchdog_ = new WatchdogThread();
4.78 + // watchdog_.start();
4.79 + }
4.80
4.81 - /**
4.82 - * fetch the WorksheetDialog identified by <code>wdialog_id</code>
4.83 - */
4.84 - /*
4.85 - public IWorksheetDialog getWorksheetDialog(String wdialog_id)
4.86 - throws RemoteException {
4.87 - return (IWorksheetDialog) sdialog_.getWorksheetDialog(wdialog_id);
4.88 - }*/
4.89 + /**
4.90 + * fetch the XBrowserDialog identified by <code>session</code>
4.91 + */
4.92 + public IBrowserDialog getBrowserDialog(String session)
4.93 + throws RemoteException {
4.94 + return (IBrowserDialog) sdialog_.getSessionByID(session)
4.95 + .getExampleDialog();
4.96 + }
4.97
4.98 - /**
4.99 - * fetch the XSessionManager of the system - multiple calls to this method
4.100 - * result in one and the same XSessionManager.
4.101 - */
4.102 - public ISessionManager getSessionDialog() throws RemoteException {
4.103 - if (sdialog_ == null)
4.104 - sdialog_ = SessionManager.getInstance();
4.105 - return sdialog_;
4.106 - }
4.107 + /**
4.108 + * fetch the WorksheetDialog identified by <code>wdialog_id</code>
4.109 + */
4.110 + /*
4.111 + * public IWorksheetDialog getWorksheetDialog(String wdialog_id) throws
4.112 + * RemoteException { return (IWorksheetDialog)
4.113 + * sdialog_.getWorksheetDialog(wdialog_id); }
4.114 + */
4.115
4.116 - /*
4.117 - * instantiates the ObjectManager and registers it on the RMIRegistry on the
4.118 - * local machine as //localhost/isac-ObjectManager . If no RMIRegistry is
4.119 - * running, a new one is started.
4.120 - */
4.121 - public static void main(String[] args) {
4.122 - try {
4.123 - String ini_load_result = ObjectManagerPaths.loadFromFile(args[0]);
4.124 -
4.125 - if (ini_load_result != null)
4.126 - ini_load_result += ObjectManagerPaths.loadFromResource(args[0]);
4.127 -
4.128 - if (ini_load_result != null)
4.129 - {
4.130 - System.err.println(ini_load_result);
4.131 - System.exit(1);
4.132 - }
4.133 -
4.134 -
4.135 - try
4.136 - {
4.137 - // Use ObjectManagerRMISocketFactory 0704
4.138 - RMISocketFactory.setSocketFactory( new FixedPortRMISocketFactory(ObjectManagerPaths.OBJECT_MANAGER_RMI_PORT));
4.139 - //new ObjectManagerRMISocketFactory(3113,ObjectManagerPaths.OBJECT_MANAGER_RMI_PORT));
4.140 - }
4.141 - catch (IOException e)
4.142 - {
4.143 - System.out.println("Exception: " + e.getMessage());
4.144 - e.printStackTrace();
4.145 - }
4.146 -
4.147 -
4.148 - System.out.println(new ObjectManager());
4.149 + /**
4.150 + * fetch the XSessionManager of the system - multiple calls to this method
4.151 + * result in one and the same XSessionManager.
4.152 + */
4.153 + public ISessionManager getSessionDialog() throws RemoteException {
4.154 + if (sdialog_ == null)
4.155 + sdialog_ = SessionManager.getInstance();
4.156 + return sdialog_;
4.157 + }
4.158
4.159 - } catch (RemoteException e) {
4.160 - e.printStackTrace();
4.161 - }
4.162 - }
4.163 + /*
4.164 + * instantiates the ObjectManager and registers it on the RMIRegistry on the
4.165 + * local machine as //localhost/isac-ObjectManager . If no RMIRegistry is
4.166 + * running, a new one is started.
4.167 + */
4.168 + public static void main(String[] args) {
4.169 + try {
4.170 + String ini_load_result = ObjectManagerPaths.loadFromFile(args[0]);
4.171
4.172 - private void rmiBind() {
4.173 - if (System.getSecurityManager() == null) {
4.174 - System.setSecurityManager(new RMISecurityManager());
4.175 - }
4.176 -
4.177 - String name = ObjectManagerPaths.OBJECT_MANAGER_PATH;
4.178 - try {
4.179 - System.out.println("try to bind as " + name);
4.180 - Naming.rebind(name, this);
4.181 - System.out.println("Object Manager bound to " + name);
4.182 - } catch (java.rmi.ConnectException e) {
4.183 - System.err.println("failed to contact as " + name
4.184 - + " (creating RMI-Server on localhost:1099)");
4.185 - try {
4.186 - LocateRegistry
4.187 - .createRegistry(ObjectManagerPaths.OBJECT_MANAGER_PORT);
4.188 - rmiBind();
4.189 - } catch (java.rmi.RemoteException exc2) {
4.190 - System.err.println("can not create registry:"
4.191 - + exc2.getMessage());
4.192 - }
4.193 - } catch (Exception exc) {
4.194 - System.err.println("failed to connect to rmiregistry");
4.195 - System.err.println(exc);
4.196 - }
4.197 - }
4.198 + if (ini_load_result != null)
4.199 + ini_load_result += ObjectManagerPaths.loadFromResource(args[0]);
4.200 +
4.201 + if (ini_load_result != null) {
4.202 + System.err.println(ini_load_result);
4.203 + System.exit(1);
4.204 + }
4.205 +
4.206 + try {
4.207 + // Use ObjectManagerRMISocketFactory 0704
4.208 + RMISocketFactory
4.209 + .setSocketFactory(new FixedPortRMISocketFactory(
4.210 + ObjectManagerPaths.OBJECT_MANAGER_RMI_PORT));
4.211 + // new
4.212 + // ObjectManagerRMISocketFactory(3113,ObjectManagerPaths.OBJECT_MANAGER_RMI_PORT));
4.213 + } catch (IOException e) {
4.214 + System.out.println("Exception: " + e.getMessage());
4.215 + e.printStackTrace();
4.216 + }
4.217 +
4.218 + System.out.println(new ObjectManager());
4.219 +
4.220 + } catch (RemoteException e) {
4.221 + e.printStackTrace();
4.222 + }
4.223 + }
4.224 +
4.225 + private void rmiBind() {
4.226 + if (System.getSecurityManager() == null) {
4.227 + System.setSecurityManager(new RMISecurityManager());
4.228 + }
4.229 +
4.230 + String name = ObjectManagerPaths.OBJECT_MANAGER_PATH;
4.231 + try {
4.232 + System.out.println("try to bind as " + name);
4.233 + Naming.rebind(name, this);
4.234 + System.out.println("Object Manager bound to " + name);
4.235 + } catch (java.rmi.ConnectException e) {
4.236 + System.err.println("failed to contact as " + name
4.237 + + " (creating RMI-Server on localhost:1099)");
4.238 + try {
4.239 + LocateRegistry
4.240 + .createRegistry(ObjectManagerPaths.OBJECT_MANAGER_PORT);
4.241 + rmiBind();
4.242 + } catch (java.rmi.RemoteException exc2) {
4.243 + System.err.println("can not create registry:"
4.244 + + exc2.getMessage());
4.245 + }
4.246 + } catch (Exception exc) {
4.247 + System.err.println("failed to connect to rmiregistry");
4.248 + System.err.println(exc);
4.249 + }
4.250 + }
4.251
4.252 }
4.253 \ No newline at end of file
5.1 --- a/src/java/isac/session/SessionManager.java Wed Feb 11 16:19:39 2009 +0100
5.2 +++ b/src/java/isac/session/SessionManager.java Fri Feb 13 12:14:56 2009 +0100
5.3 @@ -12,8 +12,11 @@
5.4 import isac.users.User;
5.5 import isac.users.UserLogger;
5.6 import isac.users.UserManager;
5.7 +import isac.util.ObjectManagerPaths;
5.8
5.9 import java.io.Serializable;
5.10 +import java.net.MalformedURLException;
5.11 +import java.net.URL;
5.12 import java.rmi.RemoteException;
5.13 import java.rmi.server.UnicastRemoteObject;
5.14 import java.util.HashMap;
5.15 @@ -46,7 +49,7 @@
5.16 private HashMap<String, Session> sessionid_map_session_;
5.17
5.18 private HashMap<String, String> sessionid_map_username_;
5.19 -
5.20 +
5.21 public ICompod compod_;
5.22
5.23 /**
5.24 @@ -61,7 +64,7 @@
5.25 sessionid_map_session_ = new HashMap<String, Session>();
5.26 sessionid_map_username_ = new HashMap<String, String>();
5.27 next_id_ = 0;
5.28 - compod_ = new CompodDummy();
5.29 + compod_ = new CompodDriver();
5.30 try {
5.31 compod_.setLMSID("isac");
5.32 } catch (Exception e) {
6.1 --- a/src/java/isac/users/UserLogger.java Wed Feb 11 16:19:39 2009 +0100
6.2 +++ b/src/java/isac/users/UserLogger.java Fri Feb 13 12:14:56 2009 +0100
6.3 @@ -250,7 +250,11 @@
6.4 0.0));// TODO use SuccessInfo not 0.0
6.5 currentStepToDatabase();
6.6 current_step_.reset();
6.7 - this.exp_dialog_.notifySomeExampleFinished((session_.getExampleId(worksheet_id)).toString(), new Float(0.0));
6.8 + // WN090112 (only!) for last Compod-exp from here no way to code of
6.9 + // notifySomeExampleFinished -- checked with breakpoint, see
6.10 + // java(325)
6.11 + this.exp_dialog_.notifySomeExampleFinished((session_
6.12 + .getExampleId(worksheet_id)).toString(), new Float(0.0));
6.13 }
6.14 current_step_.setAction(user_.getUsername(), session_id_, "worksheet",
6.15 isac.useractions.EUIElement.UI_CLOSE_WORKSHEET, null, null);
6.16 @@ -317,7 +321,11 @@
6.17 current_step_.setResult(worksheet_id, null, null, null, new Float(
6.18 1.0));// TODO use SuccessInfo not 1.0
6.19 currentStepToDatabase();
6.20 - this.exp_dialog_.notifySomeExampleFinished((session_.getExampleId(worksheet_id)).toString(), new Float(1.0));
6.21 + // WN090112 (only!) for last Compod-exp from here no way to code of
6.22 + // notifySomeExampleFinished -- checked with breakpoint, see
6.23 + // java(325)
6.24 + this.exp_dialog_.notifySomeExampleFinished((session_
6.25 + .getExampleId(worksheet_id)).toString(), new Float(1.0));
6.26 }
6.27 }
6.28
7.1 --- a/src/java/isac/util/ObjectManagerPaths.java Wed Feb 11 16:19:39 2009 +0100
7.2 +++ b/src/java/isac/util/ObjectManagerPaths.java Fri Feb 13 12:14:56 2009 +0100
7.3 @@ -6,203 +6,209 @@
7.4 import java.io.InputStream;
7.5 import java.util.Properties;
7.6
7.7 -
7.8 /**
7.9 * paths for setup of the ObjectManager; for RMI and for data.
7.10 *
7.11 * @author Manuel Koschuch (c) Manuel Koschuch 2006
7.12 */
7.13 public class ObjectManagerPaths {
7.14 -
7.15 +
7.16 static {
7.17 - loadFromResource("/properties/ObjectManager.properties");
7.18 + loadFromResource("/properties/ObjectManager.properties");
7.19 }
7.20
7.21 - /**
7.22 - * RMI to mathengine (handled through several constructors)
7.23 - */
7.24 - public static String MATH_ENGINE_PATH;
7.25 + /**
7.26 + * RMI to mathengine (handled through several constructors)
7.27 + */
7.28 + public static String MATH_ENGINE_PATH;
7.29
7.30 - // localhost
7.31 + // localhost
7.32
7.33 - /**
7.34 - * RMI to the ObjectManager
7.35 - */
7.36 - public static String OBJECT_MANAGER_PATH;
7.37 + /**
7.38 + * RMI to the ObjectManager
7.39 + */
7.40 + public static String OBJECT_MANAGER_PATH;
7.41
7.42 - // "//localhost/isac-ObjectManager"
7.43 + // "//localhost/isac-ObjectManager"
7.44
7.45 - /**
7.46 - * port to the RMI registry
7.47 - */
7.48 - public static int OBJECT_MANAGER_PORT;
7.49 -
7.50 -
7.51 - /**
7.52 - * port to the RMI object manager object
7.53 - */
7.54 - public static int OBJECT_MANAGER_RMI_PORT;
7.55 + /**
7.56 + * port to the RMI registry
7.57 + */
7.58 + public static int OBJECT_MANAGER_PORT;
7.59
7.60 - // 1099
7.61 + /**
7.62 + * port to the RMI object manager object
7.63 + */
7.64 + public static int OBJECT_MANAGER_RMI_PORT;
7.65
7.66 - /**
7.67 - * path to the user data
7.68 - */
7.69 - public static String SESSION_MANAGER_USER_PATH;
7.70 + // 1099
7.71
7.72 - // "..../isac/xmldata/users/"
7.73 + /**
7.74 + * path to the user data
7.75 + */
7.76 + public static String SESSION_MANAGER_USER_PATH;
7.77
7.78 - /**
7.79 - * RMI to the XBrowserDialog
7.80 - */
7.81 - public static String BD_DIALOG_PATH;
7.82 + // "..../isac/xmldata/users/"
7.83
7.84 - // "http://localhost:1050"
7.85 + /**
7.86 + * RMI to the XBrowserDialog
7.87 + */
7.88 + public static String BD_DIALOG_PATH;
7.89
7.90 - /**
7.91 - * RMI to the WorksheetDialog
7.92 - */
7.93 - public static String WORKSHEET_DIALOG_PATH;
7.94 + // "http://localhost:1050"
7.95
7.96 - // "//localhost/isac-WorksheetDialog"
7.97 + /**
7.98 + * RMI to the WorksheetDialog
7.99 + */
7.100 + public static String WORKSHEET_DIALOG_PATH;
7.101
7.102 - /**
7.103 - * RMI to KEStore
7.104 - */
7.105 - public static String KESTORE_PATH;
7.106 - // "http://localhost:1030"
7.107 -
7.108 - /**
7.109 - * Root directory of html files for the XMiniBrowser
7.110 - */
7.111 - public static String WEB_PATH;
7.112 - // "http://www.ist.tugraz.at/projects/isac/www/kbase-new/"
7.113 -
7.114 - public static boolean LOGGER_DATABASE_ENABLED;
7.115 + // "//localhost/isac-WorksheetDialog"
7.116
7.117 - public static String LOGGER_DATABASE_PATH;
7.118 + /**
7.119 + * RMI to KEStore
7.120 + */
7.121 + public static String KESTORE_PATH;
7.122
7.123 - public static String LOGGER_DATABASE_PORT;
7.124 + // "http://localhost:1030"
7.125
7.126 - public static String LOGGER_DATABASE_NAME;
7.127 + /**
7.128 + * Root directory of html files for the XMiniBrowser
7.129 + */
7.130 + public static String WEB_PATH;
7.131
7.132 - public static String LOGGER_DATABASE_USER;
7.133 + // "http://www.ist.tugraz.at/projects/isac/www/kbase-new/"
7.134
7.135 - public static String LOGGER_DATABASE_PASSWORD;
7.136 -
7.137 - public static String loadFromResource(String resname)
7.138 - {
7.139 - InputStream is = ObjectManagerPaths.class.getResourceAsStream(resname);
7.140 -
7.141 - if (is == null)
7.142 - return "ObjectManager: Initialisation file not found";
7.143 -
7.144 - return loadFromStream(is);
7.145 - }
7.146 -
7.147 - public static String loadFromFile(String filename)
7.148 - {
7.149 - FileInputStream fis = null;
7.150 -
7.151 - try
7.152 - {
7.153 - fis = new FileInputStream(filename);
7.154 - }
7.155 - catch( FileNotFoundException fnfex )
7.156 - {
7.157 - System.out.println(fnfex.getMessage());
7.158 - return "\nObjectManager: Initialisation file not found in resources";
7.159 - }
7.160 -
7.161 - return loadFromStream(fis);
7.162 - }
7.163 -
7.164 - private static String loadFromStream(InputStream is)
7.165 - {
7.166 - Properties p = new Properties();
7.167 -
7.168 - try
7.169 - {
7.170 - p.load(is);
7.171 - }
7.172 - catch( IOException ioex)
7.173 - {
7.174 - System.out.println(ioex.getMessage());
7.175 - return "ObjectManager: Initialisation file is not a Property file";
7.176 - }
7.177 -
7.178 - if ((MATH_ENGINE_PATH = p.getProperty("MATH_ENGINE_PATH")) == null)
7.179 - return "ObjectManager: MATH_ENGINE_PATH is required parameter";
7.180 -
7.181 - if ((OBJECT_MANAGER_PATH = p.getProperty("OBJECT_MANAGER_PATH")) == null)
7.182 - return "ObjectManager: OBJECT_MANAGER_PATH is required parameter";
7.183 -
7.184 - if (p.getProperty("OBJECT_MANAGER_PORT") == null)
7.185 - return "ObjectManager: OBJECT_MANAGER_PORT is required parameter";
7.186 -
7.187 - if (p.getProperty("OBJECT_MANAGER_RMI_PORT") == null)
7.188 - return "ObjectManager: OBJECT_MANAGER_RMI_PORT is required parameter";
7.189 -
7.190 -
7.191 - try
7.192 - {
7.193 - OBJECT_MANAGER_RMI_PORT = Integer.parseInt(p.getProperty("OBJECT_MANAGER_RMI_PORT"));
7.194 - }
7.195 - catch(NumberFormatException nfe)
7.196 - {
7.197 - System.out.println(nfe.getMessage());
7.198 - return "ObjectManager: OBJECT_MANAGER_RMI_PORT is not a number";
7.199 - }
7.200 -
7.201 - try
7.202 - {
7.203 - OBJECT_MANAGER_PORT = Integer.parseInt(p.getProperty("OBJECT_MANAGER_PORT"));
7.204 - }
7.205 - catch(NumberFormatException nfe)
7.206 - {
7.207 - System.out.println(nfe.getMessage());
7.208 - return "ObjectManager: OBJECT_MANAGER_PORT is not a number";
7.209 - }
7.210 -
7.211 - if ((SESSION_MANAGER_USER_PATH = p.getProperty("SESSION_MANAGER_USER_PATH")) == null)
7.212 - return "ObjectManager: SESSION_MANAGER_USER_PATH is required parameter";
7.213 -
7.214 - if ((BD_DIALOG_PATH = p.getProperty("BD_DIALOG_PATH")) == null)
7.215 - return "ObjectManager: BD_DIALOG_PATH is required parameter";
7.216 -
7.217 - if ((WORKSHEET_DIALOG_PATH = p.getProperty("WORKSHEET_DIALOG_PATH")) == null)
7.218 - return "ObjectManager: WORKSHEET_DIALOG_PATH is required parameter";
7.219 -
7.220 - if ((KESTORE_PATH = p.getProperty("KESTORE_PATH")) == null)
7.221 - return "ObjectManager: KESTORE_PATH is required parameter";
7.222 -
7.223 - if ((WEB_PATH = p.getProperty("WEB_PATH")) == null)
7.224 - return "ObjectManager: WEB_PATH is required parameter";
7.225 -
7.226 - if (p.getProperty("LOGGER_DATABASE_ENABLED") == null) {
7.227 - return "ObjectManager: LOGGER_DATABASE_ENABLED is required parameter";
7.228 - } else {
7.229 - LOGGER_DATABASE_ENABLED = Boolean.parseBoolean(p
7.230 - .getProperty("LOGGER_DATABASE_ENABLED"));
7.231 - }
7.232 + /** the UserLogger might write each dialog atom to an sql database */
7.233 + public static boolean LOGGER_DATABASE_ENABLED;
7.234
7.235 - if ((LOGGER_DATABASE_PATH = p.getProperty("LOGGER_DATABASE_PATH")) == null)
7.236 - return "ObjectManager: LOGGER_DATABASE_PATH is required parameter";
7.237 + public static String LOGGER_DATABASE_PATH;
7.238
7.239 - if ((LOGGER_DATABASE_PORT = p.getProperty("LOGGER_DATABASE_PORT")) == null)
7.240 - return "ObjectManager: LOGGER_DATABASE_PORT is required parameter";
7.241 + public static String LOGGER_DATABASE_PORT;
7.242
7.243 - if ((LOGGER_DATABASE_NAME = p.getProperty("LOGGER_DATABASE_NAME")) == null)
7.244 - return "ObjectManager: LOGGER_DATABASE_NAME is required parameter";
7.245 + public static String LOGGER_DATABASE_NAME;
7.246
7.247 - if ((LOGGER_DATABASE_USER = p.getProperty("LOGGER_DATABASE_USER")) == null)
7.248 - return "ObjectManager: LOGGER_DATABASE_USER is required parameter";
7.249 + public static String LOGGER_DATABASE_USER;
7.250
7.251 - if ((LOGGER_DATABASE_PASSWORD = p
7.252 - .getProperty("LOGGER_DATABASE_PASSWORD")) == null)
7.253 - return "ObjectManager: LOGGER_DATABASE_PASSWORD is required parameter";
7.254 -
7.255 - return null;
7.256 - }
7.257 + public static String LOGGER_DATABASE_PASSWORD;
7.258 +
7.259 + /** Compod is an optional tool about knowledge space theory */
7.260 + public static boolean COMPOD_ENABLED;
7.261 +
7.262 + public static String COMPOD_PATH;
7.263 +
7.264 + public static String loadFromResource(String resname) {
7.265 + InputStream is = ObjectManagerPaths.class.getResourceAsStream(resname);
7.266 +
7.267 + if (is == null)
7.268 + return "ObjectManager: Initialisation file not found";
7.269 +
7.270 + return loadFromStream(is);
7.271 + }
7.272 +
7.273 + public static String loadFromFile(String filename) {
7.274 + FileInputStream fis = null;
7.275 +
7.276 + try {
7.277 + fis = new FileInputStream(filename);
7.278 + } catch (FileNotFoundException fnfex) {
7.279 + System.out.println(fnfex.getMessage());
7.280 + return "\nObjectManager: Initialisation file not found in resources";
7.281 + }
7.282 +
7.283 + return loadFromStream(fis);
7.284 + }
7.285 +
7.286 + private static String loadFromStream(InputStream is) {
7.287 + Properties p = new Properties();
7.288 +
7.289 + try {
7.290 + p.load(is);
7.291 + } catch (IOException ioex) {
7.292 + System.out.println(ioex.getMessage());
7.293 + return "ObjectManager: Initialisation file is not a Property file";
7.294 + }
7.295 +
7.296 + if ((MATH_ENGINE_PATH = p.getProperty("MATH_ENGINE_PATH")) == null)
7.297 + return "ObjectManager: MATH_ENGINE_PATH is required parameter";
7.298 +
7.299 + if ((OBJECT_MANAGER_PATH = p.getProperty("OBJECT_MANAGER_PATH")) == null)
7.300 + return "ObjectManager: OBJECT_MANAGER_PATH is required parameter";
7.301 +
7.302 + if (p.getProperty("OBJECT_MANAGER_PORT") == null)
7.303 + return "ObjectManager: OBJECT_MANAGER_PORT is required parameter";
7.304 +
7.305 + if (p.getProperty("OBJECT_MANAGER_RMI_PORT") == null)
7.306 + return "ObjectManager: OBJECT_MANAGER_RMI_PORT is required parameter";
7.307 +
7.308 + try {
7.309 + OBJECT_MANAGER_RMI_PORT = Integer.parseInt(p
7.310 + .getProperty("OBJECT_MANAGER_RMI_PORT"));
7.311 + } catch (NumberFormatException nfe) {
7.312 + System.out.println(nfe.getMessage());
7.313 + return "ObjectManager: OBJECT_MANAGER_RMI_PORT is not a number";
7.314 + }
7.315 +
7.316 + try {
7.317 + OBJECT_MANAGER_PORT = Integer.parseInt(p
7.318 + .getProperty("OBJECT_MANAGER_PORT"));
7.319 + } catch (NumberFormatException nfe) {
7.320 + System.out.println(nfe.getMessage());
7.321 + return "ObjectManager: OBJECT_MANAGER_PORT is not a number";
7.322 + }
7.323 +
7.324 + if ((SESSION_MANAGER_USER_PATH = p
7.325 + .getProperty("SESSION_MANAGER_USER_PATH")) == null)
7.326 + return "ObjectManager: SESSION_MANAGER_USER_PATH is required parameter";
7.327 +
7.328 + if ((BD_DIALOG_PATH = p.getProperty("BD_DIALOG_PATH")) == null)
7.329 + return "ObjectManager: BD_DIALOG_PATH is required parameter";
7.330 +
7.331 + if ((WORKSHEET_DIALOG_PATH = p.getProperty("WORKSHEET_DIALOG_PATH")) == null)
7.332 + return "ObjectManager: WORKSHEET_DIALOG_PATH is required parameter";
7.333 +
7.334 + if ((KESTORE_PATH = p.getProperty("KESTORE_PATH")) == null)
7.335 + return "ObjectManager: KESTORE_PATH is required parameter";
7.336 +
7.337 + if ((WEB_PATH = p.getProperty("WEB_PATH")) == null)
7.338 + return "ObjectManager: WEB_PATH is required parameter";
7.339 +
7.340 + // ----- set properties for UserLogger -----------------------------
7.341 + if (p.getProperty("LOGGER_DATABASE_ENABLED") == null) {
7.342 + return "ObjectManager: LOGGER_DATABASE_ENABLED is required parameter";
7.343 + } else {
7.344 + LOGGER_DATABASE_ENABLED = Boolean.parseBoolean(p
7.345 + .getProperty("LOGGER_DATABASE_ENABLED"));
7.346 + }
7.347 +
7.348 + if ((LOGGER_DATABASE_PATH = p.getProperty("LOGGER_DATABASE_PATH")) == null)
7.349 + return "ObjectManager: LOGGER_DATABASE_PATH is required parameter";
7.350 +
7.351 + if ((LOGGER_DATABASE_PORT = p.getProperty("LOGGER_DATABASE_PORT")) == null)
7.352 + return "ObjectManager: LOGGER_DATABASE_PORT is required parameter";
7.353 +
7.354 + if ((LOGGER_DATABASE_NAME = p.getProperty("LOGGER_DATABASE_NAME")) == null)
7.355 + return "ObjectManager: LOGGER_DATABASE_NAME is required parameter";
7.356 +
7.357 + if ((LOGGER_DATABASE_USER = p.getProperty("LOGGER_DATABASE_USER")) == null)
7.358 + return "ObjectManager: LOGGER_DATABASE_USER is required parameter";
7.359 +
7.360 + if ((LOGGER_DATABASE_PASSWORD = p
7.361 + .getProperty("LOGGER_DATABASE_PASSWORD")) == null)
7.362 + return "ObjectManager: LOGGER_DATABASE_PASSWORD is required parameter";
7.363 +
7.364 + // ----- set properties for Compod ---------------------------------
7.365 + if (p.getProperty("COMPOD_ENABLED") == null) {
7.366 + return "ObjectManager: COMPOD_ENABLED is required parameter";
7.367 + } else {
7.368 + COMPOD_ENABLED = Boolean.parseBoolean(p
7.369 + .getProperty("COMPOD_ENABLED"));
7.370 + }
7.371 +
7.372 + if ((COMPOD_PATH = p.getProperty("COMPOD_PATH")) == null)
7.373 + return "ObjectManager: COMPOD_PATH is required parameter";
7.374 +
7.375 +
7.376 + return null;
7.377 + }
7.378
7.379 }