Changeset 4671


Ignore:
Timestamp:
03/12/14 15:56:47 (10 years ago)
Author:
olhsha
Message:

debugging and testing

Location:
DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend
Files:
1 deleted
10 edited

Legend:

Unmodified
Added
Removed
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/pom.xml

    r4670 r4671  
    129129            <groupId>de.mpg.mpgaai</groupId>
    130130            <artifactId>mpgaai-shhaa</artifactId>
    131             <version>1.0.3</version>
     131            <version>${shibboleth.version}</version>
    132132            <exclusions>
    133133                <exclusion>
     
    328328        <plugin.license.copyrightYear>2013</plugin.license.copyrightYear>
    329329        <project.version>1.3</project.version>
     330        <shibboleth.version>1.0.4</shibboleth.version>
    330331    </properties>
    331332   
     333    <repositories>
     334        <repository>
     335            <id>MPI</id>
     336            <name>MPI LAT Repository/</name>
     337            <url>http://lux15.mpi.nl/nexus/content/groups/public</url>
     338        </repository>
     339        <repository>
     340            <id>MPI-Snapshot</id>
     341            <name>MPI LAT Repository/</name>
     342            <url>http://lux15.mpi.nl/nexus/content/repositories/MPI-Snapshots</url>
     343        </repository>
     344    </repositories>
     345   
    332346   
    333347</project>
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/AutheticationResource.java

    r4670 r4671  
    2323import java.sql.SQLException;
    2424import javax.servlet.ServletException;
    25 import javax.servlet.http.HttpServletRequestWrapper;
    2625import javax.ws.rs.GET;
    2726import javax.ws.rs.Path;
    2827import javax.ws.rs.Produces;
     28import javax.ws.rs.core.Context;
    2929import javax.ws.rs.core.MediaType;
    3030import javax.xml.bind.JAXBElement;
     
    4141@Transactional(rollbackFor = {Exception.class, SQLException.class, IOException.class, ParserConfigurationException.class})
    4242public class AutheticationResource extends ResourceResource {
    43 
     43   
     44   
    4445    @GET
    4546    @Produces(MediaType.TEXT_XML)
     
    6263    @Transactional(readOnly = true)
    6364    public JAXBElement<User> loginAndGet() throws IOException {
     65        dbIntegrityService.setServiceURI(uriInfo.getBaseUri().toString());
    6466        String remoteUser = httpServletRequest.getRemoteUser();
    6567        verboseOutput = new VerboseOutput(httpServletResponse, loggerServer);
    6668        if (remoteUser != null) {
    67             if (!remoteUser.equals("anonymous")) {
    68                 dbIntegrityService.setServiceURI(uriInfo.getBaseUri().toString());
     69            if (!remoteUser.equals("anonymous")) {               
    6970                final Number remoteUserID = dbIntegrityService.getUserInternalIDFromRemoteID(remoteUser);
    7071                if (remoteUserID != null) {
     
    8586    @Transactional(readOnly = true)
    8687    public void logout() throws IOException, ServletException {
    87         httpServletResponse.sendRedirect("eu.dasish.annotation.backend.logout");
     88        httpServletResponse.sendRedirect(context.getInitParameter("eu.dasish.annotation.backend.logout"));
    8889    }
    8990}
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/CachedRepresentationResource.java

    r4615 r4671  
    2020import eu.dasish.annotation.backend.BackendConstants;
    2121import eu.dasish.annotation.backend.Resource;
    22 import eu.dasish.annotation.backend.dao.DBIntegrityService;
    2322import eu.dasish.annotation.schema.CachedRepresentationInfo;
    2423import eu.dasish.annotation.schema.ObjectFactory;
     
    3029import javax.imageio.ImageIO;
    3130import javax.servlet.http.HttpServletRequest;
    32 import javax.servlet.http.HttpServletResponse;
    3331import javax.ws.rs.GET;
    3432import javax.ws.rs.Path;
    3533import javax.ws.rs.PathParam;
    3634import javax.ws.rs.Produces;
    37 import javax.ws.rs.core.Context;
    3835import javax.ws.rs.core.MediaType;
    39 import javax.ws.rs.core.UriInfo;
    4036import javax.xml.bind.JAXBElement;
    4137import javax.xml.parsers.ParserConfigurationException;
    42 import org.slf4j.Logger;
    43 import org.slf4j.LoggerFactory;
    44 import org.springframework.beans.factory.annotation.Autowired;
    4538import org.springframework.stereotype.Component;
    4639import org.springframework.transaction.annotation.Transactional;
     
    9487                if (cachedID != null) {
    9588                    InputStream dbRespond = dbIntegrityService.getCachedRepresentationBlob(cachedID);
    96                     ImageIO.setUseCache(false);
    97                     BufferedImage result = ImageIO.read(dbRespond);
    98                     return result;
     89                    if (dbRespond != null) {
     90                        ImageIO.setUseCache(false);
     91                        BufferedImage result = ImageIO.read(dbRespond);
     92                        return result;
     93                    } else {
     94                        verboseOutput.CACHED_REPRESENTATION_IS_NULL();
     95                    }
    9996                } else {
    10097                    verboseOutput.CACHED_REPRESENTATION_NOT_FOUND(externalId);
     
    103100                verboseOutput.ILLEGAL_UUID(externalId);
    104101            }
    105         } 
    106         return null;
     102        }
     103        return new BufferedImage(20, 20, BufferedImage.TYPE_INT_ARGB);
    107104    }
    108105}
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/JaxbMarshallerFactory.java

    r4603 r4671  
    3232    private JAXBContext context;
    3333    private Marshaller marshaller;
    34     // overwritten by the context.xml's
     34    // overwritten by the web.xml's
     35    // why??
    3536    private String schemaLocation = "http://www.dasish.eu/ns/addit file:/Users/olhsha/repositories/DASISH/t5.6/schema/trunk/annotator-schema/src/main/target/DASISH-schema.xsd";
    3637   
     
    4849   
    4950    public Marshaller createMarshaller(Class<?> type) throws JAXBException{
    50         context = JAXBContext.newInstance(type);
     51        context = JAXBContext.newInstance(type); 
    5152        marshaller = context.createMarshaller();       
    5253        marshaller.setProperty(Marshaller.JAXB_SCHEMA_LOCATION, schemaLocation);
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/ResourceResource.java

    r4670 r4671  
    5252    protected String admin = "admin";
    5353    protected String anonym = "anonymous";
    54    
     54
    5555    public Number getUserID() throws IOException {
     56        dbIntegrityService.setServiceURI(uriInfo.getBaseUri().toString());
    5657        verboseOutput = new VerboseOutput(httpServletResponse, loggerServer);
    57         String remoteUser = httpServletRequest.getRemoteUser();       
     58        String remoteUser = httpServletRequest.getRemoteUser();
    5859        if (remoteUser != null) {
    5960            if (!remoteUser.equals(anonym)) {
     
    6162                if (userID != null) {
    6263                    return userID;
    63                 } 
    64                 verboseOutput.REMOTE_PRINCIPAL_NOT_FOUND(remoteUser,dbIntegrityService.getDataBaseAdmin().getDisplayName(), dbIntegrityService.getDataBaseAdmin().getEMail());
     64                }
     65                verboseOutput.REMOTE_PRINCIPAL_NOT_FOUND(remoteUser, dbIntegrityService.getDataBaseAdmin().getDisplayName(), dbIntegrityService.getDataBaseAdmin().getEMail());
    6566                return null;
    6667            }
     
    7172
    7273    }
    73    
    74    
    7574}
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/java/eu/dasish/annotation/backend/rest/VerboseOutput.java

    r4670 r4671  
    4848
    4949    private MessageStatus _NOT_LOGGED_IN(String adminName, String adminEmail) {
    50         return new MessageStatus(" The user is not logged-in or its remote login is corrupted by setting to null. In the latter case contact the admin "+adminName+" via the e-mail "+adminEmail, HttpServletResponse.SC_UNAUTHORIZED);
     50        return new MessageStatus(" The user is not logged-in or its remote login is corrupted by setting to null. In the latter case contact the admin " + adminName + " via the e-mail " + adminEmail, HttpServletResponse.SC_UNAUTHORIZED);
    5151    }
    5252
    5353    private MessageStatus _FORBIDDEN_RESOURCE_ACTION(String identifier, String resource, String action, String ownerName, String ownerEMail) {
    54         return new MessageStatus(" The logged-in principal cannot "+action+" the "+resource+" with the identifier " + identifier+ ". Contact the resource's owner "+ownerName+" via the e-mail "+ownerEMail, HttpServletResponse.SC_FORBIDDEN);
    55     }
    56 
     54        return new MessageStatus(" The logged-in principal cannot " + action + " the " + resource + " with the identifier " + identifier + ". Contact the resource's owner " + ownerName + " via the e-mail " + ownerEMail, HttpServletResponse.SC_FORBIDDEN);
     55    }
    5756
    5857    private MessageStatus _ILLEGAL_UUID(String identifier) {
     
    6160
    6261    private MessageStatus _REMOTE_PRINCIPAL_NOT_FOUND(String remoteID, String adminName, String adminEmail) {
    63         return new MessageStatus("The logged in principal with the remote ID " + remoteID + " is not found in the database or his/her internal DB identifier is corrupted by setting to null. Contact the database admin "+adminName+" by the e-mail "+adminEmail, HttpServletResponse.SC_NOT_FOUND);
     62        return new MessageStatus("The logged in principal with the remote ID " + remoteID + " is not found in the database or his/her internal DB identifier is corrupted by setting to null. Contact the database admin " + adminName + " by the e-mail " + adminEmail, HttpServletResponse.SC_NOT_FOUND);
    6463    }
    6564
     
    6867    }
    6968
    70  
    7169    private MessageStatus _PRINCIPAL_NOT_FOUND(String externalIdentifier) {
    7270        return resourceNotFound(externalIdentifier, "principal");
     
    8987    }
    9088
     89    private MessageStatus _CACHED_REPRESENTATION_IS_NULL() {
     90        return new MessageStatus("The cached representation with the give ID exist in the DB, however its BLOB is null.", HttpServletResponse.SC_NO_CONTENT);
     91
     92    }
     93
    9194    private MessageStatus _INVALID_PERMISSION_MODE(String permissionMode) {
    9295        return new MessageStatus(permissionMode + " is an invalid permission value, which must be either owner, or reader, or writer.", HttpServletResponse.SC_BAD_REQUEST);
     
    98101
    99102    private MessageStatus _ADMIN_RIGHTS_EXPECTED(String adminName, String adminEmail) {
    100         return new MessageStatus("The request can be performed only by the principal with the admin rights. Contact the admin "+adminName+" via e-mail "+adminEmail, HttpServletResponse.SC_FORBIDDEN);
     103        return new MessageStatus("The request can be performed only by the principal with the admin rights. Contact the admin " + adminName + " via e-mail " + adminEmail, HttpServletResponse.SC_FORBIDDEN);
    101104    }
    102105
     
    116119        return new MessageStatus("The account is not updated", HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    117120    }
    118    
     121
    119122    private MessageStatus _LOGOUT() {
    120123        return new MessageStatus("You are logged out.", HttpServletResponse.SC_UNAUTHORIZED);
    121124    }
    122    
     125
    123126    private MessageStatus _ANONYMOUS_PRINCIPAL() {
    124127        return new MessageStatus("Shibboleth fall-back.  Logged in as 'anonymous' with no rights.", HttpServletResponse.SC_UNAUTHORIZED);
     
    140143
    141144    public void FORBIDDEN_NOTEBOOK_WRITING(String identifier, String ownerName, String ownerEMail) throws IOException {
    142          this.sendMessage(this._FORBIDDEN_RESOURCE_ACTION(identifier, "notebook", "write", ownerName, ownerEMail));
     145        this.sendMessage(this._FORBIDDEN_RESOURCE_ACTION(identifier, "notebook", "write", ownerName, ownerEMail));
    143146    }
    144147
    145148    public void FORBIDDEN_ANNOTATION_READING(String identifier, String ownerName, String ownerEMail) throws IOException {
    146          this.sendMessage(this._FORBIDDEN_RESOURCE_ACTION(identifier, "annotation", "read", ownerName, ownerEMail));;
     149        this.sendMessage(this._FORBIDDEN_RESOURCE_ACTION(identifier, "annotation", "read", ownerName, ownerEMail));;
    147150    }
    148151
    149152    public void FORBIDDEN_ANNOTATION_WRITING(String identifier, String ownerName, String ownerEMail) throws IOException {
    150          this.sendMessage(this._FORBIDDEN_RESOURCE_ACTION(identifier, "annotation", "write", ownerName, ownerEMail));
     153        this.sendMessage(this._FORBIDDEN_RESOURCE_ACTION(identifier, "annotation", "write", ownerName, ownerEMail));
    151154    }
    152155
    153156    public void FORBIDDEN_PERMISSION_CHANGING(String identifier, String ownerName, String ownerEMail) throws IOException {
    154          this.sendMessage(this._FORBIDDEN_RESOURCE_ACTION(identifier, "resource","change", ownerName, ownerEMail));
     157        this.sendMessage(this._FORBIDDEN_RESOURCE_ACTION(identifier, "resource", "change", ownerName, ownerEMail));
    155158    }
    156159
     
    183186    }
    184187
     188    public void CACHED_REPRESENTATION_IS_NULL() throws IOException {
     189        this.sendMessage(this._CACHED_REPRESENTATION_IS_NULL());
     190    }
     191
    185192    public void INVALID_PERMISSION_MODE(String permissionMode) throws IOException {
    186193        this.sendMessage(this._INVALID_PERMISSION_MODE(permissionMode));
     
    210217        this.sendMessage(this._ACCOUNT_IS_NOT_UPDATED());
    211218    }
    212    
     219
    213220    public void LOGOUT() throws IOException {
    214221        this.sendMessage(this._LOGOUT());
    215222    }
    216    
     223
    217224    public void ANONYMOUS_PRINCIPAL() throws IOException {
    218225        this.sendMessage(this._ANONYMOUS_PRINCIPAL());
    219226    }
    220    
    221227}
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/webapp/WEB-INF/shhaa.xml

    r4670 r4671  
    2121<ROOT>
    2222    <shhaa>
    23        
    24 <!--        <webapp>
    25                 <host>http://localhost:8080</host>
    26                 <context>/annotator-backend</context>
    27         </webapp>-->
    28 
    2923        <authentication>
    3024            <shibheader>
     
    4539            </fallback>
    4640            <sso action="lI">https://lux16.mpi.nl/Shibboleth.sso/Login</sso>
    47             <slo action="lO">eu.dasish.annotation.backend.logout</slo>
     41            <slo action="lO">https://lux16.mpi.nl/Shibboleth.sso/Logout</slo>
    4842        </authentication>
    4943       
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/main/webapp/WEB-INF/web.xml

    r4670 r4671  
    8181    </servlet-mapping>
    8282   
    83 <!--    <security-constraint>
     83    <security-constraint>
    8484        <display-name>Protected backend localhost</display-name>
    8585        <web-resource-collection>
     
    104104        <role-name>tomcat</role-name>
    105105    </security-role>
    106     -->
    107     <filter>
     106   
     107    <!--    <filter>
    108108        <filter-name>AAIFilter</filter-name>
    109109        <filter-class>de.mpg.aai.shhaa.AuthFilter</filter-class>
     
    112112        <filter-name>AAIFilter</filter-name>
    113113        <url-pattern>/*</url-pattern>
    114     </filter-mapping>
     114    </filter-mapping> -->
    115115   
    116116   
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/rest/AnnotationResourceTest.java

    r4670 r4671  
    7777    public AnnotationResourceTest() {
    7878        mockRequest = new MockHttpServletRequest();
    79        
    8079    }
    8180   
     81   
     82//    public Number getUserID() throws IOException {
     83//        dbIntegrityService.setServiceURI(uriInfo.getBaseUri().toString());
     84//        verboseOutput = new VerboseOutput(httpServletResponse, loggerServer);
     85//        String remoteUser = httpServletRequest.getRemoteUser();
     86//        if (remoteUser != null) {
     87//            if (!remoteUser.equals(anonym)) {
     88//                final Number userID = dbIntegrityService.getUserInternalIDFromRemoteID(remoteUser);
     89//                if (userID != null) {
     90//                    return userID;
     91//                }
     92//                verboseOutput.REMOTE_PRINCIPAL_NOT_FOUND(remoteUser, dbIntegrityService.getDataBaseAdmin().getDisplayName(), dbIntegrityService.getDataBaseAdmin().getEMail());
     93//                return null;
     94//            }
     95//        }
     96//
     97//        verboseOutput.NOT_LOGGED_IN(dbIntegrityService.getDataBaseAdmin().getDisplayName(), dbIntegrityService.getDataBaseAdmin().getEMail());
     98//        return null;
     99//
     100//    }
    82101   
    83102    @Test
     
    89108        annotationResource.setUriInfo(mockUriInfo);
    90109        mockRequest.setRemoteUser("olhsha@mpi.nl");
     110       
     111        final URI baseUri = URI.create(TestBackendConstants._TEST_SERVLET_URI);
    91112
    92113        mockeryRest.checking(new Expectations() {
    93114            { 
    94                      
     115                oneOf(mockUriInfo).getBaseUri();
     116                will(returnValue(baseUri));
     117               
     118                oneOf(mockDbIntegrityService).setServiceURI(baseUri.toString());
     119               
    95120                oneOf(mockDbIntegrityService).getUserInternalIDFromRemoteID("olhsha@mpi.nl");
    96121                will(returnValue(3));
     
    130155        mockRequest.setRemoteUser("olhsha@mpi.nl");
    131156       
     157         final URI baseUri = URI.create(TestBackendConstants._TEST_SERVLET_URI);
     158
    132159       
    133160        mockeryRest.checking(new Expectations() {
    134161            {
    135                
     162                oneOf(mockUriInfo).getBaseUri();
     163                will(returnValue(baseUri));
     164               
     165                oneOf(mockDbIntegrityService).setServiceURI(baseUri.toString());
     166               
    136167                oneOf(mockDbIntegrityService).getUserInternalIDFromRemoteID("olhsha@mpi.nl");
    137168                will(returnValue(3));
     
    203234        annotationResource.setUriInfo(mockUriInfo);
    204235        mockRequest.setRemoteUser("olhsha@mpi.nl");
    205        
     236        final URI baseUri = URI.create(TestBackendConstants._TEST_SERVLET_URI);
     237
    206238       
    207239        mockeryRest.checking(new Expectations() {
    208240            {
    209                
     241                oneOf(mockUriInfo).getBaseUri();
     242                will(returnValue(baseUri));
     243               
     244                oneOf(mockDbIntegrityService).setServiceURI(baseUri.toString());
     245               
    210246                oneOf(mockDbIntegrityService).getUserInternalIDFromRemoteID("olhsha@mpi.nl");
    211247                will(returnValue(3));
  • DASISH/t5.6/backend/annotator-backend/trunk/annotator-backend/src/test/java/eu/dasish/annotation/backend/rest/AnnotationsTest.java

    r4670 r4671  
    111111     */
    112112    @Test
    113     @Ignore
    114113    public void testGetAnnotation() throws SQLException, DatatypeConfigurationException {
    115114       
     
    155154     */
    156155    @Test
    157     @Ignore
    158156    public void testDeleteAnnotation() throws SQLException {
    159157       
     
    181179     */
    182180    @Test
    183     @Ignore
    184181    public void testCreateAnnotation() throws SQLException, InstantiationException, IllegalAccessException, DatatypeConfigurationException, Exception {
    185182       
Note: See TracChangeset for help on using the changeset viewer.