1
package org.hisp.dhis.dashboard.action;
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;
10
import com.opensymphony.xwork.Action;
13
* Copyright (c) 2004-2007, University of Oslo
14
* All rights reserved.
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.
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.
40
* @author Lars Helge Overland
43
public class RemoveOlapUrlAction
46
// -------------------------------------------------------------------------
48
// -------------------------------------------------------------------------
50
private CurrentUserService currentUserService;
52
public void setCurrentUserService( CurrentUserService currentUserService )
54
this.currentUserService = currentUserService;
57
private UserStore userStore;
59
public void setUserStore( UserStore userStore )
61
this.userStore = userStore;
64
private OlapURLService olapURLService;
66
public void setOlapURLService( OlapURLService olapURLService )
68
this.olapURLService = olapURLService;
72
// -------------------------------------------------------------------------
74
// -------------------------------------------------------------------------
78
public void setId( Integer id )
83
// -------------------------------------------------------------------------
84
// Action implementation
85
// -------------------------------------------------------------------------
87
public String execute()
89
User user = currentUserService.getCurrentUser();
93
UserCredentials credentials = userStore.getUserCredentials( user );
95
OlapURL url = olapURLService.getOlapURL( id );
97
if ( credentials.getDashboardOlapUrls().remove( url ) )
99
userStore.updateUserCredentials( credentials );