1 18 package sync4j.server.admin.ws; 19 20 import java.util.logging.*; 21 22 import sync4j.framework.config.*; 23 import sync4j.framework.engine.source.*; 24 import sync4j.framework.logging.*; 25 import sync4j.framework.security.*; 26 import sync4j.framework.server.*; 27 import sync4j.framework.server.error.*; 28 import sync4j.framework.server.store.*; 29 import sync4j.framework.tools.beans.*; 30 31 import sync4j.server.admin.*; 32 import sync4j.server.config.*; 33 34 50 public class AdminWS { 51 53 55 private AdminManager admin; 56 57 private transient Logger log = Sync4jLogger.getLogger(); 58 59 61 67 public AdminWS() { 68 admin = new AdminManager(); 69 } 70 71 73 81 public String [] getRoles() 82 throws ServerException, AdminException { 83 return admin.getRoles(); 84 } 85 86 96 public Sync4jUser[] getUsers(String clause) 97 throws ServerException, AdminException { 98 try { 99 return admin.getUsers((Clause)BeanFactory.unmarshal(clause)); 100 } catch (AdminException e) { 101 log.severe("Server error: " + e.getMessage()); 102 log.throwing(getClass().getName(), "getUsers", e); 103 throw e; 104 } catch (ServerException e) { 105 log.severe("Server error: " + e.getMessage()); 106 log.throwing(getClass().getName(), "getUsers", e); 107 throw e; 108 } catch (Exception e) { 109 log.severe("Server error: " + e.getMessage()); 110 log.throwing(getClass().getName(), "getUsers", e); 111 throw new ServerException(e.getMessage(), e); 112 } 113 } 114 115 123 public void addUser(Sync4jUser user) 124 throws ServerException, AdminException { 125 try { 126 admin.addUser(user); 127 } catch (AdminException e) { 128 log.severe("Server error: " + e.getMessage()); 129 log.throwing(getClass().getName(), "addUser", e); 130 throw e; 131 } catch (ServerException e) { 132 log.severe("Server error: " + e.getMessage()); 133 log.throwing(getClass().getName(), "addUser", e); 134 throw e; 135 } catch (Exception e) { 136 log.severe("Server error: " + e.getMessage()); 137 log.throwing(getClass().getName(), "addUser", e); 138 throw new ServerException(e.getMessage(), e); 139 } 140 } 141 142 150 public void setUser(Sync4jUser user) 151 throws ServerException, AdminException { 152 try { 153 admin.setUser(user); 154 } catch (AdminException e) { 155 log.severe("Server error: " + e.getMessage()); 156 log.throwing(getClass().getName(), "setUser", e); 157 throw e; 158 } catch (ServerException e) { 159 log.severe("Server error: " + e.getMessage()); 160 log.throwing(getClass().getName(), "setUser", e); 161 throw e; 162 } catch (Exception e) { 163 log.severe("Server error: " + e.getMessage()); 164 log.throwing(getClass().getName(), "setUser", e); 165 throw new ServerException(e.getMessage(), e); 166 } 167 } 168 169 177 public void deleteUser(String userName) 178 throws ServerException, AdminException { 179 try { 180 admin.deleteUser(userName); 181 } catch (AdminException e) { 182 log.severe("Server error: " + e.getMessage()); 183 log.throwing(getClass().getName(), "deleteUser", e); 184 throw e; 185 } catch (ServerException e) { 186 log.severe("Server error: " + e.getMessage()); 187 log.throwing(getClass().getName(), "deleteUser", e); 188 throw e; 189 } catch (Exception e) { 190 log.severe("Server error: " + e.getMessage()); 191 log.throwing(getClass().getName(), "deleteUser", e); 192 throw new ServerException(e.getMessage(), e); 193 } 194 } 195 196 206 public int countUsers(String clause) 207 throws ServerException, AdminException { 208 try { 209 return admin.countUsers((Clause)BeanFactory.unmarshal(clause)); 210 } catch (AdminException e) { 211 log.severe("Server error: " + e.getMessage()); 212 log.throwing(getClass().getName(), "countUsers", e); 213 throw e; 214 } catch (ServerException e) { 215 log.severe("Server error: " + e.getMessage()); 216 log.throwing(getClass().getName(), "countUsers", e); 217 throw e; 218 } catch (Exception e) { 219 log.severe("Server error: " + e.getMessage()); 220 log.throwing(getClass().getName(), "countUsers", e); 221 throw new ServerException(e.getMessage(), e); 222 } 223 } 224 225 235 public Sync4jDevice[] getDevices(String clauses) 236 throws ServerException, AdminException { 237 try { 238 return admin.getDevices((Clause)BeanFactory.unmarshal(clauses)); 239 } catch (AdminException e) { 240 log.severe("Server error: " + e.getMessage()); 241 log.throwing(getClass().getName(), "getDevices", e); 242 throw e; 243 } catch (ServerException e) { 244 log.severe("Server error: " + e.getMessage()); 245 log.throwing(getClass().getName(), "getDevices", e); 246 throw e; 247 } catch (Exception e) { 248 log.severe("Server error: " + e.getMessage()); 249 log.throwing(getClass().getName(), "getDevices", e); 250 throw new ServerException(e.getMessage(), e); 251 } 252 } 253 254 264 public String addDevice(Sync4jDevice d) 265 throws ServerException, AdminException { 266 try { 267 return admin.addDevice(d); 268 } catch (AdminException e) { 269 log.severe("Server error: " + e.getMessage()); 270 log.throwing(getClass().getName(), "addDevice", e); 271 throw e; 272 } catch (ServerException e) { 273 log.severe("Server error: " + e.getMessage()); 274 log.throwing(getClass().getName(), "addDevice", e); 275 throw e; 276 } catch (Exception e) { 277 log.severe("Server error: " + e.getMessage()); 278 log.throwing(getClass().getName(), "addDevice", e); 279 throw new ServerException(e.getMessage(), e); 280 } 281 } 282 283 291 public void setDevice(Sync4jDevice d) 292 throws ServerException, AdminException { 293 try { 294 admin.setDevice(d); 295 } catch (AdminException e) { 296 log.severe("Server error: " + e.getMessage()); 297 log.throwing(getClass().getName(), "setDevice", e); 298 throw e; 299 } catch (ServerException e) { 300 log.severe("Server error: " + e.getMessage()); 301 log.throwing(getClass().getName(), "setDevice", e); 302 throw e; 303 } catch (Exception e) { 304 log.severe("Server error: " + e.getMessage()); 305 log.throwing(getClass().getName(), "setDevice", e); 306 throw new ServerException(e.getMessage(), e); 307 } 308 } 309 310 318 public void deleteDevice(String deviceId) 319 throws ServerException, AdminException{ 320 try { 321 admin.deleteDevice(deviceId); 322 } catch (AdminException e) { 323 log.severe("Server error: " + e.getMessage()); 324 log.throwing(getClass().getName(), "deleteDevice", e); 325 throw e; 326 } catch (ServerException e) { 327 log.severe("Server error: " + e.getMessage()); 328 log.throwing(getClass().getName(), "deleteDevice", e); 329 throw e; 330 } catch (Exception e) { 331 log.severe("Server error: " + e.getMessage()); 332 log.throwing(getClass().getName(), "deleteDevice", e); 333 throw new ServerException(e.getMessage(), e); 334 } 335 } 336 337 347 public int countDevices(String clauses) 348 throws ServerException, AdminException { 349 try { 350 return admin.countDevices((Clause)BeanFactory.unmarshal(clauses)); 351 } catch (AdminException e) { 352 log.severe("Server error: " + e.getMessage()); 353 log.throwing(getClass().getName(), "countDevices", e); 354 throw e; 355 } catch (ServerException e) { 356 log.severe("Server error: " + e.getMessage()); 357 log.throwing(getClass().getName(), "countDevices", e); 358 throw e; 359 } catch (Exception e) { 360 log.severe("Server error: " + e.getMessage()); 361 log.throwing(getClass().getName(), "countDevices", e); 362 throw new ServerException(e.getMessage(), e); 363 } 364 365 } 366 367 377 public Sync4jPrincipal[] getPrincipals(String clauses) 378 throws ServerException, AdminException { 379 try { 380 return admin.getPrincipals((Clause)BeanFactory.unmarshal(clauses)); 381 } catch (AdminException e) { 382 log.severe("Server error: " + e.getMessage()); 383 log.throwing(getClass().getName(), "getPrincipals", e); 384 throw e; 385 } catch (ServerException e) { 386 log.severe("Server error: " + e.getMessage()); 387 log.throwing(getClass().getName(), "getPrincipals", e); 388 throw e; 389 } catch (Exception e) { 390 log.severe("Server error: " + e.getMessage()); 391 log.throwing(getClass().getName(), "getPrincipals", e); 392 throw new ServerException(e.getMessage(), e); 393 } 394 } 395 396 406 public String addPrincipal(Sync4jPrincipal p) 407 throws ServerException, AdminException { 408 try { 409 return admin.addPrincipal(p); 410 } catch (AdminException e) { 411 log.severe("Server error: " + e.getMessage()); 412 log.throwing(getClass().getName(), "addPrincipal", e); 413 throw e; 414 } catch (ServerException e) { 415 log.severe("Server error: " + e.getMessage()); 416 log.throwing(getClass().getName(), "addPrincipal", e); 417 throw e; 418 } catch (Exception e) { 419 log.severe("Server error: " + e.getMessage()); 420 log.throwing(getClass().getName(), "addPrincipal", e); 421 throw new ServerException(e.getMessage(), e); 422 } 423 } 424 425 433 public void deletePrincipal(String principalId) 434 throws ServerException, AdminException { 435 try { 436 admin.deletePrincipal(principalId); 437 } catch (AdminException e) { 438 log.severe("Server error: " + e.getMessage()); 439 log.throwing(getClass().getName(), "deletePrincipal", e); 440 throw e; 441 } catch (ServerException e) { 442 log.severe("Server error: " + e.getMessage()); 443 log.throwing(getClass().getName(), "deletePrincipal", e); 444 throw e; 445 } catch (Exception e) { 446 log.severe("Server error: " + e.getMessage()); 447 log.throwing(getClass().getName(), "deletePrincipal", e); 448 throw new ServerException(e.getMessage(), e); 449 } 450 } 451 452 462 public int countPrincipals(String clauses) 463 throws ServerException, AdminException { 464 try { 465 return admin.countPrincipals((Clause)BeanFactory.unmarshal(clauses)); 466 } catch (AdminException e) { 467 log.severe("Server error: " + e.getMessage()); 468 log.throwing(getClass().getName(), "countPrincipals", e); 469 throw e; 470 } catch (ServerException e) { 471 log.severe("Server error: " + e.getMessage()); 472 log.throwing(getClass().getName(), "countPrincipals", e); 473 throw e; 474 } catch (Exception e) { 475 log.severe("Server error: " + e.getMessage()); 476 log.throwing(getClass().getName(), "countPrincipals", e); 477 throw new ServerException(e.getMessage(), e); 478 } 479 } 480 481 491 public Sync4jSource[] getSync4jSources(String clauses) 492 throws ServerException, AdminException { 493 try { 494 return admin.getSync4jSources((Clause)BeanFactory.unmarshal(clauses)); 495 } catch (AdminException e) { 496 log.severe("Server error: " + e.getMessage()); 497 log.throwing(getClass().getName(), "getSync4jSources", e); 498 throw e; 499 } catch (ServerException e) { 500 log.severe("Server error: " + e.getMessage()); 501 log.throwing(getClass().getName(), "getSync4jSources", e); 502 throw e; 503 } catch (Exception e) { 504 log.severe("Server error: " + e.getMessage()); 505 log.throwing(getClass().getName(), "getSync4jSources", e); 506 throw new ServerException(e.getMessage(), e); 507 } 508 } 509 510 518 public Sync4jModule[] getModulesName() 519 throws ServerException, AdminException { 520 try { 521 return admin.getModulesName(); 522 } catch (AdminException e) { 523 log.severe("Server error: " + e.getMessage()); 524 log.throwing(getClass().getName(), "getModulesName", e); 525 throw e; 526 } catch (ServerException e) { 527 log.severe("Server error: " + e.getMessage()); 528 log.throwing(getClass().getName(), "getModulesName", e); 529 throw e; 530 } catch (Exception e) { 531 log.severe("Server error: " + e.getMessage()); 532 log.throwing(getClass().getName(), "getModulesName", e); 533 throw new ServerException(e.getMessage(), e); 534 } 535 } 536 537 547 public String getModule(String moduleId) 548 throws ServerException, AdminException { 549 try { 550 return BeanFactory.marshal(admin.getModule(moduleId)); 551 } catch (AdminException e) { 552 log.severe("Server error: " + e.getMessage()); 553 log.throwing(getClass().getName(), "getModule", e); 554 throw e; 555 } catch (ServerException e) { 556 log.severe("Server error: " + e.getMessage()); 557 log.throwing(getClass().getName(), "getModule", e); 558 throw e; 559 } catch (Exception e) { 560 log.severe("Server error: " + e.getMessage()); 561 log.throwing(getClass().getName(), "getModule", e); 562 throw new ServerException(e.getMessage(), e); 563 } 564 } 565 566 580 public void addSource(String moduleId, String connectorId, String sourceTypeId, String source) 581 throws ServerException, AdminException { 582 try { 583 admin.addSource(moduleId, connectorId, sourceTypeId, (SyncSource)BeanFactory.unmarshal(source)); 584 } catch (AdminException e) { 585 log.severe("Server error: " + e.getMessage()); 586 log.throwing(getClass().getName(), "addSource", e); 587 throw e; 588 } catch (ServerException e) { 589 log.severe("Server error: " + e.getMessage()); 590 log.throwing(getClass().getName(), "addSource", e); 591 throw e; 592 } catch (Exception e) { 593 log.severe("Server error: " + e.getMessage()); 594 log.throwing(getClass().getName(), "addSource", e); 595 throw new ServerException(e.getMessage(), e); 596 } 597 } 598 599 613 public void setSource(String moduleId, String connectorId, String sourceTypeId, String source) 614 throws ServerException, AdminException{ 615 try { 616 admin.setSource(moduleId, connectorId, sourceTypeId, (SyncSource)BeanFactory.unmarshal(source)); 617 } catch (AdminException e) { 618 log.severe("Server error: " + e.getMessage()); 619 log.throwing(getClass().getName(), "setSource", e); 620 throw e; 621 } catch (ServerException e) { 622 log.severe("Server error: " + e.getMessage()); 623 log.throwing(getClass().getName(), "setSource", e); 624 throw e; 625 } catch (Exception e) { 626 log.severe("Server error: " + e.getMessage()); 627 log.throwing(getClass().getName(), "setSource", e); 628 throw new ServerException(e.getMessage(), e); 629 } 630 } 631 632 640 public void deleteSource(String sourceUri) 641 throws ServerException, AdminException { 642 try { 643 admin.deleteSource(sourceUri); 644 } catch (AdminException e) { 645 log.severe("Server error: " + e.getMessage()); 646 log.throwing(getClass().getName(), "deleteSource", e); 647 throw e; 648 } catch (ServerException e) { 649 log.severe("Server error: " + e.getMessage()); 650 log.throwing(getClass().getName(), "deleteSource", e); 651 throw e; 652 } catch (Exception e) { 653 log.severe("Server error: " + e.getMessage()); 654 log.throwing(getClass().getName(), "deleteSource", e); 655 throw new ServerException(e.getMessage(), e); 656 } 657 } 658 659 667 public LoggingConfiguration getLoggingConfiguration() 668 throws ServerException, AdminException { 669 try { 670 return admin.getLoggingConfiguration(); 671 } catch (AdminException e) { 672 log.severe("Server error: " + e.getMessage()); 673 log.throwing(getClass().getName(), "getLoggingConfiguration", e); 674 throw e; 675 } catch (ServerException e) { 676 log.severe("Server error: " + e.getMessage()); 677 log.throwing(getClass().getName(), "getLoggingConfiguration", e); 678 throw e; 679 } catch (Exception e) { 680 log.severe("Server error: " + e.getMessage()); 681 log.throwing(getClass().getName(), "getLoggingConfiguration", e); 682 throw new ServerException(e.getMessage(), e); 683 } 684 } 685 686 694 public void setLoggingConfiguration(LoggingConfiguration config) 695 throws ServerException, AdminException { 696 try { 697 admin.setLoggingConfiguration(config); 698 } catch (AdminException e) { 699 log.severe("Server error: " + e.getMessage()); 700 log.throwing(getClass().getName(), "setLoggingConfiguration", e); 701 throw e; 702 } catch (ServerException e) { 703 log.severe("Server error: " + e.getMessage()); 704 log.throwing(getClass().getName(), "setLoggingConfiguration", e); 705 throw e; 706 } catch (Exception e) { 707 log.severe("Server error: " + e.getMessage()); 708 log.throwing(getClass().getName(), "setLoggingConfiguration", e); 709 throw new ServerException(e.getMessage(), e); 710 } 711 } 712 713 721 public ServerConfiguration getServerConfiguration() 722 throws ServerException, AdminException { 723 try { 724 return admin.getServerConfiguration(); 725 } catch (AdminException e) { 726 log.severe("Server error: " + e.getMessage()); 727 log.throwing(getClass().getName(), "getServerConfiguration", e); 728 throw e; 729 } catch (ServerException e) { 730 log.severe("Server error: " + e.getMessage()); 731 log.throwing(getClass().getName(), "getServerConfiguration", e); 732 throw e; 733 } catch (Exception e) { 734 log.severe("Server error: " + e.getMessage()); 735 log.throwing(getClass().getName(), "getServerConfiguration", e); 736 throw new ServerException(e.getMessage(), e); 737 } 738 } 739 740 748 public void setServerConfiguration(ServerConfiguration config) 749 throws ServerException, AdminException { 750 try { 751 admin.setServerConfiguration(config); 752 } catch (AdminException e) { 753 log.severe("Server error: " + e.getMessage()); 754 log.throwing(getClass().getName(), "setServerConfiguration", e); 755 throw e; 756 } catch (ServerException e) { 757 log.severe("Server error: " + e.getMessage()); 758 log.throwing(getClass().getName(), "setServerConfiguration", e); 759 throw e; 760 } catch (Exception e) { 761 log.severe("Server error: " + e.getMessage()); 762 log.throwing(getClass().getName(), "setServerConfiguration", e); 763 throw new ServerException(e.getMessage(), e); 764 } 765 } 766 767 768 778 public void login(String username) { 779 if (log.isLoggable(Level.INFO)) { 780 log.info("New administrative session for " + username); 781 } 782 } 783 784 790 public String getServerVersion(String version) { 791 return admin.getServerVersion(); 792 } 793 794 802 public String getServerBean(String bean) 803 throws ServerException, AdminException { 804 try { 805 return BeanFactory.marshal(admin.getServerBean(bean)); 806 } catch (AdminException e) { 807 log.severe("Server error: " + e.getMessage()); 808 log.throwing(getClass().getName(), "getServerBean", e); 809 throw e; 810 } catch (ServerException e) { 811 log.severe("Server error: " + e.getMessage()); 812 log.throwing(getClass().getName(), "getServerBean", e); 813 throw e; 814 } catch (Exception e) { 815 log.severe("Server error: " + e.getMessage()); 816 log.throwing(getClass().getName(), "getServerBean", e); 817 throw new ServerException(e.getMessage(), e); 818 } 819 820 } 821 822 830 public void setServerBean(String bean, String obj) 831 throws ServerException, AdminException { 832 try { 833 admin.setServerBean(bean, BeanFactory.unmarshal(obj)); 834 } catch (AdminException e) { 835 log.severe("Server error: " + e.getMessage()); 836 log.throwing(getClass().getName(), "setServerBean", e); 837 throw e; 838 } catch (ServerException e) { 839 log.severe("Server error: " + e.getMessage()); 840 log.throwing(getClass().getName(), "setServerBean", e); 841 throw e; 842 } catch (Exception e) { 843 log.severe("Server error: " + e.getMessage()); 844 log.throwing(getClass().getName(), "setServerBean", e); 845 throw new ServerException(e.getMessage(), e); 846 } 847 } 848 849 } 851 852 | Popular Tags |