1 54 55 package org.apache.jetspeed.services.cms.repository.slide; 56 57 import java.lang.reflect.Constructor ; 59 import java.util.Hashtable ; 60 import java.util.Enumeration ; 61 import java.util.Vector ; 62 import java.util.List ; 63 import java.util.Iterator ; 64 import java.util.Date ; 65 66 import org.apache.slide.common.AbstractSimpleService; 68 import org.apache.slide.common.ServiceConnectionFailedException; 69 import org.apache.slide.common.ServiceDisconnectionFailedException; 70 import org.apache.slide.common.NamespaceAccessToken; 71 import org.apache.slide.common.ServiceInitializationFailedException; 72 import org.apache.slide.common.ServiceResetFailedException; 73 import org.apache.slide.common.ServiceAccessException; 74 import org.apache.slide.common.Uri; 75 import org.apache.slide.common.ServiceParameterErrorException; 76 import org.apache.slide.common.ServiceParameterMissingException; 77 78 import org.apache.slide.store.LockStore; 79 import org.apache.slide.store.NodeStore; 80 import org.apache.slide.store.RevisionDescriptorsStore; 81 import org.apache.slide.store.RevisionDescriptorStore; 82 import org.apache.slide.store.SecurityStore; 83 84 import org.apache.slide.structure.ObjectNode; 85 import org.apache.slide.structure.ObjectNotFoundException; 86 import org.apache.slide.structure.ObjectAlreadyExistsException; 87 88 import org.apache.slide.security.NodePermission; 89 90 import org.apache.slide.lock.NodeLock; 91 import org.apache.slide.lock.LockTokenNotFoundException; 92 93 import org.apache.slide.content.NodeRevisionDescriptors; 94 import org.apache.slide.content.NodeRevisionDescriptor; 95 import org.apache.slide.content.RevisionContentNotFoundException; 96 import org.apache.slide.content.RevisionDescriptorNotFoundException; 97 import org.apache.slide.content.NodeRevisionNumber; 98 99 import javax.transaction.xa.XAException ; 100 import javax.transaction.xa.Xid ; 101 102 104 import org.apache.torque.util.Criteria; 105 import org.apache.turbine.services.TurbineServices; 106 import org.apache.turbine.util.Log; 107 108 109 import org.apache.jetspeed.services.security.JetspeedSecurityService; 111 import org.apache.jetspeed.services.security.GroupManagement; 112 import org.apache.jetspeed.om.security.turbine.TurbineUserGroupRole; 113 import org.apache.jetspeed.om.security.turbine.TurbineUserGroupRolePeer; 114 import org.apache.jetspeed.om.security.turbine.TurbineUserPeer; 115 import org.apache.jetspeed.om.security.turbine.TurbineUser; 116 import org.apache.jetspeed.om.security.turbine.TurbineGroup; 117 import org.apache.jetspeed.om.security.turbine.TurbineGroupPeer; 118 import org.apache.jetspeed.om.security.Group; 119 import org.apache.jetspeed.om.security.JetspeedUser; 120 121 122 136 public class JetspeedDescriptorsStore 137 extends AbstractSimpleService 138 implements 139 LockStore, 140 NodeStore, 141 RevisionDescriptorsStore, 142 RevisionDescriptorStore, 143 SecurityStore 144 { 145 146 148 protected static final int OBJECTS_URI = 1; 149 protected static final int OBJECTS_CLASS = 2; 150 151 protected static final int CHILDREN_URI = 1; 152 protected static final int CHILDREN_CHILDURI = 2; 153 154 protected static final int LINKS_LINK = 1; 155 protected static final int LINKS_LINKTO = 2; 156 157 159 protected static final int PERMISSIONS_OBJECT = 1; 160 protected static final int PERMISSIONS_REVISION_NUMBER = 2; 161 protected static final int PERMISSIONS_SUBJECT = 3; 162 protected static final int PERMISSIONS_ACTION = 4; 163 protected static final int PERMISSIONS_INHERITABLE = 5; 164 protected static final int PERMISSIONS_NEGATIVE = 6; 165 166 168 protected static final int LOCKS_ID = 1; 169 protected static final int LOCKS_OBJECT = 2; 170 protected static final int LOCKS_SUBJECT = 3; 171 protected static final int LOCKS_TYPE = 4; 172 protected static final int LOCKS_EXPIRATIONDATE = 5; 173 protected static final int LOCKS_INHERITABLE = 6; 174 protected static final int LOCKS_EXCLUSIVE = 7; 175 176 178 protected static final int REVISIONS_URI = 1; 179 protected static final int REVISIONS_ISVERSIONED = 2; 180 protected static final int REVISIONS_INITIALREVISION = 3; 181 182 protected static final int WORKINGREVISION_URI = 1; 183 protected static final int WORKINGREVISION_BASEREVISION = 2; 184 protected static final int WORKINGREVISION_NUMBER = 3; 185 186 protected static final int LATESTREVISIONS_URI = 1; 187 protected static final int LATESTREVISIONS_BRANCHNAME = 2; 188 protected static final int LATESTREVISIONS_NUMBER = 3; 189 190 protected static final int BRANCHES_URI = 1; 191 protected static final int BRANCHES_NUMBER = 2; 192 protected static final int BRANCHES_CHILDNUMBER = 3; 193 194 protected static final int REVISION_URI = 1; 195 protected static final int REVISION_NUMBER = 2; 196 protected static final int REVISION_BRANCHNAME = 3; 197 198 protected static final int LABEL_URI = 1; 199 protected static final int LABEL_NUMBER = 2; 200 protected static final int LABEL_LABEL = 3; 201 202 protected static final int PROPERTY_URI = 1; 203 protected static final int PROPERTY_NUMBER = 2; 204 protected static final int PROPERTY_NAME = 3; 205 protected static final int PROPERTY_VALUE = 4; 206 protected static final int PROPERTY_NAMESPACE = 5; 207 protected static final int PROPERTY_TYPE = 6; 208 protected static final int PROPERTY_PROTECTED = 7; 209 210 211 213 220 public ObjectNode retrieveObject(Uri uri) 221 throws ServiceAccessException, ObjectNotFoundException 222 { 223 224 ObjectNode result = null; 225 226 try 227 { 228 if (uri.getParentUri() 230 .toString() 231 .equals(Utility.getGroupParentUri())) 232 { 233 String groupName = uri.toString().substring(uri.toString().lastIndexOf('/') + 1); 234 GroupManagement groupService = (GroupManagement)TurbineServices.getInstance() 235 .getService("GroupManagement"); 236 237 Criteria criteria = new Criteria(); 238 criteria.addJoin( 239 TurbineGroupPeer.GROUP_ID, 240 TurbineUserGroupRolePeer.GROUP_ID); 241 criteria.addJoin( 242 TurbineUserGroupRolePeer.USER_ID, 243 TurbineUserPeer.USER_ID); 244 criteria.add(TurbineGroupPeer.GROUP_NAME, groupName); 245 criteria.setDistinct(); 246 List users = TurbineUserPeer.doSelectUsers(criteria); 247 248 if (Log.getLogger().isDebugEnabled()) 249 { 250 Log.debug("TurbineDescriptorStore - Group size : " + users.size()); 251 } 252 Vector childrenVector = new Vector (); 253 Vector linksVector = new Vector (); 254 255 Iterator iterator = users.iterator(); 257 while (iterator.hasNext()) 258 { 259 JetspeedUser user = (JetspeedUser)iterator.next(); 260 childrenVector.addElement( 261 Utility.getUserParentUri() + "/" + user.getUserName()); 262 } 263 264 Class objclass = 265 Class.forName("org.apache.slide.structure.GroupNode"); 266 267 Class [] argClasses = 268 { 269 Class.forName("java.lang.String"), 270 Class.forName("java.util.Vector"), 271 Class.forName("java.util.Vector") 272 }; 273 Object [] arguments = 274 { 275 uri.toString(), 276 childrenVector, 277 linksVector 278 }; 279 280 Constructor constructor = objclass.getConstructor(argClasses); 281 282 result = (ObjectNode)constructor.newInstance(arguments); 283 284 } 286 else if (uri.getParentUri() 287 .toString() 288 .equals(Utility.getUserParentUri())) 289 { 290 291 String userName = 293 uri.toString().substring( 294 uri.toString().lastIndexOf('/') + 1); 295 296 JetspeedSecurityService service = (JetspeedSecurityService) TurbineServices.getInstance(). 297 getService(JetspeedSecurityService.SERVICE_NAME); 298 JetspeedUser user = service.getUser(userName); 299 300 Vector childrenVector = new Vector (); 302 Vector linksVector = new Vector (); 303 304 Class objclass = Class.forName("slideroles.basic.UserRoleImpl"); 305 306 Class [] argClasses = 307 { 308 Class.forName("java.lang.String"), 309 Class.forName("java.util.Vector"), 310 Class.forName("java.util.Vector") 311 }; 312 Object [] arguments = 313 { 314 uri.toString(), 315 childrenVector, 316 linksVector 317 }; 318 Constructor constructor = objclass.getConstructor(argClasses); 319 result = (ObjectNode)constructor.newInstance(arguments); 320 } 321 else 322 { 323 Vector childrenVector = new Vector (); 327 Vector linksVector = new Vector (); 328 329 Class objclass = Class.forName("slideroles.basic.UserRoleImpl"); 330 331 Class [] argClasses = 332 { 333 Class.forName("java.lang.String"), 334 Class.forName("java.util.Vector"), 335 Class.forName("java.util.Vector") 336 }; 337 Object [] arguments = 338 { 339 uri.toString(), 340 childrenVector, 341 linksVector 342 }; 343 Constructor constructor = objclass.getConstructor(argClasses); 344 result = (ObjectNode)constructor.newInstance(arguments); 345 } 346 } 347 catch (Exception e) 348 { 349 e.printStackTrace(); 352 throw new ObjectNotFoundException(uri); 353 } 354 355 return result; 356 } 357 358 363 364 365 366 368 376 385 391 public synchronized void connect() throws ServiceConnectionFailedException 392 { 393 if (Log.getLogger().isDebugEnabled()) 394 { 395 Log.debug("TurbineDescriptorStore - connect"); 396 } 397 } 398 399 405 public void disconnect() throws ServiceDisconnectionFailedException 406 { 407 if (Log.getLogger().isDebugEnabled()) 408 { 409 Log.debug("TurbineDescriptorStore - disconnect"); 410 } 411 } 412 413 425 public synchronized void initialize(NamespaceAccessToken token) 426 throws ServiceInitializationFailedException 427 { 428 if (Log.getLogger().isDebugEnabled()) 429 { 430 Log.debug("TurbineDescriptorStore - initialize"); 431 } 432 } 433 434 439 public synchronized void reset() throws ServiceResetFailedException 440 { 441 if (Log.getLogger().isDebugEnabled()) 442 { 443 Log.debug("TurbineDescriptorStore - reset"); 444 } 445 } 446 447 453 public boolean isConnected() throws ServiceAccessException 454 { 455 if (Log.getLogger().isDebugEnabled()) 456 { 457 Log.debug("TurbineDescriptorStore - isConnected : true"); 458 } 459 460 return true; 461 } 462 463 465 468 public void commit(Xid xid, boolean onePhase) throws XAException 469 { 470 if (Log.getLogger().isDebugEnabled()) 471 { 472 Log.debug("TurbineDescriptorStore - commit"); 473 } 474 475 489 } 490 491 495 public void rollback(Xid xid) throws XAException 496 { 497 if (Log.getLogger().isDebugEnabled()) 498 { 499 Log.debug("TurbineDescriptorStore - rollback"); 500 } 501 516 } 517 518 521 public void start(Xid xid, int flags) throws XAException 522 { 523 if (Log.getLogger().isDebugEnabled()) 524 { 525 Log.debug("TurbineDescriptorStore - start"); 526 } 527 539 } 540 541 548 public void storeObject(Uri uri, ObjectNode object) 549 throws ServiceAccessException, ObjectNotFoundException 550 { 551 if (Log.getLogger().isDebugEnabled()) 552 { 553 Log.debug("TurbineDescriptorStore - storeObject :" + uri); 554 } 555 } 556 557 566 public void createObject(Uri uri, ObjectNode object) 567 throws ServiceAccessException, ObjectAlreadyExistsException 568 { 569 if (Log.getLogger().isDebugEnabled()) 570 { 571 Log.debug("TurbineDescriptorStore - createObject :" + uri); 572 } 573 } 574 575 582 public void removeObject(Uri uri, ObjectNode object) 583 throws ServiceAccessException, ObjectNotFoundException 584 { 585 if (Log.getLogger().isDebugEnabled()) 586 { 587 Log.debug("TurbineDescriptorStore - removeObject"); 588 } 589 } 590 591 597 public void grantPermission(Uri uri, NodePermission permission) 598 throws ServiceAccessException 599 { 600 if (Log.getLogger().isDebugEnabled()) 601 { 602 Log.debug("TurbineDescriptorStore - grantPermission"); 603 } 604 } 605 606 612 public void revokePermission(Uri uri, NodePermission permission) 613 throws ServiceAccessException 614 { 615 if (Log.getLogger().isDebugEnabled()) 616 { 617 Log.debug("TurbineDescriptorStore - revokePermission"); 618 } 619 } 620 621 627 public void revokePermissions(Uri uri) throws ServiceAccessException 628 { 629 if (Log.getLogger().isDebugEnabled()) 630 { 631 Log.debug("TurbineDescriptorStore - revokePermission"); 632 } 633 } 634 635 641 public Enumeration enumeratePermissions(Uri uri) 642 throws ServiceAccessException 643 { 644 if (Log.getLogger().isDebugEnabled()) 646 { 647 Log.debug("TurbineDescriptorStore - enumeratePermission : " + uri); 648 } 649 660 return null; 661 } 662 663 669 public void putLock(Uri uri, NodeLock lock) throws ServiceAccessException 670 { 671 if (Log.getLogger().isDebugEnabled()) 672 { 673 Log.debug("TurbineDescriptorStore - putLock"); 674 } 675 } 676 677 684 public void renewLock(Uri uri, NodeLock lock) 685 throws ServiceAccessException, LockTokenNotFoundException 686 { 687 if (Log.getLogger().isDebugEnabled()) 688 { 689 Log.debug("TurbineDescriptorStore - renewLock"); 690 } 691 } 692 693 700 public void removeLock(Uri uri, NodeLock lock) 701 throws ServiceAccessException, LockTokenNotFoundException 702 { 703 if (Log.getLogger().isDebugEnabled()) 704 { 705 Log.debug("TurbineDescriptorStore - removeLock"); 706 } 707 } 708 709 716 public void killLock(Uri uri, NodeLock lock) 717 throws ServiceAccessException, LockTokenNotFoundException 718 { 719 if (Log.getLogger().isDebugEnabled()) 720 { 721 Log.debug("TurbineDescriptorStore - KillLock"); 722 } 723 } 724 725 732 public Enumeration enumerateLocks(Uri uri) throws ServiceAccessException 733 { 734 if (Log.getLogger().isDebugEnabled()) 735 { 736 Log.debug("TurbineDescriptorStore - enumerateLocks : " + uri); 737 } 738 739 return new Vector ().elements(); 740 } 741 742 750 public NodeRevisionDescriptors retrieveRevisionDescriptors(Uri uri) 751 throws ServiceAccessException, RevisionDescriptorNotFoundException 752 { 753 if (Log.getLogger().isDebugEnabled()) 754 { 755 Log.debug("TurbineDescriptorStore - retrieveRevisionDescriptor"); 756 } 757 758 return null; 759 } 760 761 768 public void createRevisionDescriptors( 769 Uri uri, 770 NodeRevisionDescriptors revisionDescriptors) 771 throws ServiceAccessException 772 { 773 if (Log.getLogger().isDebugEnabled()) 774 { 775 Log.debug("TurbineDescriptorStore - createRevisionDescriptors"); 776 } 777 } 778 779 788 public void storeRevisionDescriptors( 789 Uri uri, 790 NodeRevisionDescriptors revisionDescriptors) 791 throws ServiceAccessException, RevisionDescriptorNotFoundException 792 { 793 if (Log.getLogger().isDebugEnabled()) 794 { 795 Log.debug("TurbineDescriptorStore - storeRevisionDescriptors"); 796 } 797 } 798 799 805 public void removeRevisionDescriptors(Uri uri) 806 throws ServiceAccessException 807 { 808 if (Log.getLogger().isDebugEnabled()) 809 { 810 Log.debug("TurbineDescriptorStore - removeRevisionDescriptors"); 811 } 812 } 813 814 820 public NodeRevisionDescriptor retrieveRevisionDescriptor( 821 Uri uri, 822 NodeRevisionNumber revisionNumber) 823 throws ServiceAccessException, RevisionDescriptorNotFoundException 824 { 825 if (Log.getLogger().isDebugEnabled()) 826 { 827 Log.debug("TurbineDescriptorStore - retrieveRevisionDescriptor"); 828 } 829 830 return null; 831 } 832 833 840 public void createRevisionDescriptor( 841 Uri uri, 842 NodeRevisionDescriptor revisionDescriptor) 843 throws ServiceAccessException 844 { 845 if (Log.getLogger().isDebugEnabled()) 846 { 847 Log.debug("TurbineDescriptorStore - createRevisionDescriptor"); 848 } 849 850 return; 851 } 852 853 862 public void storeRevisionDescriptor( 863 Uri uri, 864 NodeRevisionDescriptor revisionDescriptor) 865 throws ServiceAccessException, RevisionDescriptorNotFoundException 866 { 867 if (Log.getLogger().isDebugEnabled()) 868 { 869 Log.debug("TurbineDescriptorStore - storeRevisionDescriptor"); 870 } 871 } 872 873 880 public void removeRevisionDescriptor(Uri uri, NodeRevisionNumber number) 881 throws ServiceAccessException 882 { 883 if (Log.getLogger().isDebugEnabled()) 884 { 885 Log.debug("TurbineDescriptorStore - removeRevisionDescriptor"); 886 } 887 } 888 889 897 public void setParameters(Hashtable parameters) 898 throws ServiceParameterErrorException, ServiceParameterMissingException 899 { 900 if (Log.getLogger().isDebugEnabled()) 901 { 902 Log.debug("TurbineDescriptorStore - setParamters"); 903 } 904 } 905 } 906 | Popular Tags |