Changeset 5923 for ComponentRegistry/trunk/ComponentRegistry/src
- Timestamp:
- 01/16/15 10:54:43 (10 years ago)
- Location:
- ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/ComponentRegistry.java
r5872 r5923 249 249 250 250 Number makeGroupMember(String principalName, String groupName) throws UserUnauthorizedException, ItemNotFoundException; 251 252 boolean canCurrentUserAccessDescription(String cmdId) throws ItemNotFoundException, AuthenticationRequiredException; 251 253 252 254 //long removeGroupMember(String principalName, String groupName) throws UserUnauthorizedException, ItemNotFoundException; -
ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/impl/database/ComponentRegistryDbImpl.java
r5872 r5923 800 800 } 801 801 802 private boolean canCurrentUserAccessDescription(String cmdId) throws ItemNotFoundException, AuthenticationRequiredException { 802 @Override 803 public boolean canCurrentUserAccessDescription(String cmdId) throws ItemNotFoundException, AuthenticationRequiredException { 803 804 if (cmdId == null) { 804 805 throw new ItemNotFoundException("Item with the null cmdIdentifier."); -
ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/MDValidator.java
r5549 r5923 1 1 package clarin.cmdi.componentregistry.rest; 2 2 3 import clarin.cmdi.componentregistry.AuthenticationRequiredException; 3 4 import clarin.cmdi.componentregistry.ComponentRegistry; 4 5 import clarin.cmdi.componentregistry.ComponentRegistryException; … … 12 13 import clarin.cmdi.componentregistry.components.CMDComponentSpec; 13 14 import clarin.cmdi.componentregistry.components.CMDComponentType; 15 import clarin.cmdi.componentregistry.impl.database.GroupService; 14 16 import clarin.cmdi.componentregistry.model.BaseDescription; 15 17 import clarin.cmdi.schema.cmd.Validator.Message; … … 39 41 static final String SCHEMA_ERROR = "Error in reading general component schema: "; 40 42 static final String IO_ERROR = "Error while reading specification or general component schema: "; 43 static final String INTERNAL_ERROR = "Internal error: "; 41 44 static final String COMPONENT_NOT_REGISTERED_IN_APPROPRIATE_SPACE_ERROR = "referenced component cannot be found in the appropriate registry components: "; 42 45 static final String COMPONENT_REGISTRY_EXCEPTION_ERROR = "An exception occurred while accessing the component registry: "; … … 119 122 } catch (NullIdException e3) { 120 123 errorMessages.add(COMPONENT_NOT_REGISTERED_ERROR + e3); 124 } catch(AuthenticationRequiredException e) { 125 errorMessages.add(INTERNAL_ERROR + e); 121 126 } 122 127 } … … 136 141 } 137 142 138 private void validateComponents(CMDComponentSpec componentSpec) throws ComponentRegistryException, UserUnauthorizedException, ItemNotFoundException, NullIdException {143 private void validateComponents(CMDComponentSpec componentSpec) throws ComponentRegistryException, UserUnauthorizedException, ItemNotFoundException, NullIdException, AuthenticationRequiredException { 139 144 validateComponents(Collections.singletonList(componentSpec.getCMDComponent())); 140 145 } 141 146 142 private void validateComponents(List<CMDComponentType> cmdComponents) throws ComponentRegistryException, UserUnauthorizedException, ItemNotFoundException, NullIdException {147 private void validateComponents(List<CMDComponentType> cmdComponents) throws ComponentRegistryException, UserUnauthorizedException, ItemNotFoundException, NullIdException, AuthenticationRequiredException { 143 148 for (CMDComponentType cmdComponentType : cmdComponents) { 144 149 this.validateDescribedComponents(cmdComponentType); … … 147 152 } 148 153 149 private void validateDescribedComponents(CMDComponentType cmdComponentType) throws ComponentRegistryException, UserUnauthorizedException, ItemNotFoundException, NullIdException {154 private void validateDescribedComponents(CMDComponentType cmdComponentType) throws ComponentRegistryException, UserUnauthorizedException, ItemNotFoundException, NullIdException, AuthenticationRequiredException { 150 155 this.checkComponentInSpace(cmdComponentType); 151 156 } 152 157 153 private void checkComponentInSpace(CMDComponentType cmdComponentType) throws ComponentRegistryException, UserUnauthorizedException, ItemNotFoundException, NullIdException {158 private void checkComponentInSpace(CMDComponentType cmdComponentType) throws ComponentRegistryException, UserUnauthorizedException, ItemNotFoundException, NullIdException, AuthenticationRequiredException { 154 159 if (isDefinedInSeparateFile(cmdComponentType)) { 155 160 String id = cmdComponentType.getComponentId(); … … 160 165 CMDComponentSpec registeredComponent = registry.getMDComponent(id); 161 166 if (registeredComponent != null) { 162 String componentId = cmdComponentType.getComponentId(); 163 Boolean isPublicB = registry.isItemPublic(id);// throws ItemNotFoundException 164 boolean isPublic = isPublicB.booleanValue(); 165 if (isPublic) { // if a component is public, it is available for any registry 167 final String componentId = cmdComponentType.getComponentId(); 168 if (registry.isItemPublic(id)) { // if a component is public, it is available for any registry 166 169 return; 167 170 }; 168 171 // a private component for a private registry is available only if its owner is the owner of the resgitry 169 172 if (registry.getRegistrySpace().equals(RegistrySpace.PRIVATE)) { 170 Number registryOwnerId = registry.getRegistryOwner().getId(); 171 Number componentOwnerId = registry.getBaseDescriptionOwnerId(cmdComponentType.getComponentId()); 172 if (registryOwnerId.equals(componentOwnerId)) { 173 if(registry.canCurrentUserAccessDescription(componentId)) { 173 174 return; 174 } ;175 } 175 176 errorMessages.add(COMPONENT_NOT_REGISTERED_IN_APPROPRIATE_SPACE_ERROR + componentId + " (private registry)"); 176 177 return;
Note: See TracChangeset
for help on using the changeset viewer.