Changeset 28612

Show
Ignore:
Timestamp:
01/09/08 18:40:16 (7 months ago)
Author:
sfermigier
Message:

Forward port of [28607], [28609], [28610].

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • org.nuxeo.common/trunk/src/main/java/org/nuxeo/common/collections/ArrayMap.java

    r19157 r28612  
    2121 
    2222import java.util.Map; 
     23 
     24import org.jetbrains.annotations.NotNull; 
    2325 
    2426/** 
     
    140142    } 
    141143 
    142     public V put(K key, V value) { 
    143         if (key == null) { 
    144             throw new NullPointerException(); 
    145         } 
    146  
     144    public V put(@NotNull K key, V value) { 
    147145        // handle the case where we don't have any attributes yet 
    148146        if (elements == null) { 
     
    177175    } 
    178176 
    179     public void add(K key, V value) { 
    180         if (key == null) { 
    181             throw new IllegalArgumentException(); 
    182         } 
    183  
     177    public void add(@NotNull K key, V value) { 
    184178        // handle the case where we don't have any attributes yet 
    185179        int insertIndex; 
  • org.nuxeo.common/trunk/src/main/java/org/nuxeo/common/collections/DependencyTree.java

    r28170 r28612  
    156156    } 
    157157 
    158  
    159158    public List<Entry<K, T>> getPendingEntries() { 
    160159        List<Entry<K, T>> result = new ArrayList<Entry<K, T>>(); 
     
    205204        return list; 
    206205    } 
    207  
    208206 
    209207    public void clear() { 
  • org.nuxeo.common/trunk/src/main/java/org/nuxeo/common/collections/ListenerList.java

    r20633 r28612  
    1919 
    2020package org.nuxeo.common.collections; 
     21 
     22import org.jetbrains.annotations.NotNull; 
    2123 
    2224 
     
    8587     * @param listener the listener to add 
    8688     */ 
    87     public synchronized void add(Object listener) { 
    88         if (listener == null) { 
    89             throw new IllegalArgumentException(); 
    90         } 
     89    public synchronized void add(@NotNull Object listener) { 
    9190        // check for duplicates 
    9291        final int oldSize = listeners.length; 
     
    147146     * @param listener the listener 
    148147     */ 
    149     public synchronized void remove(Object listener) { 
    150         if (listener == null) { 
    151             throw new IllegalArgumentException(); 
    152         } 
     148    public synchronized void remove(@NotNull Object listener) { 
    153149        int oldSize = listeners.length; 
    154150        for (int i = 0; i < oldSize; ++i) { 
  • org.nuxeo.common/trunk/src/main/java/org/nuxeo/common/collections/PrimitiveArrays.java

    r28170 r28612  
    2525import java.util.Iterator; 
    2626import java.util.List; 
     27 
     28import org.jetbrains.annotations.NotNull; 
    2729 
    2830/** 
     
    196198    } 
    197199 
    198     public static List<?> toList(Object array) { 
    199         Class<?> arrType = array.getClass().getComponentType(); 
    200         if (arrType == null) { 
    201             throw new IllegalArgumentException("Not an array"); 
    202         } 
     200    public static List<?> toList(@NotNull Object array) { 
     201        @NotNull Class<?> arrType = array.getClass().getComponentType(); 
    203202        if (arrType.isPrimitive()) { 
    204203            if (arrType == Integer.TYPE) { 
  • org.nuxeo.common/trunk/src/main/java/org/nuxeo/common/collections/SerializableArrayMap.java

    r22678 r28612  
    2222import java.io.Serializable; 
    2323import java.util.Map; 
     24 
     25import org.jetbrains.annotations.NotNull; 
    2426 
    2527/** 
     
    148150    } 
    149151 
    150     public V put(K key, V value) { 
    151         if (key == null) { 
    152             throw new NullPointerException(); 
    153         } 
     152    public V put(@NotNull K key, V value) { 
    154153 
    155154        // handle the case where we don't have any attributes yet 
     
    185184    } 
    186185 
    187     public void add(K key, V value) { 
    188         if (key == null) { 
    189             throw new IllegalArgumentException(); 
    190         } 
    191  
     186    public void add(@NotNull K key, V value) { 
    192187        // handle the case where we don't have any attributes yet 
    193188        int insertIndex; 
  • org.nuxeo.common/trunk/src/main/java/org/nuxeo/common/utils/ArrayUtils.java

    r28479 r28612  
    2626import java.util.List; 
    2727import java.util.Set; 
     28 
     29import org.jetbrains.annotations.NotNull; 
    2830 
    2931/** 
     
    8486     */ 
    8587    @SuppressWarnings("unchecked") 
    86     public static <T> T[] intersect(final T[]... arrays) { 
    87         if (null == arrays) { 
    88             throw new IllegalArgumentException("arrays cannot be null"); 
    89         } 
    90  
     88    public static <T> T[] intersect(@NotNull final T[]... arrays) { 
    9189        final Class type = arrays.getClass().getComponentType() 
    9290                .getComponentType(); 
  • org.nuxeo.common/trunk/src/main/java/org/nuxeo/common/xmap/XAnnotatedMember.java

    r26235 r28612  
    7171            throw new IllegalArgumentException( 
    7272                    String.format("%s, setter=%s, value=%s", e.getMessage(), 
    73                             setter, value)); 
     73                            setter, value), e); 
    7474        } 
    7575    } 
  • org.nuxeo.ecm.core/trunk/nuxeo-core-api/src/test/java/org/nuxeo/ecm/core/api/TestPropertyModel.java

    r28346 r28612  
    6060 * 
    6161 */ 
     62// We're declaring variables as HashMaps / ArrayLists so they can be Serializable 
     63@SuppressWarnings({"CollectionDeclaredAsConcreteClass"}) 
    6264public class TestPropertyModel extends TestCase { 
    6365 
     
    6567    protected Schema schema; 
    6668 
    67     <T> ArrayList<T> arrayList(T ... args) { 
     69    static <T> ArrayList<T> arrayList(T ... args) { 
    6870        ArrayList<T> list = new ArrayList<T>(args.length); 
    6971        list.addAll(Arrays.asList(args)); 
  • org.nuxeo.ecm.core/trunk/nuxeo-core/src/main/java/org/nuxeo/ecm/core/api/AbstractSession.java

    r28584 r28612  
    313313        try { 
    314314            Session session = getSession(); 
    315             Document doc = documentResolver.resolveReference(session, docRef); 
     315            Document doc = DocumentResolver.resolveReference(session, docRef); 
    316316            return hasPermission(doc, permission); 
    317317        } catch (DocumentException e) { 
     
    335335    protected final Document resolveReference(DocumentRef docRef) 
    336336            throws DocumentException, ClientException { 
    337         return documentResolver.resolveReference(getSession(), docRef); 
     337        return DocumentResolver.resolveReference(getSession(), docRef); 
    338338    } 
    339339 
  • org.nuxeo.ecm.core/trunk/nuxeo-core/src/main/java/org/nuxeo/ecm/core/api/DocumentResolver.java

    r20172 r28612  
    5353     * @throws DocumentException if the document could not be resolved 
    5454     */ 
    55     public final Document resolveReference(Session session, DocumentRef docRef) 
     55    public static Document resolveReference(Session session, DocumentRef docRef) 
    5656            throws DocumentException { 
    5757        int type = docRef.type(); 
  • org.nuxeo.ecm.core/trunk/nuxeo-core/src/main/java/org/nuxeo/ecm/core/security/CacheEntry.java

    r18857 r28612  
    4747    } 
    4848 
    49 /* NOT USED? 
    50  
    51     final String username() { 
    52         return username; 
    53     } 
    54  
    55     public final String permission() { 
    56         return permission; 
    57     } 
    58  
    59     public final String docUid() { 
    60         return docUid; 
    61     } 
    62 */ 
    63  
    6449    public final void setAccess(Access access) { 
    6550        this.access = access; 
     
    7358    } 
    7459 
     60    @SuppressWarnings({"NonFinalFieldReferencedInHashCode"}) 
    7561    @Override 
    7662    public int hashCode() { 
     
    10288    @Override 
    10389    public String toString() { 
    104         return docUid + ":" + username + ":" + permission; 
     90        return docUid + ':' + username + ':' + permission; 
    10591    } 
    10692 
  • org.nuxeo.ecm.core/trunk/nuxeo-core/src/main/java/org/nuxeo/ecm/core/security/DefaultPermissionProvider.java

    r28306 r28612  
    4646    // to be recomputed each time a new PermissionDescriptor is registered - 
    4747    // null means invalidated 
    48     private Map<String, MergedPermissionDescriptor> mergedPermissions = null
    49  
    50     private Map<String, Set<String>> mergedGroups = null
     48    private Map<String, MergedPermissionDescriptor> mergedPermissions
     49 
     50    private Map<String, Set<String>> mergedGroups
    5151 
    5252    private final List<PermissionVisibilityDescriptor> registeredPermissionsVisibility = new LinkedList<PermissionVisibilityDescriptor>(); 
    5353 
    54     private Map<String, PermissionVisibilityDescriptor> mergedPermissionsVisibility = null; 
     54    private Map<String, PermissionVisibilityDescriptor> mergedPermissionsVisibility; 
     55 
     56    public DefaultPermissionProvider() { 
     57        mergedPermissionsVisibility = null; 
     58    } 
    5559 
    5660    public String[] getUserVisiblePermissions() throws ClientException { 
     
    215219 
    216220    synchronized public void registerDescriptor( 
    217             PermissionDescriptor permissionDescriptor) throws Exception { 
     221            PermissionDescriptor descriptor) throws Exception { 
    218222        // check that all included permission have previously been registered 
    219223        Set<String> alreadyRegistered = new HashSet<String>(); 
     
    221225            alreadyRegistered.add(registeredPerm.getName()); 
    222226        } 
    223         for (String includePerm : permissionDescriptor.getIncludePermissions()) { 
     227        for (String includePerm : descriptor.getIncludePermissions()) { 
    224228            if (!alreadyRegistered.contains(includePerm)) { 
    225229                // TODO: OG: use a specific exception sub class instead of the 
     
    228232                        String.format( 
    229233                                "Permission '%s' included by '%s' is not a registered permission", 
    230                                 includePerm, permissionDescriptor.getName())); 
     234                                includePerm, descriptor.getName())); 
    231235            } 
    232236        } 
     
    235239        mergedGroups = null; 
    236240        // append the new descriptor 
    237         registeredPermissions.add(permissionDescriptor); 
     241        registeredPermissions.add(descriptor); 
    238242    } 
    239243 
    240244    synchronized public void unregisterDescriptor( 
    241             PermissionDescriptor permissionDescriptor) { 
    242         int lastOccurence = registeredPermissions.lastIndexOf(permissionDescriptor); 
     245            PermissionDescriptor descriptor) { 
     246        int lastOccurence = registeredPermissions.lastIndexOf(descriptor); 
    243247        if (lastOccurence != -1) { 
    244248            // invalidate merged permission 
  • org.nuxeo.ecm.core/trunk/nuxeo-core/src/main/java/org/nuxeo/ecm/core/security/PermissionUIItemDescriptor.java

    r28331 r28612  
    5353            return 0; 
    5454        } else { 
    55             return order.intValue()
     55            return order
    5656        } 
    5757    } 
     
    6262            return true; 
    6363        } else { 
    64             return show.booleanValue()
     64            return show
    6565        } 
    6666    } 
  • org.nuxeo.ecm.core/trunk/nuxeo-core/src/main/java/org/nuxeo/ecm/core/security/PermissionVisibilityDescriptor.java

    r28331 r28612  
    6666    } 
    6767 
    68     @Override 
    69     public boolean equals(Object other) { 
    70         if (other instanceof PermissionVisibilityDescriptor) { 
    71             PermissionVisibilityDescriptor otherPvd = (PermissionVisibilityDescriptor) other; 
    72             if (!typeName.equals(otherPvd.typeName)) { 
    73                 return false; 
    74             } 
    75             if (!items.equals(otherPvd.items)) { 
    76                 return false; 
    77             } 
    78             return true; 
    79         } 
    80         return false; 
    81     } 
    82  
    8368    public void merge(PermissionVisibilityDescriptor other) throws Exception { 
    8469        List<PermissionUIItemDescriptor> otherItems = new ArrayList<PermissionUIItemDescriptor>( 
     
    118103 
    119104    @Override 
     105    public boolean equals(Object other) { 
     106        if (other instanceof PermissionVisibilityDescriptor) { 
     107            PermissionVisibilityDescriptor otherPvd = (PermissionVisibilityDescriptor) other; 
     108            if (!typeName.equals(otherPvd.typeName)) { 
     109                return false; 
     110            } 
     111            if (!items.equals(otherPvd.items)) { 
     112                return false; 
     113            } 
     114            return true; 
     115        } 
     116        return false; 
     117    } 
     118 
     119    @Override 
    120120    public String toString() { 
    121121        return String.format("PermissionVisibilityDescriptor[%s]", typeName); 
  • org.nuxeo.ecm.core/trunk/nuxeo-core/src/test/java/org/nuxeo/ecm/core/lifecycle/TestLifeCycleService.java

    r28564 r28612  
    4242    public void setUp() throws Exception { 
    4343        super.setUp(); 
    44         deploy("LifeCycleService.xml"); 
    45         deploy("LifeCycleManagerTestExtensions.xml"); 
     44        deployContrib("LifeCycleService.xml"); 
     45        deployContrib("LifeCycleManagerTestExtensions.xml"); 
    4646 
    4747        lifeCycleService = NXCore.getLifeCycleService(); 
  • org.nuxeo.ecm.platform/trunk/nuxeo-platform-actions-core/src/test/java/org/nuxeo/ecm/platform/actions/TestActionFilter.java

    r28579 r28612  
    2020package org.nuxeo.ecm.platform.actions; 
    2121 
    22 import java.util.Map; 
    23  
    2422import org.nuxeo.ecm.core.api.DocumentModel; 
    2523import org.nuxeo.runtime.test.NXRuntimeTestCase; 
     
    3836    protected void setUp() throws Exception { 
    3937        super.setUp(); 
    40         deploy("test-actions-service.xml"); 
    41         deploy("test-filters-contrib.xml"); 
    42         deploy("test-filters-override-contrib.xml"); 
     38        deployContrib("test-actions-service.xml"); 
     39        deployContrib("test-filters-contrib.xml"); 
     40        deployContrib("test-filters-override-contrib.xml"); 
    4341        as = (ActionService) runtime.getComponent(ActionService.ID); 
    4442    } 
    4543 
    46     private boolean filterAccept(DocumentModel doc, ActionFilter filter) { 
     44    private static boolean filterAccept(DocumentModel doc, ActionFilter filter) { 
    4745        // XXX AT: action is not used anyway 
    4846        Action action = new Action(); 
     
    157155 
    158156        DefaultActionFilter dFilter = (DefaultActionFilter) filter; 
    159         assertEquals(dFilter.getRules().length, 2); 
     157        assertEquals(2, dFilter.getRules().length); 
    160158 
    161159        doc = new MockDocumentModel("Workspace", new String[0]); 
  • org.nuxeo.ecm.platform/trunk/nuxeo-platform-audit-client/src/main/java/org/nuxeo/ecm/platform/audit/ws/WSAuditBean.java

    r28475 r28612  
    7272    } 
    7373 
    74     /* 
    75      * (non-Javadoc) 
    76      * 
    77      * @see org.nuxeo.ecm.platform.audit.ws.api.WSAudit#listModifiedDocuments(java.lang.String, 
    78      *      java.lang.String) 
    79      */ 
    8074    @WebMethod 
    8175    @WebResult (name="docList") 
     
    8882            initSession(sessionId); 
    8983        } catch (ClientException ce) { 
    90             throw new AuditException(ce.getMessage()); 
     84            throw new AuditException(ce.getMessage(), ce); 
    9185        } 
    9286 
  • org.nuxeo.ecm.platform/trunk/nuxeo-platform-audit-facade/src/main/java/org/nuxeo/ecm/platform/audit/ejb/LogsBean.java

    r28475 r28612  
    244244    @SuppressWarnings("unchecked") 
    245245    public LogEntry getLogEntryByID(long id) throws AuditException { 
     246        log.debug("getLogEntriesFor() logID=" + id); 
     247        Class<LogEntry> klass = getLogEntryClass(); 
    246248        LogEntryBase match = null; 
    247         log.debug("getLogEntriesFor() logID=" + id); 
    248         Class<LogEntry> klass = getLogEntryClass(); 
    249249        try { 
    250250            Query query = em.createQuery("from " + klass.getSimpleName() 
  • org.nuxeo.ecm.platform/trunk/nuxeo-platform-audit-facade/src/test/java/org/nuxeo/ecm/platform/audit/facade/TestLogEntryFactory.java

    r19481 r28612  
    4040    public void setUp() throws Exception { 
    4141        super.setUp(); 
    42         deploy("nxaudit-service-definitions.xml"); 
    43         deploy("nxaudit-service-contrib.xml"); 
     42        deployContrib("nxaudit-service-definitions.xml"); 
     43        deployContrib("nxaudit-service-contrib.xml"); 
    4444 
    45         aes = (NXAuditEventsService) runtime 
    46                 .getComponent(NXAuditEventsService.NAME); 
     45        aes = (NXAuditEventsService) runtime.getComponent(NXAuditEventsService.NAME); 
    4746    } 
    4847 
  • org.nuxeo.ecm.platform/trunk/nuxeo-platform-audit-search/src/test/java/org/nuxeo/ecm/platform/audit/search/TestAuditIndexableResource.java

    r28584 r28612  
    4343        super.setUp(); 
    4444 
    45         deploy("nxsearch-test-framework.xml"); 
    46         deploy("nxsearch-test-contrib.xml"); 
    47         deploy("test-nxsearch-backend-compass-framework.xml"); 
    48         deploy("nxsearch-compass-test-contrib.xml"); 
     45        deployContrib("nxsearch-test-framework.xml"); 
     46        deployContrib("nxsearch-test-contrib.xml"); 
     47        deployContrib("test-nxsearch-backend-compass-framework.xml"); 
     48        deployContrib("nxsearch-compass-test-contrib.xml"); 
    4949 
    5050        // Local lookup is enough 
    5151        service = Framework.getLocalService(SearchService.class); 
    5252        assertNotNull(service); 
    53  
    5453    } 
    5554 
    5655    public void testAuditResourceConfRegistration() { 
    57  
    5856        IndexableResourceConf conf = service.getIndexableResourceConfByName("audit", false); 
    5957        assertNotNull(conf); 
     
    7270        IndexableResourceFactory factory = desc.getFactory(); 
    7371        assertTrue(factory.createEmptyIndexableResource() instanceof AuditIndexableResourceImpl); 
    74  
    7572    } 
    7673 
  • org.nuxeo.ecm.platform/trunk/nuxeo-platform-cache-jboss/src/main/java/org/nuxeo/ecm/platform/cache/CacheServiceException.java

    r20672 r28612  
    3131 
    3232    public CacheServiceException() { 
    33         super(); 
    34         // TODO Auto-generated constructor stub 
    3533    } 
    3634 
    3735    public CacheServiceException(String arg0, Throwable arg1) { 
    3836        super(arg0, arg1); 
    39         // TODO Auto-generated constructor stub 
    4037    } 
    4138 
    4239    public CacheServiceException(String arg0) { 
    4340        super(arg0); 
    44         // TODO Auto-generated constructor stub 
    4541    } 
    4642 
    4743    public CacheServiceException(Throwable arg0) { 
    4844        super(arg0); 
    49         // TODO Auto-generated constructor stub 
    5045    } 
    5146 
  • org.nuxeo.ecm.platform/trunk/nuxeo-platform-content-template-manager/src/test/java/org/nuxeo/ecm/platform/content/template/tests/TestContentTemplateFactory.java

    r28584 r28612  
    4747        super.setUp(); 
    4848 
    49         deploy("ServiceManagement.xml"); 
    50         deploy("LoginComponent.xml"); 
    51         deploy("RepositoryManager.xml"); 
    52         deploy("RepositoryService.xml"); 
    53         deploy("CoreTestExtensions.xml"); 
    54         deploy("CoreEventListenerService.xml"); 
    55         deploy("DemoRepository.xml"); 
    56         deploy("LifeCycleService.xml"); 
    57         deploy("LifeCycleServiceExtensions.xml"); 
    58         deploy("CoreEventListenerService.xml"); 
    59         deploy("PlatformService.xml"); 
    60         deploy("DefaultPlatform.xml"); 
    61  
    62         deploy("test-content-template-framework.xml"); 
    63         deploy("test-content-template-contrib.xml"); 
    64         deploy("test-content-template-listener.xml"); 
     49        deployContrib("ServiceManagement.xml"); 
     50        deployContrib("LoginComponent.xml"); 
     51        deployContrib("RepositoryManager.xml"); 
     52        deployContrib("RepositoryService.xml"); 
     53        deployContrib("CoreTestExtensions.xml"); 
     54        deployContrib("CoreEventListenerService.xml"); 
     55        deployContrib("DemoRepository.xml"); 
     56        deployContrib("LifeCycleService.xml"); 
     57        deployContrib("LifeCycleServiceExtensions.xml"); 
     58        deployContrib("CoreEventListenerService.xml"); 
     59        deployContrib("PlatformService.xml"); 
     60        deployContrib("DefaultPlatform.xml"); 
     61 
     62        deployContrib("test-content-template-framework.xml"); 
     63        deployContrib("test-content-template-contrib.xml"); 
     64        deployContrib("test-content-template-listener.xml"); 
    6565 
    6666 
     
    7070        session = mgr.getDefaultRepository().open(); 
    7171        assertNotNull(session); 
    72  
    73     } 
    74  
    75     private ContentTemplateService getService() { 
    7672        service = Framework.getLocalService(ContentTemplateService.class); 
    77         return service; 
    78     } 
    79  
    80     public void testServiceRegistration() { 
    81         getService(); 
    8273        assertNotNull(service); 
    8374    } 
    8475 
    8576    public void testServiceFactoryContribs() { 
    86         getService(); 
    87         ContentTemplateServiceImpl serviceImpl = (ContentTemplateServiceImpl) service; 
    88         assertNotNull(serviceImpl); 
    89         Map<String, ContentFactoryDescriptor> factories = serviceImpl 
    90                 .getFactories(); 
     77        ContentTemplateServiceImpl serviceImpl = (ContentTemplateServiceImpl) service; 
     78        assertNotNull(serviceImpl); 
     79        Map<String, ContentFactoryDescriptor> factories = serviceImpl.getFactories(); 
    9180        assertTrue(factories.containsKey("SimpleTemplateFactory")); 
    9281        assertTrue(factories.containsKey("ImportFactory")); 
     
    9584 
    9685    public void testServiceFactoryBindingContribs() { 
    97         getService(); 
    98         ContentTemplateServiceImpl serviceImpl = (ContentTemplateServiceImpl) service; 
    99         assertNotNull(serviceImpl); 
    100         Map<String, FactoryBindingDescriptor> factoryBindings = serviceImpl 
    101                 .getFactoryBindings(); 
     86        ContentTemplateServiceImpl serviceImpl = (ContentTemplateServiceImpl) service; 
     87        assertNotNull(serviceImpl); 
     88        Map<String, FactoryBindingDescriptor> factoryBindings = serviceImpl.getFactoryBindings(); 
    10289        assertEquals(3, factoryBindings.size()); 
    10390        assertTrue(factoryBindings.containsKey("Root")); 
     
    11097 
    11198    public void testServiceFactoryForSecurity() { 
    112         getService(); 
    113         ContentTemplateServiceImpl serviceImpl = (ContentTemplateServiceImpl) service; 
    114         assertNotNull(serviceImpl); 
    115         Map<String, FactoryBindingDescriptor> factoryBindings = serviceImpl 
    116                 .getFactoryBindings(); 
     99        ContentTemplateServiceImpl serviceImpl = (ContentTemplateServiceImpl) service; 
     100        assertNotNull(serviceImpl); 
     101        Map<String, FactoryBindingDescriptor> factoryBindings = serviceImpl.getFactoryBindings(); 
    117102 
    118103        FactoryBindingDescriptor wsFactory = factoryBindings.get("Workspace"); 
     
    125110 
    126111    public void testServiceFactoryInstancesContribs() { 
    127         getService(); 
    128         ContentTemplateServiceImpl serviceImpl = (ContentTemplateServiceImpl) service; 
    129         assertNotNull(serviceImpl); 
    130         Map<String, ContentFactory> factoryInstances = serviceImpl 
    131                 .getFactoryInstancesByType(); 
     112        ContentTemplateServiceImpl serviceImpl = (ContentTemplateServiceImpl) service; 
     113        assertNotNull(serviceImpl); 
     114        Map<String, ContentFactory> factoryInstances = serviceImpl.getFactoryInstancesByType();