Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
Juhtimislauad back
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Statistikaamet
Juhtimislauad back
Commits
efca98c7
Commit
efca98c7
authored
Nov 08, 2019
by
oleg.pahhomov
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SA0140-537 | remove user check from find user widget
parent
3b5ddc53
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
10 deletions
+6
-10
src/main/java/ee/stat/dashboard/repository/custom/DashboardWidgetCustomRepository.java
...rd/repository/custom/DashboardWidgetCustomRepository.java
+1
-0
src/main/java/ee/stat/dashboard/service/widget/widget/WidgetFinder.java
...ee/stat/dashboard/service/widget/widget/WidgetFinder.java
+4
-9
src/main/java/ee/stat/dashboard/service/widget/widget/WidgetService.java
...e/stat/dashboard/service/widget/widget/WidgetService.java
+1
-1
No files found.
src/main/java/ee/stat/dashboard/repository/custom/DashboardWidgetCustomRepository.java
View file @
efca98c7
...
@@ -5,4 +5,5 @@ public interface DashboardWidgetCustomRepository {
...
@@ -5,4 +5,5 @@ public interface DashboardWidgetCustomRepository {
boolean
existsByAppUserWidget
(
Long
appUser
,
Long
widget
);
boolean
existsByAppUserWidget
(
Long
appUser
,
Long
widget
);
boolean
existsByAppUserAndDashboardAndWidget
(
Long
appUser
,
Long
dashboard
,
Long
widget
);
boolean
existsByAppUserAndDashboardAndWidget
(
Long
appUser
,
Long
dashboard
,
Long
widget
);
}
}
src/main/java/ee/stat/dashboard/service/widget/widget/WidgetFinder.java
View file @
efca98c7
package
ee.stat.dashboard.service.widget.widget
;
package
ee.stat.dashboard.service.widget.widget
;
import
ee.stat.dashboard.config.security.StatUser
;
import
ee.stat.dashboard.model.dashboard.Dashboard
;
import
ee.stat.dashboard.model.dashboard.Dashboard
;
import
ee.stat.dashboard.model.widget.back.Widget
;
import
ee.stat.dashboard.model.widget.back.Widget
;
import
ee.stat.dashboard.repository.DashboardWidgetRepository
;
import
ee.stat.dashboard.repository.DashboardWidgetRepository
;
import
ee.stat.dashboard.repository.WidgetRepository
;
import
ee.stat.dashboard.repository.WidgetRepository
;
import
ee.stat.dashboard.service.dashboard.DashboardFinder
;
import
ee.stat.dashboard.service.dashboard.DashboardFinder
;
import
ee.stat.dashboard.service.dashboard.DashboardServiceCache
;
import
ee.stat.dashboard.util.StatBadRequestException
;
import
ee.stat.dashboard.util.StatBadRequestException
;
import
ee.stat.dashboard.util.StatNotFoundRequestException
;
import
ee.stat.dashboard.util.StatNotFoundRequestException
;
import
lombok.AllArgsConstructor
;
import
lombok.AllArgsConstructor
;
...
@@ -36,12 +34,12 @@ public class WidgetFinder {
...
@@ -36,12 +34,12 @@ public class WidgetFinder {
return
widgetRepository
.
findById
(
id
).
orElseThrow
(()->
new
StatBadRequestException
(
widget_is_not_existing
));
return
widgetRepository
.
findById
(
id
).
orElseThrow
(()->
new
StatBadRequestException
(
widget_is_not_existing
));
}
}
public
Widget
findWidget
(
Long
id
,
Long
dashboardId
,
StatUser
user
)
{
public
Widget
findWidget
(
Long
id
,
Long
dashboardId
)
{
Dashboard
dashboard
=
dashboardFinder
.
findById
(
dashboardId
);
Dashboard
dashboard
=
dashboardFinder
.
findById
(
dashboardId
);
if
(
dashboard
.
getUserType
().
isAdmin
())
{
if
(
dashboard
.
getUserType
().
isAdmin
())
{
existsAdminWidget
(
id
,
dashboardId
);
existsAdminWidget
(
id
,
dashboardId
);
}
else
{
}
else
{
existsUserWidget
(
id
,
dashboardId
,
user
);
existsUserWidget
(
id
,
dashboardId
);
}
}
Widget
widget
=
findWidgetByIdFromCache
(
id
);
Widget
widget
=
findWidgetByIdFromCache
(
id
);
mustBeVisible
(
widget
);
mustBeVisible
(
widget
);
...
@@ -52,11 +50,8 @@ public class WidgetFinder {
...
@@ -52,11 +50,8 @@ public class WidgetFinder {
return
widgetServiceCache
.
findById
(
id
).
orElseThrow
(()
->
new
StatBadRequestException
(
widget_is_not_existing
));
return
widgetServiceCache
.
findById
(
id
).
orElseThrow
(()
->
new
StatBadRequestException
(
widget_is_not_existing
));
}
}
private
void
existsUserWidget
(
Long
widgetId
,
Long
dashboardId
,
StatUser
user
)
{
private
void
existsUserWidget
(
Long
widgetId
,
Long
dashboardId
)
{
if
(
user
==
null
)
{
if
(!
dashboardWidgetRepository
.
existsByDashboardAndWidget
(
dashboardId
,
widgetId
))
{
throw
new
StatNotFoundRequestException
(
my_dashboard_must_have_user
);
}
if
(!
dashboardWidgetRepository
.
existsByAppUserAndDashboardAndWidget
(
user
.
getId
(),
dashboardId
,
widgetId
))
{
throw
new
StatNotFoundRequestException
(
my_dashboard_does_not_exist
);
throw
new
StatNotFoundRequestException
(
my_dashboard_does_not_exist
);
}
}
}
}
...
...
src/main/java/ee/stat/dashboard/service/widget/widget/WidgetService.java
View file @
efca98c7
...
@@ -52,7 +52,7 @@ public class WidgetService {
...
@@ -52,7 +52,7 @@ public class WidgetService {
public
WidgetResponse
findById
(
Long
id
,
Long
dashboardId
,
Long
ehakId
,
Language
lang
,
String
graphType
,
public
WidgetResponse
findById
(
Long
id
,
Long
dashboardId
,
Long
ehakId
,
Language
lang
,
String
graphType
,
StatUser
user
,
Map
<
String
,
String
>
params
,
FilterType
filterType
)
{
StatUser
user
,
Map
<
String
,
String
>
params
,
FilterType
filterType
)
{
Widget
widget
=
widgetFinder
.
findWidget
(
id
,
dashboardId
,
user
);
Widget
widget
=
widgetFinder
.
findWidget
(
id
,
dashboardId
);
return
mapWidget
(
widget
,
dashboardId
,
ehakId
,
lang
,
graphType
,
user
,
params
,
filterType
);
return
mapWidget
(
widget
,
dashboardId
,
ehakId
,
lang
,
graphType
,
user
,
params
,
filterType
);
}
}
...
...
Andrus Aru
@andrusaru
mentioned in commit
4e5314cc
·
Nov 08, 2019
mentioned in commit
4e5314cc
mentioned in commit 4e5314cc7d06e48d2c482ab0d72e77533203dc0e
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment