Skip to content

Commit

Permalink
O3-3002: Queue Module - REST endpoints can be accessed without authen…
Browse files Browse the repository at this point in the history
…tication.
  • Loading branch information
IamMujuziMoses committed Apr 4, 2024
1 parent aa52acb commit 4b47256
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,70 @@
import java.util.List;
import java.util.Optional;

import org.openmrs.annotation.Authorized;
import org.openmrs.api.APIException;
import org.openmrs.api.OpenmrsService;
import org.openmrs.module.queue.api.search.QueueRoomSearchCriteria;
import org.openmrs.module.queue.model.QueueRoom;
import org.openmrs.module.queue.utils.PrivilegeConstants;

public interface QueueRoomService {
public interface QueueRoomService extends OpenmrsService {

/**
* Gets a queue room given uuid.
*
* @param uuid uuid of the queue room to be returned.
* @return {@link org.openmrs.module.queue.model.QueueRoom}
*/
@Authorized({ PrivilegeConstants.GET_QUEUE_ROOMS })
Optional<QueueRoom> getQueueRoomByUuid(@NotNull String uuid);

/**
* Gets a queue room by id.
*
* @param id queueRoomId - the id of the queue room to retrieve.
* @return {@link org.openmrs.module.queue.model.QueueRoom}
*/
@Authorized({ PrivilegeConstants.GET_QUEUE_ROOMS })
Optional<QueueRoom> getQueueRoomById(@NotNull int id);

/**
* @return {@link List} of all queue rooms
*/
@Authorized({ PrivilegeConstants.GET_QUEUE_ROOMS })
List<QueueRoom> getAllQueueRooms();

/**
* Saves a queue room
*
* @param queueRoom the queue room to be saved
* @return saved {@link org.openmrs.module.queue.model.QueueRoom}
*/
@Authorized({ PrivilegeConstants.MANAGE_QUEUE_ROOMS })
QueueRoom saveQueueRoom(@NotNull QueueRoom queueRoom);

/**
* @return {@link List} of queue rooms that match the given
* {@link org.openmrs.module.queue.api.search.QueueRoomSearchCriteria}
*/
@Authorized({ PrivilegeConstants.GET_QUEUE_ROOMS })
List<QueueRoom> getQueueRooms(QueueRoomSearchCriteria searchCriteria);

/**
* Voids a queue room
*
* @param queueRoom the queue room to retire
* @param voidReason the reason for voiding the queue room
*/
@Authorized({ PrivilegeConstants.MANAGE_QUEUE_ROOMS })
void retireQueueRoom(@NotNull QueueRoom queueRoom, String voidReason);

/**
* Completely remove a queue room from the database
*
* @param queueRoom queue room to be deleted
* @throws org.openmrs.api.APIException
*/
@Authorized({ PrivilegeConstants.PURGE_QUEUE_ROOMS })
void purgeQueueRoom(@NotNull QueueRoom queueRoom) throws APIException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,71 @@
import java.util.List;
import java.util.Optional;

import org.openmrs.annotation.Authorized;
import org.openmrs.api.APIException;
import org.openmrs.api.OpenmrsService;
import org.openmrs.module.queue.api.search.RoomProviderMapSearchCriteria;
import org.openmrs.module.queue.model.RoomProviderMap;
import org.openmrs.module.queue.utils.PrivilegeConstants;

public interface RoomProviderMapService {
public interface RoomProviderMapService extends OpenmrsService {

/**
* Gets a room provider map given uuid.
*
* @param uuid uuid of the room provider map to be returned.
* @return {@link org.openmrs.module.queue.model.RoomProviderMap}
*/
@Authorized({ PrivilegeConstants.GET_ROOM_PROVIDER_MAPS })
Optional<RoomProviderMap> getRoomProviderMapByUuid(@NotNull String uuid);

/**
* Gets a room provider map by id.
*
* @param id roomProviderMapId - the id of the room provider map to retrieve.
* @return {@link org.openmrs.module.queue.model.RoomProviderMap}
*/
@Authorized({ PrivilegeConstants.GET_ROOM_PROVIDER_MAPS })
Optional<RoomProviderMap> getRoomProviderMapById(@NotNull int id);

/**
* Saves a room provider map
*
* @param roomProviderMap the room provider map to be saved
* @return saved {@link org.openmrs.module.queue.model.RoomProviderMap}
*/
@Authorized({ PrivilegeConstants.MANAGE_ROOM_PROVIDER_MAPS })
RoomProviderMap saveRoomProviderMap(@NotNull RoomProviderMap roomProviderMap);

/**
* @return {@link List} of all room provider maps
*/
@Authorized({ PrivilegeConstants.GET_ROOM_PROVIDER_MAPS })
List<RoomProviderMap> getAllRoomProviderMaps();

/**
* @return {@link List} of room provider maps that match the given
* {@link org.openmrs.module.queue.api.search.RoomProviderMapSearchCriteria}
*/
@Authorized({ PrivilegeConstants.GET_ROOM_PROVIDER_MAPS })
List<RoomProviderMap> getRoomProviderMaps(RoomProviderMapSearchCriteria searchCriteria);

/**
* Voids a room provider map
*
* @param roomProviderMap the room provider map to retire
* @param voidReason the reason for voiding the room provider map
*/
@Authorized({ PrivilegeConstants.MANAGE_ROOM_PROVIDER_MAPS })
void voidRoomProviderMap(@NotNull RoomProviderMap roomProviderMap, String voidReason);

/**
* Completely remove a room provider map from the database
*
* @param roomProviderMap room provider map to be deleted
* @throws org.openmrs.api.APIException
*/
@Authorized({ PrivilegeConstants.PURGE_ROOM_PROVIDER_MAPS })
void purgeRoomProviderMap(@NotNull RoomProviderMap roomProviderMap) throws APIException;

}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ public class PrivilegeConstants {
@AddOnStartup(description = "Able to get/view queue entries")
public static final String GET_QUEUE_ENTRIES = "Get Queue Entries";

@AddOnStartup(description = "Able to get/view queue rooms")
public static final String GET_QUEUE_ROOMS = "Get Queue Rooms";

@AddOnStartup(description = "Able to get/view room provider maps")
public static final String GET_ROOM_PROVIDER_MAPS = "Get Room Provider Maps";

// Delete Privilege Constants
@AddOnStartup(description = "Able to delete/retire queues")
public static final String DELETE_QUEUES = "Delete Queues";
Expand All @@ -45,8 +51,18 @@ public class PrivilegeConstants {
@AddOnStartup(description = "Able to add/edit/retire queue entries")
public static final String MANAGE_QUEUE_ENTRIES = "Manage Queue Entries";

@AddOnStartup(description = "Able to add/edit/retire queue rooms")
public static final String MANAGE_QUEUE_ROOMS = "Manage Queue Rooms";

@AddOnStartup(description = "Able to add/edit/retire room provider maps")
public static final String MANAGE_ROOM_PROVIDER_MAPS = "Manage Room Provider Maps";

// Purge Privilege Constants
public static final String PURGE_QUEUES = "Purge Queues";

public static final String PURGE_QUEUE_ENTRIES = "Purge Queue Entries";

public static final String PURGE_QUEUE_ROOMS = "Purge Queue Rooms";

public static final String PURGE_ROOM_PROVIDER_MAPS = "Purge Room Provider Maps";
}

0 comments on commit 4b47256

Please sign in to comment.