1 31 32 package org.opencms.test; 33 34 import org.opencms.file.CmsProperty; 35 36 import java.util.ArrayList ; 37 import java.util.Iterator ; 38 import java.util.List ; 39 40 54 public abstract class OpenCmsTestResourceFilter { 55 56 57 public static final OpenCmsTestResourceFilter FILTER_CHACC = getFilterChacc(); 58 59 60 public static final OpenCmsTestResourceFilter FILTER_CHFLAGS = getFilterChflags(); 61 62 63 public static final OpenCmsTestResourceFilter FILTER_CHTYPE = getFilterChtype(); 64 65 66 public static final OpenCmsTestResourceFilter FILTER_COPY_FILE_AS_NEW = getFilterCopyFileAsNew(); 67 68 69 public static final OpenCmsTestResourceFilter FILTER_COPY_FOLDER = getFilterCopyFolder(); 70 71 72 public static final OpenCmsTestResourceFilter FILTER_COPY_SOURCE_DESTINATION_AS_SIBLING = getFilterCopySourceDestinationAsSibling(); 73 74 75 public static final OpenCmsTestResourceFilter FILTER_CREATE_RESOURCE = getFilterCreateResource(); 76 77 78 public static final OpenCmsTestResourceFilter FILTER_EQUAL = new OpenCmsTestResourceConfigurableFilter(); 79 80 81 public static final OpenCmsTestResourceFilter FILTER_EXISTING_AND_NEW_SIBLING = getFilterExistingAndNewSibling(); 82 83 84 public static final OpenCmsTestResourceFilter FILTER_EXISTING_SIBLING = getFilterExistingSibling(); 85 86 87 public static final OpenCmsTestResourceFilter FILTER_MOVE_DESTINATION = getFilterMoveDestination(); 88 89 90 public static final OpenCmsTestResourceFilter FILTER_MOVE_SOURCE = getFilterMoveSource(); 91 92 93 public static final OpenCmsTestResourceFilter FILTER_PUBLISHRESOURCE = getFilterPublishResource(); 94 95 96 public static final OpenCmsTestResourceFilter FILTER_REPLACERESOURCE = getFilterReplaceResource(); 97 98 99 public static final OpenCmsTestResourceFilter FILTER_TOUCH = getFilterTouch(); 100 101 102 public static final OpenCmsTestResourceFilter FILTER_UNDOCHANGES = getFilterUndoChanges(); 103 104 105 public static final OpenCmsTestResourceFilter FILTER_WRITEPROPERTY = getFilterWriteProperty(); 106 107 108 protected boolean m_ace; 109 110 111 protected boolean m_acl; 112 113 114 protected boolean m_contentId; 115 116 117 protected boolean m_contents; 118 119 120 protected boolean m_dateCreated; 121 122 123 protected boolean m_dateExpired; 124 125 126 protected boolean m_dateLastModified; 127 128 129 protected boolean m_dateReleased; 130 131 132 protected boolean m_flags; 133 134 135 protected boolean m_isTouched; 136 137 138 protected boolean m_length; 139 140 141 protected boolean m_lockstate; 142 143 144 protected boolean m_name; 145 146 147 protected boolean m_projectLastModified; 148 149 150 protected boolean m_properties; 151 152 153 protected boolean m_resourceId; 154 155 156 protected boolean m_siblingCount; 157 158 159 protected boolean m_state; 160 161 162 protected boolean m_structureId; 163 164 165 protected boolean m_type; 166 167 168 protected boolean m_userCreated; 169 170 171 protected boolean m_userLastModified; 172 173 183 public static List compareProperties(List source, List target, List exclude) { 184 185 List result = new ArrayList (); 186 List targetClone = new ArrayList (target); 187 Iterator i = source.iterator(); 188 while (i.hasNext()) { 189 boolean found = false; 190 CmsProperty sourceProperty = (CmsProperty)i.next(); 191 Iterator j = targetClone.iterator(); 192 CmsProperty targetProperty = null; 193 while (j.hasNext()) { 194 targetProperty = (CmsProperty)j.next(); 195 if (sourceProperty.isIdentical(targetProperty)) { 196 found = true; 197 break; 198 } 199 } 200 if (!found) { 201 result.add(sourceProperty); 202 } else { 203 targetClone.remove(targetProperty); 204 } 205 } 206 207 if (exclude != null) { 209 Iterator l = exclude.iterator(); 210 while (l.hasNext()) { 211 CmsProperty excludeProperty = (CmsProperty)l.next(); 212 if (result.contains(excludeProperty)) { 213 result.remove(excludeProperty); 214 } 215 } 216 } 217 218 return result; 219 } 220 221 226 private static OpenCmsTestResourceConfigurableFilter getFilterChacc() { 227 228 OpenCmsTestResourceConfigurableFilter filter = new OpenCmsTestResourceConfigurableFilter(); 229 230 filter.disableStateTest(); 231 filter.disableProjectLastModifiedTest(); 232 filter.disableAclTest(); 233 filter.disableAceTest(); 234 235 return filter; 236 } 237 238 243 private static OpenCmsTestResourceConfigurableFilter getFilterChflags() { 244 245 OpenCmsTestResourceConfigurableFilter filter = new OpenCmsTestResourceConfigurableFilter(); 246 247 filter.disableFlagsTest(); 248 filter.disableStateTest(); 249 filter.disableProjectLastModifiedTest(); 250 filter.disableDateLastModifiedTest(); 251 filter.disableUserLastModifiedTest(); 252 253 return filter; 254 } 255 256 261 private static OpenCmsTestResourceConfigurableFilter getFilterChtype() { 262 263 OpenCmsTestResourceConfigurableFilter filter = new OpenCmsTestResourceConfigurableFilter(); 264 265 filter.disableTypeTest(); 266 filter.disableDateLastModifiedTest(); 267 268 return filter; 269 } 270 271 276 private static OpenCmsTestResourceConfigurableFilter getFilterCopyFileAsNew() { 277 278 OpenCmsTestResourceConfigurableFilter filter = new OpenCmsTestResourceConfigurableFilter(); 279 280 filter.disableProjectLastModifiedTest(); 281 filter.disableStateTest(); 282 filter.disableStructureIdTest(); 283 filter.disableContentIdTest(); 284 filter.disableResourceIdTest(); 285 filter.disableUserCreatedTest(); 286 filter.disableDateCreatedTest(); 287 filter.disableLockTest(); 288 filter.disableNameTest(); 289 filter.disableAceTest(); 290 return filter; 291 } 292 293 298 private static OpenCmsTestResourceConfigurableFilter getFilterCopyFolder() { 299 300 OpenCmsTestResourceConfigurableFilter filter = getFilterCopyFileAsNew(); 301 302 filter.disableDateLastModifiedTest(); 304 filter.disableUserLastModifiedTest(); 305 return filter; 306 } 307 308 313 private static OpenCmsTestResourceConfigurableFilter getFilterCopySourceDestinationAsSibling() { 314 315 OpenCmsTestResourceConfigurableFilter filter = new OpenCmsTestResourceConfigurableFilter(); 316 317 filter.disableProjectLastModifiedTest(); 318 filter.disableStateTest(); 319 filter.disableStructureIdTest(); 320 filter.disableLockTest(); 321 filter.disableNameTest(); 322 return filter; 323 } 324 325 330 private static OpenCmsTestResourceConfigurableFilter getFilterCreateResource() { 331 332 OpenCmsTestResourceConfigurableFilter filter = new OpenCmsTestResourceConfigurableFilter(); 333 334 filter.disableProjectLastModifiedTest(); 335 filter.disableStateTest(); 336 filter.disableDateLastModifiedTest(); 337 filter.disableUserLastModifiedTest(); 338 filter.disableContentsTest(); 339 filter.disableLengthTest(); 340 filter.disableLockTest(); 341 return filter; 342 } 343 344 350 private static OpenCmsTestResourceConfigurableFilter getFilterExistingAndNewSibling() { 351 352 OpenCmsTestResourceConfigurableFilter filter = new OpenCmsTestResourceConfigurableFilter(); 353 354 filter.disableStateTest(); 355 filter.disableStructureIdTest(); 356 filter.disableNameTest(); 357 filter.disableLockTest(); 358 359 return filter; 360 } 361 362 368 private static OpenCmsTestResourceConfigurableFilter getFilterExistingSibling() { 369 370 OpenCmsTestResourceConfigurableFilter filter = new OpenCmsTestResourceConfigurableFilter(); 371 372 filter.disableProjectLastModifiedTest(); 373 filter.disableSiblingCountTest(); 374 filter.disableLockTest(); 375 376 return filter; 377 } 378 379 384 private static OpenCmsTestResourceConfigurableFilter getFilterMoveDestination() { 385 386 OpenCmsTestResourceConfigurableFilter filter = new OpenCmsTestResourceConfigurableFilter(); 387 388 filter.disableProjectLastModifiedTest(); 389 filter.disableStateTest(); 390 filter.disableStructureIdTest(); 391 filter.disableLockTest(); 392 filter.disableNameTest(); 393 filter.disableSiblingCountTest(); 394 return filter; 395 } 396 397 402 private static OpenCmsTestResourceConfigurableFilter getFilterMoveSource() { 403 404 OpenCmsTestResourceConfigurableFilter filter = new OpenCmsTestResourceConfigurableFilter(); 405 406 filter.disableProjectLastModifiedTest(); 407 filter.disableLockTest(); 408 filter.disableStateTest(); 409 filter.disablePropertiesTest(); 410 filter.disableSiblingCountTest(); 411 return filter; 412 } 413 414 419 private static OpenCmsTestResourceFilter getFilterPublishResource() { 420 421 OpenCmsTestResourceConfigurableFilter filter = new OpenCmsTestResourceConfigurableFilter(); 422 423 filter.disableLockTest(); 424 filter.disableStateTest(); 425 filter.disableSiblingCountTest(); 426 return filter; 427 } 428 429 434 private static OpenCmsTestResourceFilter getFilterReplaceResource() { 435 436 OpenCmsTestResourceConfigurableFilter filter = new OpenCmsTestResourceConfigurableFilter(); 437 438 filter.disableLockTest(); 439 filter.disableStateTest(); 440 filter.disableDateLastModifiedTest(); 441 filter.disableUserLastModifiedTest(); 442 filter.disableContentsTest(); 443 filter.disableLengthTest(); 444 filter.disableProjectLastModifiedTest(); 445 return filter; 446 } 447 448 453 private static OpenCmsTestResourceConfigurableFilter getFilterTouch() { 454 455 OpenCmsTestResourceConfigurableFilter filter = new OpenCmsTestResourceConfigurableFilter(); 456 457 filter.disableProjectLastModifiedTest(); 458 filter.disableStateTest(); 459 filter.disableDateLastModifiedTest(); 460 filter.disableUserLastModifiedTest(); 461 return filter; 462 } 463 464 469 private static OpenCmsTestResourceFilter getFilterUndoChanges() { 470 471 OpenCmsTestResourceConfigurableFilter filter = new OpenCmsTestResourceConfigurableFilter(); 472 473 filter.disableProjectLastModifiedTest(); 474 filter.disableLockTest(); 475 return filter; 476 } 477 478 483 private static OpenCmsTestResourceFilter getFilterWriteProperty() { 484 485 OpenCmsTestResourceConfigurableFilter filter = new OpenCmsTestResourceConfigurableFilter(); 486 487 filter.disableProjectLastModifiedTest(); 488 filter.disableStateTest(); 489 filter.disableDateLastModifiedTest(); 490 filter.disableUserLastModifiedTest(); 491 filter.disablePropertiesTest(); 492 return filter; 493 } 494 495 500 public boolean testAce() { 501 502 return m_ace; 503 } 504 505 510 public boolean testAcl() { 511 512 return m_acl; 513 } 514 515 520 public boolean testContentId() { 521 522 return m_contentId; 523 } 524 525 530 public boolean testContents() { 531 532 return m_contents; 533 } 534 535 540 public boolean testDateCreated() { 541 542 return m_dateCreated; 543 } 544 545 550 public boolean testDateExpired() { 551 552 return m_dateExpired; 553 } 554 555 560 public boolean testDateLastModified() { 561 562 return m_dateLastModified; 563 } 564 565 570 public boolean testDateReleased() { 571 572 return m_dateReleased; 573 } 574 575 580 public boolean testFlags() { 581 582 return m_flags; 583 } 584 585 590 public boolean testLength() { 591 592 return m_length; 593 } 594 595 600 public boolean testLock() { 601 602 return m_lockstate; 603 } 604 605 610 public boolean testName() { 611 612 return m_name; 613 } 614 615 620 public boolean testProjectLastModified() { 621 622 return m_projectLastModified; 623 } 624 625 630 public boolean testProperties() { 631 632 return m_properties; 633 } 634 635 640 public boolean testResourceId() { 641 642 return m_resourceId; 643 } 644 645 650 public boolean testSiblingCount() { 651 652 return m_siblingCount; 653 } 654 655 660 public boolean testState() { 661 662 return m_state; 663 } 664 665 670 public boolean testStructureId() { 671 672 return m_structureId; 673 } 674 675 680 public boolean testTouched() { 681 682 return m_isTouched; 683 } 684 685 690 public boolean testType() { 691 692 return m_type; 693 } 694 695 700 public boolean testUserCreated() { 701 702 return m_userCreated; 703 } 704 705 710 public boolean testUserLastModified() { 711 712 return m_userLastModified; 713 } 714 } | Popular Tags |