Changeset 5553
- Timestamp:
- 08/15/14 16:02:36 (10 years ago)
- Location:
- ComponentRegistry/trunk/ComponentRegistry
- Files:
-
- 1 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
ComponentRegistry/trunk/ComponentRegistry/pom.xml
r5549 r5553 1 1 2 2 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 3 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 4 <modelVersion>4.0.0</modelVersion> 5 <parent> 6 <groupId>clarin.cmdi</groupId> 7 <artifactId>componentRegistry.parent</artifactId> 8 <version>1.0</version> 9 </parent> 10 <groupId>clarin.cmdi</groupId> 11 <artifactId>ComponentRegistry</artifactId> 12 <packaging>${packaging}</packaging> 13 <version>${ComponentRegistry.version}</version> 14 <name>ComponentRegistry</name> 15 <description> 16 ComponentRegistry is part of the clarin metadata infrastructure (cmdi). 17 The goal of the ComponentRegistry will be to register and make searchable Metadata Components and Profiles. 18 18 </description> 19 19 20 21 22 23 24 with -D or change here -->25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 </dependency> 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 cannot resolve the conflict and gives me both jars (two of stax and two of134 jaxb-impl). Excluding them manually to overcome the problem -->135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 <!--523 <reporting>524 <plugins>525 <plugin>526 <groupId>org.codehaus.mojo</groupId>527 <artifactId>findbugs-maven-plugin</artifactId>528 <version>2.5.4-SNAPSHOT</version>529 <configuration>530 <excludeFilterFile>${basedir}/src/main/resources/findbugs-exclude.xml</excludeFilterFile>531 <threshold>Normal</threshold>532 <effort>Min</effort>533 </configuration>534 </plugin>535 </plugins>536 </reporting>537 -->538 539 540 541 542 543 544 545 <repository>546 <id>sonatype</id>547 <url>https://oss.sonatype.org/content/groups/public</url>548 </repository>549 -->550 20 <properties> 21 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 22 <packaging>war</packaging> 23 <!-- Properties to configure ComponentRegistry override on commandline 24 with -D or change here --> 25 <serviceRootUrl>http://localhost:8080/${project.artifactId}</serviceRootUrl> 26 <!-- Will be inserted in context.xml --> 27 <webXmlPath>src/main/webapp/WEB-INF/web-test.xml</webXmlPath> 28 <!-- non-shib web.xml --> 29 <isocatSearchUrl>http://www.isocat.org/rest/user/guest/search</isocatSearchUrl> 30 <ComponentRegistrySwfName>${project.artifactId}-${ComponentBrowserGui.version}</ComponentRegistrySwfName> 31 <flexDebug>0</flexDebug> 32 <spring-data-jpa.version>1.3.4.RELEASE</spring-data-jpa.version> 33 <spring.version>3.2.10.RELEASE</spring.version> 34 <jackson.version>1.9.13</jackson.version> 35 <jersey.version>1.17.1</jersey.version> 36 <!-- hibernate.version>4.2.4.Final</hibernate.version --> 37 <hibernate.version>3.6.10.Final</hibernate.version> 38 <spring-data-jpa.version>1.3.4.RELEASE</spring-data-jpa.version> 39 </properties> 40 41 42 <ciManagement> 43 <system>hudson</system> 44 <url>http://lux16.mpi.nl/jenkins/job/ComponentRegistry/</url> 45 </ciManagement> 46 <scm> 47 <connection>scm:svn:http://svn.clarin.eu/ComponentRegistry/trunk/ComponentRegistry</connection> 48 <developerConnection>scm:svn:http://svn.clarin.eu/ComponentRegistry/trunk/ComponentRegistry</developerConnection> 49 <url>http://trac.clarin.eu/browser/ComponentRegistry</url> 50 </scm> 51 52 53 54 <dependencies> 55 <dependency> 56 <groupId>org.springframework.data</groupId> 57 <artifactId>spring-data-jpa</artifactId> 58 <version>${spring-data-jpa.version}</version> 59 </dependency> 60 <dependency> 61 <groupId>org.hibernate</groupId> 62 <artifactId>hibernate-entitymanager</artifactId> 63 <version>${hibernate.version}</version> 64 </dependency> 65 <dependency> 66 <groupId>junit</groupId> 67 <artifactId>junit</artifactId> 68 <version>4.11</version> 69 <scope>test</scope> 70 </dependency> 71 <dependency> 72 <groupId>javax.servlet</groupId> 73 <artifactId>servlet-api</artifactId> 74 <version>2.5</version> 75 <scope>provided</scope> 76 </dependency> 77 <dependency> 78 <groupId>commons-codec</groupId> 79 <artifactId>commons-codec</artifactId> 80 <version>1.3</version> 81 </dependency> 82 <dependency> 83 <groupId>commons-io</groupId> 84 <artifactId>commons-io</artifactId> 85 <version>1.4</version> 86 </dependency> 87 <dependency> 88 <groupId>commons-lang</groupId> 89 <artifactId>commons-lang</artifactId> 90 <version>2.5</version> 91 </dependency> 92 <dependency> 93 <groupId>commons-fileupload</groupId> 94 <artifactId>commons-fileupload</artifactId> 95 <version>1.2.1</version> 96 </dependency> 97 <dependency> 98 <groupId>commons-collections</groupId> 99 <artifactId>commons-collections</artifactId> 100 <version>3.2.1</version> 101 </dependency> 102 <dependency> 103 <groupId>xml-resolver</groupId> 104 <artifactId>xml-resolver</artifactId> 105 <version>1.2</version> 106 </dependency> 107 <dependency> 108 <groupId>org.slf4j</groupId> 109 <artifactId>slf4j-log4j12</artifactId> 110 <version>1.7.2</version> 111 </dependency> 112 <dependency> 113 <groupId>org.slf4j</groupId> 114 <artifactId>jcl-over-slf4j</artifactId> 115 <version>1.7.2</version> 116 </dependency> 117 <dependency> 118 <groupId>com.sun.jersey.contribs</groupId> 119 <artifactId>jersey-multipart</artifactId> 120 <version>${jersey.version}</version> 121 </dependency> 122 <dependency> 123 <groupId>org.codehaus.jackson</groupId> 124 <artifactId>jackson-core-asl</artifactId> 125 <version>${jackson.version}</version> 126 </dependency> 127 <dependency> 128 <groupId>com.sun.jersey</groupId> 129 <artifactId>jersey-bundle</artifactId> 130 <version>${jersey.version}</version> 131 <exclusions> 132 <!-- Jersey has dependencies with different group ids therefore maven 133 cannot resolve the conflict and gives me both jars (two of stax and two of 134 jaxb-impl). Excluding them manually to overcome the problem --> 135 <exclusion> 136 <groupId>stax</groupId> 137 <artifactId>stax-api</artifactId> 138 </exclusion> 139 </exclusions> 140 </dependency> 141 <dependency> 142 <groupId>com.sun.jersey.jersey-test-framework</groupId> 143 <artifactId>jersey-test-framework-grizzly</artifactId> 144 <version>${jersey.version}</version> 145 <scope>test</scope> 146 </dependency> 147 <dependency> 148 <groupId>com.sun.grizzly</groupId> 149 <artifactId>grizzly-servlet-webserver</artifactId> 150 <version>1.9.19</version> 151 <scope>test</scope> 152 </dependency> 153 <dependency> 154 <groupId>xmlunit</groupId> 155 <artifactId>xmlunit</artifactId> 156 <version>1.5</version> 157 <scope>test</scope> 158 </dependency> 159 <dependency> 160 <groupId>com.sun.xml.stream</groupId> 161 <artifactId>sjsxp</artifactId> 162 <version>1.0.1</version> 163 </dependency> 164 <dependency> 165 <groupId>de.mpg.mpgaai</groupId> 166 <artifactId>mpgaai-jaas</artifactId> 167 <version>1.3.2</version> 168 <exclusions> 169 <exclusion> 170 <groupId>commons-logging</groupId> 171 <artifactId>commons-logging</artifactId> 172 </exclusion> 173 </exclusions> 174 </dependency> 175 <dependency> 176 <groupId>de.mpg.mpgaai</groupId> 177 <artifactId>mpgaai-shhaa</artifactId> 178 <version>1.0.4</version> 179 <exclusions> 180 <exclusion> 181 <groupId>commons-logging</groupId> 182 <artifactId>commons-logging</artifactId> 183 </exclusion> 184 </exclusions> 185 </dependency> 186 <dependency> 187 <groupId>org.apache.wicket</groupId> 188 <artifactId>wicket</artifactId> 189 <version>1.4.8</version> 190 </dependency> 191 <dependency> 192 <groupId>org.apache.wicket</groupId> 193 <artifactId>wicket-extensions</artifactId> 194 <version>1.4.8</version> 195 </dependency> 196 <dependency> 197 <groupId>javax.servlet</groupId> 198 <artifactId>jsp-api</artifactId> 199 <version>2.0</version> 200 <scope>provided</scope> 201 </dependency> 202 203 <!-- Spring framework --> 204 205 <dependency> 206 <groupId>org.springframework</groupId> 207 <artifactId>spring-webmvc</artifactId> 208 <version>${spring.version}</version> 209 </dependency> 210 <dependency> 211 <groupId>org.springframework</groupId> 212 <artifactId>spring-test</artifactId> 213 <version>${spring.version}</version> 214 <scope>test</scope> 215 </dependency> 216 <dependency> 217 <groupId>org.springframework</groupId> 218 <artifactId>spring-context</artifactId> 219 <version>${spring.version}</version> 220 </dependency> 221 <dependency> 222 <groupId>org.springframework.data</groupId> 223 <artifactId>spring-data-jpa</artifactId> 224 <version>${spring-data-jpa.version}</version> 225 <exclusions> 226 <exclusion> 227 <artifactId>spring-aop</artifactId> 228 <groupId>org.springframework</groupId> 229 </exclusion> 230 <exclusion> 231 <artifactId>spring-core</artifactId> 232 <groupId>org.springframework</groupId> 233 </exclusion> 234 <exclusion> 235 <artifactId>spring-context</artifactId> 236 <groupId>org.springframework</groupId> 237 </exclusion> 238 <exclusion> 239 <artifactId>spring-beans</artifactId> 240 <groupId>org.springframework</groupId> 241 </exclusion> 242 </exclusions> 243 </dependency> 244 <dependency> 245 <groupId>org.springframework</groupId> 246 <artifactId>spring-core</artifactId> 247 <version>${spring.version}</version> 248 </dependency> 249 <dependency> 250 <groupId>org.apache.wicket</groupId> 251 <artifactId>wicket-spring</artifactId> 252 <version>1.4.8</version> 253 <exclusions> 254 <exclusion> 255 <groupId>org.springframework</groupId> 256 <artifactId>spring</artifactId> 257 </exclusion> 258 </exclusions> 259 </dependency> 260 <dependency> 261 <groupId>com.sun.jersey.contribs</groupId> 262 <artifactId>jersey-spring</artifactId> 263 <version>${jersey.version}</version> 264 <exclusions> 265 <exclusion> 266 <groupId>commons-logging</groupId> 267 <artifactId>commons-logging</artifactId> 268 </exclusion> 269 <exclusion> 270 <artifactId>spring-core</artifactId> 271 <groupId>org.springframework</groupId> 272 </exclusion> 273 <exclusion> 274 <artifactId>spring-aop</artifactId> 275 <groupId>org.springframework</groupId> 276 </exclusion> 277 <exclusion> 278 <artifactId>spring-context</artifactId> 279 <groupId>org.springframework</groupId> 280 </exclusion> 281 <exclusion> 282 <artifactId>spring-web</artifactId> 283 <groupId>org.springframework</groupId> 284 </exclusion> 285 <exclusion> 286 <artifactId>spring-beans</artifactId> 287 <groupId>org.springframework</groupId> 288 </exclusion> 289 </exclusions> 290 </dependency> 291 292 <!-- Database --> 293 294 <dependency> 295 <groupId>commons-dbcp</groupId> 296 <artifactId>commons-dbcp</artifactId> 297 <version>1.4</version> 298 </dependency> 299 <dependency> 300 <groupId>postgresql</groupId> 301 <artifactId>postgresql</artifactId> 302 <version>8.4-701.jdbc3</version> 303 <scope>provided</scope> 304 </dependency> 305 <dependency> 306 <groupId>org.hsqldb</groupId> 307 <artifactId>hsqldb</artifactId> 308 <version>2.2.8</version> 309 <scope>test</scope> 310 </dependency> 311 <dependency> 312 <groupId>clarin.cmdi</groupId> 313 <artifactId>cmd-validate</artifactId> 314 <version>1.2-SNAPSHOT</version> 315 </dependency> 316 <dependency> 317 <groupId>org.slf4j</groupId> 318 <artifactId>jul-to-slf4j</artifactId> 319 <version>1.7.2</version> 320 </dependency> 321 <dependency> 322 <groupId>com.google.guava</groupId> 323 <artifactId>guava</artifactId> 324 <version>16.0.1</version> 325 </dependency> 326 </dependencies> 327 328 329 <profiles> 330 <profile> 331 <id>lux16</id> 332 <properties> 333 <serviceRootUrl>http://lux16.mpi.nl/ds/ComponentRegistry</serviceRootUrl> 334 <!-- Will be inserted in context.xml --> 335 <shibLI>http://lux16.mpi.nl/Shibboleth.sso/Login</shibLI> 336 <!-- Shibboleth login URI for SHHAA --> 337 <shibLO>http://lux16.mpi.nl/Shibboleth.sso/Logout</shibLO> 338 <!-- Shibboleth logout URI for SHHAA --> 339 <webXmlPath>src/main/webapp/WEB-INF/web-shib.xml</webXmlPath> 340 <!-- web.xml for shibboleth authentication --> 341 </properties> 342 </profile> 343 <profile> 344 <id>clarin</id> 345 <properties> 346 <serviceRootUrl>http://catalog.clarin.eu/ds/ComponentRegistry</serviceRootUrl> 347 <!-- Will be inserted in context.xml --> 348 <shibLI>https://catalog.clarin.eu/Shibboleth.sso/DiscoJuice</shibLI> 349 <!-- Shibboleth login URI for SHHAA --> 350 <shibLO>https://catalog.clarin.eu/Shibboleth.sso/Logout</shibLO> 351 <!-- Shibboleth logout URI for SHHAA --> 352 <webXmlPath>src/main/webapp/WEB-INF/web-shib.xml</webXmlPath> 353 <!-- web.xml for shibboleth authentication --> 354 </properties> 355 </profile> 356 </profiles> 357 358 <build> 359 <filters> 360 <filter>properties/flexindex.properties</filter> 361 </filters> 362 <resources> 363 <resource> 364 <filtering>false</filtering> 365 <directory>src/generated/jaxb/components</directory> 366 </resource> 367 <resource> 368 <filtering>false</filtering> 369 <directory>src/generated/jaxb/rss</directory> 370 </resource> 371 <resource> 372 <filtering>true</filtering> 373 <directory>src/main/resources</directory> 374 </resource> 375 <resource> 376 <filtering>false</filtering> 377 <directory>src/main/java</directory> 378 <includes> 379 <include>**/*.html</include> 380 </includes> 381 </resource> 382 </resources> 383 <testResources> 384 <testResource> 385 <directory>src/test/resources</directory> 386 </testResource> 387 </testResources> 388 <plugins> 389 <plugin> 390 <groupId>org.apache.maven.plugins</groupId> 391 <artifactId>maven-compiler-plugin</artifactId> 392 <configuration> 393 <source>1.6</source> 394 <target>1.6</target> 395 </configuration> 396 </plugin> 397 <plugin> 398 <groupId>org.apache.maven.plugins</groupId> 399 <artifactId>maven-war-plugin</artifactId> 400 <configuration> 401 <warName>${project.artifactId}</warName> 402 <webXml>${webXmlPath}</webXml> 403 <webResources> 404 <resource> 405 <directory>src/main/webapp</directory> 406 <filtering>true</filtering> 407 </resource> 408 </webResources> 409 <archive> 410 <manifest> 411 <addDefaultImplementationEntries>true</addDefaultImplementationEntries> 412 </manifest> 413 </archive> 414 </configuration> 415 </plugin> 416 <plugin> 417 <groupId>org.jvnet.jaxb2.maven2</groupId> 418 <artifactId>maven-jaxb2-plugin</artifactId> 419 <executions> 420 <execution> 421 <id>jaxb-components</id> 422 <goals> 423 <goal>generate</goal> 424 </goals> 425 <configuration> 426 <schemaDirectory>src/main/binding/components</schemaDirectory> 427 <schemaIncludes> 428 <include>general-component-schema.xsd</include> 429 </schemaIncludes> 430 <bindingDirectory>src/main/binding/components</bindingDirectory> 431 <extension>true</extension> 432 <generateDirectory>${basedir}/src/generated/jaxb/components</generateDirectory> 433 <generatePackage>clarin.cmdi.componentregistry.components</generatePackage> 434 <catalog>src/main/resources/catalog.cat</catalog> 435 <catalogResolver>org.jvnet.jaxb2.maven2.resolver.tools.ClasspathCatalogResolver</catalogResolver> 436 </configuration> 437 </execution> 438 <execution> 439 <id>jaxb-rrs</id> 440 <goals> 441 <goal>generate</goal> 442 </goals> 443 <configuration> 444 <schemaDirectory>src/main/binding/rss</schemaDirectory> 445 <schemaIncludes> 446 <include>rss-2_0.xsd</include> 447 </schemaIncludes> 448 <bindingDirectory>src/main/binding/rss</bindingDirectory> 449 <extension>true</extension> 450 <generateDirectory>${basedir}/src/generated/jaxb/rss</generateDirectory> 451 <generatePackage>clarin.cmdi.componentregistry.rss</generatePackage> 452 <catalog>src/main/resources/catalog.cat</catalog> 453 <catalogResolver>org.jvnet.jaxb2.maven2.resolver.tools.ClasspathCatalogResolver</catalogResolver> 454 </configuration> 455 </execution> 456 </executions> 457 </plugin> 458 <plugin> 459 <groupId>org.apache.maven.plugins</groupId> 460 <artifactId>maven-dependency-plugin</artifactId> 461 <executions> 462 <execution> 463 <id>copy</id> 464 <phase>process-resources</phase> 465 <goals> 466 <goal>copy</goal> 467 </goals> 468 <configuration> 469 <artifactItems> 470 <artifactItem> 471 <groupId>clarin.cmdi</groupId> 472 <artifactId>ComponentBrowserGui</artifactId> 473 <version>${ComponentBrowserGui.version}</version> 474 <type>swf</type> 475 <overWrite>true</overWrite> 476 <outputDirectory>${project.build.directory}/${project.artifactId}-${project.version}</outputDirectory> 477 <destFileName>${ComponentRegistrySwfName}.swf</destFileName> 478 </artifactItem> 479 </artifactItems> 480 </configuration> 481 </execution> 482 </executions> 483 </plugin> 484 <plugin> 485 <artifactId>maven-assembly-plugin</artifactId> 486 <version>2.2.2</version> 487 <executions> 488 <execution> 489 <id>make-assembly</id> 490 <phase>package</phase> 491 <goals> 492 <goal>single</goal> 493 </goals> 494 <configuration> 495 <descriptors> 496 <descriptor>src/main/assembly/release.xml</descriptor> 497 </descriptors> 498 </configuration> 499 </execution> 500 </executions> 501 </plugin> 502 <plugin> 503 <groupId>org.apache.maven.plugins</groupId> 504 <artifactId>maven-surefire-plugin</artifactId> 505 <version>2.13</version> 506 <configuration> 507 <systemProperties> 508 <property> 509 <name>java.util.logging.config.file</name> 510 <value>${project.build.directory}/classes/logging.properties</value> 511 </property> 512 </systemProperties> 513 <additionalClasspathElements> 514 <additionalClasspathElement>src/test/resources</additionalClasspathElement> 515 </additionalClasspathElements> 516 </configuration> 517 </plugin> 518 519 </plugins> 520 </build> 521 522 <!-- 523 <reporting> 524 <plugins> 525 <plugin> 526 <groupId>org.codehaus.mojo</groupId> 527 <artifactId>findbugs-maven-plugin</artifactId> 528 <version>2.5.4-SNAPSHOT</version> 529 <configuration> 530 <excludeFilterFile>${basedir}/src/main/resources/findbugs-exclude.xml</excludeFilterFile> 531 <threshold>Normal</threshold> 532 <effort>Min</effort> 533 </configuration> 534 </plugin> 535 </plugins> 536 </reporting> 537 --> 538 <repositories> 539 <repository> 540 <id>cmdi.clarin.repository</id> 541 <name>Clarin Repository</name> 542 <url>http://catalog.clarin.eu/ds/nexus/content/groups/public/</url> 543 </repository> 544 <!-- 545 <repository> 546 <id>sonatype</id> 547 <url>https://oss.sonatype.org/content/groups/public</url> 548 </repository> 549 --> 550 </repositories> 551 551 </project> -
ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/ComponentRegistry.java
r5550 r5553 236 236 Boolean isItemPublic(String id) throws ItemNotFoundException; 237 237 238 Number makeGroupMember(String principalName, String groupName) throws UserUnauthorizedException, ItemNotFoundException; 239 240 //long removeGroupMember(String principalName, String groupName) throws UserUnauthorizedException, ItemNotFoundException; 241 238 242 } -
ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/impl/database/ComponentRegistryDbImpl.java
r5552 r5553 48 48 import org.springframework.beans.factory.annotation.Qualifier; 49 49 import org.springframework.dao.DataAccessException; 50 import org.springframework.orm.jpa.vendor.Database; 50 51 import org.springframework.transaction.annotation.Transactional; 51 52 … … 154 155 } 155 156 } 156 157 158 @Override 159 public Number makeGroupMember(String principalName, String groupName) throws UserUnauthorizedException, ItemNotFoundException{ 160 RegistryUser regOwner = userDao.getPrincipalNameById(registryOwner.getId()); 161 if (groupService.isUserOwnerOfGroup(groupName, regOwner.getPrincipalName()) || 162 configuration.isAdminUser(regOwner.getPrincipalName())) { 163 return groupService.makeMember(principalName, groupName); 164 } else { 165 throw new UserUnauthorizedException("The registry owner is not the admin or not the owner of the group and cannot add users to the group"); 166 } 167 } 168 169 // @Override 170 // public long removeGroupMember(String principalName, String groupName) throws UserUnauthorizedException, ItemNotFoundException{ 171 // RegistryUser regOwner = userDao.getPrincipalNameById(registryOwner.getId()); 172 // if (groupService.isUserOwnerOfGroup(groupName, regOwner.getPrincipalName()) || 173 // configuration.isAdminUser(regOwner.getPrincipalName())) { 174 // return groupService.removeMember(principalName, groupName); 175 // } else { 176 // throw new UserUnauthorizedException("The registry owner is not the admin or not the owner of the group and cannot add users to the group"); 177 // } 178 // } 179 180 157 181 @Override 158 182 public List<ProfileDescription> getProfileDescriptions() throws ComponentRegistryException, UserUnauthorizedException { … … 960 984 } 961 985 } 986 987 962 988 } -
ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/impl/database/GroupService.java
r5549 r5553 1 1 package clarin.cmdi.componentregistry.impl.database; 2 2 3 import clarin.cmdi.componentregistry.ItemNotFoundException; 3 4 import clarin.cmdi.componentregistry.UserUnauthorizedException; 4 5 import java.util.List; … … 49 50 List<String> listGroupNames(); 50 51 51 /** 52 * Determines whether a user is the direct owner of a group 53 * @param groupId 54 * @param user 55 * @return 56 */ 57 boolean isUserOwnerOfGroup(long groupId, RegistryUser user); 52 53 boolean isUserOwnerOfGroup(String groupName, String ownerPrincipalName); 58 54 59 55 /** … … 88 84 * @return database ID of group membership row 89 85 */ 90 long makeMember(String userName, String groupName); 86 long makeMember(String userName, String groupName) throws ItemNotFoundException; 87 88 // long removeMember(String userName, String groupName) throws ItemNotFoundException; 91 89 92 90 /** … … 130 128 boolean userGroupMember(String principalName, String groupId); 131 129 130 public Number getGroupIdByName(String groupName) throws ItemNotFoundException; 131 132 public String getGroupNameById(long groupId) throws ItemNotFoundException; 132 133 } -
ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/impl/database/GroupServiceImpl.java
r5549 r5553 1 1 package clarin.cmdi.componentregistry.impl.database; 2 2 3 import clarin.cmdi.componentregistry.ItemNotFoundException; 3 4 import clarin.cmdi.componentregistry.UserUnauthorizedException; 4 5 import java.util.ArrayList; … … 34 35 * functions over JMX, that's why some methods use human-friendly names (user 35 36 * principal names, group names) rather than ID arguments. 36 * 37 * 37 38 * @author george.georgovassilis@mpi.nl 38 * 39 * 39 40 */ 40 41 @ManagedResource(objectName = "componentregistry:name=GroupService", description = "Operations for managing groups") … … 43 44 public class GroupServiceImpl implements GroupService { 44 45 45 @Autowired 46 private GroupDao groupDao; 47 @Autowired 48 private GroupMembershipDao groupMembershipDao; 49 @Autowired 50 private OwnershipDao ownershipDao; 51 @Autowired 52 private ComponentDao componentDao; 53 @Autowired 54 private UserDao userDao; 55 56 public void setGroupDao(GroupDao groupDao) { 57 this.groupDao = groupDao; 58 } 59 60 public void setGroupMembershipDao(GroupMembershipDao groupMembershipDao) { 61 this.groupMembershipDao = groupMembershipDao; 62 } 63 64 public void setOwnershipDao(OwnershipDao ownershipDao) { 65 this.ownershipDao = ownershipDao; 66 } 67 68 @Override 69 public List<Group> getGroupsOwnedByUser(String ownerPrincipalName) { 70 RegistryUser owner = userDao.getByPrincipalName(ownerPrincipalName); 71 return groupDao.findGroupOwnedByUser(owner.getId().longValue()); 72 } 73 74 @Override 75 public boolean isUserOwnerOfGroup(long groupId, RegistryUser user) { 76 List<Group> groups = getGroupsOwnedByUser(user.getPrincipalName()); 77 for (Group group : groups) 78 if (group.getId() == groupId) 79 return true; 80 return false; 81 } 82 83 private void checkOwnership(Ownership ownership) { 84 if (ownership.getComponentId() == null) 85 throw new RuntimeException("Ownership needs a componentId"); 86 if (ownership.getUserId() == 0 && ownership.getGroupId() == 0) 87 throw new RuntimeException("Ownership needs a groupId or userId"); 88 if (ownership.getUserId() != 0 && ownership.getGroupId() != 0) 89 throw new RuntimeException("Ownership has both a groupId and a userId "); 90 } 91 92 private void assertOwnershipDoesNotExist(Ownership ownership) { 93 Ownership o = ownershipDao.findOwnershipByGroupAndComponent(ownership.getGroupId(), ownership.getComponentId()); 94 if (o != null) 95 throw new ValidationException("Ownership exists"); 96 } 97 98 @Override 99 public void addOwnership(Ownership ownership) { 100 checkOwnership(ownership); 101 assertOwnershipDoesNotExist(ownership); 102 ownershipDao.save(ownership); 103 } 104 105 @Override 106 public void removeOwnership(Ownership ownership) { 107 throw new RuntimeException("not implemented"); 108 } 109 110 protected boolean canUserAccessAbstractDescriptionEitherOnHisOwnOrThroughGroupMembership(RegistryUser user, 111 BaseDescription description) { 112 // TODO make some joins and multi-id queries to speed the entire method 113 // up 114 boolean isProfile = (description instanceof ProfileDescription); 115 long userId = user.getId().longValue(); 116 // anyone can access public profile 117 if (componentDao.isPublic(description.getId())) 118 return true; 119 // the creator can also access any profile 120 if (description.getUserId().equals(user.getId() + "")) 121 return true; 122 123 // a co-ownership on the profile also allows access 124 Ownership ownership = ownershipDao.findOwnershipByUserAndComponent(userId, description.getId()); 125 if (ownership != null) 126 return true; 127 128 // get a list of groups the user owns and is a member of 129 List<Group> groups = groupDao.findGroupOwnedByUser(userId); 130 Set<Long> groupIds = new HashSet<Long>(); 131 for (Group group : groups) 132 groupIds.add(group.getId()); 133 134 List<GroupMembership> memberships = groupMembershipDao.findGroupsTheUserIsAmemberOf(userId); 135 for (GroupMembership gm : memberships) 136 groupIds.add(gm.getGroupId()); 137 138 for (Long groupId : groupIds) { 139 ownership = ownershipDao.findOwnershipByGroupAndComponent(groupId, description.getId()); 140 if (ownership != null) 141 return true; 142 } 143 return false; 144 } 145 146 @Override 147 public boolean canUserAccessComponentEitherOnHisOwnOrThroughGroupMembership(RegistryUser user, 148 BaseDescription baseDescription) { 149 return canUserAccessAbstractDescriptionEitherOnHisOwnOrThroughGroupMembership(user, baseDescription); 150 } 151 152 @Override 153 @ManagedOperation(description = "Make a user member of a group") 154 @ManagedOperationParameters({ 155 @ManagedOperationParameter(name = "principalName", description = "Principal name of the user to make a member"), 156 @ManagedOperationParameter(name = "groupName", description = "Name of the group") }) 157 public long makeMember(String userPrincipalName, String groupName) { 158 RegistryUser user = userDao.getByPrincipalName(userPrincipalName); 159 Group group = groupDao.findGroupByName(groupName); 160 GroupMembership gm = groupMembershipDao.findMembership(user.getId().longValue(), group.getId()); 161 if (gm != null) 162 return gm.getId(); 163 gm = new GroupMembership(); 164 gm.setGroupId(group.getId()); 165 gm.setUserId(user.getId().longValue()); 166 return groupMembershipDao.save(gm).getId(); 167 } 168 169 @ManagedOperation(description = "Create a new group") 170 @ManagedOperationParameters({ 171 @ManagedOperationParameter(name = "name", description = "Name of the group, must be unique"), 172 @ManagedOperationParameter(name = "ownerPrincipalName", description = "Principal name of the user") }) 173 @Override 174 public long createNewGroup(String name, String ownerPrincipalName) { 175 RegistryUser owner = userDao.getByPrincipalName(ownerPrincipalName); 176 if (owner == null) 177 throw new ValidationException("No principal '" + ownerPrincipalName + "' found"); 178 Group group = groupDao.findGroupByName(name); 179 if (group != null) 180 throw new ValidationException("Group '" + name + "' already exists"); 181 group = new Group(); 182 group.setName(name); 183 group.setOwnerId(owner.getId().longValue()); 184 group = groupDao.save(group); 185 return group.getId(); 186 } 187 188 @ManagedOperation(description = "List available groups") 189 @Override 190 public List<String> listGroupNames() { 191 List<String> groupNames = new ArrayList<String>(); 192 for (Group group : groupDao.findAll()) 193 groupNames.add(group.getName()); 194 return groupNames; 195 } 196 197 @Override 198 public List<Group> getGroupsOfWhichUserIsAMember(String principal) { 199 RegistryUser user = userDao.getByPrincipalName(principal); 200 if (user == null || user.getId() == null) 201 return new ArrayList<Group>(); 202 List<GroupMembership> memberships = groupMembershipDao.findGroupsTheUserIsAmemberOf(user.getId().longValue()); 203 List<Group> groups = new ArrayList<Group>(); 204 for (GroupMembership m : memberships) 205 groups.add(groupDao.findOne(m.getGroupId())); 206 return groups; 207 } 208 209 @Override 210 public List<String> getComponentIdsInGroup(long groupId) { 211 List<Ownership> ownerships = ownershipDao.findOwnershipByGroup(groupId); 212 Set<String> componentIds = new HashSet<String>(); 213 for (Ownership o : ownerships) 214 if (ComponentUtils.isComponentId(o.getComponentId())) 215 componentIds.add(o.getComponentId()); 216 List<String> idsList = new ArrayList<String>(componentIds); 217 Collections.sort(idsList); 218 return idsList; 219 } 220 221 @Override 222 public List<String> getProfileIdsInGroup(long groupId) { 223 List<Ownership> ownerships = ownershipDao.findOwnershipByGroup(groupId); 224 Set<String> profileIds = new HashSet<String>(); 225 for (Ownership o : ownerships) 226 if (ComponentUtils.isProfileId(o.getComponentId())) 227 profileIds.add(o.getComponentId()); 228 List<String> idsList = new ArrayList<String>(profileIds); 229 Collections.sort(idsList); 230 return idsList; 231 } 232 233 @Override 234 public List<Group> getGroupsTheItemIsAMemberOf(String itemId) { 235 Set<Ownership> ownerships = new HashSet<Ownership>(); 236 ownerships.addAll(ownershipDao.findOwnershipByComponentId(itemId)); 237 Set<Group> groups = new HashSet<Group>(); 238 for (Ownership ownership : ownerships) { 239 groups.add(groupDao.findOne(ownership.getGroupId())); 240 } 241 List<Group> groupList = new ArrayList<Group>(groups); 242 Collections.sort(groupList, new Comparator<Group>() { 243 244 @Override 245 public int compare(Group g1, Group g2) { 246 return (int) (g1.getId() - g2.getId()); 247 } 248 }); 249 return groupList; 250 } 46 @Autowired 47 private GroupDao groupDao; 48 @Autowired 49 private GroupMembershipDao groupMembershipDao; 50 @Autowired 51 private OwnershipDao ownershipDao; 52 @Autowired 53 private ComponentDao componentDao; 54 @Autowired 55 private UserDao userDao; 56 57 public void setGroupDao(GroupDao groupDao) { 58 this.groupDao = groupDao; 59 } 60 61 public void setGroupMembershipDao(GroupMembershipDao groupMembershipDao) { 62 this.groupMembershipDao = groupMembershipDao; 63 } 64 65 public void setOwnershipDao(OwnershipDao ownershipDao) { 66 this.ownershipDao = ownershipDao; 67 } 68 69 @Override 70 public List<Group> getGroupsOwnedByUser(String ownerPrincipalName) { 71 RegistryUser owner = userDao.getByPrincipalName(ownerPrincipalName); 72 return groupDao.findGroupOwnedByUser(owner.getId().longValue()); 73 } 74 75 @Override 76 public boolean isUserOwnerOfGroup(String groupName, String ownerPrincipalName) { 77 List<Group> groups = getGroupsOwnedByUser(ownerPrincipalName); 78 for (Group group : groups) { 79 if (group.getName().equals(groupName)) { 80 return true; 81 } 82 } 83 84 return false; 85 } 86 87 private void checkOwnership(Ownership ownership) { 88 if (ownership.getComponentId() == null) { 89 throw new RuntimeException("Ownership needs a componentId"); 90 } 91 if (ownership.getUserId() == 0 && ownership.getGroupId() == 0) { 92 throw new RuntimeException("Ownership needs a groupId or userId"); 93 } 94 if (ownership.getUserId() != 0 && ownership.getGroupId() != 0) { 95 throw new RuntimeException("Ownership has both a groupId and a userId "); 96 } 97 } 98 99 private void assertOwnershipDoesNotExist(Ownership ownership) { 100 Ownership o = ownershipDao.findOwnershipByGroupAndComponent(ownership.getGroupId(), ownership.getComponentId()); 101 if (o != null) { 102 throw new ValidationException("Ownership exists"); 103 } 104 } 105 106 @Override 107 public void addOwnership(Ownership ownership) { 108 checkOwnership(ownership); 109 assertOwnershipDoesNotExist(ownership); 110 ownershipDao.save(ownership); 111 } 112 113 @Override 114 public void removeOwnership(Ownership ownership) { 115 throw new RuntimeException("not implemented"); 116 } 117 118 protected boolean canUserAccessAbstractDescriptionEitherOnHisOwnOrThroughGroupMembership(RegistryUser user, 119 BaseDescription description) { 120 // TODO make some joins and multi-id queries to speed the entire method 121 // up 122 boolean isProfile = (description instanceof ProfileDescription); 123 long userId = user.getId().longValue(); 124 // anyone can access public profile 125 if (componentDao.isPublic(description.getId())) { 126 return true; 127 } 128 // the creator can also access any profile 129 if (description.getUserId().equals(user.getId() + "")) { 130 return true; 131 } 132 133 // a co-ownership on the profile also allows access 134 Ownership ownership = ownershipDao.findOwnershipByUserAndComponent(userId, description.getId()); 135 if (ownership != null) { 136 return true; 137 } 138 139 // get a list of groups the user owns and is a member of 140 List<Group> groups = groupDao.findGroupOwnedByUser(userId); 141 Set<Long> groupIds = new HashSet<Long>(); 142 for (Group group : groups) { 143 groupIds.add(group.getId()); 144 } 145 146 List<GroupMembership> memberships = groupMembershipDao.findGroupsTheUserIsAmemberOf(userId); 147 for (GroupMembership gm : memberships) { 148 groupIds.add(gm.getGroupId()); 149 } 150 151 for (Long groupId : groupIds) { 152 ownership = ownershipDao.findOwnershipByGroupAndComponent(groupId, description.getId()); 153 if (ownership != null) { 154 return true; 155 } 156 } 157 return false; 158 } 159 160 @Override 161 public boolean canUserAccessComponentEitherOnHisOwnOrThroughGroupMembership(RegistryUser user, 162 BaseDescription baseDescription) { 163 return canUserAccessAbstractDescriptionEitherOnHisOwnOrThroughGroupMembership(user, baseDescription); 164 } 165 166 @Override 167 @ManagedOperation(description = "Make a user member of a group") 168 @ManagedOperationParameters({ 169 @ManagedOperationParameter(name = "principalName", description = "Principal name of the user to make a member"), 170 @ManagedOperationParameter(name = "groupName", description = "Name of the group")}) 171 public long makeMember(String userPrincipalName, String groupName) throws ItemNotFoundException{ 251 172 173 RegistryUser user = userDao.getByPrincipalName(userPrincipalName); 252 174 253 254 @ManagedOperation(description = "Make a component owned by a group instead of a user") 255 @ManagedOperationParameters({ 256 @ManagedOperationParameter(name = "principal", description = "Name of the principal who owns the component"), 257 @ManagedOperationParameter(name = "groupName", description = "Name of the group to move the component to"), 258 @ManagedOperationParameter(name = "componentId", description = "Id of component") }) 259 @Override 260 public void transferItemOwnershipFromUserToGroup(String principal, String groupName, String itemId) throws UserUnauthorizedException{ 261 262 263 BaseDescription item = null; 264 item = componentDao.getByCmdId(itemId); 265 if (item == null) { 266 throw new ValidationException("No profile or component found with ID " + itemId); 267 } 268 Group group = groupDao.findGroupByName(groupName); 269 if (group == null) { 270 throw new ValidationException("No group found with name " + groupName); 271 } 272 273 if (!this.userGroupMember(principal, String.valueOf(group.getId()))) { 274 throw new UserUnauthorizedException("User " + principal+ " is not a member of group "+groupName); 275 } 276 277 String creatorName = item.getCreatorName(); 278 if (!creatorName.equals(principal)) { 279 throw new UserUnauthorizedException("User " + principal+ " is not creator of the item "+item.getName()); 280 } 281 282 283 Ownership ownership = null; 284 List<Ownership> oldOwnerships = ownershipDao.findOwnershipByComponentId(itemId); 285 ownershipDao.delete(oldOwnerships); 286 ownership = new Ownership(); 287 ownership.setComponentId(itemId); 288 ownership.setGroupId(group.getId()); 289 addOwnership(ownership); 290 } 291 292 @Override 293 public void transferItemOwnershipFromUserToGroupId(String principal, long groupId, String componentId) throws UserUnauthorizedException{ 294 Group group = groupDao.findOne(groupId); 295 if (group == null) { 296 throw new ValidationException("No group found with id " + groupId); 297 } 298 this.transferItemOwnershipFromUserToGroup(principal, group.getName(), componentId); 299 } 300 301 @Override 302 public boolean userGroupMember(String principalName, String groupId) { 303 RegistryUser user = userDao.getByPrincipalName(principalName); 304 GroupMembership gm = groupMembershipDao.findMembership(user.getId(), Long.parseLong(groupId)); 305 return gm != null; 306 } 175 if (user == null) { 176 throw new ItemNotFoundException("User with the principal name "+userPrincipalName+" is not found."); 177 } 178 Group group = groupDao.findGroupByName(groupName); 179 180 if (group == null) { 181 throw new ItemNotFoundException("Group with the name "+groupName+" is not found."); 182 } 183 184 GroupMembership gm = groupMembershipDao.findMembership(user.getId().longValue(), group.getId()); 185 if (gm != null) { 186 return gm.getId(); 187 } 188 gm = new GroupMembership(); 189 gm.setGroupId(group.getId()); 190 gm.setUserId(user.getId().longValue()); 191 return groupMembershipDao.save(gm).getId(); 192 } 193 194 195 // @Override 196 // @ManagedOperation(description = "Remove user member from a group") 197 // @ManagedOperationParameters({ 198 // @ManagedOperationParameter(name = "principalName", description = "Principal name of the user to make a member"), 199 // @ManagedOperationParameter(name = "groupName", description = "Name of the group")}) 200 // public long removeMember(String userPrincipalName, String groupName) throws ItemNotFoundException{ 201 // 202 // RegistryUser user = userDao.getByPrincipalName(userPrincipalName); 203 // 204 // if (user == null) { 205 // throw new ItemNotFoundException("User the the principal name "+userPrincipalName+" is not found."); 206 // } 207 // Group group = groupDao.findGroupByName(groupName); 208 // 209 // if (group == null) { 210 // throw new ItemNotFoundException("Group with the name "+groupName+" is not found."); 211 // } 212 // 213 // 214 // return groupMembershipDao.deleteMembership(user.getId(), group.getId()); 215 // } 216 217 218 @ManagedOperation(description = "Create a new group") 219 @ManagedOperationParameters({ 220 @ManagedOperationParameter(name = "name", description = "Name of the group, must be unique"), 221 @ManagedOperationParameter(name = "ownerPrincipalName", description = "Principal name of the user")}) 222 @Override 223 public long createNewGroup(String name, String ownerPrincipalName) { 224 RegistryUser owner = userDao.getByPrincipalName(ownerPrincipalName); 225 if (owner == null) { 226 throw new ValidationException("No principal '" + ownerPrincipalName + "' found"); 227 } 228 Group group = groupDao.findGroupByName(name); 229 if (group != null) { 230 throw new ValidationException("Group '" + name + "' already exists"); 231 } 232 group = new Group(); 233 group.setName(name); 234 group.setOwnerId(owner.getId().longValue()); 235 group = groupDao.save(group); 236 return group.getId(); 237 } 238 239 @ManagedOperation(description = "List available groups") 240 @Override 241 public List<String> listGroupNames() { 242 List<String> groupNames = new ArrayList<String>(); 243 for (Group group : groupDao.findAll()) { 244 groupNames.add(group.getName()); 245 } 246 return groupNames; 247 } 248 249 @Override 250 public List<Group> getGroupsOfWhichUserIsAMember(String principal) { 251 RegistryUser user = userDao.getByPrincipalName(principal); 252 if (user == null || user.getId() == null) { 253 return new ArrayList<Group>(); 254 } 255 List<GroupMembership> memberships = groupMembershipDao.findGroupsTheUserIsAmemberOf(user.getId().longValue()); 256 List<Group> groups = new ArrayList<Group>(); 257 for (GroupMembership m : memberships) { 258 groups.add(groupDao.findOne(m.getGroupId())); 259 } 260 return groups; 261 } 262 263 @Override 264 public List<String> getComponentIdsInGroup(long groupId) { 265 List<Ownership> ownerships = ownershipDao.findOwnershipByGroup(groupId); 266 Set<String> componentIds = new HashSet<String>(); 267 for (Ownership o : ownerships) { 268 if (ComponentUtils.isComponentId(o.getComponentId())) { 269 componentIds.add(o.getComponentId()); 270 } 271 } 272 List<String> idsList = new ArrayList<String>(componentIds); 273 Collections.sort(idsList); 274 return idsList; 275 } 276 277 @Override 278 public List<String> getProfileIdsInGroup(long groupId) { 279 List<Ownership> ownerships = ownershipDao.findOwnershipByGroup(groupId); 280 Set<String> profileIds = new HashSet<String>(); 281 for (Ownership o : ownerships) { 282 if (ComponentUtils.isProfileId(o.getComponentId())) { 283 profileIds.add(o.getComponentId()); 284 } 285 } 286 List<String> idsList = new ArrayList<String>(profileIds); 287 Collections.sort(idsList); 288 return idsList; 289 } 290 291 @Override 292 public List<Group> getGroupsTheItemIsAMemberOf(String itemId) { 293 Set<Ownership> ownerships = new HashSet<Ownership>(); 294 ownerships.addAll(ownershipDao.findOwnershipByComponentId(itemId)); 295 Set<Group> groups = new HashSet<Group>(); 296 for (Ownership ownership : ownerships) { 297 groups.add(groupDao.findOne(ownership.getGroupId())); 298 } 299 List<Group> groupList = new ArrayList<Group>(groups); 300 Collections.sort(groupList, new Comparator<Group>() { 301 @Override 302 public int compare(Group g1, Group g2) { 303 return (int) (g1.getId() - g2.getId()); 304 } 305 }); 306 return groupList; 307 } 308 309 @ManagedOperation(description = "Make a component owned by a group instead of a user") 310 @ManagedOperationParameters({ 311 @ManagedOperationParameter(name = "principal", description = "Name of the principal who owns the component"), 312 @ManagedOperationParameter(name = "groupName", description = "Name of the group to move the component to"), 313 @ManagedOperationParameter(name = "componentId", description = "Id of component")}) 314 @Override 315 public void transferItemOwnershipFromUserToGroup(String principal, String groupName, String itemId) throws UserUnauthorizedException { 316 317 318 BaseDescription item = null; 319 item = componentDao.getByCmdId(itemId); 320 if (item == null) { 321 throw new ValidationException("No profile or component found with ID " + itemId); 322 } 323 Group group = groupDao.findGroupByName(groupName); 324 if (group == null) { 325 throw new ValidationException("No group found with name " + groupName); 326 } 327 328 if (!this.userGroupMember(principal, String.valueOf(group.getId()))) { 329 throw new UserUnauthorizedException("User " + principal + " is not a member of group " + groupName); 330 } 331 332 String creatorName = item.getCreatorName(); 333 if (!creatorName.equals(principal)) { 334 throw new UserUnauthorizedException("User " + principal + " is not creator of the item " + item.getName()); 335 } 336 337 338 Ownership ownership = null; 339 List<Ownership> oldOwnerships = ownershipDao.findOwnershipByComponentId(itemId); 340 ownershipDao.delete(oldOwnerships); 341 ownership = new Ownership(); 342 ownership.setComponentId(itemId); 343 ownership.setGroupId(group.getId()); 344 addOwnership(ownership); 345 } 346 347 @Override 348 public void transferItemOwnershipFromUserToGroupId(String principal, long groupId, String componentId) throws UserUnauthorizedException { 349 Group group = groupDao.findOne(groupId); 350 if (group == null) { 351 throw new ValidationException("No group found with id " + groupId); 352 } 353 this.transferItemOwnershipFromUserToGroup(principal, group.getName(), componentId); 354 } 355 356 @Override 357 public boolean userGroupMember(String principalName, String groupId) { 358 RegistryUser user = userDao.getByPrincipalName(principalName); 359 GroupMembership gm = groupMembershipDao.findMembership(user.getId(), Long.parseLong(groupId)); 360 return gm != null; 361 } 362 363 @Override 364 public Number getGroupIdByName(String groupName) throws ItemNotFoundException { 365 Group group = groupDao.findGroupByName(groupName); 366 if (group != null) { 367 return group.getId(); 368 } else { 369 throw new ItemNotFoundException("No group with the name "+groupName); 370 } 371 } 372 373 @Override 374 public String getGroupNameById(long groupId) throws ItemNotFoundException { 375 Group group = groupDao.findOne(groupId); 376 if (group != null) { 377 return group.getName(); 378 } else { 379 throw new ItemNotFoundException("No group with the id "+groupId); 380 } 381 } 307 382 } -
ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/persistence/jpa/GroupMembershipDao.java
r4098 r5553 16 16 @Query("select gm from GroupMembership gm where gm.userId = ?1 and gm.groupId = ?2") 17 17 GroupMembership findMembership(long userId, long groupId); 18 18 // 19 // @Query("delete gm from GroupMembership gm where gm.userId = ?1 and gm.groupId = ?2") 20 // int deleteMembership(long userId, long groupId); 19 21 } -
ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/ComponentRegistryRestService.java
r5552 r5553 28 28 import clarin.cmdi.componentregistry.rss.RssCreatorDescriptions; 29 29 import com.google.common.collect.Lists; 30 import com.sun.jersey.api.client.ClientResponse;31 import com.sun.jersey.api.client.UniformInterfaceException;32 30 33 31 import com.sun.jersey.api.core.InjectParam; … … 61 59 import javax.ws.rs.WebApplicationException; 62 60 import javax.ws.rs.core.Context; 61 import javax.ws.rs.core.GenericEntity; 63 62 import javax.ws.rs.core.MediaType; 64 63 import javax.ws.rs.core.Response; … … 68 67 import javax.ws.rs.core.UriInfo; 69 68 import javax.xml.bind.JAXBException; 69 import javax.xml.bind.annotation.XmlElement; 70 import javax.xml.bind.annotation.XmlRootElement; 70 71 71 72 import org.slf4j.Logger; … … 189 190 "Releasing {} registered components into the world ({} millisecs)", 190 191 result.size(), (System.currentTimeMillis() - start)); 191 192 192 193 return result; 193 194 } catch (AuthenticationFailException e) { … … 226 227 "Releasing {} registered components into the world ({} millisecs)", 227 228 result.size(), (System.currentTimeMillis() - start)); 228 229 229 230 return result; 230 231 } catch (AuthenticationFailException e) { … … 553 554 } 554 555 555 556 556 @Override 557 557 @POST … … 568 568 } 569 569 570 571 570 @Override 572 571 @POST … … 881 880 882 881 LOG.info("Component with id: {} deleted.", componentId); 883 return Response.ok("Component with id" + componentId +" deleted.").build();882 return Response.ok("Component with id" + componentId + " deleted.").build(); 884 883 } 885 884 … … 1792 1791 } 1793 1792 } 1793 1794 // Group Service (added by Olha) 1795 @Override 1796 @POST 1797 @Path("/groups/create") 1798 @Produces({MediaType.TEXT_XML, MediaType.APPLICATION_XML, 1799 MediaType.APPLICATION_JSON}) 1800 public Response createNewGroup(@QueryParam("groupName") String groupName) throws IOException { 1801 1802 try { 1803 Principal principal = this.checkAndGetUserPrincipal(); 1804 Number id = groupService.createNewGroup(groupName, principal.getName()); 1805 return Response.ok("Group with the name " + groupName + " is created and given an id " + id).build(); 1806 } catch (AuthenticationFailException e) { 1807 return Response.status(Status.UNAUTHORIZED).build(); 1808 } 1809 } 1810 1811 @Override 1812 @GET 1813 @Path("/groups/principal") 1814 @Produces({MediaType.TEXT_XML, MediaType.APPLICATION_XML, 1815 MediaType.APPLICATION_JSON}) 1816 public List<Group> getGroupsOwnedByUser(@QueryParam("principalName") String pricipalName) throws IOException { 1817 1818 try { 1819 Principal principal = this.checkAndGetUserPrincipal(); 1820 return groupService.getGroupsOwnedByUser(principal.getName()); 1821 } catch (AuthenticationFailException e) { 1822 response.sendError(Status.UNAUTHORIZED.getStatusCode()); 1823 return new ArrayList<Group>(); 1824 } 1825 } 1826 1827 @Override 1828 @GET 1829 @Path("/groups/names") 1830 public Response listGroupNames() throws IOException { 1831 1832 try { 1833 Principal principal = this.checkAndGetUserPrincipal(); 1834 List<String> result = groupService.listGroupNames(); 1835 //final GenericEntity<List<String>> entity = new GenericEntity<List<String>>(result){}; 1836 //return Response.status(Status.OK).entity(entity).build(); 1837 StringsWrapper ids = new StringsWrapper(); 1838 ids.setStrings(result); 1839 return Response.status(Status.OK).entity(ids).build(); 1840 } catch (AuthenticationFailException e) { 1841 return Response.status(Status.UNAUTHORIZED).build(); 1842 } 1843 } 1844 1845 @Override 1846 @GET 1847 @Path("/groups/ownership") 1848 public Response isOwner(@QueryParam("groupName") String groupName) throws IOException { 1849 1850 try { 1851 Principal principal = this.checkAndGetUserPrincipal(); 1852 Boolean isOwner = groupService.isUserOwnerOfGroup(groupName, principal.getName()); 1853 return Response.ok(isOwner.toString()).build(); 1854 } catch (AuthenticationFailException e) { 1855 return Response.serverError().status(Status.UNAUTHORIZED).build(); 1856 } 1857 } 1858 1859 @Override 1860 @POST 1861 @Path("/groups/makemember") 1862 @Produces({MediaType.TEXT_XML, MediaType.APPLICATION_XML, 1863 MediaType.APPLICATION_JSON}) 1864 public Response makeGroupMember(@QueryParam("groupName") String groupName, @QueryParam("principalName") String principalName) throws IOException { 1865 try { 1866 ComponentRegistry registry = this.getBaseRegistry(); 1867 Number id = registry.makeGroupMember(principalName, groupName); 1868 return Response.ok(id.toString()).build(); 1869 } catch (UserUnauthorizedException e) { 1870 return Response.status(Status.FORBIDDEN).entity(e.getMessage()).build(); 1871 } catch (ItemNotFoundException e) { 1872 return Response.status(Status.NOT_FOUND).entity(e.getMessage()).build(); 1873 1874 } catch (AuthenticationFailException e) { 1875 return Response.status(Status.UNAUTHORIZED).build(); 1876 } 1877 } 1878 1879 // @Override 1880 // @DELETE 1881 // @Path("/groups/removemember") 1882 // @Produces({MediaType.TEXT_XML, MediaType.APPLICATION_XML, 1883 // MediaType.APPLICATION_JSON}) 1884 // public Response removeGroupMember(@QueryParam("groupName") String groupName, @QueryParam("principalName") String principalName) throws IOException { 1885 // try { 1886 // ComponentRegistry registry = this.getBaseRegistry(); 1887 // Number id = registry.removeGroupMember(principalName, groupName); 1888 // return Response.ok(id.toString()).build(); 1889 // } catch (UserUnauthorizedException e) { 1890 // return Response.status(Status.FORBIDDEN).entity(e.getMessage()).build(); 1891 // } catch (ItemNotFoundException e) { 1892 // return Response.status(Status.NOT_FOUND).entity(e.getMessage()).build(); 1893 // 1894 // } catch (AuthenticationFailException e) { 1895 // return Response.status(Status.UNAUTHORIZED).build(); 1896 // } 1897 // } 1898 1899 @Override 1900 @GET 1901 @Path("/groups/profiles") 1902 public Response listProfiles(@QueryParam("groupId") String groupId) throws IOException { 1903 1904 try { 1905 Principal principal = this.checkAndGetUserPrincipal(); 1906 List<String> result = groupService.getProfileIdsInGroup(Long.parseLong(groupId)); 1907 StringsWrapper ids = new StringsWrapper(); 1908 ids.setStrings(result); 1909 return Response.status(Status.OK).entity(ids).build(); 1910 } catch (AuthenticationFailException e) { 1911 return Response.status(Status.UNAUTHORIZED).build(); 1912 } 1913 } 1914 1915 @Override 1916 @GET 1917 @Path("/groups/components") 1918 public Response listComponents(@QueryParam("groupId") String groupId) throws IOException { 1919 1920 try { 1921 Principal principal = this.checkAndGetUserPrincipal(); 1922 List<String> result = groupService.getComponentIdsInGroup(Long.parseLong(groupId)); 1923 StringsWrapper ids = new StringsWrapper(); 1924 ids.setStrings(result); 1925 return Response.status(Status.OK).entity(ids).build(); 1926 } catch (AuthenticationFailException e) { 1927 response.sendError(Status.UNAUTHORIZED.getStatusCode()); 1928 return Response.status(Status.UNAUTHORIZED).build(); 1929 } 1930 } 1931 1932 @Override 1933 @GET 1934 @Path("/groups/nameById") 1935 public Response getGroupNameById(@QueryParam("groupId") String groupId) throws IOException { 1936 1937 try { 1938 Principal principal = this.checkAndGetUserPrincipal(); 1939 String name = groupService.getGroupNameById(Long.parseLong(groupId)); 1940 return Response.ok(name).build(); 1941 } catch (AuthenticationFailException e) { 1942 return Response.status(Status.UNAUTHORIZED).build(); 1943 } catch (ItemNotFoundException e) { 1944 return Response.status(Status.NOT_FOUND).build(); 1945 } 1946 } 1947 1948 @Override 1949 @GET 1950 @Path("/groups/idByName") 1951 public Response getGroupIdByName(@QueryParam("groupName") String groupName) throws IOException { 1952 1953 try { 1954 Principal principal = this.checkAndGetUserPrincipal(); 1955 Number id = groupService.getGroupIdByName(groupName); 1956 return Response.ok(id.toString()).build(); 1957 } catch (AuthenticationFailException e) { 1958 return Response.status(Status.UNAUTHORIZED).build(); 1959 } catch (ItemNotFoundException e) { 1960 return Response.status(Status.NOT_FOUND).build(); 1961 } 1962 } 1963 1964 @XmlRootElement(name = "Identifiers") 1965 public static class StringsWrapper { 1966 1967 @XmlElement(name = "item") 1968 List<String> strings = new ArrayList<String>(); 1969 1970 StringsWrapper() { 1971 } 1972 1973 public void setStrings(List<String> strings) { 1974 this.strings = strings; 1975 } 1976 1977 1978 } 1794 1979 } -
ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/rest/IComponentRegistryRestService.java
r5552 r5553 27 27 28 28 /** 29 * 29 * 30 30 * @author twago@mpi.nl 31 31 * @author olsha@mpi.nl … … 35 35 @Path("/registry") 36 36 @Singleton 37 @Transactional(rollbackFor =Exception.class)37 @Transactional(rollbackFor = Exception.class) 38 38 public interface IComponentRegistryRestService { 39 39 40 public static final String APPLICATION_BASE_URL_PARAM = "eu.clarin.cmdi.componentregistry.serviceRootUrl"; 41 public static final String DATA_FORM_FIELD = "data"; 42 public static final String NAME_FORM_FIELD = "name"; 43 public static final String DESCRIPTION_FORM_FIELD = "description"; 44 public static final String GROUP_FORM_FIELD = "group"; 45 public static final String DOMAIN_FORM_FIELD = "domainName"; 46 public static final String REGISTRY_SPACE_PARAM = "registrySpace"; 47 public static final String GROUPID_PARAM = "groupid"; 48 public static final String METADATA_EDITOR_PARAM = "mdEditor"; 49 public static final String NUMBER_OF_RSSITEMS = "limit"; 50 51 List<ComponentDescription> getRegisteredComponents(String registrySpace, String groupId) 52 throws ComponentRegistryException, IOException, UserUnauthorizedException; 53 54 List<ProfileDescription> getRegisteredProfiles(String registrySpace, boolean metadataEditor, String groupId) throws ComponentRegistryException, IOException, UserUnauthorizedException; 55 56 Response getRegisteredComponent(String componentId) throws IOException; 57 58 Response getRegisteredProfile(String profileId) throws IOException; 59 60 Response getRegisteredComponentRawType(String componentId, String rawType) throws ComponentRegistryException; 61 62 40 public static final String APPLICATION_BASE_URL_PARAM = "eu.clarin.cmdi.componentregistry.serviceRootUrl"; 41 public static final String DATA_FORM_FIELD = "data"; 42 public static final String NAME_FORM_FIELD = "name"; 43 public static final String DESCRIPTION_FORM_FIELD = "description"; 44 public static final String GROUP_FORM_FIELD = "group"; 45 public static final String DOMAIN_FORM_FIELD = "domainName"; 46 public static final String REGISTRY_SPACE_PARAM = "registrySpace"; 47 public static final String GROUPID_PARAM = "groupid"; 48 public static final String METADATA_EDITOR_PARAM = "mdEditor"; 49 public static final String NUMBER_OF_RSSITEMS = "limit"; 50 51 List<ComponentDescription> getRegisteredComponents(String registrySpace, String groupId) 52 throws ComponentRegistryException, IOException, UserUnauthorizedException; 53 54 List<ProfileDescription> getRegisteredProfiles(String registrySpace, boolean metadataEditor, String groupId) throws ComponentRegistryException, IOException, UserUnauthorizedException; 55 56 Response getRegisteredComponent(String componentId) throws IOException; 57 58 Response getRegisteredProfile(String profileId) throws IOException; 59 60 Response getRegisteredComponentRawType(String componentId, String rawType) throws ComponentRegistryException; 61 63 62 // ComponentRegistry findRegistry(String id, 64 63 // RegistryClosure<? extends BaseDescription> clos) … … 66 65 // 67 66 // 68 69 List<BaseDescription> getComponentUsage(String componentId) throws ComponentRegistryException, IOException; 70 71 List<Comment> getCommentsFromProfile(String profileId) throws ComponentRegistryException, IOException; 72 73 List<Comment> getCommentsFromComponent(String componentId) throws ComponentRegistryException, IOException; 74 75 Comment getSpecifiedCommentFromProfile(String profileId, String commentId) throws ComponentRegistryException, IOException ; 76 77 Comment getSpecifiedCommentFromComponent(String componentId, String commentId) throws ComponentRegistryException, IOException ; 78 79 /** 80 * 81 * Purely helper method for my front-end (FLEX) which only does post/get 82 * requests. The query param is checked and the "proper" method is called. 83 * 84 * @param profileId 85 * @param method 86 * @return 87 */ 88 Response manipulateRegisteredProfile(String profileId, String method); 89 90 Response manipulateCommentFromProfile(String profileId, String commentId, 91 String method); 92 93 Response manipulateCommentFromComponent(String componentId, 94 String commentId, String method); 95 96 Response publishRegisteredProfile(String profileId, InputStream input, 97 String name, String description, String group, String domainName); 98 99 Response updateRegisteredProfile(String profileId, 100 InputStream input, String name, String description, String groupId, 101 String domainName); 102 103 /** 104 * 105 * Purely helper method for my front-end (FLEX) which van only do post/get 106 * requests. The query param is checked and the "proper" method is called. 107 * 108 * @param componentId 109 * @param method 110 * @return 111 */ 112 Response manipulateRegisteredComponent(String componentId, String method); 113 114 Response publishRegisteredComponent(String componentId, InputStream input, 115 String name, String description, String groupId, String domainName); 116 117 Response updateRegisteredComponent(String componentId, 118 InputStream input, String name, String description, String groupId, 119 String domainName); 120 121 Response deleteRegisteredComponent(String componentId); 122 123 Response deleteRegisteredProfile(String profileId); 124 125 Response deleteCommentFromProfile(String profileId, String commentId); 126 127 Response deleteCommentFromComponent(String componentId, String commentId); 128 129 Response getRegisteredProfileRawType(String profileId, String rawType) throws ComponentRegistryException; 130 131 Response registerProfile(InputStream input, String name, 132 String description, String groupId, String domainName); 133 134 Response registerComponent(InputStream input, String name, 135 String description, String groupId, String domainName); 136 137 Response registerCommentInComponent(InputStream input, String componentId) throws ComponentRegistryException; 138 139 Response registerCommentInProfile(InputStream input, String profileId) throws ComponentRegistryException; 140 141 Response pingSession(); 142 143 /** 144 * @param componentRegistryFactory the componentRegistryFactory to set 145 */ 146 void setComponentRegistryFactory(ComponentRegistryFactory componentRegistryFactory); 147 148 149 Rss getRssComponent(String groupId, String registrySpace, String limit) 150 throws ComponentRegistryException, ParseException, IOException; 151 152 153 Rss getRssProfile(String groupId, String registrySpace, String limit) 154 throws ComponentRegistryException, ParseException, IOException; 155 156 157 Rss getRssOfCommentsFromProfile(String profileId, String limit) throws ComponentRegistryException, 158 JAXBException, ParseException, IOException; 159 160 161 Rss getRssOfCommentsFromComponent(String componentId, 162 String limit) throws ComponentRegistryException, IOException, 163 JAXBException, ParseException; 164 165 AllowedAttributetypesXML getAllowedAttributeTypes() 166 throws ComponentRegistryException, IOException, JAXBException, 167 ParseException; 168 169 void setFileNamesFromListToNull(List<CMDComponentType> listofcomponents); 170 171 /** 172 * Get a list of groups the user is a member of 173 * @return 174 */ 175 List<Group> getGroupsTheCurrentUserIsAMemberOf(); 176 177 /** 178 * Get a list of groups the item is available to. For all practical reasons, this will return either 0 or 1 groups 179 * @param itemId ID of component or profile. This is not the DB id but the logical ID which is unique across components and profiles 180 * @return List of groups 181 */ 182 List<Group> getGroupsTheItemIsAMemberOf(String itemId); 183 184 /** 185 * Transfer ownership of an item (group/profile) to a group 186 * @param itemId 187 * @param groupId 188 */ 189 Response transferItemOwnershipToGroup(String itemId, long groupId) throws IOException; 190 191 /** 192 * Get any component (public or private) with the specified ID 193 * @param componentId 194 * @return 195 */ 196 BaseDescription getBaseDescription(String componentId) throws ComponentRegistryException, IOException; 197 67 List<BaseDescription> getComponentUsage(String componentId) throws ComponentRegistryException, IOException; 68 69 List<Comment> getCommentsFromProfile(String profileId) throws ComponentRegistryException, IOException; 70 71 List<Comment> getCommentsFromComponent(String componentId) throws ComponentRegistryException, IOException; 72 73 Comment getSpecifiedCommentFromProfile(String profileId, String commentId) throws ComponentRegistryException, IOException; 74 75 Comment getSpecifiedCommentFromComponent(String componentId, String commentId) throws ComponentRegistryException, IOException; 76 77 /** 78 * 79 * Purely helper method for my front-end (FLEX) which only does post/get 80 * requests. The query param is checked and the "proper" method is called. 81 * 82 * @param profileId 83 * @param method 84 * @return 85 */ 86 Response manipulateRegisteredProfile(String profileId, String method); 87 88 Response manipulateCommentFromProfile(String profileId, String commentId, 89 String method); 90 91 Response manipulateCommentFromComponent(String componentId, 92 String commentId, String method); 93 94 Response publishRegisteredProfile(String profileId, InputStream input, 95 String name, String description, String group, String domainName); 96 97 Response updateRegisteredProfile(String profileId, 98 InputStream input, String name, String description, String groupId, 99 String domainName); 100 101 /** 102 * 103 * Purely helper method for my front-end (FLEX) which van only do post/get 104 * requests. The query param is checked and the "proper" method is called. 105 * 106 * @param componentId 107 * @param method 108 * @return 109 */ 110 Response manipulateRegisteredComponent(String componentId, String method); 111 112 Response publishRegisteredComponent(String componentId, InputStream input, 113 String name, String description, String groupId, String domainName); 114 115 Response updateRegisteredComponent(String componentId, 116 InputStream input, String name, String description, String groupId, 117 String domainName); 118 119 Response deleteRegisteredComponent(String componentId); 120 121 Response deleteRegisteredProfile(String profileId); 122 123 Response deleteCommentFromProfile(String profileId, String commentId); 124 125 Response deleteCommentFromComponent(String componentId, String commentId); 126 127 Response getRegisteredProfileRawType(String profileId, String rawType) throws ComponentRegistryException; 128 129 Response registerProfile(InputStream input, String name, 130 String description, String groupId, String domainName); 131 132 Response registerComponent(InputStream input, String name, 133 String description, String groupId, String domainName); 134 135 Response registerCommentInComponent(InputStream input, String componentId) throws ComponentRegistryException; 136 137 Response registerCommentInProfile(InputStream input, String profileId) throws ComponentRegistryException; 138 139 Response pingSession(); 140 141 /** 142 * @param componentRegistryFactory the componentRegistryFactory to set 143 */ 144 void setComponentRegistryFactory(ComponentRegistryFactory componentRegistryFactory); 145 146 Rss getRssComponent(String groupId, String registrySpace, String limit) 147 throws ComponentRegistryException, ParseException, IOException; 148 149 Rss getRssProfile(String groupId, String registrySpace, String limit) 150 throws ComponentRegistryException, ParseException, IOException; 151 152 Rss getRssOfCommentsFromProfile(String profileId, String limit) throws ComponentRegistryException, 153 JAXBException, ParseException, IOException; 154 155 Rss getRssOfCommentsFromComponent(String componentId, 156 String limit) throws ComponentRegistryException, IOException, 157 JAXBException, ParseException; 158 159 AllowedAttributetypesXML getAllowedAttributeTypes() 160 throws ComponentRegistryException, IOException, JAXBException, 161 ParseException; 162 163 void setFileNamesFromListToNull(List<CMDComponentType> listofcomponents); 164 165 166 167 /** 168 * Get any component (public or private) with the specified ID 169 * 170 * @param componentId 171 * @return 172 */ 173 BaseDescription getBaseDescription(String componentId) throws ComponentRegistryException, IOException; 174 175 // Group Service 176 177 /** 178 * Get a list of groups the user is a member of 179 * 180 * @return 181 */ 182 List<Group> getGroupsTheCurrentUserIsAMemberOf(); 183 184 185 186 /** 187 * Get a list of groups the item is available to. For all practical reasons, 188 * this will return either 0 or 1 groups 189 * 190 * @param itemId ID of component or profile. This is not the DB id but the 191 * logical ID which is unique across components and profiles 192 * @return List of groups 193 */ 194 List<Group> getGroupsTheItemIsAMemberOf(String itemId); 195 196 /** 197 * Transfer ownership of an item (group/profile) to a group 198 * 199 * @param itemId 200 * @param groupId 201 */ 202 Response transferItemOwnershipToGroup(String itemId, long groupId) throws IOException; 203 204 // (added by Olha) 205 206 Response createNewGroup(String groupName) throws IOException; 207 208 List<Group> getGroupsOwnedByUser(String pricipalName) throws IOException; 209 210 Response listGroupNames() throws IOException; 211 212 Response isOwner(String groupName) throws IOException; 213 214 Response makeGroupMember(String groupName, String principalName) throws IOException; 215 216 //Response removeGroupMember(String groupName, String principalName) throws IOException; 217 218 Response listProfiles(String groupId) throws IOException; 219 220 Response listComponents(String groupId) throws IOException; 221 222 Response getGroupNameById(String groupId) throws IOException; 223 224 Response getGroupIdByName(String groupName) throws IOException; 198 225 } -
ComponentRegistry/trunk/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/impl/database/GroupServiceImplTest.java
r5549 r5553 8 8 9 9 import clarin.cmdi.componentregistry.BaseUnitTest; 10 import clarin.cmdi.componentregistry.ItemNotFoundException; 10 11 import clarin.cmdi.componentregistry.UserUnauthorizedException; 11 12 import clarin.cmdi.componentregistry.model.BaseDescription; … … 159 160 160 161 @Test 161 public void testAccessViaGroupToPrivateProfile() {162 public void testAccessViaGroupToPrivateProfile() throws ItemNotFoundException{ 162 163 // Make a profile that belongs to someone else 163 164 BaseDescription profile = makeTestProfile("4567", false, 9999); … … 230 231 231 232 @Test 232 public void testAccessViaGroupToPrivateComponent() {233 public void testAccessViaGroupToPrivateComponent() throws ItemNotFoundException{ 233 234 // Make a profile that belongs to someone else 234 235 BaseDescription componentDescription = makeTestComponent(false, … … 257 258 258 259 @Test 259 public void testTransferComponentOwnershipFromUserToGroup() throws UserUnauthorizedException {260 public void testTransferComponentOwnershipFromUserToGroup() throws UserUnauthorizedException, ItemNotFoundException{ 260 261 261 262 // Make a group … … 309 310 310 311 @Test 311 public void testtransferComponentOwnershipFromUserToGroup() throws UserUnauthorizedException {312 public void testtransferComponentOwnershipFromUserToGroup() throws UserUnauthorizedException, ItemNotFoundException{ 312 313 313 314 // Make a group … … 362 363 363 364 @Test 364 public void testTransferItemOwnershipFromUserToGroup() throws UserUnauthorizedException {365 public void testTransferItemOwnershipFromUserToGroup() throws UserUnauthorizedException, ItemNotFoundException{ 365 366 //TODO: improve test by mixing in components and exclusing components/profiles 366 367 // Make a group … … 415 416 416 417 @Test 417 public void testGetGroupsTheItemIsAMemberOf() throws UserUnauthorizedException {418 public void testGetGroupsTheItemIsAMemberOf() throws UserUnauthorizedException, ItemNotFoundException{ 418 419 // Make a group 419 420 Group group1 = groupDao.findOne(groupService.createNewGroup("Group 1", -
ComponentRegistry/trunk/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/rest/ComponentRegistryRestServiceTestCase.java
r4098 r5553 7 7 import clarin.cmdi.componentregistry.model.Comment; 8 8 import clarin.cmdi.componentregistry.model.ComponentDescription; 9 import clarin.cmdi.componentregistry.model.Group; 9 10 import clarin.cmdi.componentregistry.model.ProfileDescription; 10 11 import clarin.cmdi.componentregistry.model.RegistryUser; … … 28 29 import org.springframework.test.context.ContextConfiguration; 29 30 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 30 import org.springframework.test.context.transaction.TransactionConfiguration;31 import org.springframework.transaction.annotation.Transactional;32 31 import org.springframework.web.context.ContextLoaderListener; 33 32 import org.springframework.web.context.request.RequestContextListener; … … 52 51 }; 53 52 protected final static GenericType<List<Comment>> COMMENT_LIST_GENERICTYPE = new GenericType<List<Comment>>() { 53 }; 54 protected final static GenericType<List<Group>> GROUP_LIST_GENERICTYPE = new GenericType<List<Group>>() { 55 }; 56 protected final static GenericType<List<String>> STRING_LIST_GENERICTYPE = new GenericType<List<String>>() { 54 57 }; 55 58 -
ComponentRegistry/trunk/ComponentRegistry/src/test/java/clarin/cmdi/componentregistry/rest/RegistryTestHelper.java
r5549 r5553 43 43 RegistryTestHelper.marshaller = marshaller; 44 44 } 45 46 45 47 46 48 public static ComponentDescription addComponent(ComponentRegistry testRegistry, String id, boolean isPublic) throws ParseException, JAXBException { … … 111 113 return addProfile(testRegistry, id, new ByteArrayInputStream(content.getBytes()), isPublic); 112 114 } 115 116 113 117 114 118 private static ProfileDescription addProfile(ComponentRegistry testRegistry, String id, InputStream content, boolean isPublic) throws ParseException,
Note: See TracChangeset
for help on using the changeset viewer.