1 31 32 package org.opencms.db; 33 34 import org.opencms.configuration.CmsConfigurationManager; 35 import org.opencms.configuration.CmsSystemConfiguration; 36 import org.opencms.file.CmsBackupProject; 37 import org.opencms.file.CmsBackupResource; 38 import org.opencms.file.CmsFile; 39 import org.opencms.file.CmsFolder; 40 import org.opencms.file.CmsGroup; 41 import org.opencms.file.CmsObject; 42 import org.opencms.file.CmsProject; 43 import org.opencms.file.CmsProperty; 44 import org.opencms.file.CmsPropertyDefinition; 45 import org.opencms.file.CmsRequestContext; 46 import org.opencms.file.CmsResource; 47 import org.opencms.file.CmsResourceFilter; 48 import org.opencms.file.CmsUser; 49 import org.opencms.file.CmsVfsException; 50 import org.opencms.file.CmsVfsResourceNotFoundException; 51 import org.opencms.file.types.CmsResourceTypeJsp; 52 import org.opencms.i18n.CmsMessageContainer; 53 import org.opencms.lock.CmsLock; 54 import org.opencms.lock.CmsLockException; 55 import org.opencms.main.CmsException; 56 import org.opencms.main.CmsInitException; 57 import org.opencms.main.CmsLog; 58 import org.opencms.main.CmsMultiException; 59 import org.opencms.main.OpenCms; 60 import org.opencms.report.I_CmsReport; 61 import org.opencms.security.CmsAccessControlEntry; 62 import org.opencms.security.CmsAccessControlList; 63 import org.opencms.security.CmsPermissionSet; 64 import org.opencms.security.CmsPermissionSetCustom; 65 import org.opencms.security.CmsPermissionViolationException; 66 import org.opencms.security.CmsRole; 67 import org.opencms.security.CmsRoleViolationException; 68 import org.opencms.security.CmsSecurityException; 69 import org.opencms.security.I_CmsPrincipal; 70 import org.opencms.util.CmsFileUtil; 71 import org.opencms.util.CmsStringUtil; 72 import org.opencms.util.CmsUUID; 73 import org.opencms.workflow.CmsTask; 74 import org.opencms.workflow.CmsTaskLog; 75 76 import java.util.ArrayList ; 77 import java.util.Collections ; 78 import java.util.Date ; 79 import java.util.Iterator ; 80 import java.util.List ; 81 import java.util.Map ; 82 import java.util.Set ; 83 import java.util.regex.Pattern ; 84 import java.util.regex.PatternSyntaxException ; 85 86 import org.apache.commons.collections.map.LRUMap; 87 import org.apache.commons.logging.Log; 88 89 100 public final class CmsSecurityManager { 101 102 103 public static final int PERM_ALLOWED = 0; 104 105 106 public static final int PERM_DENIED = 1; 107 108 109 public static final int PERM_FILTERED = 2; 110 111 112 public static final int PERM_NOTLOCKED = 3; 113 114 115 private static final Log LOG = CmsLog.getLog(CmsSecurityManager.class); 116 117 118 private static final Integer PERM_ALLOWED_INTEGER = new Integer (PERM_ALLOWED); 119 120 121 private static final Integer PERM_DENIED_INTEGER = new Integer (PERM_DENIED); 122 123 124 protected I_CmsDbContextFactory m_dbContextFactory; 125 126 127 protected CmsDriverManager m_driverManager; 128 129 130 private I_CmsCacheKey m_keyGenerator; 131 132 133 private Map m_permissionCache; 134 135 138 private CmsSecurityManager() { 139 140 } 142 143 153 public static CmsSecurityManager newInstance( 154 CmsConfigurationManager configurationManager, 155 I_CmsDbContextFactory runtimeInfoFactory) throws CmsInitException { 156 157 if (OpenCms.getRunLevel() > OpenCms.RUNLEVEL_2_INITIALIZING) { 158 throw new CmsInitException(org.opencms.main.Messages.get().container( 160 org.opencms.main.Messages.ERR_ALREADY_INITIALIZED_0)); 161 } 162 163 CmsSecurityManager securityManager = new CmsSecurityManager(); 164 securityManager.init(configurationManager, runtimeInfoFactory); 165 166 return securityManager; 167 } 168 169 177 public void acceptTask(CmsRequestContext context, int taskId) throws CmsException { 178 179 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 180 try { 181 m_driverManager.acceptTask(dbc, taskId); 182 } catch (Exception e) { 183 dbc.report(null, Messages.get().container(Messages.ERR_ACCEPT_TASK_1, new Integer (taskId)), e); 184 } finally { 185 dbc.clear(); 186 } 187 } 188 189 198 public void addUserToGroup(CmsRequestContext context, String username, String groupname) throws CmsException { 199 200 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 201 try { 202 checkRole(dbc, CmsRole.ACCOUNT_MANAGER); 203 m_driverManager.addUserToGroup(dbc, username, groupname); 204 } catch (Exception e) { 205 dbc.report(null, Messages.get().container(Messages.ERR_ADD_USER_GROUP_FAILED_2, username, groupname), e); 206 } finally { 207 dbc.clear(); 208 } 209 } 210 211 231 public CmsUser addWebUser( 232 CmsRequestContext context, 233 String name, 234 String password, 235 String group, 236 String description, 237 Map additionalInfos) throws CmsException { 238 239 CmsUser result = null; 240 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 241 try { 242 result = m_driverManager.addWebUser(dbc, name, password, group, description, additionalInfos); 243 } catch (Exception e) { 244 dbc.report(null, Messages.get().container(Messages.ERR_ADD_USER_WEB_1, name), e); 245 } finally { 246 dbc.clear(); 247 } 248 return result; 249 } 250 251 268 public CmsUser addWebUser( 269 CmsRequestContext context, 270 String name, 271 String password, 272 String group, 273 String additionalGroup, 274 String description, 275 Map additionalInfos) throws CmsException { 276 277 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 278 CmsUser result = null; 279 try { 280 result = m_driverManager.addWebUser( 281 dbc, 282 name, 283 password, 284 group, 285 additionalGroup, 286 description, 287 additionalInfos); 288 } catch (Exception e) { 289 dbc.report(null, Messages.get().container(Messages.ERR_ADD_USER_WEB_1, name), e); 290 } finally { 291 dbc.clear(); 292 } 293 return result; 294 } 295 296 305 public void backupProject(CmsRequestContext context, int tagId, long publishDate) throws CmsException { 306 307 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 308 try { 309 m_driverManager.backupProject(dbc, tagId, publishDate); 310 } catch (Exception e) { 311 dbc.report(null, Messages.get().container( 312 Messages.ERR_BACKUP_PROJECT_4, 313 new Object [] { 314 new Integer (tagId), 315 dbc.currentProject().getName(), 316 new Integer (dbc.currentProject().getId()), 317 new Long (publishDate)}), e); 318 } finally { 319 dbc.clear(); 320 } 321 } 322 323 332 public void changeLastModifiedProjectId(CmsRequestContext context, CmsResource resource) throws CmsException { 333 334 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 335 try { 336 checkOfflineProject(dbc); 337 checkPermissions(dbc, resource, CmsPermissionSet.ACCESS_WRITE, true, CmsResourceFilter.ALL); 338 m_driverManager.changeLastModifiedProjectId(dbc, resource); 339 } catch (Exception e) { 340 dbc.report(null, Messages.get().container( 341 Messages.ERR_CHANGE_LAST_MODIFIED_RESOURCE_IN_PROJECT_1, 342 context.getSitePath(resource)), e); 343 } finally { 344 dbc.clear(); 345 } 346 347 } 348 349 357 public void changeLock(CmsRequestContext context, CmsResource resource) throws CmsException { 358 359 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 360 checkOfflineProject(dbc); 361 try { 362 m_driverManager.changeLock(dbc, resource); 363 } catch (Exception e) { 364 dbc.report(null, Messages.get().container( 365 Messages.ERR_CHANGE_LOCK_OF_RESOURCE_1, 366 context.getSitePath(resource)), e); 367 } finally { 368 dbc.clear(); 369 } 370 } 371 372 388 public synchronized List changeResourcesInFolderWithProperty( 389 CmsRequestContext context, 390 CmsResource resource, 391 String propertyDefinition, 392 String oldValue, 393 String newValue, 394 boolean recursive) throws CmsException, CmsVfsException { 395 396 int todo = 0; 397 399 List resources = new ArrayList (); 401 if (recursive) { 402 resources = readResourcesWithProperty(context, resource.getRootPath(), propertyDefinition); 403 } else { 404 resources.add(resource); 405 } 406 407 Pattern oldPattern; 408 try { 409 oldPattern = Pattern.compile(oldValue); 411 } catch (PatternSyntaxException e) { 412 throw new CmsVfsException(Messages.get().container( 413 Messages.ERR_CHANGE_RESOURCES_IN_FOLDER_WITH_PROP_4, 414 new Object [] {propertyDefinition, oldValue, newValue, context.getSitePath(resource)}), e); 415 } 416 417 List changedResources = new ArrayList (resources.size()); 418 CmsPermissionSet perm = CmsPermissionSet.ACCESS_WRITE; 420 CmsResourceFilter filter = CmsResourceFilter.IGNORE_EXPIRATION; 421 for (int i = 0; i < resources.size(); i++) { 422 CmsResource res = (CmsResource)resources.get(i); 424 try { 426 checkPermissions(context, res, perm, true, filter); 427 } catch (Exception e) { 428 continue; 430 } 431 CmsProperty property = readPropertyObject(context, res, propertyDefinition, false); 432 String structureValue = property.getStructureValue(); 433 String resourceValue = property.getResourceValue(); 434 boolean changed = false; 435 if (structureValue != null && oldPattern.matcher(structureValue).matches()) { 436 property.setStructureValue(newValue); 438 changed = true; 439 } 440 if (resourceValue != null && oldPattern.matcher(resourceValue).matches()) { 441 property.setResourceValue(newValue); 443 changed = true; 444 } 445 if (changed) { 446 writePropertyObject(context, res, property); 448 changedResources.add(res); 449 } 450 } 451 return changedResources; 452 } 453 454 463 public void changeUserType(CmsRequestContext context, CmsUUID userId, int userType) throws CmsException { 464 465 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 466 467 try { 468 checkRole(dbc, CmsRole.ACCOUNT_MANAGER); 469 m_driverManager.changeUserType(dbc, userId, userType); 470 } catch (Exception e) { 471 dbc.report(null, Messages.get().container(Messages.ERR_CHANGE_USER_TYPE_WITH_ID_1, userId.toString()), e); 472 } finally { 473 dbc.clear(); 474 } 475 } 476 477 487 public void changeUserType(CmsRequestContext context, String username, int userType) throws CmsException { 488 489 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 490 491 try { 492 checkRole(dbc, CmsRole.ACCOUNT_MANAGER); 493 m_driverManager.changeUserType(dbc, username, userType); 494 } catch (Exception e) { 495 dbc.report(null, Messages.get().container(Messages.ERR_CHANGE_USER_TYPE_WITH_NAME_1, username), e); 496 } finally { 497 dbc.clear(); 498 } 499 } 500 501 509 public void checkManagerOfProjectRole(CmsDbContext dbc, CmsProject project) throws CmsRoleViolationException { 510 511 if (!hasManagerOfProjectRole(dbc, project)) { 512 throw new CmsRoleViolationException(org.opencms.security.Messages.get().container( 513 org.opencms.security.Messages.ERR_NOT_MANAGER_OF_PROJECT_2, 514 dbc.currentUser().getName(), 515 dbc.currentProject().getName())); 516 } 517 } 518 519 530 public void checkOfflineProject(CmsDbContext dbc) throws CmsVfsException { 531 532 if (dbc.currentProject().isOnlineProject()) { 533 throw new CmsVfsException(org.opencms.file.Messages.get().container( 534 org.opencms.file.Messages.ERR_NOT_ALLOWED_IN_ONLINE_PROJECT_0)); 535 } 536 } 537 538 555 public void checkPermissions( 556 CmsRequestContext context, 557 CmsResource resource, 558 CmsPermissionSet requiredPermissions, 559 boolean checkLock, 560 CmsResourceFilter filter) throws CmsException, CmsSecurityException { 561 562 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 563 try { 564 checkPermissions(dbc, resource, requiredPermissions, checkLock, filter); 566 } finally { 567 dbc.clear(); 568 } 569 } 570 571 583 public void checkPublishPermissions(CmsDbContext dbc, CmsPublishList publishList) 584 throws CmsException, CmsMultiException { 585 586 checkOfflineProject(dbc); 588 589 if (dbc.currentProject().getFlags() != CmsProject.PROJECT_STATE_UNLOCKED) { 591 CmsMessageContainer errMsg = org.opencms.security.Messages.get().container( 592 org.opencms.security.Messages.ERR_RESOURCE_LOCKED_1, 593 dbc.currentProject().getName()); 594 throw new CmsLockException(errMsg); 595 } 596 597 if (!publishList.isDirectPublish()) { 599 checkManagerOfProjectRole(dbc, dbc.getRequestContext().currentProject()); 601 } else { 602 CmsMultiException resourceIssues = new CmsMultiException(); 604 CmsMultiException permissionIssues = new CmsMultiException(); 605 Iterator it = publishList.getDirectPublishResources().iterator(); 607 List parentFolders = new ArrayList (); 608 while (it.hasNext()) { 609 CmsResource res = (CmsResource)it.next(); 610 String parentFolder = CmsResource.getParentFolder(res.getRootPath()); 612 if ((parentFolder != null) && !parentFolders.contains(parentFolder)) { 613 CmsResource parent = readResource(dbc, parentFolder, CmsResourceFilter.ALL); 615 if (parent.getState() == CmsResource.STATE_DELETED) { 616 resourceIssues.addException(new CmsVfsException(Messages.get().container( 618 Messages.ERR_DIRECT_PUBLISH_PARENT_DELETED_2, 619 dbc.getRequestContext().removeSiteRoot(res.getRootPath()), 620 parentFolder))); 621 } 622 if (parent.getState() == CmsResource.STATE_NEW) { 623 resourceIssues.addException(new CmsVfsException(Messages.get().container( 625 Messages.ERR_DIRECT_PUBLISH_PARENT_NEW_2, 626 dbc.removeSiteRoot(res.getRootPath()), 627 parentFolder))); 628 } 629 parentFolders.add(parentFolder); 631 } 632 if (PERM_ALLOWED != hasPermissions( 634 dbc.getRequestContext(), 635 res, 636 CmsPermissionSet.ACCESS_DIRECT_PUBLISH, 637 true, 638 CmsResourceFilter.ALL)) { 639 640 permissionIssues.addException(new CmsSecurityException(Messages.get().container( 642 Messages.ERR_DIRECT_PUBLISH_NO_PERMISSIONS_1, 643 dbc.removeSiteRoot(res.getRootPath())))); 644 } 645 } 646 647 if (permissionIssues.hasExceptions()) { 648 if (hasManagerOfProjectRole(dbc, dbc.getRequestContext().currentProject())) { 650 permissionIssues = new CmsMultiException(); 652 } 653 } 654 if (resourceIssues.hasExceptions() || permissionIssues.hasExceptions()) { 655 resourceIssues.addExceptions(permissionIssues.getExceptions()); 657 throw resourceIssues; 658 } 659 } 660 } 662 663 675 public void checkPublishPermissions(CmsRequestContext context, CmsPublishList publishList) 676 throws CmsException, CmsMultiException { 677 678 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 679 try { 680 checkPublishPermissions(dbc, publishList); 682 } finally { 683 dbc.clear(); 684 } 685 } 686 687 696 public void checkRole(CmsDbContext dbc, CmsRole role) throws CmsRoleViolationException { 697 698 if (!hasRole(dbc, role)) { 699 throw role.createRoleViolationException(dbc.getRequestContext()); 700 } 701 } 702 703 712 public void checkRole(CmsRequestContext context, CmsRole role) throws CmsRoleViolationException { 713 714 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 715 try { 716 checkRole(dbc, role); 717 } finally { 718 dbc.clear(); 719 } 720 } 721 722 736 public void chflags(CmsRequestContext context, CmsResource resource, int flags) 737 throws CmsException, CmsSecurityException { 738 739 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 740 try { 741 checkOfflineProject(dbc); 742 checkPermissions(dbc, resource, CmsPermissionSet.ACCESS_WRITE, true, CmsResourceFilter.ALL); 743 m_driverManager.chflags(dbc, resource, flags); 744 } catch (Exception e) { 745 dbc.report(null, Messages.get().container( 746 Messages.ERR_CHANGE_RESOURCE_FLAGS_1, 747 context.getSitePath(resource)), e); 748 } finally { 749 dbc.clear(); 750 } 751 } 752 753 772 public void chtype(CmsRequestContext context, CmsResource resource, int type) 773 throws CmsException, CmsSecurityException { 774 775 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 776 try { 777 checkOfflineProject(dbc); 778 checkPermissions(dbc, resource, CmsPermissionSet.ACCESS_WRITE, true, CmsResourceFilter.ALL); 779 m_driverManager.chtype(dbc, resource, type); 780 } catch (Exception e) { 781 dbc.report(null, Messages.get().container( 782 Messages.ERR_CHANGE_RESOURCE_TYPE_1, 783 context.getSitePath(resource)), e); 784 } finally { 785 dbc.clear(); 786 } 787 } 788 789 801 public void copyAccessControlEntries(CmsRequestContext context, CmsResource source, CmsResource destination) 802 throws CmsException, CmsSecurityException { 803 804 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 805 try { 806 checkOfflineProject(dbc); 807 checkPermissions(dbc, source, CmsPermissionSet.ACCESS_READ, true, CmsResourceFilter.ALL); 808 checkPermissions(dbc, destination, CmsPermissionSet.ACCESS_CONTROL, true, CmsResourceFilter.ALL); 809 m_driverManager.copyAccessControlEntries(dbc, source, destination, true); 810 } catch (Exception e) { 811 CmsRequestContext rc = context; 812 dbc.report(null, Messages.get().container( 813 Messages.ERR_COPY_ACE_2, 814 rc.removeSiteRoot(source.getRootPath()), 815 rc.removeSiteRoot(destination.getRootPath())), e); 816 } finally { 817 dbc.clear(); 818 } 819 } 820 821 853 public void copyResource(CmsRequestContext context, CmsResource source, String destination, int siblingMode) 854 throws CmsException, CmsSecurityException { 855 856 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 857 CmsRequestContext rc = context; 858 try { 859 checkOfflineProject(dbc); 860 checkPermissions(dbc, source, CmsPermissionSet.ACCESS_READ, true, CmsResourceFilter.ALL); 861 m_driverManager.copyResource(dbc, source, destination, siblingMode); 863 } catch (Exception e) { 864 dbc.report(null, Messages.get().container( 865 Messages.ERR_COPY_RESOURCE_2, 866 rc.removeSiteRoot(source.getRootPath()), 867 rc.removeSiteRoot(destination)), e); 868 } finally { 869 dbc.clear(); 870 } 871 } 872 873 882 public void copyResourceToProject(CmsRequestContext context, CmsResource resource) 883 throws CmsException, CmsRoleViolationException { 884 885 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 886 try { 887 checkOfflineProject(dbc); 888 checkManagerOfProjectRole(dbc, context.currentProject()); 889 890 if (dbc.currentProject().getFlags() != CmsProject.PROJECT_STATE_UNLOCKED) { 891 throw new CmsLockException(org.opencms.lock.Messages.get().container( 892 org.opencms.lock.Messages.ERR_RESOURCE_LOCKED_1, 893 dbc.currentProject().getName())); 894 } 895 896 m_driverManager.copyResourceToProject(dbc, resource); 897 } catch (Exception e) { 898 dbc.report(null, Messages.get().container( 899 Messages.ERR_COPY_RESOURCE_TO_PROJECT_2, 900 context.getSitePath(resource), 901 context.currentProject().getName()), e); 902 } finally { 903 dbc.clear(); 904 } 905 } 906 907 918 public int countLockedResources(CmsRequestContext context, int id) throws CmsException, CmsRoleViolationException { 919 920 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 921 CmsProject project = null; 922 int result = 0; 923 try { 924 project = m_driverManager.readProject(dbc, id); 925 checkManagerOfProjectRole(dbc, project); 926 result = m_driverManager.countLockedResources(project); 927 } catch (Exception e) { 928 dbc.report(null, Messages.get().container( 929 Messages.ERR_COUNT_LOCKED_RESOURCES_PROJECT_2, 930 (project == null) ? "<failed to read>" : project.getName(), 931 new Integer (id)), e); 932 } finally { 933 dbc.clear(); 934 } 935 return result; 936 } 937 938 948 public int countLockedResources(CmsRequestContext context, String foldername) throws CmsException { 949 950 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 951 readResource(dbc, foldername, CmsResourceFilter.ALL); 953 int result = 0; 954 try { 955 result = m_driverManager.countLockedResources(dbc, foldername); 956 } catch (Exception e) { 957 dbc.report(null, Messages.get().container(Messages.ERR_COUNT_LOCKED_RESOURCES_FOLDER_1, foldername), e); 958 } finally { 959 dbc.clear(); 960 } 961 return result; 962 } 963 964 979 public CmsGroup createGroup(CmsRequestContext context, String name, String description, int flags, String parent) 980 throws CmsException, CmsRoleViolationException { 981 982 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 983 984 CmsGroup result = null; 985 try { 986 checkRole(dbc, CmsRole.ACCOUNT_MANAGER); 987 result = m_driverManager.createGroup(dbc, new CmsUUID(), name, description, flags, parent); 988 } catch (Exception e) { 989 dbc.report(null, Messages.get().container(Messages.ERR_CREATE_GROUP_1, name), e); 990 } finally { 991 dbc.clear(); 992 } 993 return result; 994 } 995 996 1011 public CmsProject createProject( 1012 CmsRequestContext context, 1013 String name, 1014 String description, 1015 String groupname, 1016 String managergroupname, 1017 int projecttype) throws CmsException, CmsRoleViolationException { 1018 1019 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 1020 1021 CmsProject result = null; 1022 try { 1023 checkRole(dbc, CmsRole.PROJECT_MANAGER); 1024 result = m_driverManager.createProject(dbc, name, description, groupname, managergroupname, projecttype); 1025 } catch (Exception e) { 1026 1027 dbc.report(null, Messages.get().container(Messages.ERR_CREATE_PROJECT_1, name), e); 1028 } finally { 1029 dbc.clear(); 1030 } 1031 return result; 1032 } 1033 1034 1048 public CmsPropertyDefinition createPropertyDefinition(CmsRequestContext context, String name) 1049 throws CmsException, CmsSecurityException, CmsRoleViolationException { 1050 1051 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 1052 CmsPropertyDefinition result = null; 1053 1054 try { 1055 checkOfflineProject(dbc); 1056 checkRole(dbc, CmsRole.PROPERTY_MANAGER); 1057 result = m_driverManager.createPropertyDefinition(dbc, name); 1058 } catch (Exception e) { 1059 dbc.report(null, Messages.get().container(Messages.ERR_CREATE_PROPDEF_1, name), e); 1060 } finally { 1061 dbc.clear(); 1062 } 1063 return result; 1064 } 1065 1066 1081 public CmsResource createResource( 1082 CmsRequestContext context, 1083 String resourcename, 1084 int type, 1085 byte[] content, 1086 List properties) throws CmsException { 1087 1088 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 1089 CmsResource newResource = null; 1090 try { 1091 checkOfflineProject(dbc); 1092 newResource = m_driverManager.createResource(dbc, resourcename, type, content, properties); 1093 } catch (Exception e) { 1094 dbc.report(null, Messages.get().container(Messages.ERR_CREATE_RESOURCE_1, resourcename), e); 1095 } finally { 1096 dbc.clear(); 1097 } 1098 return newResource; 1099 } 1100 1101 1111 public void createSibling(CmsRequestContext context, CmsResource source, String destination, List properties) 1112 throws CmsException { 1113 1114 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 1115 try { 1116 checkOfflineProject(dbc); 1117 m_driverManager.createSibling(dbc, source, destination, properties); 1118 } catch (Exception e) { 1119 dbc.report(null, Messages.get().container( 1120 Messages.ERR_CREATE_SIBLING_1, 1121 context.removeSiteRoot(source.getRootPath())), e); 1122 } finally { 1123 dbc.clear(); 1124 } 1125 } 1126 1127 1145 public CmsTask createTask( 1146 CmsRequestContext context, 1147 CmsUser currentUser, 1148 int projectid, 1149 String agentName, 1150 String roleName, 1151 String taskName, 1152 String taskComment, 1153 int taskType, 1154 long timeout, 1155 int priority) throws CmsException { 1156 1157 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 1158 CmsTask result = null; 1159 try { 1160 result = m_driverManager.createTask( 1161 dbc, 1162 currentUser, 1163 projectid, 1164 agentName, 1165 roleName, 1166 taskName, 1167 taskComment, 1168 taskType, 1169 timeout, 1170 priority); 1171 } catch (Exception e) { 1172 dbc.report(null, Messages.get().container(Messages.ERR_CREATE_TASK_1, taskName), e); 1173 } finally { 1174 dbc.clear(); 1175 } 1176 return result; 1177 } 1178 1179 1202 public CmsTask createTask( 1203 CmsRequestContext context, 1204 String agentName, 1205 String roleName, 1206 String taskname, 1207 long timeout, 1208 int priority) throws CmsException { 1209 1210 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 1211 CmsTask result = null; 1212 try { 1213 result = m_driverManager.createTask(dbc, agentName, roleName, taskname, timeout, priority); 1214 } catch (Exception e) { 1215 dbc.report(null, Messages.get().container(Messages.ERR_CREATE_TASK_1, taskname), e); 1216 } finally { 1217 dbc.clear(); 1218 } 1219 return result; 1220 } 1221 1222 1231 public CmsProject createTempfileProject(CmsRequestContext context) throws CmsException { 1232 1233 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 1234 1235 CmsProject result = null; 1236 try { 1237 checkRole(dbc, CmsRole.PROJECT_MANAGER); 1238 result = m_driverManager.createTempfileProject(dbc); 1239 } catch (Exception e) { 1240 dbc.report(null, Messages.get().container(Messages.ERR_CREATE_TEMPFILE_PROJECT_0), e); 1241 } finally { 1242 dbc.clear(); 1243 } 1244 return result; 1245 } 1246 1247 1263 public CmsUser createUser( 1264 CmsRequestContext context, 1265 String name, 1266 String password, 1267 String description, 1268 Map additionalInfos) throws CmsException, CmsRoleViolationException { 1269 1270 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 1271 1272 CmsUser result = null; 1273 try { 1274 checkRole(dbc, CmsRole.ACCOUNT_MANAGER); 1275 result = m_driverManager.createUser(dbc, name, password, description, additionalInfos); 1276 } catch (Exception e) { 1277 dbc.report(null, Messages.get().container(Messages.ERR_CREATE_USER_1, name), e); 1278 } finally { 1279 dbc.clear(); 1280 } 1281 return result; 1282 } 1283 1284 1292 public void deleteAllStaticExportPublishedResources(CmsRequestContext context, int linkType) throws CmsException { 1293 1294 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 1295 try { 1296 m_driverManager.deleteAllStaticExportPublishedResources(dbc, linkType); 1297 } catch (Exception e) { 1298 dbc.report(null, Messages.get().container(Messages.ERR_DELETE_STATEXP_PUBLISHED_RESOURCES_0), e); 1299 } finally { 1300 dbc.clear(); 1301 } 1302 } 1303 1304 1321 public void deleteBackups(CmsRequestContext context, long timestamp, int versions, I_CmsReport report) 1322 throws CmsException, CmsRoleViolationException { 1323 1324 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 1325 try { 1326 checkRole(dbc, CmsRole.HISTORY_MANAGER); 1327 m_driverManager.deleteBackups(dbc, timestamp, versions, report); 1328 } catch (Exception e) { 1329 dbc.report(null, Messages.get().container( 1330 Messages.ERR_DELETE_BACKUPS_2, 1331 new Date (timestamp), 1332 new Integer (versions)), e); 1333 } finally { 1334 dbc.clear(); 1335 } 1336 } 1337 1338 1350 public void deleteGroup(CmsRequestContext context, CmsUUID groupId, CmsUUID replacementId) 1351 throws CmsException, CmsRoleViolationException, CmsSecurityException { 1352 1353 CmsGroup group = readGroup(context, groupId); 1354 if (OpenCms.getDefaultUsers().isDefaultGroup(group.getName())) { 1355 throw new CmsSecurityException(Messages.get().container( 1356 Messages.ERR_CONSTRAINT_DELETE_GROUP_DEFAULT_1, 1357 group.getName())); 1358 } 1359 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 1360 try { 1361 checkRole(dbc, CmsRole.ACCOUNT_MANAGER); 1363 checkOfflineProject(dbc); 1367 m_driverManager.deleteGroup(dbc, group, replacementId); 1368 } catch (Exception e) { 1369 dbc.report(null, Messages.get().container(Messages.ERR_DELETE_GROUP_1, group.getName()), e); 1370 } finally { 1371 dbc.clear(); 1372 } 1373 } 1374 1375 1388 public void deleteGroup(CmsRequestContext context, String name) 1389 throws CmsException, CmsRoleViolationException, CmsSecurityException { 1390 1391 if (OpenCms.getDefaultUsers().isDefaultGroup(name)) { 1392 throw new CmsSecurityException(Messages.get().container( 1393 Messages.ERR_CONSTRAINT_DELETE_GROUP_DEFAULT_1, 1394 name)); 1395 } 1396 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 1397 try { 1398 checkRole(dbc, CmsRole.ACCOUNT_MANAGER); 1400 checkOfflineProject(dbc); 1404 m_driverManager.deleteGroup(dbc, name); 1405 } catch (Exception e) { 1406 dbc.report(null, Messages.get().container(Messages.ERR_DELETE_GROUP_1, name), e); 1407 } finally { 1408 dbc.clear(); 1409 } 1410 } 1411 1412 1423 public void deleteProject(CmsRequestContext context, int projectId) throws CmsException, CmsRoleViolationException { 1424 1425 if (projectId == CmsProject.ONLINE_PROJECT_ID) { 1426 throw new CmsVfsException(org.opencms.file.Messages.get().container( 1428 org.opencms.file.Messages.ERR_NOT_ALLOWED_IN_ONLINE_PROJECT_0)); 1429 } 1430 1431 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 1432 CmsProject deleteProject = null; 1433 try { 1434 deleteProject = m_driverManager.readProject(dbc, projectId); 1436 checkManagerOfProjectRole(dbc, deleteProject); 1437 m_driverManager.deleteProject(dbc, deleteProject); 1438 } catch (Exception e) { 1439 String projectName = deleteProject == null ? String.valueOf(projectId) : deleteProject.getName(); 1440 dbc.report(null, Messages.get().container(Messages.ERR_DELETE_PROJECT_1, projectName), e); 1441 } finally { 1442 dbc.clear(); 1443 } 1444 } 1445 1446 1456 public void deletePropertyDefinition(CmsRequestContext context, String name) 1457 throws CmsException, CmsSecurityException, CmsRoleViolationException { 1458 1459 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 1460 try { 1461 checkOfflineProject(dbc); 1462 checkRole(dbc, CmsRole.PROPERTY_MANAGER); 1463 m_driverManager.deletePropertyDefinition(dbc, name); 1464 } catch (Exception e) { 1465 dbc.report(null, Messages.get().container(Messages.ERR_DELETE_PROPERTY_1, name), e); 1466 } finally { 1467 dbc.clear(); 1468 } 1469 } 1470 1471 1489 public void deleteResource(CmsRequestContext context, CmsResource resource, int siblingMode) 1490 throws CmsException, CmsSecurityException { 1491 1492 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 1493 try { 1494 checkOfflineProject(dbc); 1495 checkPermissions(dbc, resource, CmsPermissionSet.ACCESS_WRITE, true, CmsResourceFilter.ALL); 1496 m_driverManager.deleteResource(dbc, resource, siblingMode); 1497 } catch (Exception e) { 1498 dbc.report(null, Messages.get().container(Messages.ERR_DELETE_RESOURCE_1, context.getSitePath(resource)), e); 1499 } finally { 1500 dbc.clear(); 1501 } 1502 } 1503 1504 1514 public void deleteStaticExportPublishedResource( 1515 CmsRequestContext context, 1516 String resourceName, 1517 int linkType, 1518 String linkParameter) throws CmsException { 1519 1520 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 1521 try { 1522 m_driverManager.deleteStaticExportPublishedResource(dbc, resourceName, linkType, linkParameter); 1523 } catch (Exception e) { 1524 dbc.report( 1525 null, 1526 Messages.get().container(Messages.ERR_DELETE_STATEXP_PUBLISHES_RESOURCE_1, resourceName), 1527 e); 1528 } finally { 1529 dbc.clear(); 1530 } 1531 } 1532 1533 1541 public void deleteUser(CmsRequestContext context, CmsUUID userId) throws CmsException { 1542 1543 CmsUser user = readUser(context, userId); 1544 deleteUser(context, user, null); 1545 } 1546 1547 1557 public void deleteUser(CmsRequestContext context, CmsUUID userId, CmsUUID replacementId) throws CmsException { 1558 1559 CmsUser user = readUser(context, userId); 1560 CmsUser replacementUser = null; 1561 if (replacementId != null && !replacementId.isNullUUID()) { 1562 replacementUser = readUser(context, replacementId); 1563 } 1564 deleteUser(context, user, replacementUser); 1565 } 1566 1567 1575 public void deleteUser(CmsRequestContext context, String username) throws CmsException { 1576 1577 CmsUser user = readUser(context, username, CmsUser.USER_TYPE_SYSTEMUSER); 1578 deleteUser(context, user, null); 1579 } 1580 1581 1589 public void deleteWebUser(CmsRequestContext context, CmsUUID userId) throws CmsException { 1590 1591 CmsUser user = readUser(context, userId); 1592 deleteUser(context, user, null); 1593 } 1594 1595 1600 public synchronized void destroy() throws Throwable { 1601 1602 finalize(); 1603 if (CmsLog.INIT.isInfoEnabled()) { 1604 CmsLog.INIT.info(Messages.get().getBundle().key( 1605 Messages.INIT_SECURITY_MANAGER_SHUTDOWN_1, 1606 this.getClass().getName())); 1607 } 1608 } 1609 1610 1618 public void endTask(CmsRequestContext context, int taskid) throws CmsException { 1619 1620 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 1621 try { 1622 m_driverManager.endTask(dbc, taskid); 1623 } catch (Exception e) { 1624 dbc.report(null, Messages.get().container(Messages.ERR_END_TASK_1, new Integer (taskid)), e); 1625 } finally { 1626 dbc.clear(); 1627 } 1628 } 1629 1630 1656 public boolean existsResource(CmsRequestContext context, String resourcePath, CmsResourceFilter filter) { 1657 1658 boolean result = false; 1659 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 1660 try { 1661 readResource(dbc, resourcePath, filter); 1662 result = true; 1663 } catch (Exception e) { 1664 result = false; 1665 } finally { 1666 dbc.clear(); 1667 } 1668 return result; 1669 } 1670 1671 1687 public CmsPublishList fillPublishList(CmsRequestContext context, CmsPublishList publishList) throws CmsException { 1688 1689 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 1690 CmsPublishList result = null; 1691 try { 1692 result = m_driverManager.fillPublishList(dbc, publishList); 1693 } catch (Exception e) { 1694 if (publishList.isDirectPublish()) { 1695 dbc.report(null, Messages.get().container( 1696 Messages.ERR_GET_PUBLISH_LIST_DIRECT_1, 1697 CmsFileUtil.formatResourceNames(context, publishList.getDirectPublishResources())), e); 1698 } else { 1699 dbc.report(null, Messages.get().container( 1700 Messages.ERR_GET_PUBLISH_LIST_PROJECT_1, 1701 context.currentProject().getName()), e); 1702 } 1703 } finally { 1704 dbc.clear(); 1705 } 1706 return result; 1707 } 1708 1709 1719 public void forwardTask(CmsRequestContext context, int taskid, String newRoleName, String newUserName) 1720 throws CmsException { 1721 1722 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 1723 try { 1724 m_driverManager.forwardTask(dbc, taskid, newRoleName, newUserName); 1725 } catch (Exception e) { 1726 dbc.report(null, Messages.get().container( 1727 Messages.ERR_FORWARD_TASK_3, 1728 new Integer (taskid), 1729 newUserName, 1730 newRoleName), e); 1731 } finally { 1732 dbc.clear(); 1733 } 1734 } 1735 1736 1747 public List getAccessControlEntries(CmsRequestContext context, CmsResource resource, boolean getInherited) 1748 throws CmsException { 1749 1750 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 1751 List result = null; 1752 try { 1753 result = m_driverManager.getAccessControlEntries(dbc, resource, getInherited); 1754 } catch (Exception e) { 1755 dbc.report(null, Messages.get().container(Messages.ERR_GET_ACL_ENTRIES_1, context.getSitePath(resource)), e); 1756 } finally { 1757 dbc.clear(); 1758 } 1759 return result; 1760 } 1761 1762 1775 public CmsAccessControlList getAccessControlList( 1776 CmsRequestContext context, 1777 CmsResource resource, 1778 boolean inheritedOnly) throws CmsException { 1779 1780 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 1781 CmsAccessControlList result = null; 1782 try { 1783 result = m_driverManager.getAccessControlList(dbc, resource, inheritedOnly); 1784 } catch (Exception e) { 1785 dbc.report(null, Messages.get().container(Messages.ERR_GET_ACL_ENTRIES_1, context.getSitePath(resource)), e); 1786 1787 } finally { 1788 dbc.clear(); 1789 } 1790 return result; 1791 } 1792 1793 1803 public List getAllAccessibleProjects(CmsRequestContext context) throws CmsException { 1804 1805 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 1806 List result = null; 1807 try { 1808 result = m_driverManager.getAllAccessibleProjects(dbc); 1809 } catch (Exception e) { 1810 dbc.report(null, Messages.get().container( 1811 Messages.ERR_GET_ALL_ACCESSIBLE_PROJECTS_1, 1812 dbc.currentUser().getName()), e); 1813 } finally { 1814 dbc.clear(); 1815 } 1816 return result; 1817 } 1818 1819 1829 public List getAllBackupProjects(CmsRequestContext context) throws CmsException { 1830 1831 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 1832 List result = null; 1833 try { 1834 result = m_driverManager.getAllBackupProjects(dbc); 1835 } catch (Exception e) { 1836 dbc.report(null, Messages.get().container( 1837 Messages.ERR_GET_ALL_ACCESSIBLE_PROJECTS_1, 1838 dbc.currentUser().getName()), e); 1839 } finally { 1840 dbc.clear(); 1841 } 1842 return result; 1843 } 1844 1845 1855 public List getAllManageableProjects(CmsRequestContext context) throws CmsException { 1856 1857 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 1858 List result = null; 1859 try { 1860 result = m_driverManager.getAllManageableProjects(dbc); 1861 } catch (Exception e) { 1862 dbc.report(null, Messages.get().container( 1863 Messages.ERR_GET_ALL_MANAGEABLE_PROJECTS_1, 1864 dbc.currentUser().getName()), e); 1865 } finally { 1866 dbc.clear(); 1867 } 1868 return result; 1869 } 1870 1871 1878 public int getBackupTagId(CmsRequestContext context) { 1879 1880 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 1881 int result = 0; 1882 try { 1883 result = m_driverManager.getBackupTagId(dbc); 1884 } finally { 1885 dbc.clear(); 1886 } 1887 return result; 1888 } 1889 1890 1900 public List getChild(CmsRequestContext context, String groupname) throws CmsException { 1901 1902 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 1903 List result = null; 1904 try { 1905 checkRole(dbc, CmsRole.SYSTEM_USER); 1906 result = m_driverManager.getChild(dbc, groupname); 1907 } catch (Exception e) { 1908 dbc.report(null, Messages.get().container(Messages.ERR_GET_CHILD_GROUPS_1, groupname), e); 1909 } finally { 1910 dbc.clear(); 1911 } 1912 return result; 1913 } 1914 1915 1927 public List getChilds(CmsRequestContext context, String groupname) throws CmsException { 1928 1929 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 1930 List result = null; 1931 try { 1932 checkRole(dbc, CmsRole.SYSTEM_USER); 1933 result = m_driverManager.getChilds(dbc, groupname); 1934 } catch (Exception e) { 1935 dbc.report(null, Messages.get().container(Messages.ERR_GET_CHILD_GROUPS_TRANSITIVE_1, groupname), e); 1936 } finally { 1937 dbc.clear(); 1938 } 1939 return result; 1940 } 1941 1942 1947 public Map getConfigurations() { 1948 1949 return m_driverManager.getConfigurations(); 1950 } 1951 1952 1962 public List getDirectGroupsOfUser(CmsRequestContext context, String username) throws CmsException { 1963 1964 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 1965 List result = null; 1966 try { 1967 result = m_driverManager.getDirectGroupsOfUser(dbc, username); 1968 } catch (Exception e) { 1969 dbc.report(null, Messages.get().container(Messages.ERR_GET_DIRECT_GROUP_OF_USER_1, username), e); 1970 } finally { 1971 dbc.clear(); 1972 } 1973 return result; 1974 } 1975 1976 1985 public List getGroups(CmsRequestContext context) throws CmsException { 1986 1987 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 1988 List result = null; 1989 try { 1990 checkRole(dbc, CmsRole.SYSTEM_USER); 1991 result = m_driverManager.getGroups(dbc); 1992 } catch (Exception e) { 1993 dbc.report(null, Messages.get().container(Messages.ERR_GET_GROUPS_0), e); 1994 } finally { 1995 dbc.clear(); 1996 } 1997 return result; 1998 } 1999 2000 2010 public List getGroupsOfUser(CmsRequestContext context, String username) throws CmsException { 2011 2012 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 2013 List result = null; 2014 try { 2015 result = m_driverManager.getGroupsOfUser(dbc, username); 2016 } catch (Exception e) { 2017 dbc.report(null, Messages.get().container(Messages.ERR_GET_GROUPS_OF_USER_1, username), e); 2018 } finally { 2019 dbc.clear(); 2020 } 2021 return result; 2022 } 2023 2024 2035 public List getGroupsOfUser(CmsRequestContext context, String username, String remoteAddress) throws CmsException { 2036 2037 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 2038 List result = null; 2039 try { 2040 result = m_driverManager.getGroupsOfUser(dbc, username, remoteAddress); 2041 } catch (Exception e) { 2042 dbc.report(null, Messages.get().container(Messages.ERR_GET_GROUPS_OF_USER_2, username, remoteAddress), e); 2043 } finally { 2044 dbc.clear(); 2045 } 2046 return result; 2047 } 2048 2049 2057 public CmsLock getLock(CmsRequestContext context, CmsResource resource) throws CmsException { 2058 2059 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 2060 CmsLock result = null; 2061 try { 2062 result = m_driverManager.getLock(dbc, resource); 2063 } catch (Exception e) { 2064 dbc.report(null, Messages.get().container(Messages.ERR_GET_LOCK_1, context.getSitePath(resource)), e); 2065 } finally { 2066 dbc.clear(); 2067 } 2068 return result; 2069 } 2070 2071 2081 public CmsGroup getParent(CmsRequestContext context, String groupname) throws CmsException { 2082 2083 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 2084 CmsGroup result = null; 2085 try { 2086 result = m_driverManager.getParent(dbc, groupname); 2087 } catch (Exception e) { 2088 dbc.report(null, Messages.get().container(Messages.ERR_GET_PARENT_GROUP_1, groupname), e); 2089 } finally { 2090 dbc.clear(); 2091 } 2092 return result; 2093 } 2094 2095 2106 public CmsPermissionSetCustom getPermissions(CmsRequestContext context, CmsResource resource, CmsUser user) 2107 throws CmsException { 2108 2109 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 2110 CmsPermissionSetCustom result = null; 2111 try { 2112 result = m_driverManager.getPermissions(dbc, resource, user); 2113 } catch (Exception e) { 2114 dbc.report(null, Messages.get().container( 2115 Messages.ERR_GET_PERMISSIONS_2, 2116 user.getName(), 2117 context.getSitePath(resource)), e); 2118 } finally { 2119 dbc.clear(); 2120 } 2121 return result; 2122 } 2123 2124 2144 public List getResourcesForPrincipal( 2145 CmsRequestContext context, 2146 CmsUUID principalId, 2147 CmsPermissionSet permissions, 2148 boolean includeAttr) throws CmsException { 2149 2150 List dependencies; 2151 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 2152 try { 2153 dependencies = m_driverManager.getResourcesForPrincipal( 2154 dbc, 2155 dbc.currentProject(), 2156 principalId, 2157 permissions, 2158 includeAttr); 2159 } catch (Exception e) { 2160 dbc.report(null, Messages.get().container(Messages.ERR_READ_RESOURCES_FOR_PRINCIPAL_LOG_1, principalId), e); 2161 dependencies = new ArrayList (); 2162 } finally { 2163 dbc.clear(); 2164 } 2165 return dependencies; 2166 } 2167 2168 2173 public CmsSqlManager getSqlManager() { 2174 2175 return m_driverManager.getSqlManager(); 2176 } 2177 2178 2189 public String getTaskPar(CmsRequestContext context, int taskId, String parName) throws CmsException { 2190 2191 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 2192 String result = null; 2193 try { 2194 result = m_driverManager.getTaskPar(dbc, taskId, parName); 2195 } catch (Exception e) { 2196 dbc.report(null, Messages.get().container(Messages.ERR_GET_TASK_PARAM_2, parName, new Integer (taskId)), e); 2197 } finally { 2198 dbc.clear(); 2199 } 2200 return result; 2201 } 2202 2203 2213 public int getTaskType(CmsRequestContext context, String taskName) throws CmsException { 2214 2215 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 2216 int result = 0; 2217 try { 2218 result = m_driverManager.getTaskType(dbc, taskName); 2219 } catch (Exception e) { 2220 dbc.report(null, Messages.get().container(Messages.ERR_GET_TASK_TYPE_1, taskName), e); 2221 } finally { 2222 dbc.clear(); 2223 } 2224 return result; 2225 } 2226 2227 2236 public List getUsers(CmsRequestContext context) throws CmsException { 2237 2238 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 2239 List result = null; 2240 try { 2241 checkRole(dbc, CmsRole.SYSTEM_USER); 2242 result = m_driverManager.getUsers(dbc); 2243 } catch (Exception e) { 2244 dbc.report(null, Messages.get().container(Messages.ERR_GET_USERS_0), e); 2245 } finally { 2246 dbc.clear(); 2247 } 2248 return result; 2249 } 2250 2251 2261 public List getUsers(CmsRequestContext context, int type) throws CmsException { 2262 2263 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 2264 List result = null; 2265 try { 2266 if (type != CmsUser.USER_TYPE_WEBUSER) { 2267 checkRole(dbc, CmsRole.SYSTEM_USER); 2268 } 2269 result = m_driverManager.getUsers(dbc, type); 2270 } catch (Exception e) { 2271 dbc.report(null, Messages.get().container(Messages.ERR_GET_USERS_OF_TYPE_1, new Integer (type)), e); 2272 } finally { 2273 dbc.clear(); 2274 } 2275 return result; 2276 } 2277 2278 2288 public List getUsersOfGroup(CmsRequestContext context, String groupname) throws CmsException { 2289 2290 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 2291 List result = null; 2292 try { 2293 checkRole(dbc, CmsRole.SYSTEM_USER); 2294 result = m_driverManager.getUsersOfGroup(dbc, groupname); 2295 } catch (Exception e) { 2296 dbc.report(null, Messages.get().container(Messages.ERR_GET_USERS_OF_GROUP_1, groupname), e); 2297 } finally { 2298 dbc.clear(); 2299 } 2300 return result; 2301 } 2302 2303 2311 public boolean hasManagerOfProjectRole(CmsDbContext dbc, CmsProject project) { 2312 2313 if (project.isOnlineProject()) { 2314 return false; 2316 } 2317 2318 if (dbc.currentUser().getId().equals(project.getOwnerId())) { 2319 return true; 2321 } 2322 2323 if (hasRole(dbc, CmsRole.PROJECT_MANAGER)) { 2324 return true; 2326 } 2327 2328 List groups; 2330 try { 2331 groups = m_driverManager.getGroupsOfUser(dbc, dbc.currentUser().getName()); 2332 } catch (CmsException e) { 2333 return false; 2335 } 2336 2337 for (int i = 0; i < groups.size(); i++) { 2338 if (((CmsGroup)groups.get(i)).getId().equals(project.getManagerGroupId())) { 2340 return true; 2342 } 2343 } 2344 2345 return false; 2347 } 2348 2349 2374 public int hasPermissions( 2375 CmsRequestContext context, 2376 CmsResource resource, 2377 CmsPermissionSet requiredPermissions, 2378 boolean checkLock, 2379 CmsResourceFilter filter) throws CmsException { 2380 2381 int result = 0; 2382 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 2383 try { 2384 result = hasPermissions(dbc, resource, requiredPermissions, checkLock, filter); 2385 } finally { 2386 dbc.clear(); 2387 } 2388 return result; 2389 } 2390 2391 2400 public boolean hasRole(CmsDbContext dbc, CmsRole role) { 2401 2402 return hasRole(dbc, dbc.currentUser(), role); 2403 } 2404 2405 2415 public boolean hasRole(CmsDbContext dbc, CmsUser user, CmsRole role) { 2416 2417 List groups; 2419 try { 2420 groups = m_driverManager.getGroupsOfUser(dbc, user.getName(), dbc.getRequestContext().getRemoteAddress()); 2421 } catch (CmsException e) { 2422 return false; 2424 } 2425 2426 return role.hasRole(groups); 2427 } 2428 2429 2439 public boolean hasRole(CmsRequestContext context, CmsRole role) { 2440 2441 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 2442 boolean result; 2443 try { 2444 result = hasRole(dbc, role); 2445 } finally { 2446 dbc.clear(); 2447 } 2448 return result; 2449 } 2450 2451 2468 public void importAccessControlEntries(CmsRequestContext context, CmsResource resource, List acEntries) 2469 throws CmsException, CmsSecurityException { 2470 2471 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 2472 try { 2473 checkOfflineProject(dbc); 2474 checkPermissions(dbc, resource, CmsPermissionSet.ACCESS_CONTROL, true, CmsResourceFilter.ALL); 2475 m_driverManager.importAccessControlEntries(dbc, resource, acEntries); 2476 } catch (Exception e) { 2477 dbc.report( 2478 null, 2479 Messages.get().container(Messages.ERR_IMPORT_ACL_ENTRIES_1, context.getSitePath(resource)), 2480 e); 2481 } finally { 2482 dbc.clear(); 2483 } 2484 } 2485 2486 2510 public CmsResource importResource( 2511 CmsRequestContext context, 2512 String resourcePath, 2513 CmsResource resource, 2514 byte[] content, 2515 List properties, 2516 boolean importCase) throws CmsException { 2517 2518 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 2519 CmsResource newResource = null; 2520 try { 2521 checkOfflineProject(dbc); 2522 newResource = m_driverManager.createResource(dbc, resourcePath, resource, content, properties, importCase); 2523 } catch (Exception e) { 2524 dbc.report(null, Messages.get().container( 2525 Messages.ERR_IMPORT_RESOURCE_2, 2526 context.getSitePath(resource), 2527 resourcePath), e); 2528 } finally { 2529 dbc.clear(); 2530 } 2531 return newResource; 2532 } 2533 2534 2555 public CmsUser importUser( 2556 CmsRequestContext context, 2557 String id, 2558 String name, 2559 String password, 2560 String description, 2561 String firstname, 2562 String lastname, 2563 String email, 2564 String address, 2565 int flags, 2566 int type, 2567 Map additionalInfos) throws CmsException, CmsRoleViolationException { 2568 2569 CmsUser newUser = null; 2570 2571 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 2572 2573 try { 2574 checkRole(dbc, CmsRole.ACCOUNT_MANAGER); 2575 newUser = m_driverManager.importUser( 2576 dbc, 2577 id, 2578 name, 2579 password, 2580 description, 2581 firstname, 2582 lastname, 2583 email, 2584 address, 2585 flags, 2586 type, 2587 additionalInfos); 2588 2589 } catch (Exception e) { 2590 dbc.report(null, Messages.get().container( 2591 Messages.ERR_IMPORT_USER_9, 2592 new Object [] { 2593 id, 2594 name, 2595 description, 2596 firstname, 2597 lastname, 2598 email, 2599 address, 2600 new Integer (flags), 2601 new Integer (type), 2602 additionalInfos}), e); 2603 } finally { 2604 dbc.clear(); 2605 } 2606 2607 return newUser; 2608 } 2609 2610 2618 public void init(CmsConfigurationManager configurationManager, I_CmsDbContextFactory dbContextFactory) 2619 throws CmsInitException { 2620 2621 if (dbContextFactory == null) { 2622 throw new CmsInitException(org.opencms.main.Messages.get().container( 2623 org.opencms.main.Messages.ERR_CRITICAL_NO_DB_CONTEXT_0)); 2624 } 2625 2626 m_dbContextFactory = dbContextFactory; 2627 2628 CmsSystemConfiguration systemConfiguation = (CmsSystemConfiguration)configurationManager.getConfiguration(CmsSystemConfiguration.class); 2629 CmsCacheSettings settings = systemConfiguation.getCacheSettings(); 2630 2631 String className = settings.getCacheKeyGenerator(); 2632 try { 2633 m_keyGenerator = (I_CmsCacheKey)Class.forName(className).newInstance(); 2635 } catch (Exception e) { 2636 throw new CmsInitException(org.opencms.main.Messages.get().container( 2637 org.opencms.main.Messages.ERR_CRITICAL_CLASS_CREATION_1, 2638 className)); 2639 } 2640 2641 LRUMap lruMap = new LRUMap(settings.getPermissionCacheSize()); 2642 m_permissionCache = Collections.synchronizedMap(lruMap); 2643 if (OpenCms.getMemoryMonitor().enabled()) { 2644 OpenCms.getMemoryMonitor().register(this.getClass().getName() + ".m_permissionCache", lruMap); 2645 } 2646 2647 m_driverManager = CmsDriverManager.newInstance(configurationManager, this, dbContextFactory); 2648 2649 if (CmsLog.INIT.isInfoEnabled()) { 2650 CmsLog.INIT.info(Messages.get().getBundle().key(Messages.INIT_SECURITY_MANAGER_INIT_0)); 2651 } 2652 } 2653 2654 2666 public boolean isInsideCurrentProject(CmsRequestContext context, String resourcename) { 2667 2668 boolean result = false; 2669 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 2670 try { 2671 result = m_driverManager.isInsideCurrentProject(dbc, resourcename); 2672 } finally { 2673 dbc.clear(); 2674 } 2675 return result; 2676 } 2677 2678 2685 public boolean isManagerOfProject(CmsRequestContext context) { 2686 2687 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 2688 return hasManagerOfProjectRole(dbc, context.currentProject()); 2689 } 2690 2691 2710 public void lockResource(CmsRequestContext context, CmsResource resource, int mode) throws CmsException { 2711 2712 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 2713 try { 2714 checkOfflineProject(dbc); 2715 checkPermissions(dbc, resource, CmsPermissionSet.ACCESS_WRITE, false, CmsResourceFilter.ALL); 2716 m_driverManager.lockResource(dbc, resource, mode); 2717 } catch (Exception e) { 2718 dbc.report(null, Messages.get().container( 2719 Messages.ERR_LOCK_RESOURCE_2, 2720 context.getSitePath(resource), 2721 (mode == CmsLock.COMMON) ? "CmsLock.C_MODE_COMMON" : "CmsLock.C_MODE_TEMP"), e); 2722 } finally { 2723 dbc.clear(); 2724 } 2725 } 2726 2727 2740 public CmsUser loginUser( 2741 CmsRequestContext context, 2742 String username, 2743 String password, 2744 String remoteAddress, 2745 int userType) throws CmsException { 2746 2747 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 2748 CmsUser result = null; 2749 try { 2750 result = m_driverManager.loginUser(dbc, username, password, remoteAddress, userType); 2751 } finally { 2752 dbc.clear(); 2753 } 2754 return result; 2755 } 2756 2757 2765 public I_CmsPrincipal lookupPrincipal(CmsRequestContext context, CmsUUID principalId) { 2766 2767 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 2768 I_CmsPrincipal result = null; 2769 try { 2770 result = m_driverManager.lookupPrincipal(dbc, principalId); 2771 } finally { 2772 dbc.clear(); 2773 } 2774 return result; 2775 } 2776 2777 2785 public I_CmsPrincipal lookupPrincipal(CmsRequestContext context, String principalName) { 2786 2787 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 2788 I_CmsPrincipal result = null; 2789 try { 2790 result = m_driverManager.lookupPrincipal(dbc, principalName); 2791 } finally { 2792 dbc.clear(); 2793 } 2794 return result; 2795 } 2796 2797 2821 public String moveToLostAndFound(CmsRequestContext context, String resourcename, boolean returnNameOnly) 2822 throws CmsException { 2823 2824 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 2825 String result = null; 2826 try { 2827 result = m_driverManager.moveToLostAndFound(dbc, resourcename, returnNameOnly); 2828 } catch (Exception e) { 2829 dbc.report(null, Messages.get().container(Messages.ERR_MOVE_TO_LOST_AND_FOUND_1, resourcename), e); 2830 } finally { 2831 dbc.clear(); 2832 } 2833 return result; 2834 } 2835 2836 2849 public CmsUUID publishProject(CmsObject cms, CmsPublishList publishList, I_CmsReport report) throws CmsException { 2850 2851 CmsRequestContext context = cms.getRequestContext(); 2852 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 2853 try { 2854 checkPublishPermissions(dbc, publishList); 2856 m_driverManager.publishProject(cms, dbc, publishList, report); 2857 } finally { 2858 dbc.clear(); 2859 } 2860 return publishList.getPublishHistoryId(); 2861 } 2862 2863 2874 public void reactivateTask(CmsRequestContext context, int taskId) throws CmsException { 2875 2876 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 2877 try { 2878 m_driverManager.reactivateTask(dbc, taskId); 2879 } catch (Exception e) { 2880 dbc.report(null, Messages.get().container(Messages.ERR_REACTIVATE_TASK_1, new Integer (taskId)), e); 2881 } finally { 2882 dbc.clear(); 2883 } 2884 } 2885 2886 2896 public CmsUser readAgent(CmsRequestContext context, CmsTask task) throws CmsException { 2897 2898 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 2899 CmsUser result = null; 2900 try { 2901 result = m_driverManager.readAgent(dbc, task); 2902 } catch (Exception e) { 2903 dbc.report(null, Messages.get().container( 2904 Messages.ERR_READ_TASK_OWNER_2, 2905 task.getName(), 2906 new Integer (task.getId())), e); 2907 } finally { 2908 dbc.clear(); 2909 } 2910 return result; 2911 } 2912 2913 2928 public List readAllBackupFileHeaders(CmsRequestContext context, CmsResource resource) throws CmsException { 2929 2930 List result = null; 2931 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 2932 try { 2933 result = m_driverManager.readAllBackupFileHeaders(dbc, resource); 2934 } catch (Exception e) { 2935 dbc.report(null, Messages.get().container( 2936 Messages.ERR_READ_ALL_BKP_FILE_HEADERS_1, 2937 context.getSitePath(resource)), e); 2938 } finally { 2939 dbc.clear(); 2940 } 2941 return result; 2942 } 2943 2944 2953 public List readAllPropertyDefinitions(CmsRequestContext context) throws CmsException { 2954 2955 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 2956 List result = null; 2957 try { 2958 result = m_driverManager.readAllPropertyDefinitions(dbc); 2959 } catch (Exception e) { 2960 dbc.report(null, Messages.get().container(Messages.ERR_READ_ALL_PROPDEF_0), e); 2961 } finally { 2962 dbc.clear(); 2963 } 2964 return result; 2965 } 2966 2967 2980 public CmsFolder readAncestor(CmsRequestContext context, CmsResource resource, CmsResourceFilter filter) 2981 throws CmsException { 2982 2983 String path = CmsResource.getFolderPath(resource.getRootPath()); 2985 do { 2986 if (existsResource(context, path, filter)) { 2988 return readFolder(context, path, filter); 2990 } else { 2991 path = CmsResource.getParentFolder(path); 2993 } 2994 2995 if (CmsStringUtil.isEmpty(path) || !path.startsWith(context.getSiteRoot())) { 2996 return null; 2998 } 2999 } while (true); 3000 } 3001 3002 3015 public CmsBackupResource readBackupFile(CmsRequestContext context, int tagId, CmsResource resource) 3016 throws CmsException { 3017 3018 CmsBackupResource result = null; 3019 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 3020 try { 3021 result = m_driverManager.readBackupFile(dbc, tagId, resource); 3022 } catch (Exception e) { 3023 dbc.report(null, Messages.get().container( 3024 Messages.ERR_READ_BKP_FILE_2, 3025 context.getSitePath(resource), 3026 new Integer (tagId)), e); 3027 } finally { 3028 dbc.clear(); 3029 } 3030 return result; 3031 } 3032 3033 3043 public CmsBackupProject readBackupProject(CmsRequestContext context, int tagId) throws CmsException { 3044 3045 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 3046 CmsBackupProject result = null; 3047 try { 3048 result = m_driverManager.readBackupProject(dbc, tagId); 3049 } catch (Exception e) { 3050 dbc.report(null, Messages.get().container( 3051 Messages.ERR_READ_BKP_PROJECT_2, 3052 new Integer (tagId), 3053 dbc.currentProject().getName()), e); 3054 } finally { 3055 dbc.clear(); 3056 } 3057 return result; 3058 } 3059 3060 3070 public List readBackupPropertyObjects(CmsRequestContext context, CmsBackupResource resource) throws CmsException { 3071 3072 List result = null; 3073 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 3074 try { 3075 result = m_driverManager.readBackupPropertyObjects(dbc, resource); 3076 } catch (Exception e) { 3077 dbc.report(null, Messages.get().container( 3078 Messages.ERR_READ_PROPS_FOR_RESOURCE_1, 3079 context.getSitePath(resource)), e); 3080 } finally { 3081 dbc.clear(); 3082 } 3083 return result; 3084 } 3085 3086 3108 public List readChildResources( 3109 CmsRequestContext context, 3110 CmsResource resource, 3111 CmsResourceFilter filter, 3112 boolean getFolders, 3113 boolean getFiles) throws CmsException, CmsSecurityException { 3114 3115 List result = null; 3116 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 3117 try { 3118 checkPermissions(dbc, resource, CmsPermissionSet.ACCESS_READ, true, CmsResourceFilter.ALL); 3120 result = m_driverManager.readChildResources(dbc, resource, filter, getFolders, getFiles); 3121 } catch (Exception e) { 3122 dbc.report(null, Messages.get().container( 3123 Messages.ERR_READ_CHILD_RESOURCES_1, 3124 context.getSitePath(resource)), e); 3125 } finally { 3126 dbc.clear(); 3127 } 3128 return result; 3129 } 3130 3131 3152 public CmsFile readFile(CmsRequestContext context, CmsResource resource, CmsResourceFilter filter) 3153 throws CmsException { 3154 3155 CmsFile result = null; 3156 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 3157 try { 3158 result = m_driverManager.readFile(dbc, resource, filter); 3159 } catch (Exception e) { 3160 dbc.report( 3161 null, 3162 Messages.get().container(Messages.ERR_READ_FILE_2, context.getSitePath(resource), filter), 3163 e); 3164 } finally { 3165 dbc.clear(); 3166 } 3167 return result; 3168 } 3169 3170 3188 public CmsFolder readFolder(CmsRequestContext context, String resourcename, CmsResourceFilter filter) 3189 throws CmsException { 3190 3191 CmsFolder result = null; 3192 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 3193 try { 3194 result = readFolder(dbc, resourcename, filter); 3195 } catch (Exception e) { 3196 dbc.report(null, Messages.get().container(Messages.ERR_READ_FOLDER_2, resourcename, filter), e); 3197 } finally { 3198 dbc.clear(); 3199 } 3200 return result; 3201 } 3202 3203 3226 public List readGivenTasks( 3227 CmsRequestContext context, 3228 int projectId, 3229 String ownerName, 3230 int taskType, 3231 String orderBy, 3232 String sort) throws CmsException { 3233 3234 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 3235 List result = null; 3236 try { 3237 result = m_driverManager.readGivenTasks(dbc, projectId, ownerName, taskType, orderBy, sort); 3238 } catch (Exception e) { 3239 dbc.report(null, Messages.get().container( 3240 org.opencms.workflow.Messages.toTaskTypeString(taskType, context), 3241 new Integer (projectId), 3242 ownerName), e); 3243 } finally { 3244 dbc.clear(); 3245 } 3246 return result; 3247 } 3248 3249 3257 public CmsGroup readGroup(CmsRequestContext context, CmsProject project) { 3258 3259 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 3260 CmsGroup result = null; 3261 try { 3262 result = m_driverManager.readGroup(dbc, project); 3263 } finally { 3264 dbc.clear(); 3265 } 3266 return result; 3267 } 3268 3269 3279 public CmsGroup readGroup(CmsRequestContext context, CmsTask task) throws CmsException { 3280 3281 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 3282 CmsGroup result = null; 3283 try { 3284 result = m_driverManager.readGroup(dbc, task); 3285 } catch (Exception e) { 3286 dbc.report(null, Messages.get().container(Messages.ERR_READ_GROUP_TASK_1, task.getName()), e); 3287 } finally { 3288 dbc.clear(); 3289 } 3290 return result; 3291 } 3292 3293 3303 public CmsGroup readGroup(CmsRequestContext context, CmsUUID groupId) throws CmsException { 3304 3305 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 3306 CmsGroup result = null; 3307 try { 3308 result = m_driverManager.readGroup(dbc, groupId); 3309 } catch (Exception e) { 3310 dbc.report(null, Messages.get().container(Messages.ERR_READ_GROUP_FOR_ID_1, groupId.toString()), e); 3311 } finally { 3312 dbc.clear(); 3313 } 3314 return result; 3315 } 3316 3317 3327 public CmsGroup readGroup(CmsRequestContext context, String groupname) throws CmsException { 3328 3329 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 3330 CmsGroup result = null; 3331 try { 3332 result = m_driverManager.readGroup(dbc, groupname); 3333 } catch (Exception e) { 3334 dbc.report(null, Messages.get().container(Messages.ERR_READ_GROUP_FOR_NAME_1, groupname), e); 3335 } finally { 3336 dbc.clear(); 3337 } 3338 return result; 3339 } 3340 3341 3349 public CmsGroup readManagerGroup(CmsRequestContext context, CmsProject project) { 3350 3351 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 3352 CmsGroup result = null; 3353 try { 3354 result = m_driverManager.readManagerGroup(dbc, project); 3355 } finally { 3356 dbc.clear(); 3357 } 3358 return result; 3359 } 3360 3361 3371 public CmsUser readOriginalAgent(CmsRequestContext context, CmsTask task) throws CmsException { 3372 3373 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 3374 CmsUser result = null; 3375 try { 3376 result = m_driverManager.readOriginalAgent(dbc, task); 3377 } catch (Exception e) { 3378 dbc.report(null, Messages.get().container( 3379 Messages.ERR_READ_ORIGINAL_TASK_OWNER_2, 3380 task.getName(), 3381 new Integer (task.getId())), e); 3382 } finally { 3383 dbc.clear(); 3384 } 3385 return result; 3386 } 3387 3388 3398 public CmsUser readOwner(CmsRequestContext context, CmsProject project) throws CmsException { 3399 3400 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 3401 CmsUser result = null; 3402 try { 3403 result = m_driverManager.readOwner(dbc, project); 3404 } catch (Exception e) { 3405 dbc.report(null, Messages.get().container( 3406 Messages.ERR_READ_OWNER_FOR_PROJECT_2, 3407 project.getName(), 3408 new Integer (project.getId())), e); 3409 } finally { 3410 dbc.clear(); 3411 } 3412 return result; 3413 } 3414 3415 3425 public CmsUser readOwner(CmsRequestContext context, CmsTask task) throws CmsException { 3426 3427 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 3428 CmsUser result = null; 3429 try { 3430 result = m_driverManager.readOwner(dbc, task); 3431 } catch (Exception e) { 3432 dbc.report(null, Messages.get().container( 3433 Messages.ERR_READ_OWNER_FOR_TASK_2, 3434 task.getName(), 3435 new Integer (task.getId())), e); 3436 } finally { 3437 dbc.clear(); 3438 } 3439 return result; 3440 } 3441 3442 3452 public CmsUser readOwner(CmsRequestContext context, CmsTaskLog log) throws CmsException { 3453 3454 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 3455 CmsUser result = null; 3456 try { 3457 result = m_driverManager.readOwner(dbc, log); 3458 } catch (Exception e) { 3459 dbc.report( 3460 null, 3461 Messages.get().container(Messages.ERR_READ_OWNER_FOR_TASKLOG_1, new Integer (log.getId())), 3462 e); 3463 } finally { 3464 dbc.clear(); 3465 } 3466 return result; 3467 } 3468 3469 3481 public List readPath(CmsRequestContext context, int projectId, String path, CmsResourceFilter filter) 3482 throws CmsException { 3483 3484 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 3485 List result = null; 3486 try { 3487 result = m_driverManager.readPath(dbc, projectId, path, filter); 3488 } catch (Exception e) { 3489 dbc.report(null, Messages.get().container(Messages.ERR_READ_PATH_2, new Integer (projectId), path), e); 3490 } finally { 3491 dbc.clear(); 3492 } 3493 return result; 3494 } 3495 3496 3506 public CmsProject readProject(CmsRequestContext context, CmsTask task) throws CmsException { 3507 3508 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 3509 CmsProject result = null; 3510 try { 3511 result = m_driverManager.readProject(dbc, task); 3512 } catch (Exception e) { 3513 dbc.report(null, Messages.get().container( 3514 Messages.ERR_READ_PROJECT_FOR_TASK_2, 3515 task.getName(), 3516 new Integer (task.getId())), e); 3517 } finally { 3518 dbc.clear(); 3519 } 3520 return result; 3521 } 3522 3523 3532 public CmsProject readProject(int id) throws CmsException { 3533 3534 CmsDbContext dbc = m_dbContextFactory.getDbContext(); 3535 CmsProject result = null; 3536 try { 3537 result = m_driverManager.readProject(dbc, id); 3538 } catch (Exception e) { 3539 dbc.report(null, Messages.get().container(Messages.ERR_READ_PROJECT_FOR_ID_1, new Integer (id)), e); 3540 } finally { 3541 dbc.clear(); 3542 } 3543 return result; 3544 } 3545 3546 3560 public CmsProject readProject(String name) throws CmsException { 3561 3562 CmsDbContext dbc = m_dbContextFactory.getDbContext(); 3563 CmsProject result = null; 3564 try { 3565 result = m_driverManager.readProject(dbc, name); 3566 } catch (Exception e) { 3567 dbc.report(null, Messages.get().container(Messages.ERR_READ_PROJECT_FOR_NAME_1, name), e); 3568 } finally { 3569 dbc.clear(); 3570 } 3571 return result; 3572 } 3573 3574 3584 public List readProjectLogs(CmsRequestContext context, int projectId) throws CmsException { 3585 3586 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 3587 List result = null; 3588 try { 3589 result = m_driverManager.readProjectLogs(dbc, projectId); 3590 } catch (Exception e) { 3591 dbc.report( 3592 null, 3593 Messages.get().container(Messages.ERR_READ_TASKLOGS_FOR_PROJECT_1, new Integer (projectId)), 3594 e); 3595 } finally { 3596 dbc.clear(); 3597 } 3598 return result; 3599 } 3600 3601 3612 public List readProjectResources(CmsRequestContext context, CmsProject project) throws CmsException { 3613 3614 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 3615 List result = null; 3616 try { 3617 result = m_driverManager.readProjectResources(dbc, project); 3618 } catch (Exception e) { 3619 dbc.report(null, Messages.get().container( 3620 Messages.ERR_READ_PROJECT_RESOURCES_2, 3621 project.getName(), 3622 new Integer (project.getId())), e); 3623 } finally { 3624 dbc.clear(); 3625 } 3626 return result; 3627 } 3628 3629 3650 public List readProjectView(CmsRequestContext context, int projectId, int state) throws CmsException { 3651 3652 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 3653 List result = null; 3654 try { 3655 result = m_driverManager.readProjectView(dbc, projectId, state); 3656 } catch (Exception e) { 3657 dbc.report(null, Messages.get().container( 3658 Messages.ERR_READ_PROJECT_VIEW_2, 3659 new Integer (projectId), 3660 org.opencms.workflow.Messages.toTaskTypeString(state, context)), e); 3661 } finally { 3662 dbc.clear(); 3663 } 3664 return result; 3665 } 3666 3667 3681 public CmsPropertyDefinition readPropertyDefinition(CmsRequestContext context, String name) throws CmsException { 3682 3683 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 3684 CmsPropertyDefinition result = null; 3685 try { 3686 result = m_driverManager.readPropertyDefinition(dbc, name); 3687 } catch (Exception e) { 3688 dbc.report(null, Messages.get().container(Messages.ERR_READ_PROPDEF_1, name), e); 3689 } finally { 3690 dbc.clear(); 3691 } 3692 return result; 3693 } 3694 3695 3710 public CmsProperty readPropertyObject(CmsRequestContext context, CmsResource resource, String key, boolean search) 3711 throws CmsException { 3712 3713 CmsProperty result = null; 3714 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 3715 try { 3716 result = m_driverManager.readPropertyObject(dbc, resource, key, search); 3717 } catch (Exception e) { 3718 dbc.report(null, Messages.get().container( 3719 Messages.ERR_READ_PROP_FOR_RESOURCE_2, 3720 key, 3721 context.getSitePath(resource)), e); 3722 } finally { 3723 dbc.clear(); 3724 } 3725 return result; 3726 } 3727 3728 3749 public List readPropertyObjects(CmsRequestContext context, CmsResource resource, boolean search) 3750 throws CmsException { 3751 3752 List result = null; 3753 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 3754 try { 3755 result = m_driverManager.readPropertyObjects(dbc, resource, search); 3756 } catch (Exception e) { 3757 dbc.report(null, Messages.get().container( 3758 Messages.ERR_READ_PROPS_FOR_RESOURCE_1, 3759 context.getSitePath(resource)), e); 3760 } finally { 3761 dbc.clear(); 3762 } 3763 return result; 3764 } 3765 3766 3776 public List readPublishedResources(CmsRequestContext context, CmsUUID publishHistoryId) throws CmsException { 3777 3778 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 3779 List result = null; 3780 try { 3781 result = m_driverManager.readPublishedResources(dbc, publishHistoryId); 3782 } catch (Exception e) { 3783 dbc.report(null, Messages.get().container( 3784 Messages.ERR_READ_PUBLISHED_RESOURCES_FOR_ID_1, 3785 publishHistoryId.toString()), e); 3786 } finally { 3787 dbc.clear(); 3788 } 3789 return result; 3790 } 3791 3792 3822 public CmsResource readResource(CmsRequestContext context, String resourcePath, CmsResourceFilter filter) 3823 throws CmsException { 3824 3825 CmsResource result = null; 3826 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 3827 try { 3828 result = readResource(dbc, resourcePath, filter); 3829 } catch (Exception e) { 3830 dbc.report( 3831 null, 3832 Messages.get().container(Messages.ERR_READ_RESOURCE_1, dbc.removeSiteRoot(resourcePath)), 3833 e); 3834 } finally { 3835 dbc.clear(); 3836 } 3837 return result; 3838 } 3839 3840 3856 public List readResources(CmsRequestContext context, CmsResource parent, CmsResourceFilter filter, boolean readTree) 3857 throws CmsException, CmsSecurityException { 3858 3859 List result = null; 3860 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 3861 try { 3862 checkPermissions(dbc, parent, CmsPermissionSet.ACCESS_READ, true, CmsResourceFilter.ALL); 3864 result = m_driverManager.readResources(dbc, parent, filter, readTree); 3865 } catch (Exception e) { 3866 dbc.report(null, Messages.get().container( 3867 Messages.ERR_READ_RESOURCES_1, 3868 context.removeSiteRoot(parent.getRootPath())), e); 3869 } finally { 3870 dbc.clear(); 3871 } 3872 return result; 3873 } 3874 3875 3889 public List readResourcesWithProperty(CmsRequestContext context, String path, String propertyDefinition) 3890 throws CmsException { 3891 3892 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 3893 List result = null; 3894 try { 3895 result = m_driverManager.readResourcesWithProperty(dbc, path, propertyDefinition); 3896 } catch (Exception e) { 3897 dbc.report(null, Messages.get().container( 3898 Messages.ERR_READ_RESOURCES_FOR_PROP_SET_2, 3899 path, 3900 propertyDefinition), e); 3901 } finally { 3902 dbc.clear(); 3903 } 3904 return result; 3905 } 3906 3907 3923 public List readResourcesWithProperty( 3924 CmsRequestContext context, 3925 String path, 3926 String propertyDefinition, 3927 String value) throws CmsException { 3928 3929 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 3930 List result = null; 3931 try { 3932 result = m_driverManager.readResourcesWithProperty(dbc, path, propertyDefinition, value); 3933 } catch (Exception e) { 3934 dbc.report(null, Messages.get().container( 3935 Messages.ERR_READ_RESOURCES_FOR_PROP_VALUE_3, 3936 path, 3937 propertyDefinition, 3938 value), e); 3939 } finally { 3940 dbc.clear(); 3941 } 3942 return result; 3943 } 3944 3945 3955 public Set readResponsiblePrincipals(CmsRequestContext context, CmsResource resource) throws CmsException { 3956 3957 Set result = null; 3958 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 3959 try { 3960 result = m_driverManager.readResponsiblePrincipals(dbc, resource); 3961 } catch (Exception e) { 3962 dbc.report(null, Messages.get().container(Messages.ERR_READ_RESPONSIBLE_USERS_1, resource.getRootPath()), e); 3963 } finally { 3964 dbc.clear(); 3965 } 3966 return result; 3967 } 3968 3969 3979 public Set readResponsibleUsers(CmsRequestContext context, CmsResource resource) throws CmsException { 3980 3981 Set result = null; 3982 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 3983 try { 3984 result = m_driverManager.readResponsibleUsers(dbc, resource); 3985 } catch (Exception e) { 3986 dbc.report(null, Messages.get().container(Messages.ERR_READ_RESPONSIBLE_USERS_1, resource.getRootPath()), e); 3987 } finally { 3988 dbc.clear(); 3989 } 3990 return result; 3991 } 3992 3993 4007 public List readSiblings(CmsRequestContext context, CmsResource resource, CmsResourceFilter filter) 4008 throws CmsException { 4009 4010 List result = null; 4011 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 4012 try { 4013 result = m_driverManager.readSiblings(dbc, resource, filter); 4014 } catch (Exception e) { 4015 dbc.report(null, Messages.get().container(Messages.ERR_READ_SIBLINGS_1, context.getSitePath(resource)), e); 4016 } finally { 4017 dbc.clear(); 4018 } 4019 return result; 4020 } 4021 4022 4032 public String readStaticExportPublishedResourceParameters(CmsRequestContext context, String rfsName) 4033 throws CmsException { 4034 4035 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 4036 String result = null; 4037 try { 4038 result = m_driverManager.readStaticExportPublishedResourceParameters(dbc, rfsName); 4039 } catch (Exception e) { 4040 dbc.report( 4041 null, 4042 Messages.get().container(Messages.ERR_READ_STATEXP_PUBLISHED_RESOURCE_PARAMS_1, rfsName), 4043 e); 4044 } finally { 4045 dbc.clear(); 4046 } 4047 return result; 4048 } 4049 4050 4061 public List readStaticExportResources(CmsRequestContext context, int parameterResources, long timestamp) 4062 throws CmsException { 4063 4064 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 4065 List result = null; 4066 try { 4067 result = m_driverManager.readStaticExportResources(dbc, parameterResources, timestamp); 4068 } catch (Exception e) { 4069 dbc.report(null, Messages.get().container(Messages.ERR_READ_STATEXP_RESOURCES_1, new Date (timestamp)), e); 4070 } finally { 4071 dbc.clear(); 4072 } 4073 return result; 4074 } 4075 4076 4086 public CmsTask readTask(CmsRequestContext context, int id) throws CmsException { 4087 4088 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 4089 CmsTask result = null; 4090 try { 4091 result = m_driverManager.readTask(dbc, id); 4092 } catch (Exception e) { 4093 dbc.report(null, Messages.get().container(Messages.ERR_READ_TASK_FOR_ID_1, new Integer (id)), e); 4094 } finally { 4095 dbc.clear(); 4096 } 4097 return result; 4098 } 4099 4100 4110 public List readTaskLogs(CmsRequestContext context, int taskid) throws CmsException { 4111 4112 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 4113 List result = null; 4114 try { 4115 result = m_driverManager.readTaskLogs(dbc, taskid); 4116 } catch (Exception e) { 4117 dbc.report(null, Messages.get().container(Messages.ERR_READ_TASKLOGS_FOR_ID_1, new Integer (taskid)), e); 4118 } finally { 4119 dbc.clear(); 4120 } 4121 return result; 4122 } 4123 4124 4146 public List readTasksForProject(CmsRequestContext context, int projectId, int tasktype, String orderBy, String sort) 4147 throws CmsException { 4148 4149 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 4150 List result = null; 4151 try { 4152 result = m_driverManager.readTasksForProject(dbc, projectId, tasktype, orderBy, sort); 4153 } catch (Exception e) { 4154 dbc.report(null, Messages.get().container( 4155 Messages.ERR_READ_TASK_FOR_PROJECT_AND_TYPE_2, 4156 new Integer (projectId), 4157 org.opencms.workflow.Messages.toTaskTypeString(tasktype, context)), e); 4158 } finally { 4159 dbc.clear(); 4160 } 4161 return result; 4162 } 4163 4164 4187 public List readTasksForRole( 4188 CmsRequestContext context, 4189 int projectId, 4190 String roleName, 4191 int tasktype, 4192 String orderBy, 4193 String sort) throws CmsException { 4194 4195 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 4196 List result = null; 4197 try { 4198 result = m_driverManager.readTasksForRole(dbc, projectId, roleName, tasktype, orderBy, sort); 4199 } catch (Exception e) { 4200 dbc.report(null, Messages.get().container( 4201 Messages.ERR_READ_TASK_FOR_PROJECT_AND_ROLE_AND_TYPE_3, 4202 new Integer (projectId), 4203 roleName, 4204 org.opencms.workflow.Messages.toTaskTypeString(tasktype, context)), e); 4205 } finally { 4206 dbc.clear(); 4207 } 4208 return result; 4209 } 4210 4211 4234 public List readTasksForUser( 4235 CmsRequestContext context, 4236 int projectId, 4237 String userName, 4238 int taskType, 4239 String orderBy, 4240 String sort) throws CmsException { 4241 4242 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 4243 List result = null; 4244 try { 4245 result = m_driverManager.readTasksForUser(dbc, projectId, userName, taskType, orderBy, sort); 4246 } catch (Exception e) { 4247 dbc.report(null, Messages.get().container( 4248 Messages.ERR_READ_TASK_FOR_PROJECT_AND_USER_AND_TYPE_3, 4249 new Integer (projectId), 4250 userName, 4251 org.opencms.workflow.Messages.toTaskTypeString(taskType, context)), e); 4252 } finally { 4253 dbc.clear(); 4254 } 4255 return result; 4256 } 4257 4258 4268 public CmsUser readUser(CmsRequestContext context, CmsUUID id) throws CmsException { 4269 4270 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 4271 CmsUser result = null; 4272 try { 4273 result = m_driverManager.readUser(dbc, id); 4274 } catch (Exception e) { 4275 dbc.report(null, Messages.get().container(Messages.ERR_READ_USER_FOR_ID_1, id.toString()), e); 4276 } finally { 4277 dbc.clear(); 4278 } 4279 return result; 4280 } 4281 4282 4293 public CmsUser readUser(CmsRequestContext context, String username, int type) throws CmsException { 4294 4295 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 4296 CmsUser result = null; 4297 try { 4298 result = m_driverManager.readUser(dbc, username, type); 4299 } catch (Exception e) { 4300 dbc.report(null, Messages.get().container(Messages.ERR_READ_USER_FOR_NAME_1, username), e); 4301 } finally { 4302 dbc.clear(); 4303 } 4304 return result; 4305 } 4306 4307 4320 public CmsUser readUser(CmsRequestContext context, String username, String password) throws CmsException { 4321 4322 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 4323 CmsUser result = null; 4324 try { 4325 result = m_driverManager.readUser(dbc, username, password); 4326 } catch (Exception e) { 4327 dbc.report(null, Messages.get().container(Messages.ERR_READ_USER_FOR_NAME_1, username), e); 4328 } finally { 4329 dbc.clear(); 4330 } 4331 return result; 4332 } 4333 4334 4343 public CmsUser readUser(String username) throws CmsException { 4344 4345 CmsDbContext dbc = m_dbContextFactory.getDbContext(); 4346 CmsUser result = null; 4347 try { 4348 result = m_driverManager.readUser(dbc, username); 4349 } catch (Exception e) { 4350 dbc.report(null, Messages.get().container(Messages.ERR_READ_USER_FOR_NAME_1, username), e); 4351 } finally { 4352 dbc.clear(); 4353 } 4354 return result; 4355 } 4356 4357 4367 public CmsUser readWebUser(CmsRequestContext context, String username) throws CmsException { 4368 4369 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 4370 CmsUser result = null; 4371 try { 4372 result = m_driverManager.readWebUser(dbc, username); 4373 } catch (Exception e) { 4374 dbc.report(null, Messages.get().container(Messages.ERR_READ_USER_WEB_1, username), e); 4375 } finally { 4376 dbc.clear(); 4377 } 4378 return result; 4379 } 4380 4381 4394 public CmsUser readWebUser(CmsRequestContext context, String username, String password) throws CmsException { 4395 4396 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 4397 CmsUser result = null; 4398 try { 4399 result = m_driverManager.readWebUser(dbc, username, password); 4400 } catch (Exception e) { 4401 dbc.report(null, Messages.get().container(Messages.ERR_READ_USER_WEB_1, username), e); 4402 } finally { 4403 dbc.clear(); 4404 } 4405 return result; 4406 } 4407 4408 4419 public void removeAccessControlEntry(CmsRequestContext context, CmsResource resource, CmsUUID principal) 4420 throws CmsException, CmsSecurityException { 4421 4422 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 4423 try { 4424 checkOfflineProject(dbc); 4425 checkPermissions(dbc, resource, CmsPermissionSet.ACCESS_CONTROL, true, CmsResourceFilter.ALL); 4426 m_driverManager.removeAccessControlEntry(dbc, resource, principal); 4427 } catch (Exception e) { 4428 dbc.report(null, Messages.get().container( 4429 Messages.ERR_REMOVE_ACL_ENTRY_2, 4430 context.getSitePath(resource), 4431 principal.toString()), e); 4432 } finally { 4433 dbc.clear(); 4434 } 4435 } 4436 4437 4446 public void removeResourceFromProject(CmsRequestContext context, CmsResource resource) 4447 throws CmsException, CmsRoleViolationException { 4448 4449 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 4450 try { 4451 checkOfflineProject(dbc); 4452 checkManagerOfProjectRole(dbc, context.currentProject()); 4453 4454 if (dbc.currentProject().getFlags() != CmsProject.PROJECT_STATE_UNLOCKED) { 4455 throw new CmsLockException(org.opencms.lock.Messages.get().container( 4456 org.opencms.lock.Messages.ERR_RESOURCE_LOCKED_1, 4457 dbc.currentProject().getName())); 4458 } 4459 4460 m_driverManager.removeResourceFromProject(dbc, resource); 4461 } catch (Exception e) { 4462 dbc.report(null, Messages.get().container( 4463 Messages.ERR_COPY_RESOURCE_TO_PROJECT_2, 4464 context.getSitePath(resource), 4465 context.currentProject().getName()), e); 4466 } finally { 4467 dbc.clear(); 4468 } 4469 } 4470 4471 4482 public void removeUserFromGroup(CmsRequestContext context, String username, String groupname) 4483 throws CmsException, CmsRoleViolationException { 4484 4485 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 4486 try { 4487 checkRole(dbc, CmsRole.ACCOUNT_MANAGER); 4488 m_driverManager.removeUserFromGroup(dbc, username, groupname); 4489 } catch (Exception e) { 4490 dbc.report(null, Messages.get().container(Messages.ERR_REMOVE_USER_FROM_GROUP_2, username, groupname), e); 4491 } finally { 4492 dbc.clear(); 4493 } 4494 } 4495 4496 4511 public void replaceResource( 4512 CmsRequestContext context, 4513 CmsResource resource, 4514 int type, 4515 byte[] content, 4516 List properties) throws CmsException, CmsSecurityException { 4517 4518 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 4519 try { 4520 checkOfflineProject(dbc); 4521 checkPermissions(dbc, resource, CmsPermissionSet.ACCESS_WRITE, true, CmsResourceFilter.ALL); 4522 m_driverManager.replaceResource(dbc, resource, type, content, properties); 4523 } catch (Exception e) { 4524 dbc.report( 4525 null, 4526 Messages.get().container(Messages.ERR_REPLACE_RESOURCE_1, context.getSitePath(resource)), 4527 e); 4528 } finally { 4529 dbc.clear(); 4530 } 4531 } 4532 4533 4544 public void resetPassword(CmsRequestContext context, String username, String oldPassword, String newPassword) 4545 throws CmsException, CmsSecurityException { 4546 4547 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 4548 try { 4549 m_driverManager.resetPassword(dbc, username, oldPassword, newPassword); 4550 } catch (Exception e) { 4551 dbc.report(null, Messages.get().container(Messages.ERR_RESET_PASSWORD_1, username), e); 4552 } finally { 4553 dbc.clear(); 4554 } 4555 } 4556 4557 4570 public void restoreResource(CmsRequestContext context, CmsResource resource, int tag) 4571 throws CmsException, CmsSecurityException { 4572 4573 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 4574 try { 4575 checkOfflineProject(dbc); 4576 checkPermissions(dbc, resource, CmsPermissionSet.ACCESS_WRITE, true, CmsResourceFilter.ALL); 4577 m_driverManager.restoreResource(dbc, resource, tag); 4578 } catch (Exception e) { 4579 dbc.report(null, Messages.get().container( 4580 Messages.ERR_RESTORE_RESOURCE_2, 4581 context.getSitePath(resource), 4582 new Integer (tag)), e); 4583 } finally { 4584 dbc.clear(); 4585 } 4586 } 4587 4588 4601 public void setDateExpired(CmsRequestContext context, CmsResource resource, long dateExpired) 4602 throws CmsException, CmsSecurityException { 4603 4604 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 4605 try { 4606 checkOfflineProject(dbc); 4607 checkPermissions(dbc, resource, CmsPermissionSet.ACCESS_WRITE, true, CmsResourceFilter.IGNORE_EXPIRATION); 4608 m_driverManager.setDateExpired(dbc, resource, dateExpired); 4609 } catch (Exception e) { 4610 dbc.report(null, Messages.get().container( 4611 Messages.ERR_SET_DATE_EXPIRED_2, 4612 new Object [] {new Date (dateExpired), context.getSitePath(resource)}), e); 4613 } finally { 4614 dbc.clear(); 4615 } 4616 } 4617 4618 4631 public void setDateLastModified(CmsRequestContext context, CmsResource resource, long dateLastModified) 4632 throws CmsException, CmsSecurityException { 4633 4634 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 4635 try { 4636 checkOfflineProject(dbc); 4637 checkPermissions(dbc, resource, CmsPermissionSet.ACCESS_WRITE, true, CmsResourceFilter.IGNORE_EXPIRATION); 4638 m_driverManager.setDateLastModified(dbc, resource, dateLastModified); 4639 } catch (Exception e) { 4640 dbc.report(null, Messages.get().container( 4641 Messages.ERR_SET_DATE_LAST_MODIFIED_2, 4642 new Object [] {new Date (dateLastModified), context.getSitePath(resource)}), e); 4643 } finally { 4644 dbc.clear(); 4645 } 4646 } 4647 4648 4661 public void setDateReleased(CmsRequestContext context, CmsResource resource, long dateReleased) 4662 throws CmsException, CmsSecurityException { 4663 4664 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 4665 try { 4666 checkOfflineProject(dbc); 4667 checkPermissions(dbc, resource, CmsPermissionSet.ACCESS_WRITE, true, CmsResourceFilter.IGNORE_EXPIRATION); 4668 m_driverManager.setDateReleased(dbc, resource, dateReleased); 4669 } catch (Exception e) { 4670 dbc.report(null, Messages.get().container( 4671 Messages.ERR_SET_DATE_RELEASED_2, 4672 new Object [] {new Date (dateReleased), context.getSitePath(resource)}), e); 4673 } finally { 4674 dbc.clear(); 4675 } 4676 } 4677 4678 4687 public void setName(CmsRequestContext context, int taskId, String name) throws CmsException { 4688 4689 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 4690 try { 4691 m_driverManager.setName(dbc, taskId, name); 4692 } catch (Exception e) { 4693 dbc.report(null, Messages.get().container(Messages.ERR_SET_TASK_NAME_2, name, new Integer (taskId)), e); 4694 } finally { 4695 dbc.clear(); 4696 } 4697 } 4698 4699 4712 public void setParentGroup(CmsRequestContext context, String groupName, String parentGroupName) 4713 throws CmsException, CmsRoleViolationException { 4714 4715 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 4716 4717 try { 4718 checkRole(dbc, CmsRole.ACCOUNT_MANAGER); 4719 m_driverManager.setParentGroup(dbc, groupName, parentGroupName); 4720 } catch (Exception e) { 4721 dbc.report(null, Messages.get().container(Messages.ERR_SET_PARENT_GROUP_2, parentGroupName, groupName), e); 4722 } finally { 4723 dbc.clear(); 4724 } 4725 } 4726 4727 4737 public void setPassword(CmsRequestContext context, String username, String newPassword) 4738 throws CmsException, CmsRoleViolationException { 4739 4740 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 4741 try { 4742 checkRole(dbc, CmsRole.ACCOUNT_MANAGER); 4743 m_driverManager.setPassword(dbc, username, newPassword); 4744 } catch (Exception e) { 4745 dbc.report(null, Messages.get().container(Messages.ERR_SET_PASSWORD_1, username), e); 4746 } finally { 4747 dbc.clear(); 4748 } 4749 } 4750 4751 4760 public void setPriority(CmsRequestContext context, int taskId, int priority) throws CmsException { 4761 4762 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 4763 try { 4764 m_driverManager.setPriority(dbc, taskId, priority); 4765 } catch (Exception e) { 4766 dbc.report(null, Messages.get().container( 4767 Messages.ERR_SET_TASK_PRIORITY_2, 4768 new Integer (taskId), 4769 new Integer (priority)), e); 4770 } finally { 4771 dbc.clear(); 4772 } 4773 } 4774 4775 4785 public void setTaskPar(CmsRequestContext context, int taskId, String parName, String parValue) throws CmsException { 4786 4787 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 4788 try { 4789 m_driverManager.setTaskPar(dbc, taskId, parName, parValue); 4790 } catch (Exception e) { 4791 dbc.report(null, Messages.get().container( 4792 Messages.ERR_SET_TASK_PARAM_3, 4793 parName, 4794 parValue, 4795 new Integer (taskId)), e); 4796 } finally { 4797 dbc.clear(); 4798 } 4799 } 4800 4801 4810 public void setTimeout(CmsRequestContext context, int taskId, long timeout) throws CmsException { 4811 4812 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 4813 try { 4814 m_driverManager.setTimeout(dbc, taskId, timeout); 4815 } catch (Exception e) { 4816 dbc.report(null, Messages.get().container( 4817 Messages.ERR_SET_TASK_TIMEOUT_2, 4818 new Date (timeout), 4819 new Integer (taskId)), e); 4820 } finally { 4821 dbc.clear(); 4822 } 4823 } 4824 4825 4838 public void undoChanges(CmsRequestContext context, CmsResource resource) throws CmsException, CmsSecurityException { 4839 4840 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 4841 try { 4842 checkOfflineProject(dbc); 4843 checkPermissions(dbc, resource, CmsPermissionSet.ACCESS_WRITE, true, CmsResourceFilter.ALL); 4844 m_driverManager.undoChanges(dbc, resource); 4845 } catch (Exception e) { 4846 dbc.report(null, Messages.get().container( 4847 Messages.ERR_UNDO_CHANGES_FOR_RESOURCE_1, 4848 context.getSitePath(resource)), e); 4849 } finally { 4850 dbc.clear(); 4851 } 4852 } 4853 4854 4863 public void unlockProject(CmsRequestContext context, int projectId) throws CmsException, CmsRoleViolationException { 4864 4865 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 4866 CmsProject project = m_driverManager.readProject(dbc, projectId); 4867 4868 try { 4869 checkManagerOfProjectRole(dbc, project); 4870 m_driverManager.unlockProject(project); 4871 } catch (Exception e) { 4872 dbc.report(null, Messages.get().container( 4873 Messages.ERR_UNLOCK_PROJECT_2, 4874 new Integer (projectId), 4875 dbc.currentUser().getName()), e); 4876 } finally { 4877 dbc.clear(); 4878 } 4879 } 4880 4881 4893 public void unlockResource(CmsRequestContext context, CmsResource resource) 4894 throws CmsException, CmsSecurityException { 4895 4896 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 4897 try { 4898 checkOfflineProject(dbc); 4899 checkPermissions(dbc, resource, CmsPermissionSet.ACCESS_WRITE, true, CmsResourceFilter.ALL); 4900 m_driverManager.unlockResource(dbc, resource); 4901 } catch (Exception e) { 4902 dbc.report(null, Messages.get().container( 4903 Messages.ERR_UNLOCK_RESOURCE_2, 4904 context.getSitePath(resource), 4905 dbc.currentUser().getName()), e); 4906 } finally { 4907 dbc.clear(); 4908 } 4909 } 4910 4911 4922 public boolean userInGroup(CmsRequestContext context, String username, String groupname) throws CmsException { 4923 4924 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 4925 boolean result = false; 4926 try { 4927 result = m_driverManager.userInGroup(dbc, username, groupname); 4928 } catch (Exception e) { 4929 dbc.report(null, Messages.get().container(Messages.ERR_USER_IN_GROUP_2, username, groupname), e); 4930 } finally { 4931 dbc.clear(); 4932 } 4933 return result; 4934 } 4935 4936 4951 public Map validateHtmlLinks(CmsObject cms, CmsPublishList publishList, I_CmsReport report) throws Exception { 4952 4953 return m_driverManager.validateHtmlLinks(cms, publishList, report); 4954 } 4955 4956 4968 public void validatePassword(String password) throws CmsSecurityException { 4969 4970 m_driverManager.validatePassword(password); 4971 } 4972 4973 4983 public void writeAccessControlEntry(CmsRequestContext context, CmsResource resource, CmsAccessControlEntry ace) 4984 throws CmsException, CmsSecurityException { 4985 4986 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 4987 try { 4988 checkOfflineProject(dbc); 4989 checkPermissions(dbc, resource, CmsPermissionSet.ACCESS_CONTROL, true, CmsResourceFilter.ALL); 4990 m_driverManager.writeAccessControlEntry(dbc, resource, ace); 4991 } catch (Exception e) { 4992 dbc.report(null, Messages.get().container(Messages.ERR_WRITE_ACL_ENTRY_1, context.getSitePath(resource)), e); 4993 } finally { 4994 dbc.clear(); 4995 } 4996 } 4997 4998 5019 public CmsFile writeFile(CmsRequestContext context, CmsFile resource) throws CmsException, CmsSecurityException { 5020 5021 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 5022 CmsFile result = null; 5023 try { 5024 checkOfflineProject(dbc); 5025 checkPermissions(dbc, resource, CmsPermissionSet.ACCESS_WRITE, true, CmsResourceFilter.ALL); 5026 result = m_driverManager.writeFile(dbc, resource); 5027 } catch (Exception e) { 5028 dbc.report(null, Messages.get().container(Messages.ERR_WRITE_FILE_1, context.getSitePath(resource)), e); 5029 } finally { 5030 dbc.clear(); 5031 } 5032 return result; 5033 } 5034 5035 5049 public void writeGroup(CmsRequestContext context, CmsGroup group) throws CmsException, CmsRoleViolationException { 5050 5051 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 5052 try { 5053 checkRole(dbc, CmsRole.ACCOUNT_MANAGER); 5054 m_driverManager.writeGroup(dbc, group); 5055 } catch (Exception e) { 5056 dbc.report(null, Messages.get().container(Messages.ERR_WRITE_GROUP_1, group.getName()), e); 5057 } finally { 5058 dbc.clear(); 5059 } 5060 } 5061 5062 5076 public void writeProject(CmsRequestContext context, CmsProject project) 5077 throws CmsRoleViolationException, CmsException { 5078 5079 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 5080 try { 5081 checkRole(dbc, CmsRole.PROJECT_MANAGER); 5082 m_driverManager.writeProject(dbc, project); 5083 } catch (Exception e) { 5084 dbc.report(null, Messages.get().container(Messages.ERR_WRITE_PROJECT_1, project.getName()), e); 5085 } finally { 5086 dbc.clear(); 5087 } 5088 } 5089 5090 5103 public void writePropertyObject(CmsRequestContext context, CmsResource resource, CmsProperty property) 5104 throws CmsException, CmsSecurityException { 5105 5106 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 5107 try { 5108 checkOfflineProject(dbc); 5109 checkPermissions(dbc, resource, CmsPermissionSet.ACCESS_WRITE, true, CmsResourceFilter.IGNORE_EXPIRATION); 5110 m_driverManager.writePropertyObject(dbc, resource, property); 5111 } catch (Exception e) { 5112 dbc.report(null, Messages.get().container( 5113 Messages.ERR_WRITE_PROP_2, 5114 property.getName(), 5115 context.getSitePath(resource)), e); 5116 } finally { 5117 dbc.clear(); 5118 } 5119 } 5120 5121 5138 public void writePropertyObjects(CmsRequestContext context, CmsResource resource, List properties) 5139 throws CmsException, CmsSecurityException { 5140 5141 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 5142 try { 5143 checkOfflineProject(dbc); 5144 checkPermissions(dbc, resource, CmsPermissionSet.ACCESS_WRITE, true, CmsResourceFilter.IGNORE_EXPIRATION); 5145 5146 m_driverManager.writePropertyObjects(dbc, resource, properties); 5148 5149 resource.setUserLastModified(context.currentUser().getId()); 5151 m_driverManager.getVfsDriver().writeResource( 5152 dbc, 5153 context.currentProject(), 5154 resource, 5155 CmsDriverManager.UPDATE_RESOURCE_STATE); 5156 5157 } catch (Exception e) { 5158 dbc.report(null, Messages.get().container(Messages.ERR_WRITE_PROPS_1, context.getSitePath(resource)), e); 5159 } finally { 5160 dbc.clear(); 5161 } 5162 } 5163 5164 5173 public void writeResource(CmsRequestContext context, CmsResource resource) 5174 throws CmsException, CmsSecurityException { 5175 5176 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 5177 try { 5178 checkOfflineProject(dbc); 5179 checkPermissions(dbc, resource, CmsPermissionSet.ACCESS_WRITE, true, CmsResourceFilter.ALL); 5180 m_driverManager.writeResource(dbc, resource); 5181 } catch (Exception e) { 5182 dbc.report(null, Messages.get().container(Messages.ERR_WRITE_RESOURCE_1, context.getSitePath(resource)), e); 5183 } finally { 5184 dbc.clear(); 5185 } 5186 } 5187 5188 5201 public void writeStaticExportPublishedResource( 5202 CmsRequestContext context, 5203 String resourceName, 5204 int linkType, 5205 String linkParameter, 5206 long timestamp) throws CmsException { 5207 5208 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 5209 try { 5210 m_driverManager.writeStaticExportPublishedResource(dbc, resourceName, linkType, linkParameter, timestamp); 5211 } catch (Exception e) { 5212 dbc.report(null, Messages.get().container( 5213 Messages.ERR_WRITE_STATEXP_PUBLISHED_RESOURCES_3, 5214 resourceName, 5215 linkParameter, 5216 new Date (timestamp)), e); 5217 } finally { 5218 dbc.clear(); 5219 } 5220 } 5221 5222 5231 public void writeTaskLog(CmsRequestContext context, int taskid, String comment) throws CmsException { 5232 5233 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 5234 try { 5235 m_driverManager.writeTaskLog(dbc, taskid, comment); 5236 } catch (Exception e) { 5237 dbc.report(null, Messages.get().container(Messages.ERR_WRITE_TASK_LOG_1, new Integer (taskid)), e); 5238 } finally { 5239 dbc.clear(); 5240 } 5241 } 5242 5243 5253 public void writeTaskLog(CmsRequestContext context, int taskId, String comment, int type) throws CmsException { 5254 5255 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 5256 try { 5257 m_driverManager.writeTaskLog(dbc, taskId, comment, type); 5258 } catch (Exception e) { 5259 dbc.report(null, Messages.get().container(Messages.ERR_WRITE_TASK_LOG_1, new Integer (taskId)), e); 5260 } finally { 5261 dbc.clear(); 5262 } 5263 } 5264 5265 5279 public void writeUser(CmsRequestContext context, CmsUser user) throws CmsException, CmsRoleViolationException { 5280 5281 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 5282 try { 5283 if (!context.currentUser().equals(user)) { 5284 checkRole(dbc, CmsRole.ACCOUNT_MANAGER); 5286 } 5287 m_driverManager.writeUser(dbc, user); 5288 } catch (Exception e) { 5289 dbc.report(null, Messages.get().container(Messages.ERR_WRITE_USER_1, user.getName()), e); 5290 } finally { 5291 dbc.clear(); 5292 } 5293 } 5294 5295 5310 public void writeWebUser(CmsRequestContext context, CmsUser user) throws CmsException { 5311 5312 if (!user.isWebUser()) { 5313 throw new CmsSecurityException(Messages.get().container(Messages.ERR_WRITE_WEB_USER_CONSTRAINT_0)); 5314 } 5315 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 5316 try { 5317 m_driverManager.writeWebUser(dbc, user); 5318 } catch (Exception e) { 5319 dbc.report(null, Messages.get().container(Messages.ERR_WRITE_WEB_USER_1, user.getName()), e); 5320 } finally { 5321 dbc.clear(); 5322 } 5323 } 5324 5325 5342 protected void checkPermissions( 5343 CmsDbContext dbc, 5344 CmsResource resource, 5345 CmsPermissionSet requiredPermissions, 5346 boolean checkLock, 5347 CmsResourceFilter filter) throws CmsException, CmsSecurityException { 5348 5349 int permissions = hasPermissions(dbc, resource, requiredPermissions, checkLock, filter); 5351 if (permissions != 0) { 5352 checkPermissions(dbc.getRequestContext(), resource, requiredPermissions, permissions); 5353 } 5354 } 5355 5356 5369 protected void checkPermissions( 5370 CmsRequestContext context, 5371 CmsResource resource, 5372 CmsPermissionSet requiredPermissions, 5373 int permissions) throws CmsSecurityException, CmsLockException, CmsVfsResourceNotFoundException { 5374 5375 switch (permissions) { 5376 case PERM_FILTERED: 5377 throw new CmsVfsResourceNotFoundException(Messages.get().container( 5378 Messages.ERR_PERM_FILTERED_1, 5379 context.getSitePath(resource))); 5380 5381 case PERM_DENIED: 5382 throw new CmsPermissionViolationException(Messages.get().container( 5383 Messages.ERR_PERM_DENIED_2, 5384 context.getSitePath(resource), 5385 requiredPermissions.getPermissionString())); 5386 5387 case PERM_NOTLOCKED: 5388 throw new CmsLockException(Messages.get().container( 5389 Messages.ERR_PERM_NOTLOCKED_2, 5390 context.getSitePath(resource), 5391 context.currentUser().getName())); 5392 5393 case PERM_ALLOWED: 5394 default: 5395 return; 5396 } 5397 } 5398 5399 5402 protected void clearPermissionCache() { 5403 5404 m_permissionCache.clear(); 5405 } 5406 5407 5410 protected void finalize() throws Throwable { 5411 5412 try { 5413 if (m_driverManager != null) { 5414 m_driverManager.destroy(); 5415 } 5416 } catch (Throwable t) { 5417 if (LOG.isErrorEnabled()) { 5418 LOG.error(Messages.get().getBundle().key(Messages.LOG_ERR_DRIVER_MANAGER_CLOSE_0), t); 5419 } 5420 } 5421 5422 m_driverManager = null; 5423 m_dbContextFactory = null; 5424 5425 super.finalize(); 5426 5427 } 5428 5429 5452 protected int hasPermissions( 5453 CmsDbContext dbc, 5454 CmsResource resource, 5455 CmsPermissionSet requiredPermissions, 5456 boolean checkLock, 5457 CmsResourceFilter filter) throws CmsException { 5458 5459 if (!filter.isValid(dbc.getRequestContext(), resource)) { 5462 return PERM_FILTERED; 5463 } 5464 5465 String cacheKey = m_keyGenerator.getCacheKeyForUserPermissions( 5468 filter.requireVisible() && checkLock ? "11" : (!filter.requireVisible() && checkLock ? "01" 5469 : (filter.requireVisible() && !checkLock ? "10" : "00")), 5470 dbc, 5471 resource, 5472 requiredPermissions); 5473 Integer cacheResult = (Integer )m_permissionCache.get(cacheKey); 5474 if (cacheResult != null) { 5475 return cacheResult.intValue(); 5476 } 5477 5478 int denied = 0; 5479 5480 if (dbc.currentProject().isOnlineProject()) { 5482 denied |= CmsPermissionSet.PERMISSION_WRITE; 5483 } 5484 5485 boolean canIgnorePermissions = hasRole(dbc, CmsRole.VFS_MANAGER); 5487 5488 boolean writeRequired = requiredPermissions.requiresWritePermission() 5490 || requiredPermissions.requiresControlPermission(); 5491 5492 if (writeRequired && !canIgnorePermissions && (resource.getTypeId() == CmsResourceTypeJsp.getStaticTypeId())) { 5495 if (!hasRole(dbc, CmsRole.DEVELOPER)) { 5496 denied |= CmsPermissionSet.PERMISSION_WRITE; 5497 denied |= CmsPermissionSet.PERMISSION_CONTROL; 5498 } 5499 } 5500 5501 if (writeRequired && checkLock) { 5502 CmsLock lock = m_driverManager.getLock(dbc, resource); 5504 if (lock.isNullLock() || !dbc.currentUser().getId().equals(lock.getUserId())) { 5507 return PERM_NOTLOCKED; 5508 } 5509 } 5510 5511 CmsPermissionSetCustom permissions; 5512 if (canIgnorePermissions) { 5513 permissions = new CmsPermissionSetCustom(~0); 5515 } else { 5516 permissions = m_driverManager.getPermissions(dbc, resource, dbc.currentUser()); 5518 } 5519 5520 permissions.denyPermissions(denied); 5522 5523 if ((permissions.getPermissions() & CmsPermissionSet.PERMISSION_VIEW) == 0) { 5524 if (filter.requireVisible()) { 5526 requiredPermissions = new CmsPermissionSet(requiredPermissions.getAllowedPermissions() 5528 | CmsPermissionSet.PERMISSION_VIEW, requiredPermissions.getDeniedPermissions()); 5529 } else { 5530 permissions.setPermissions( 5532 permissions.getAllowedPermissions() | CmsPermissionSet.PERMISSION_VIEW, 5534 permissions.getDeniedPermissions() & ~CmsPermissionSet.PERMISSION_VIEW); 5535 } 5536 } 5537 5538 Integer result; 5539 if ((requiredPermissions.getPermissions() & (permissions.getPermissions())) == requiredPermissions.getPermissions()) { 5540 result = PERM_ALLOWED_INTEGER; 5541 } else { 5542 result = PERM_DENIED_INTEGER; 5543 } 5544 m_permissionCache.put(cacheKey, result); 5545 5546 if ((result != PERM_ALLOWED_INTEGER) && LOG.isDebugEnabled()) { 5547 LOG.debug(Messages.get().getBundle().key( 5548 Messages.LOG_NO_PERMISSION_RESOURCE_USER_4, 5549 new Object [] { 5550 dbc.getRequestContext().removeSiteRoot(resource.getRootPath()), 5551 dbc.currentUser().getName(), 5552 requiredPermissions.getPermissionString(), 5553 permissions.getPermissionString()})); 5554 } 5555 5556 return result.intValue(); 5557 } 5558 5559 5570 protected CmsFolder readFolder(CmsDbContext dbc, String resourcename, CmsResourceFilter filter) throws CmsException { 5571 5572 CmsResource resource = readResource(dbc, resourcename, filter); 5573 return m_driverManager.convertResourceToFolder(resource); 5574 } 5575 5576 5591 protected CmsResource readResource(CmsDbContext dbc, String resourcePath, CmsResourceFilter filter) 5592 throws CmsException { 5593 5594 CmsResource resource = m_driverManager.readResource(dbc, resourcePath, filter); 5596 5597 checkPermissions(dbc, resource, CmsPermissionSet.ACCESS_READ, true, filter); 5599 5600 return resource; 5602 } 5603 5604 5616 private void deleteUser(CmsRequestContext context, CmsUser user, CmsUser replacement) 5617 throws CmsException, CmsSecurityException, CmsRoleViolationException { 5618 5619 if (OpenCms.getDefaultUsers().isDefaultUser(user.getName())) { 5620 throw new CmsSecurityException(org.opencms.security.Messages.get().container( 5621 org.opencms.security.Messages.ERR_CANT_DELETE_DEFAULT_USER_1, 5622 user.getName())); 5623 } 5624 if (context.currentUser().equals(user)) { 5625 throw new CmsSecurityException(Messages.get().container(Messages.ERR_USER_CANT_DELETE_ITSELF_USER_0)); 5626 } 5627 CmsDbContext dbc = m_dbContextFactory.getDbContext(context); 5628 try { 5629 checkRole(dbc, CmsRole.ACCOUNT_MANAGER); 5630 checkOfflineProject(dbc); 5634 if (replacement == null) { 5635 m_driverManager.deleteUser(dbc, context.currentProject(), user.getName(), null); 5636 } else { 5637 m_driverManager.deleteUser(dbc, context.currentProject(), user.getName(), replacement.getName()); 5638 } 5639 } catch (Exception e) { 5640 dbc.report(null, Messages.get().container(Messages.ERR_DELETE_USER_1, user.getName()), e); 5641 } finally { 5642 dbc.clear(); 5643 } 5644 } 5645} | Popular Tags |