Changeset 24978 for main/trunk
- Timestamp:
- 2012-01-26T10:39:17+13:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/Authentication.java
r17452 r24978 15 15 import java.io.UnsupportedEncodingException; 16 16 17 public class Authentication 18 extends ServiceRack{17 public class Authentication extends ServiceRack 18 { 19 19 //the services on offer 20 protected static final String AUTHENTICATION_SERVICE ="Authentication";20 protected static final String AUTHENTICATION_SERVICE = "Authentication"; 21 21 22 22 /** constructor */ 23 23 public Authentication() 24 { } 25 26 public boolean configure(Element info, Element extra_info) 24 { 25 } 26 27 public boolean configure(Element info, Element extra_info) 27 28 { 28 29 logger.info("Configuring Authentication..."); … … 30 31 31 32 // set up Authentication service info - for now just has name and type 32 Element authentication_service = this.doc.createElement(GSXML.SERVICE_ELEM);33 authentication_service.setAttribute(GSXML.TYPE_ATT, "authen"); 33 Element authentication_service = this.doc.createElement(GSXML.SERVICE_ELEM); 34 authentication_service.setAttribute(GSXML.TYPE_ATT, "authen"); 34 35 authentication_service.setAttribute(GSXML.NAME_ATT, AUTHENTICATION_SERVICE); 35 36 this.short_service_info.appendChild(authentication_service); … … 38 39 } 39 40 40 protected Element getServiceDescription(String service_id, String lang, String subset) 41 { 42 43 Element authen_service=this.doc.createElement(GSXML.SERVICE_ELEM); 44 45 if (service_id.equals(AUTHENTICATION_SERVICE)) { 46 authen_service.setAttribute(GSXML.TYPE_ATT,"authen"); 41 protected Element getServiceDescription(String service_id, String lang, String subset) 42 { 43 44 Element authen_service = this.doc.createElement(GSXML.SERVICE_ELEM); 45 46 if (service_id.equals(AUTHENTICATION_SERVICE)) 47 { 48 authen_service.setAttribute(GSXML.TYPE_ATT, "authen"); 47 49 authen_service.setAttribute(GSXML.NAME_ATT, AUTHENTICATION_SERVICE); 48 } else { 50 } 51 else 52 { 49 53 return null; 50 54 } 51 55 52 if (subset==null || subset.equals(GSXML.DISPLAY_TEXT_ELEM+GSXML.LIST_MODIFIER)) { 53 authen_service.appendChild(GSXML.createDisplayTextElement(this.doc, GSXML.DISPLAY_TEXT_NAME, getServiceName(service_id, lang) )); 56 if (subset == null || subset.equals(GSXML.DISPLAY_TEXT_ELEM + GSXML.LIST_MODIFIER)) 57 { 58 authen_service.appendChild(GSXML.createDisplayTextElement(this.doc, GSXML.DISPLAY_TEXT_NAME, getServiceName(service_id, lang))); 54 59 authen_service.appendChild(GSXML.createDisplayTextElement(this.doc, GSXML.DISPLAY_TEXT_DESCRIPTION, getServiceDescription(service_id, lang))); 55 60 } 56 return authen_service; 57 } 58 59 protected String getServiceName(String service_id, String lang) { 60 return getTextString(service_id+".name", lang); 61 } 62 63 protected String getServiceSubmit(String service_id, String lang) { 64 return getTextString(service_id+".submit", lang); 65 } 66 67 protected String getServiceDescription(String service_id, String lang) { 68 return getTextString(service_id+".description", lang); 69 } 70 71 protected void addCustomParams(String service, Element param_list, String lang) { 72 } 73 74 protected void createParameter(String name, Element param_list, String lang) { 75 } 76 77 protected Element processAuthentication(Element request) throws SQLException, UnsupportedEncodingException{ 61 return authen_service; 62 } 63 64 protected String getServiceName(String service_id, String lang) 65 { 66 return getTextString(service_id + ".name", lang); 67 } 68 69 protected String getServiceSubmit(String service_id, String lang) 70 { 71 return getTextString(service_id + ".submit", lang); 72 } 73 74 protected String getServiceDescription(String service_id, String lang) 75 { 76 return getTextString(service_id + ".description", lang); 77 } 78 79 protected void addCustomParams(String service, Element param_list, String lang) 80 { 81 } 82 83 protected void createParameter(String name, Element param_list, String lang) 84 { 85 } 86 87 protected Element processAuthentication(Element request) throws SQLException, UnsupportedEncodingException 88 { 78 89 79 90 // Create a new (empty) result message … … 85 96 String lang = request.getAttribute(GSXML.LANG_ATT); 86 97 // Get the parameters of the request 87 Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM+GSXML.LIST_MODIFIER); 88 89 if (param_list == null) { 98 Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER); 99 100 if (param_list == null) 101 { 90 102 logger.error("AddUsers request had no paramList."); 91 return result; 92 } 93 94 String aup =null; //Actions: ListUsers, AddUser, ModifyPassword, DeleteUser, Login95 String un =""; //login user's name96 String pw =""; //login user's password97 String asn =""; //whether a user is authenticated98 String uan =""; //whether a authentication for a particular action is needed99 String cm =""; //whether the action is confirmed100 101 String umun =""; //the new user name102 String umpw =""; //user's new password103 String umas =""; //user account status104 String umgp =""; //user greoups105 String umc =""; // comments for the user106 107 String oumun =""; //the original user's name108 String umpw1 =""; //user's new password109 String umpw2 =""; //user's retyped new password103 return result; // Return the empty result 104 } 105 106 String aup = null; //Actions: ListUsers, AddUser, ModifyPassword, DeleteUser, Login 107 String un = ""; //login user's name 108 String pw = ""; //login user's password 109 String asn = ""; //whether a user is authenticated 110 String uan = ""; //whether a authentication for a particular action is needed 111 String cm = ""; //whether the action is confirmed 112 113 String umun = ""; //the new user name 114 String umpw = ""; //user's new password 115 String umas = ""; //user account status 116 String umgp = ""; //user greoups 117 String umc = ""; // comments for the user 118 119 String oumun = ""; //the original user's name 120 String umpw1 = ""; //user's new password 121 String umpw2 = ""; //user's retyped new password 110 122 111 123 //used for adding a list of users at one time. Format: name,password,role]name,password,role]... 112 124 //in which, role may be in the format: student:[teacher's username] 113 String unpwlist ="";125 String unpwlist = ""; 114 126 String service = ""; 115 127 116 128 // get parameters from the request 117 129 NodeList params = param_list.getElementsByTagName(GSXML.PARAM_ELEM); 118 for (int i=0; i<params.getLength();i++) { 119 Element param = (Element)params.item(i); 130 for (int i = 0; i < params.getLength(); i++) 131 { 132 Element param = (Element) params.item(i); 120 133 String p_name = param.getAttribute(GSXML.NAME_ATT); 121 134 String p_value = GSXML.getValue(param); 122 135 123 if (p_name.equals("aup")){ 136 if (p_name.equals("aup")) 137 { 124 138 aup = p_value; 125 }else if (p_name.equals("un")) { 139 } 140 else if (p_name.equals("un")) 141 { 126 142 un = p_value; 127 }else if(p_name.equals("pw")) { 143 } 144 else if (p_name.equals("pw")) 145 { 128 146 pw = p_value; 129 }else if(p_name.equals("umun")) { 147 } 148 else if (p_name.equals("umun")) 149 { 130 150 umun = p_value; 131 }else if(p_name.equals("umpw")) { 151 } 152 else if (p_name.equals("umpw")) 153 { 132 154 umpw = p_value; 133 }else if (p_name.equals("umas")){ 155 } 156 else if (p_name.equals("umas")) 157 { 134 158 umas = p_value; 135 }else if (p_name.equals("umgp")){ 159 } 160 else if (p_name.equals("umgp")) 161 { 136 162 umgp = p_value; 137 }else if (p_name.equals("umc")){ 163 } 164 else if (p_name.equals("umc")) 165 { 138 166 umc = p_value; 139 }else if (p_name.equals("asn")){ 167 } 168 else if (p_name.equals("asn")) 169 { 140 170 asn = p_value; 141 }else if (p_name.equals("uan")){ 171 } 172 else if (p_name.equals("uan")) 173 { 142 174 uan = p_value; 143 }else if (p_name.equals("cm")){ 175 } 176 else if (p_name.equals("cm")) 177 { 144 178 cm = p_value; 145 }else if(p_name.equals("umpw1")) { 179 } 180 else if (p_name.equals("umpw1")) 181 { 146 182 umpw1 = p_value; 147 }else if(p_name.equals("umpw2")) { 183 } 184 else if (p_name.equals("umpw2")) 185 { 148 186 umpw2 = p_value; 149 }else if(p_name.equals("oumun")) { 187 } 188 else if (p_name.equals("oumun")) 189 { 150 190 oumun = p_value; 151 }else if(p_name.equals("unpwlist")) { 191 } 192 else if (p_name.equals("unpwlist")) 193 { 152 194 unpwlist = p_value; 153 195 } … … 162 204 Element service_node = this.doc.createElement(GSXML.SERVICE_ELEM); 163 205 authen_node.appendChild(service_node); 164 service_node.setAttribute("aup", aup);206 service_node.setAttribute("aup", aup); 165 207 // user's info 166 UserQueryResult userQueryResult =null;208 UserQueryResult userQueryResult = null; 167 209 168 210 // check the usersDb database, if it isn't existing, check the etc dir, create the etc dir if it isn't existing, then create the user database and add a "admin" user 169 211 String usersDB_dir = this.site_home + File.separatorChar + "etc" + File.separatorChar + "usersDB"; 170 DerbyWrapper derbyWrapper=new DerbyWrapper(); 171 File usersDB_file =new File(usersDB_dir); 172 if (!usersDB_file.exists()){ 212 DerbyWrapper derbyWrapper = new DerbyWrapper(); 213 File usersDB_file = new File(usersDB_dir); 214 if (!usersDB_file.exists()) 215 { 173 216 String etc_dir = this.site_home + File.separatorChar + "etc"; 174 File etc_file =new File(etc_dir); 175 if (!etc_file.exists()){ 217 File etc_file = new File(etc_dir); 218 if (!etc_file.exists()) 219 { 176 220 boolean success = etc_file.mkdir(); 177 if (!success){ 178 logger.error("Couldn't create the etc dir under "+this.site_home + "."); 179 return result; 180 } 181 } 182 derbyWrapper.connectDatabase(usersDB_dir,true); 221 if (!success) 222 { 223 logger.error("Couldn't create the etc dir under " + this.site_home + "."); 224 return result; 225 } 226 } 227 derbyWrapper.connectDatabase(usersDB_dir, true); 183 228 derbyWrapper.createDatabase(); 184 }else{ 229 } 230 else 231 { 185 232 derbyWrapper.connectDatabase(usersDB_dir, false); 186 233 } 187 234 188 235 // Action: login 189 if (aup.equals("Login")){ 190 if (uan.equals("")){ //return a login page, if the user's name is not given 191 service_node.setAttribute("info","Login"); 236 if (aup.equals("Login")) 237 { 238 if (uan.equals("")) 239 { //return a login page, if the user's name is not given 240 service_node.setAttribute("info", "Login"); 192 241 derbyWrapper.closeDatabase(); 193 242 return result; … … 195 244 String groups = ""; 196 245 // if the authentication(uan=1) is required,but the user hasn't been authenticated(asn=0),the user is asked to login first 197 if ((uan.equals("1") && asn.equals("0"))) { 198 if ((un.length()==0) && (pw.length()==0)){ 199 service_node.setAttribute("asn","0"); 200 service_node.setAttribute("info","Login"); 201 derbyWrapper.closeDatabase(); 202 return result; 203 } 204 if ((un.length()==0) || (pw.length()==0)){ 205 service_node.setAttribute("asn","0"); 206 service_node.setAttribute("info","Login"); 207 service_node.setAttribute("err","un-pw-err"); 208 derbyWrapper.closeDatabase(); 209 return result; 210 }else{ 211 userQueryResult=derbyWrapper.findUser(un,pw);//looking for the user from the users table 212 service_node.setAttribute(GSXML.NAME_ATT,"Authentication"); 213 service_node.setAttribute("un",un); 214 if (userQueryResult==null){ 246 if ((uan.equals("1") && asn.equals("0"))) 247 { 248 if ((un.length() == 0) && (pw.length() == 0)) 249 { 250 service_node.setAttribute("asn", "0"); 251 service_node.setAttribute("info", "Login"); 252 derbyWrapper.closeDatabase(); 253 return result; 254 } 255 if ((un.length() == 0) || (pw.length() == 0)) 256 { 257 service_node.setAttribute("asn", "0"); 258 service_node.setAttribute("info", "Login"); 259 service_node.setAttribute("err", "un-pw-err"); 260 derbyWrapper.closeDatabase(); 261 return result; 262 } 263 else 264 { 265 userQueryResult = derbyWrapper.findUser(un, pw);//looking for the user from the users table 266 service_node.setAttribute(GSXML.NAME_ATT, "Authentication"); 267 service_node.setAttribute("un", un); 268 if (userQueryResult == null) 269 { 215 270 //the user isn't a vaild user 216 service_node.setAttribute("asn","0"); 217 service_node.setAttribute("err","un-pw-err");// either unsername or password is wrong 218 service_node.setAttribute("info","Login"); 219 derbyWrapper.closeDatabase(); 220 return result; 221 }else{ 271 service_node.setAttribute("asn", "0"); 272 service_node.setAttribute("err", "un-pw-err");// either unsername or password is wrong 273 service_node.setAttribute("info", "Login"); 274 derbyWrapper.closeDatabase(); 275 return result; 276 } 277 else 278 { 222 279 // asn="1"; //the user is a member of the "administrator" group 223 Vector userInfo=userQueryResult.users_; 224 groups=((UserTermInfo)userInfo.get(0)).groups_; 225 String accountstatus=((UserTermInfo)userInfo.get(0)).accountstatus_; 226 if (accountstatus.trim().equals("false")){ 227 service_node.setAttribute("asn","0"); 228 service_node.setAttribute("err","as-false");//the account status is false 229 service_node.setAttribute("info","Login"); 280 Vector userInfo = userQueryResult.users_; 281 groups = ((UserTermInfo) userInfo.get(0)).groups_; 282 String accountstatus = ((UserTermInfo) userInfo.get(0)).accountstatus_; 283 if (accountstatus.trim().equals("false")) 284 { 285 service_node.setAttribute("asn", "0"); 286 service_node.setAttribute("err", "as-false");//the account status is false 287 service_node.setAttribute("info", "Login"); 230 288 derbyWrapper.closeDatabase(); 231 289 return result; 232 290 } 233 String[] groups_array=groups.split(","); 234 for (int i=0; i<groups_array.length;i++){ 235 if ((groups_array[i].trim().toLowerCase()).equals("administrator")){// check whether the user is in the administrator group 236 asn="1"; 237 service_node.setAttribute("asn","1"); 291 String[] groups_array = groups.split(","); 292 for (int i = 0; i < groups_array.length; i++) 293 { 294 if ((groups_array[i].trim().toLowerCase()).equals("administrator")) 295 {// check whether the user is in the administrator group 296 asn = "1"; 297 service_node.setAttribute("asn", "1"); 238 298 break; 239 299 } 240 300 } 241 if (!asn.equals("1")){ 242 asn="2"; 243 service_node.setAttribute("asn","2");//the user is authenticated 301 if (!asn.equals("1")) 302 { 303 asn = "2"; 304 service_node.setAttribute("asn", "2");//the user is authenticated 244 305 } 245 306 } … … 248 309 249 310 //asn!=0 This is a valid user 250 if (!asn.equals("0")){ 251 service_node.setAttribute("info","Login"); 252 service_node.setAttribute("un",un); 253 service_node.setAttribute("pw",pw); 254 service_node.setAttribute("asn",asn); 255 service_node.setAttribute("umgp",groups); 311 if (!asn.equals("0")) 312 { 313 service_node.setAttribute("info", "Login"); 314 service_node.setAttribute("un", un); 315 service_node.setAttribute("pw", pw); 316 service_node.setAttribute("asn", asn); 317 service_node.setAttribute("umgp", groups); 256 318 derbyWrapper.closeDatabase(); 257 319 return result; … … 260 322 261 323 //Action: listuser 262 if (aup.equals("ListUsers")){ 263 if (asn.equals("") && un.equals("")){ 264 service_node.setAttribute("info","Login"); 324 if (aup.equals("ListUsers")) 325 { 326 if (asn.equals("") && un.equals("")) 327 { 328 service_node.setAttribute("info", "Login"); 265 329 derbyWrapper.closeDatabase(); 266 330 return result; … … 268 332 269 333 //valid users but not in the administrator group(asn=2), they cannot list all users 270 if (asn.equals("2")){ 271 service_node.setAttribute("info","Login"); 272 service_node.setAttribute("err","no-permission"); 273 service_node.setAttribute("un",un); 274 service_node.setAttribute("asn",asn); 334 if (asn.equals("2")) 335 { 336 service_node.setAttribute("info", "Login"); 337 service_node.setAttribute("err", "no-permission"); 338 service_node.setAttribute("un", un); 339 service_node.setAttribute("asn", asn); 275 340 derbyWrapper.closeDatabase(); 276 341 return result; 277 342 } 278 343 //valid users belong to the administrator group(asn=1), they can list all users 279 if (asn.equals("1")){ 280 userQueryResult=derbyWrapper.findUser(null,null); 281 derbyWrapper.closeDatabase(); 282 service_node.setAttribute(GSXML.NAME_ATT,"Authentication"); 283 service_node.setAttribute("un",un); 284 service_node.setAttribute("asn",asn); 285 286 if (userQueryResult!=null && userQueryResult.getSize()>0){ 287 service_node.setAttribute("info","all-un"); // got a user list 288 Element user_node=getUserNode(userQueryResult); 344 if (asn.equals("1")) 345 { 346 userQueryResult = derbyWrapper.findUser(null, null); 347 derbyWrapper.closeDatabase(); 348 service_node.setAttribute(GSXML.NAME_ATT, "Authentication"); 349 service_node.setAttribute("un", un); 350 service_node.setAttribute("asn", asn); 351 352 if (userQueryResult != null && userQueryResult.getSize() > 0) 353 { 354 service_node.setAttribute("info", "all-un"); // got a user list 355 Element user_node = getUserNode(userQueryResult); 289 356 service_node.appendChild(user_node); 290 357 derbyWrapper.closeDatabase(); 291 358 return result; 292 }else { 293 service_node.setAttribute("err","no-un"); // no user returned 294 derbyWrapper.closeDatabase(); 295 return result; 296 } 359 } 360 else 361 { 362 service_node.setAttribute("err", "no-un"); // no user returned 363 derbyWrapper.closeDatabase(); 364 return result; 365 } 297 366 } 298 367 } 299 368 //TODO: Action : addStudents (bulk adding) 300 if (aup.equals("AddStudents")){ 369 if (aup.equals("AddStudents")) 370 { 301 371 String[] users = unpwlist.split("]"); 302 for(int i=0; i<users.length; i++) { 372 for (int i = 0; i < users.length; i++) 373 { 303 374 String[] user = users[i].split(","); 304 375 String uname = user[0]; 305 376 String password = user[1]; 306 377 String group = user[2].split(":")[0]; 307 String add_user=derbyWrapper.addUser(uname, password, group,"true",""); 308 if (add_user.equals("succeed")){ 309 userQueryResult=derbyWrapper.findUser(null,null); 310 derbyWrapper.closeDatabase(); 311 service_node.setAttribute("info","all-un"); // return a list of all users if the user has been added 312 Element user_node=getUserNode(userQueryResult); 378 String add_user = derbyWrapper.addUser(uname, password, group, "true", ""); 379 if (add_user.equals("succeed")) 380 { 381 userQueryResult = derbyWrapper.findUser(null, null); 382 derbyWrapper.closeDatabase(); 383 service_node.setAttribute("info", "all-un"); // return a list of all users if the user has been added 384 Element user_node = getUserNode(userQueryResult); 313 385 service_node.appendChild(user_node); 314 386 derbyWrapper.closeDatabase(); 315 387 return result; 316 } 317 } 318 } 319 388 } 389 } 390 } 391 320 392 //Action : adduder 321 if (aup.equals("AddUser")){ 322 if (asn.equals("") && un.equals("")){ 323 service_node.setAttribute("info","Login"); 393 if (aup.equals("AddUser")) 394 { 395 if (asn.equals("") && un.equals("")) 396 { 397 service_node.setAttribute("info", "Login"); 324 398 derbyWrapper.closeDatabase(); 325 399 return result; 326 400 } 327 401 //valid users can't add a new user because they aren't in the administrator group(asn=2) 328 if (asn.equals("2")){ 329 service_node.setAttribute("info","Login"); 330 service_node.setAttribute("err","no-permission"); 331 service_node.setAttribute("un",un); 332 service_node.setAttribute("asn",asn); 402 if (asn.equals("2")) 403 { 404 service_node.setAttribute("info", "Login"); 405 service_node.setAttribute("err", "no-permission"); 406 service_node.setAttribute("un", un); 407 service_node.setAttribute("asn", asn); 333 408 derbyWrapper.closeDatabase(); 334 409 return result; 335 410 } 336 411 //valid users are in the administrator group, they can add a new user(asn=1) 337 if (asn.equals("1")){ 338 service_node.setAttribute(GSXML.NAME_ATT,"Authentication"); 339 service_node.setAttribute("un",un); 340 service_node.setAttribute("asn",asn); 341 342 if (umun.length()==0 && umpw.length()==0 && umgp.length()==0 && umas.length()==0 && umc.length()==0){ 343 service_node.setAttribute("info","adduser_interface"); 412 if (asn.equals("1")) 413 { 414 service_node.setAttribute(GSXML.NAME_ATT, "Authentication"); 415 service_node.setAttribute("un", un); 416 service_node.setAttribute("asn", asn); 417 418 if (umun.length() == 0 && umpw.length() == 0 && umgp.length() == 0 && umas.length() == 0 && umc.length() == 0) 419 { 420 service_node.setAttribute("info", "adduser_interface"); 344 421 derbyWrapper.closeDatabase(); 345 422 return result; … … 347 424 348 425 //check the strings of username and password 349 if ((umun==null) || (umun.length()<2) || (umun.length()>30) || (!(Pattern.matches("[a-zA-Z0-9//_//.]+",umun)))){ 350 service_node.setAttribute("err","un-err"); //the input username string is illegal 351 service_node.setAttribute("info","adduser_interface"); 352 derbyWrapper.closeDatabase(); 353 return result; 354 } 355 356 if ((umpw==null) || (umpw.length()<3) || (umpw.length()>8) || (!(Pattern.matches("[\\p{ASCII}]+",umpw)))){ 357 service_node.setAttribute("err","pw-err"); //the input passwrod string is illegal 358 service_node.setAttribute("info","adduser_interface"); 426 if ((umun == null) || (umun.length() < 2) || (umun.length() > 30) || (!(Pattern.matches("[a-zA-Z0-9//_//.]+", umun)))) 427 { 428 service_node.setAttribute("err", "un-err"); //the input username string is illegal 429 service_node.setAttribute("info", "adduser_interface"); 430 derbyWrapper.closeDatabase(); 431 return result; 432 } 433 434 if ((umpw == null) || (umpw.length() < 3) || (umpw.length() > 8) || (!(Pattern.matches("[\\p{ASCII}]+", umpw)))) 435 { 436 service_node.setAttribute("err", "pw-err"); //the input passwrod string is illegal 437 service_node.setAttribute("info", "adduser_interface"); 359 438 derbyWrapper.closeDatabase(); 360 439 return result; … … 362 441 363 442 // add the new users into the users table 364 umgp=umgp.replaceAll(" ","");//get rid of the space of the groups string 365 userQueryResult=derbyWrapper.findUser(umun,null);// check whether the new user name has existed in the table. 366 if (userQueryResult!=null){ 367 service_node.setAttribute("err","un-exist"); //the new username string is duplicated 368 service_node.setAttribute("info","adduser_interface"); 369 derbyWrapper.closeDatabase(); 370 return result; 371 }else{ 372 String add_user=derbyWrapper.addUser(umun,umpw,umgp,umas,umc); 373 if (add_user.equals("succeed")){ 374 userQueryResult=derbyWrapper.findUser(null,null); 375 derbyWrapper.closeDatabase(); 376 service_node.setAttribute("info","all-un"); // return a list of all users if the user has been added 377 Element user_node=getUserNode(userQueryResult); 443 umgp = umgp.replaceAll(" ", "");//get rid of the space of the groups string 444 userQueryResult = derbyWrapper.findUser(umun, null);// check whether the new user name has existed in the table. 445 if (userQueryResult != null) 446 { 447 service_node.setAttribute("err", "un-exist"); //the new username string is duplicated 448 service_node.setAttribute("info", "adduser_interface"); 449 derbyWrapper.closeDatabase(); 450 return result; 451 } 452 else 453 { 454 String add_user = derbyWrapper.addUser(umun, umpw, umgp, umas, umc); 455 if (add_user.equals("succeed")) 456 { 457 userQueryResult = derbyWrapper.findUser(null, null); 458 derbyWrapper.closeDatabase(); 459 service_node.setAttribute("info", "all-un"); // return a list of all users if the user has been added 460 Element user_node = getUserNode(userQueryResult); 378 461 service_node.appendChild(user_node); 379 462 derbyWrapper.closeDatabase(); 380 463 return result; 381 }else{ 382 derbyWrapper.closeDatabase(); 383 service_node.setAttribute("err",add_user);// return the error message if the user couldn't be added 464 } 465 else 466 { 467 derbyWrapper.closeDatabase(); 468 service_node.setAttribute("err", add_user);// return the error message if the user couldn't be added 384 469 derbyWrapper.closeDatabase(); 385 470 return result; … … 390 475 391 476 //Action: edituser 392 if (aup.equals("EditUser")){ 393 service_node.setAttribute(GSXML.NAME_ATT,"Authentication"); 394 service_node.setAttribute("un",un); 395 service_node.setAttribute("asn",asn); 477 if (aup.equals("EditUser")) 478 { 479 service_node.setAttribute(GSXML.NAME_ATT, "Authentication"); 480 service_node.setAttribute("un", un); 481 service_node.setAttribute("asn", asn); 396 482 397 483 //Get the user's info from the database 398 if (cm.length()==0){ 399 service_node.setAttribute("info","edituser-interface"); 400 userQueryResult=derbyWrapper.findUser(umun,null); 401 derbyWrapper.closeDatabase(); 402 Vector userInfo=userQueryResult.users_; 403 String username=((UserTermInfo)userInfo.get(0)).username_; 404 String password=((UserTermInfo)userInfo.get(0)).password_; 405 String groups=((UserTermInfo)userInfo.get(0)).groups_; 406 String accountstatus=((UserTermInfo)userInfo.get(0)).accountstatus_; 407 String comment=((UserTermInfo)userInfo.get(0)).comment_; 408 409 service_node.setAttribute("oumun",oumun); 410 service_node.setAttribute("umun",username); 411 service_node.setAttribute("umpw",password); 412 service_node.setAttribute("umgp",groups); 413 service_node.setAttribute("umas",accountstatus); 414 service_node.setAttribute("umc",comment); 484 if (cm.length() == 0) 485 { 486 service_node.setAttribute("info", "edituser-interface"); 487 userQueryResult = derbyWrapper.findUser(umun, null); 488 derbyWrapper.closeDatabase(); 489 Vector userInfo = userQueryResult.users_; 490 String username = ((UserTermInfo) userInfo.get(0)).username_; 491 String password = ((UserTermInfo) userInfo.get(0)).password_; 492 String groups = ((UserTermInfo) userInfo.get(0)).groups_; 493 String accountstatus = ((UserTermInfo) userInfo.get(0)).accountstatus_; 494 String comment = ((UserTermInfo) userInfo.get(0)).comment_; 495 496 service_node.setAttribute("oumun", oumun); 497 service_node.setAttribute("umun", username); 498 service_node.setAttribute("umpw", password); 499 service_node.setAttribute("umgp", groups); 500 service_node.setAttribute("umas", accountstatus); 501 service_node.setAttribute("umc", comment); 415 502 derbyWrapper.closeDatabase(); 416 503 return result; … … 418 505 419 506 //Commit the modified user's info to the database 420 if (cm.toLowerCase().equals("submit")){ 421 if (oumun.equals(umun)){// the user's name hasn't been changed, update the user's info 422 if (umpw.length()==0){ 423 derbyWrapper.modifyUserInfo(umun,null,umgp,umas,umc); 424 userQueryResult=derbyWrapper.findUser(null,null); 425 derbyWrapper.closeDatabase(); 426 service_node.setAttribute("info","all-un"); // the user's info has been updated, return a list of all users 427 Element user_node=getUserNode(userQueryResult); 507 if (cm.toLowerCase().equals("submit")) 508 { 509 if (oumun.equals(umun)) 510 {// the user's name hasn't been changed, update the user's info 511 if (umpw.length() == 0) 512 { 513 derbyWrapper.modifyUserInfo(umun, null, umgp, umas, umc); 514 userQueryResult = derbyWrapper.findUser(null, null); 515 derbyWrapper.closeDatabase(); 516 service_node.setAttribute("info", "all-un"); // the user's info has been updated, return a list of all users 517 Element user_node = getUserNode(userQueryResult); 428 518 service_node.appendChild(user_node); 429 519 derbyWrapper.closeDatabase(); 430 520 return result; 431 }else{ 432 if ((umpw.length()==0) || (umpw.length()<3) || (umpw.length()>8) || (!(Pattern.matches("[\\p{ASCII}]+",umpw)))){ 433 service_node.setAttribute("err","umpw-err"); //the input passwrod string is illegal 434 service_node.setAttribute("info","edituser-interface"); 435 service_node.setAttribute("umun",umun); 436 service_node.setAttribute("umpw",umpw); 437 service_node.setAttribute("umgp",umgp); 438 service_node.setAttribute("umas",umas); 439 service_node.setAttribute("umc",umc); 440 service_node.setAttribute("oumun",oumun); 521 } 522 else 523 { 524 if ((umpw.length() == 0) || (umpw.length() < 3) || (umpw.length() > 8) || (!(Pattern.matches("[\\p{ASCII}]+", umpw)))) 525 { 526 service_node.setAttribute("err", "umpw-err"); //the input passwrod string is illegal 527 service_node.setAttribute("info", "edituser-interface"); 528 service_node.setAttribute("umun", umun); 529 service_node.setAttribute("umpw", umpw); 530 service_node.setAttribute("umgp", umgp); 531 service_node.setAttribute("umas", umas); 532 service_node.setAttribute("umc", umc); 533 service_node.setAttribute("oumun", oumun); 441 534 derbyWrapper.closeDatabase(); 442 535 return result; 443 536 } 444 umgp =umgp.replaceAll(" ","");// get rid of the space445 derbyWrapper.modifyUserInfo(umun, umpw,umgp,umas,umc);446 userQueryResult =derbyWrapper.listAllUser();447 derbyWrapper.closeDatabase(); 448 service_node.setAttribute("info", "all-un"); // if the new user has been added successfully, return a list of all users449 Element user_node =getUserNode(userQueryResult);537 umgp = umgp.replaceAll(" ", "");// get rid of the space 538 derbyWrapper.modifyUserInfo(umun, umpw, umgp, umas, umc); 539 userQueryResult = derbyWrapper.listAllUser(); 540 derbyWrapper.closeDatabase(); 541 service_node.setAttribute("info", "all-un"); // if the new user has been added successfully, return a list of all users 542 Element user_node = getUserNode(userQueryResult); 450 543 service_node.appendChild(user_node); 451 544 derbyWrapper.closeDatabase(); … … 454 547 } 455 548 // The user's name has been changed, add a new user record to the database 456 else{ 457 if ((umun.length()==0) || (umun.length()<2) || (umun.length()>30) || (!(Pattern.matches("[a-zA-Z0-9//_//.]+",umun)))){ 458 service_node.setAttribute("err","umun-err"); //the input username string is illegal 459 service_node.setAttribute("umun",umun); 460 service_node.setAttribute("umpw",umpw); 461 service_node.setAttribute("umgp",umgp); 462 service_node.setAttribute("umas",umas); 463 service_node.setAttribute("umc",umc); 464 service_node.setAttribute("oumun",oumun); 465 service_node.setAttribute("info","edituser-interface"); 466 derbyWrapper.closeDatabase(); 467 return result; 468 } 469 if (umpw.length()==0){ 470 service_node.setAttribute("err","ini-umpw-err"); //the input passwrod string is illegal 471 service_node.setAttribute("info","edituser-interface"); 472 service_node.setAttribute("umun",umun); 473 service_node.setAttribute("umpw",umpw); 474 service_node.setAttribute("umgp",umgp); 475 service_node.setAttribute("umas",umas); 476 service_node.setAttribute("umc",umc); 477 service_node.setAttribute("oumun",oumun); 478 derbyWrapper.closeDatabase(); 479 return result; 480 } 481 if ((umpw.length()<3) || (umpw.length()>8) || (!(Pattern.matches("[\\p{ASCII}]+",umpw)))){ 482 service_node.setAttribute("err","umpw-err"); //the input passwrod string is illegal 483 service_node.setAttribute("info","edituser-interface"); 484 service_node.setAttribute("umun",umun); 485 service_node.setAttribute("umpw",umpw); 486 service_node.setAttribute("umgp",umgp); 487 service_node.setAttribute("umas",umas); 488 service_node.setAttribute("umc",umc); 489 service_node.setAttribute("oumun",oumun); 490 derbyWrapper.closeDatabase(); 491 return result; 492 } 493 umgp=umgp.replaceAll(" ","");// get rid of the space 494 userQueryResult=derbyWrapper.findUser(umun,null);// check whether the new user name has existed in the table. 495 if (userQueryResult!=null){ 496 service_node.setAttribute("err","un-exist"); //the new username string is duplicated 497 service_node.setAttribute("info","edituser-interface"); 498 service_node.setAttribute("umun",""); 499 service_node.setAttribute("umpw",""); 500 service_node.setAttribute("umgp",umgp); 501 service_node.setAttribute("umas",umas); 502 service_node.setAttribute("umc",umc); 503 service_node.setAttribute("oumun",oumun); 504 derbyWrapper.closeDatabase(); 505 return result; 506 }else{ 507 derbyWrapper.addUser(umun,umpw,umgp,umas,umc); 508 userQueryResult=derbyWrapper.listAllUser(); 509 derbyWrapper.closeDatabase(); 510 service_node.setAttribute("info","all-un"); // if the new user has been added successfully, return a list of all users 511 Element user_node=getUserNode(userQueryResult); 549 else 550 { 551 if ((umun.length() == 0) || (umun.length() < 2) || (umun.length() > 30) || (!(Pattern.matches("[a-zA-Z0-9//_//.]+", umun)))) 552 { 553 service_node.setAttribute("err", "umun-err"); //the input username string is illegal 554 service_node.setAttribute("umun", umun); 555 service_node.setAttribute("umpw", umpw); 556 service_node.setAttribute("umgp", umgp); 557 service_node.setAttribute("umas", umas); 558 service_node.setAttribute("umc", umc); 559 service_node.setAttribute("oumun", oumun); 560 service_node.setAttribute("info", "edituser-interface"); 561 derbyWrapper.closeDatabase(); 562 return result; 563 } 564 if (umpw.length() == 0) 565 { 566 service_node.setAttribute("err", "ini-umpw-err"); //the input passwrod string is illegal 567 service_node.setAttribute("info", "edituser-interface"); 568 service_node.setAttribute("umun", umun); 569 service_node.setAttribute("umpw", umpw); 570 service_node.setAttribute("umgp", umgp); 571 service_node.setAttribute("umas", umas); 572 service_node.setAttribute("umc", umc); 573 service_node.setAttribute("oumun", oumun); 574 derbyWrapper.closeDatabase(); 575 return result; 576 } 577 if ((umpw.length() < 3) || (umpw.length() > 8) || (!(Pattern.matches("[\\p{ASCII}]+", umpw)))) 578 { 579 service_node.setAttribute("err", "umpw-err"); //the input passwrod string is illegal 580 service_node.setAttribute("info", "edituser-interface"); 581 service_node.setAttribute("umun", umun); 582 service_node.setAttribute("umpw", umpw); 583 service_node.setAttribute("umgp", umgp); 584 service_node.setAttribute("umas", umas); 585 service_node.setAttribute("umc", umc); 586 service_node.setAttribute("oumun", oumun); 587 derbyWrapper.closeDatabase(); 588 return result; 589 } 590 umgp = umgp.replaceAll(" ", "");// get rid of the space 591 userQueryResult = derbyWrapper.findUser(umun, null);// check whether the new user name has existed in the table. 592 if (userQueryResult != null) 593 { 594 service_node.setAttribute("err", "un-exist"); //the new username string is duplicated 595 service_node.setAttribute("info", "edituser-interface"); 596 service_node.setAttribute("umun", ""); 597 service_node.setAttribute("umpw", ""); 598 service_node.setAttribute("umgp", umgp); 599 service_node.setAttribute("umas", umas); 600 service_node.setAttribute("umc", umc); 601 service_node.setAttribute("oumun", oumun); 602 derbyWrapper.closeDatabase(); 603 return result; 604 } 605 else 606 { 607 derbyWrapper.addUser(umun, umpw, umgp, umas, umc); 608 userQueryResult = derbyWrapper.listAllUser(); 609 derbyWrapper.closeDatabase(); 610 service_node.setAttribute("info", "all-un"); // if the new user has been added successfully, return a list of all users 611 Element user_node = getUserNode(userQueryResult); 512 612 service_node.appendChild(user_node); 513 613 derbyWrapper.closeDatabase(); … … 517 617 } 518 618 519 if (cm.toLowerCase().equals("cancel")){ 520 userQueryResult=derbyWrapper.listAllUser(); 521 derbyWrapper.closeDatabase(); 522 service_node.setAttribute("info","all-un"); // if the new user has been added successfully, return a list of all users 523 Element user_node=getUserNode(userQueryResult); 619 if (cm.toLowerCase().equals("cancel")) 620 { 621 userQueryResult = derbyWrapper.listAllUser(); 622 derbyWrapper.closeDatabase(); 623 service_node.setAttribute("info", "all-un"); // if the new user has been added successfully, return a list of all users 624 Element user_node = getUserNode(userQueryResult); 524 625 service_node.appendChild(user_node); 525 626 derbyWrapper.closeDatabase(); … … 529 630 530 631 //Action: modifypassword 531 if (aup.equals("ModifyPassword")){ 532 if (un.equals("")){ 533 service_node.setAttribute("info","Login"); 534 derbyWrapper.closeDatabase(); 535 return result; 536 } 537 538 service_node.setAttribute(GSXML.NAME_ATT,"Authentication"); 539 service_node.setAttribute("un",un); 540 service_node.setAttribute("asn",asn); 541 542 userQueryResult=derbyWrapper.findUser(un,null); 543 Vector userInfo=userQueryResult.users_; 544 pw=((UserTermInfo)userInfo.get(0)).password_; 545 546 if ((umpw1.length()==0) && (umpw2.length()==0) && (umpw.length()==0)){ 547 service_node.setAttribute("info","modify_interface");// call the interface of the modifying password 548 derbyWrapper.closeDatabase(); 549 return result; 550 } 551 552 if (!pw.equals(umpw) && umpw.length()>0){ 553 service_node.setAttribute("info","modify_interface"); 554 service_node.setAttribute("err","pw-umpw-nm-err");//if the original password is not match 555 derbyWrapper.closeDatabase(); 556 return result; 557 } 558 559 if ((umpw1.length()==0) || (umpw2.length()==0)){ 560 service_node.setAttribute("info","modify_interface"); 561 service_node.setAttribute("err","umpw1-umpw2-null-err");//if one of the password strings is none,return the err info back 562 derbyWrapper.closeDatabase(); 563 return result; 564 } 565 566 if(!umpw1.equals(umpw2)){ 567 service_node.setAttribute("info","modify_interface"); 568 service_node.setAttribute("err","umpw1-umpw2-nm-err");//if one of the password strings is none,return the err info back 569 derbyWrapper.closeDatabase(); 570 return result; 571 } 572 573 if (umpw.length()==0){ 574 service_node.setAttribute("info","modify_interface"); 575 service_node.setAttribute("err","umpw-null-err");//if one of the password strings is none,return the err info back 632 if (aup.equals("ModifyPassword")) 633 { 634 if (un.equals("")) 635 { 636 service_node.setAttribute("info", "Login"); 637 derbyWrapper.closeDatabase(); 638 return result; 639 } 640 641 service_node.setAttribute(GSXML.NAME_ATT, "Authentication"); 642 service_node.setAttribute("un", un); 643 service_node.setAttribute("asn", asn); 644 645 userQueryResult = derbyWrapper.findUser(un, null); 646 Vector userInfo = userQueryResult.users_; 647 pw = ((UserTermInfo) userInfo.get(0)).password_; 648 649 if ((umpw1.length() == 0) && (umpw2.length() == 0) && (umpw.length() == 0)) 650 { 651 service_node.setAttribute("info", "modify_interface");// call the interface of the modifying password 652 derbyWrapper.closeDatabase(); 653 return result; 654 } 655 656 if (!pw.equals(umpw) && umpw.length() > 0) 657 { 658 service_node.setAttribute("info", "modify_interface"); 659 service_node.setAttribute("err", "pw-umpw-nm-err");//if the original password is not match 660 derbyWrapper.closeDatabase(); 661 return result; 662 } 663 664 if ((umpw1.length() == 0) || (umpw2.length() == 0)) 665 { 666 service_node.setAttribute("info", "modify_interface"); 667 service_node.setAttribute("err", "umpw1-umpw2-null-err");//if one of the password strings is none,return the err info back 668 derbyWrapper.closeDatabase(); 669 return result; 670 } 671 672 if (!umpw1.equals(umpw2)) 673 { 674 service_node.setAttribute("info", "modify_interface"); 675 service_node.setAttribute("err", "umpw1-umpw2-nm-err");//if one of the password strings is none,return the err info back 676 derbyWrapper.closeDatabase(); 677 return result; 678 } 679 680 if (umpw.length() == 0) 681 { 682 service_node.setAttribute("info", "modify_interface"); 683 service_node.setAttribute("err", "umpw-null-err");//if one of the password strings is none,return the err info back 576 684 derbyWrapper.closeDatabase(); 577 685 return result; 578 686 } 579 687 //check the new password and the retyped password 580 if ((umpw1==null) || (umpw1.length()<3) || (umpw1.length()>8) || (!(Pattern.matches("[\\p{ASCII}]+",umpw1)))){ 581 service_node.setAttribute("info","modify_interface"); 582 service_node.setAttribute("err","umpw1-err");// the new password is illegal 583 derbyWrapper.closeDatabase(); 584 return result; 585 } 586 587 if ((umpw2==null) || (umpw2.length()<3) || (umpw2.length()>8) || (!(Pattern.matches("[\\p{ASCII}]+",umpw2)))){ 588 service_node.setAttribute("info","modify_interface"); 589 service_node.setAttribute("err","umpw2-err"); // the retyped password is illegal 590 derbyWrapper.closeDatabase(); 591 return result; 592 } 593 String modify_user_info=derbyWrapper.modifyUserInfo(un,umpw1,null,null,null); 594 if (modify_user_info.equals("succeed")){ 595 service_node.setAttribute("err","");// the passsword has been changed successfully 596 derbyWrapper.closeDatabase(); 597 return result; 598 }else{ 599 service_node.setAttribute("err",modify_user_info);// return the error message of the pasword couldn't be modified 688 if ((umpw1 == null) || (umpw1.length() < 3) || (umpw1.length() > 8) || (!(Pattern.matches("[\\p{ASCII}]+", umpw1)))) 689 { 690 service_node.setAttribute("info", "modify_interface"); 691 service_node.setAttribute("err", "umpw1-err");// the new password is illegal 692 derbyWrapper.closeDatabase(); 693 return result; 694 } 695 696 if ((umpw2 == null) || (umpw2.length() < 3) || (umpw2.length() > 8) || (!(Pattern.matches("[\\p{ASCII}]+", umpw2)))) 697 { 698 service_node.setAttribute("info", "modify_interface"); 699 service_node.setAttribute("err", "umpw2-err"); // the retyped password is illegal 700 derbyWrapper.closeDatabase(); 701 return result; 702 } 703 String modify_user_info = derbyWrapper.modifyUserInfo(un, umpw1, null, null, null); 704 if (modify_user_info.equals("succeed")) 705 { 706 service_node.setAttribute("err", "");// the passsword has been changed successfully 707 derbyWrapper.closeDatabase(); 708 return result; 709 } 710 else 711 { 712 service_node.setAttribute("err", modify_user_info);// return the error message of the pasword couldn't be modified 600 713 derbyWrapper.closeDatabase(); 601 714 return result; … … 604 717 605 718 //Action: deleteuser 606 if (aup.equals("DeleteUser")){ 607 service_node.setAttribute("un",un); 608 service_node.setAttribute("asn",asn); 609 service_node.setAttribute("umun",umun); 610 if (cm.equals("yes")){ 611 String delete_user=derbyWrapper.deleteUser(umun); 612 if (delete_user.equals("succeed")){ 613 service_node.setAttribute("err",""); 614 userQueryResult=derbyWrapper.listAllUser(); 615 service_node.setAttribute("info","all-un"); // return a list of all users 616 Element user_node=getUserNode(userQueryResult); 719 if (aup.equals("DeleteUser")) 720 { 721 service_node.setAttribute("un", un); 722 service_node.setAttribute("asn", asn); 723 service_node.setAttribute("umun", umun); 724 if (cm.equals("yes")) 725 { 726 String delete_user = derbyWrapper.deleteUser(umun); 727 if (delete_user.equals("succeed")) 728 { 729 service_node.setAttribute("err", ""); 730 userQueryResult = derbyWrapper.listAllUser(); 731 service_node.setAttribute("info", "all-un"); // return a list of all users 732 Element user_node = getUserNode(userQueryResult); 617 733 service_node.appendChild(user_node); 618 }else{ 619 service_node.setAttribute("err",delete_user);//return the error message 620 derbyWrapper.closeDatabase(); 621 return result; 622 } 623 }else if (cm.equals("no")){ 624 service_node.setAttribute("err",""); 625 userQueryResult=derbyWrapper.listAllUser(); 626 service_node.setAttribute("info","all-un"); // return a list of all users 627 Element user_node=getUserNode(userQueryResult); 734 } 735 else 736 { 737 service_node.setAttribute("err", delete_user);//return the error message 738 derbyWrapper.closeDatabase(); 739 return result; 740 } 741 } 742 else if (cm.equals("no")) 743 { 744 service_node.setAttribute("err", ""); 745 userQueryResult = derbyWrapper.listAllUser(); 746 service_node.setAttribute("info", "all-un"); // return a list of all users 747 Element user_node = getUserNode(userQueryResult); 628 748 service_node.appendChild(user_node); 629 749 derbyWrapper.closeDatabase(); 630 750 return result; 631 }else{ 632 service_node.setAttribute("info","confirm"); 751 } 752 else 753 { 754 service_node.setAttribute("info", "confirm"); 633 755 derbyWrapper.closeDatabase(); 634 756 return result; … … 639 761 } 640 762 641 private Element getUserNode(UserQueryResult userQueryResult){ 642 Element user_list_node= this.doc.createElement(GSXML.USER_NODE_ELEM+"List"); 643 644 Vector userInfo=userQueryResult.users_; 645 646 for (int i=0; i<userQueryResult.getSize(); i++){ 647 Element user_node= this.doc.createElement(GSXML.USER_NODE_ELEM); 648 String username=((UserTermInfo)userInfo.get(i)).username_; 649 String password=((UserTermInfo)userInfo.get(i)).password_; 650 String groups=((UserTermInfo)userInfo.get(i)).groups_; 651 String accountstatus=((UserTermInfo)userInfo.get(i)).accountstatus_; 652 String comment=((UserTermInfo)userInfo.get(i)).comment_; 653 user_node.setAttribute("umun",username); 654 user_node.setAttribute("umpw",password); 655 user_node.setAttribute("umgp",groups); 656 user_node.setAttribute("umas",accountstatus); 657 user_node.setAttribute("umc",comment); 763 private Element getUserNode(UserQueryResult userQueryResult) 764 { 765 Element user_list_node = this.doc.createElement(GSXML.USER_NODE_ELEM + "List"); 766 767 Vector userInfo = userQueryResult.users_; 768 769 for (int i = 0; i < userQueryResult.getSize(); i++) 770 { 771 Element user_node = this.doc.createElement(GSXML.USER_NODE_ELEM); 772 String username = ((UserTermInfo) userInfo.get(i)).username_; 773 String password = ((UserTermInfo) userInfo.get(i)).password_; 774 String groups = ((UserTermInfo) userInfo.get(i)).groups_; 775 String accountstatus = ((UserTermInfo) userInfo.get(i)).accountstatus_; 776 String comment = ((UserTermInfo) userInfo.get(i)).comment_; 777 user_node.setAttribute("umun", username); 778 user_node.setAttribute("umpw", password); 779 user_node.setAttribute("umgp", groups); 780 user_node.setAttribute("umas", accountstatus); 781 user_node.setAttribute("umc", comment); 658 782 659 783 user_list_node.appendChild(user_node); 660 784 } 661 return user_list_node; 662 } 663 664 private Element getCollectList(String collect){ 665 Element collect_list_node = this.doc.createElement(GSXML.COLLECTION_ELEM+"List"); 666 File[] collect_dir= (new File(collect)).listFiles(); 667 if(collect_dir!=null && collect_dir.length > 0){ 668 for (int i=0;i<collect_dir.length;i++){ 669 if (collect_dir[i].isDirectory() && (!collect_dir[i].getName().startsWith(".svn"))){ 785 return user_list_node; 786 } 787 788 private Element getCollectList(String collect) 789 { 790 Element collect_list_node = this.doc.createElement(GSXML.COLLECTION_ELEM + "List"); 791 File[] collect_dir = (new File(collect)).listFiles(); 792 if (collect_dir != null && collect_dir.length > 0) 793 { 794 for (int i = 0; i < collect_dir.length; i++) 795 { 796 if (collect_dir[i].isDirectory() && (!collect_dir[i].getName().startsWith(".svn"))) 797 { 670 798 Element collect_node = this.doc.createElement(GSXML.COLLECTION_ELEM); 671 collect_node.setAttribute("name", collect_dir[i].getName());799 collect_node.setAttribute("name", collect_dir[i].getName()); 672 800 collect_list_node.appendChild(collect_node); 673 801 } … … 677 805 } 678 806 } 679
Note:
See TracChangeset
for help on using the changeset viewer.