~mortenoh/+junk/dhis2-detailed-import-export

« back to all changes in this revision

Viewing changes to dhis-2/dhis-web/dhis-web-dashboard-integration/src/main/java/org/hisp/dhis/dashboard/action/RemoveOlapUrlAction.java

  • Committer: larshelge at gmail
  • Date: 2009-03-03 16:46:36 UTC
  • Revision ID: larshelge@gmail.com-20090303164636-2sjlrquo7ib1gf7r
Initial check-in

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package org.hisp.dhis.dashboard.action;
 
2
 
 
3
import org.hisp.dhis.olap.OlapURL;
 
4
import org.hisp.dhis.olap.OlapURLService;
 
5
import org.hisp.dhis.user.CurrentUserService;
 
6
import org.hisp.dhis.user.User;
 
7
import org.hisp.dhis.user.UserCredentials;
 
8
import org.hisp.dhis.user.UserStore;
 
9
 
 
10
import com.opensymphony.xwork.Action;
 
11
 
 
12
/*
 
13
 * Copyright (c) 2004-2007, University of Oslo
 
14
 * All rights reserved.
 
15
 *
 
16
 * Redistribution and use in source and binary forms, with or without
 
17
 * modification, are permitted provided that the following conditions are met:
 
18
 * * Redistributions of source code must retain the above copyright notice, this
 
19
 *   list of conditions and the following disclaimer.
 
20
 * * Redistributions in binary form must reproduce the above copyright notice,
 
21
 *   this list of conditions and the following disclaimer in the documentation
 
22
 *   and/or other materials provided with the distribution.
 
23
 * * Neither the name of the HISP project nor the names of its contributors may
 
24
 *   be used to endorse or promote products derived from this software without
 
25
 *   specific prior written permission.
 
26
 *
 
27
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 
28
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 
29
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 
30
 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
 
31
 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 
32
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 
33
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
 
34
 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 
35
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 
36
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
37
 */
 
38
 
 
39
/**
 
40
 * @author Lars Helge Overland
 
41
 * @version $Id$
 
42
 */
 
43
public class RemoveOlapUrlAction
 
44
implements Action
 
45
{
 
46
    // -------------------------------------------------------------------------
 
47
    // Dependencies
 
48
    // -------------------------------------------------------------------------
 
49
    
 
50
    private CurrentUserService currentUserService;
 
51
    
 
52
    public void setCurrentUserService( CurrentUserService currentUserService )
 
53
    {
 
54
        this.currentUserService = currentUserService;
 
55
    }
 
56
    
 
57
    private UserStore userStore;
 
58
    
 
59
    public void setUserStore( UserStore userStore )
 
60
    {
 
61
        this.userStore = userStore;
 
62
    }
 
63
    
 
64
    private OlapURLService olapURLService;
 
65
 
 
66
    public void setOlapURLService( OlapURLService olapURLService )
 
67
    {
 
68
        this.olapURLService = olapURLService;
 
69
    }
 
70
    
 
71
 
 
72
    // -------------------------------------------------------------------------
 
73
    // Input
 
74
    // -------------------------------------------------------------------------
 
75
 
 
76
    private Integer id;
 
77
 
 
78
    public void setId( Integer id )
 
79
    {
 
80
        this.id = id;
 
81
    }
 
82
    
 
83
    // -------------------------------------------------------------------------
 
84
    // Action implementation
 
85
    // -------------------------------------------------------------------------
 
86
 
 
87
    public String execute()
 
88
    {
 
89
        User user = currentUserService.getCurrentUser();
 
90
        
 
91
        if ( user != null )
 
92
        {
 
93
            UserCredentials credentials = userStore.getUserCredentials( user );
 
94
            
 
95
            OlapURL url = olapURLService.getOlapURL( id );
 
96
            
 
97
            if ( credentials.getDashboardOlapUrls().remove( url ) )
 
98
            {
 
99
                userStore.updateUserCredentials( credentials );
 
100
            }
 
101
        }
 
102
        
 
103
        return SUCCESS;
 
104
    }
 
105
}