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 11, 2024
1 parent aa52acb commit df181af
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@
import org.openmrs.VisitAttributeType;
import org.openmrs.annotation.Authorized;
import org.openmrs.api.APIException;
import org.openmrs.api.OpenmrsService;
import org.openmrs.module.queue.api.search.QueueEntrySearchCriteria;
import org.openmrs.module.queue.api.sort.SortWeightGenerator;
import org.openmrs.module.queue.model.Queue;
import org.openmrs.module.queue.model.QueueEntry;
import org.openmrs.module.queue.model.QueueEntryTransition;
import org.openmrs.module.queue.utils.PrivilegeConstants;

public interface QueueEntryService extends OpenmrsService {
public interface QueueEntryService {

/**
* Gets a queue entry given uuid.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,69 @@
import java.util.List;
import java.util.Optional;

import org.openmrs.annotation.Authorized;
import org.openmrs.api.APIException;
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 {

/**
* 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 @@ -16,15 +16,14 @@

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

/**
* This interface defines methods for Queue objects
*/
public interface QueueService extends OpenmrsService {
public interface QueueService {

/**
* Gets a queue given UUID.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,70 @@
import java.util.List;
import java.util.Optional;

import org.openmrs.annotation.Authorized;
import org.openmrs.api.APIException;
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 {

/**
* 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 @@ -22,31 +22,41 @@
@HasAddOnStartupPrivileges
public class PrivilegeConstants {

// Add Privilege Constants
@AddOnStartup(description = "Able to add/save queues")
public static final String ADD_QUEUES = "Add Queues";

// Get Privilege Constants
@AddOnStartup(description = "Able to get/view queues")
public static final String GET_QUEUES = "Get Queues";

@AddOnStartup(description = "Able to get/view queue entries")
public static final String GET_QUEUE_ENTRIES = "Get Queue Entries";

// Delete Privilege Constants
@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";

@AddOnStartup(description = "Able to delete/retire queues")
public static final String DELETE_QUEUES = "Delete Queues";

// Edit Privilege Constants
@AddOnStartup(description = "Able to edit queues")
public static final String EDIT_QUEUES = "Edit Queues";

// Manage Privilege Constants
@AddOnStartup(description = "Able to add/edit/retire queue entries")
public static final String MANAGE_QUEUE_ENTRIES = "Manage Queue Entries";

// Purge Privilege Constants
@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";

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 df181af

Please sign in to comment.