-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor EntityPermissions and AuthorizationService
- Loading branch information
Showing
12 changed files
with
214 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 80 additions & 12 deletions
92
src/main/java/org/rutebanken/tiamat/model/authorization/EntityPermissions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,93 @@ | ||
package org.rutebanken.tiamat.model.authorization; | ||
|
||
import org.rutebanken.tiamat.diff.generic.StopPlaceTypeSubmodeEnumuration; | ||
import org.rutebanken.tiamat.diff.generic.SubmodeEnumuration; | ||
import org.rutebanken.tiamat.model.StopTypeEnumeration; | ||
|
||
import java.util.Collections; | ||
import java.util.Set; | ||
|
||
public class EntityPermissions { | ||
private final Set<StopPlaceTypeSubmodeEnumuration> allowedStopPlaceTypes; | ||
private final Set<StopPlaceTypeSubmodeEnumuration> bannedStopPlaceTypes; | ||
private final Set<StopPlaceTypeSubmodeEnumuration> allowedSubmodes; | ||
private final Set<StopPlaceTypeSubmodeEnumuration> bannedSubmodes; | ||
private final Set<StopTypeEnumeration> allowedStopPlaceTypes; | ||
private final Set<StopTypeEnumeration> bannedStopPlaceTypes; | ||
private final Set<SubmodeEnumuration> allowedSubmodes; | ||
private final Set<SubmodeEnumuration> bannedSubmodes; | ||
private boolean canEdit; | ||
private boolean canDelete; | ||
|
||
public EntityPermissions(boolean canEdit, boolean canDelete, Set<StopPlaceTypeSubmodeEnumuration> allowedStopPlaceTypes, Set<StopPlaceTypeSubmodeEnumuration> bannedStopPlaceTypes, Set<StopPlaceTypeSubmodeEnumuration> allowedSubmodes, Set<StopPlaceTypeSubmodeEnumuration> bannedSubmodes) { | ||
this.canEdit = canEdit; | ||
this.canDelete = canDelete; | ||
this.allowedStopPlaceTypes = allowedStopPlaceTypes == null ? Collections.emptySet() : allowedStopPlaceTypes; | ||
this.bannedStopPlaceTypes = bannedStopPlaceTypes == null ? Collections.emptySet() : bannedStopPlaceTypes; | ||
this.allowedSubmodes = allowedSubmodes == null ? Collections.emptySet() : allowedSubmodes; | ||
this.bannedSubmodes = bannedSubmodes == null ? Collections.emptySet() : bannedSubmodes; | ||
private EntityPermissions(Builder builder) { | ||
this.canEdit = builder.canEdit; | ||
this.canDelete = builder.canDelete; | ||
this.allowedStopPlaceTypes = builder.allowedStopPlaceTypes == null ? Collections.emptySet() : builder.allowedStopPlaceTypes; | ||
this.bannedStopPlaceTypes = builder.bannedStopPlaceTypes == null ? Collections.emptySet() : builder.bannedStopPlaceTypes; | ||
this.allowedSubmodes = builder.allowedSubmodes == null ? Collections.emptySet() : builder.allowedSubmodes; | ||
this.bannedSubmodes = builder.bannedSubmodes == null ? Collections.emptySet() : builder.bannedSubmodes; | ||
} | ||
|
||
public static class Builder { | ||
private Set<StopTypeEnumeration> allowedStopPlaceTypes; | ||
private Set<StopTypeEnumeration> bannedStopPlaceTypes; | ||
private Set<SubmodeEnumuration> allowedSubmodes; | ||
private Set<SubmodeEnumuration> bannedSubmodes; | ||
private boolean canEdit; | ||
private boolean canDelete; | ||
|
||
public Builder canEdit(boolean canEdit) { | ||
this.canEdit = canEdit; | ||
return this; | ||
} | ||
|
||
public Builder canDelete(boolean canDelete) { | ||
this.canDelete = canDelete; | ||
return this; | ||
} | ||
|
||
public Builder allowedStopPlaceTypes(Set<StopTypeEnumeration> allowedStopPlaceTypes) { | ||
this.allowedStopPlaceTypes = allowedStopPlaceTypes; | ||
return this; | ||
} | ||
|
||
public Builder bannedStopPlaceTypes(Set<StopTypeEnumeration> bannedStopPlaceTypes) { | ||
this.bannedStopPlaceTypes = bannedStopPlaceTypes; | ||
return this; | ||
} | ||
|
||
public Builder allowedSubmodes(Set<SubmodeEnumuration> allowedSubmodes) { | ||
this.allowedSubmodes = allowedSubmodes; | ||
return this; | ||
} | ||
|
||
public Builder bannedSubmodes(Set<SubmodeEnumuration> bannedSubmodes) { | ||
this.bannedSubmodes = bannedSubmodes; | ||
return this; | ||
} | ||
|
||
public EntityPermissions build() { | ||
return new EntityPermissions(this); | ||
} | ||
} | ||
|
||
public Set<StopTypeEnumeration> getAllowedStopPlaceTypes() { | ||
return allowedStopPlaceTypes; | ||
} | ||
|
||
public Set<StopTypeEnumeration> getBannedStopPlaceTypes() { | ||
return bannedStopPlaceTypes; | ||
} | ||
|
||
public Set<SubmodeEnumuration> getAllowedSubmodes() { | ||
return allowedSubmodes; | ||
} | ||
|
||
public Set<SubmodeEnumuration> getBannedSubmodes() { | ||
return bannedSubmodes; | ||
} | ||
|
||
public boolean isCanEdit() { | ||
return canEdit; | ||
} | ||
|
||
public boolean isCanDelete() { | ||
return canDelete; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.