use of com.emc.metalnx.core.domain.entity.DataGridTicket in project metalnx-web by irods-contrib.
the class TicketServiceImpl method modify.
@Override
public DataGridTicket modify(DataGridTicket t) throws DataGridConnectionRefusedException, DataGridTicketException {
logger.info("Modify ticket");
if (t == null) {
logger.error("Null ticket provided.");
throw new DataGridTicketException("Null ticket instance");
}
if (t.getTicketString().isEmpty()) {
logger.error("Ticket with empty string provided.");
throw new DataGridTicketException("Ticket string missing");
}
String ticketString = t.getTicketString();
DataGridTicket dgTicket;
try {
updateHostRestrictions(t);
updateUserRestrictions(t);
updateGroupRestrictions(t);
TicketAdminService tas = irodsServices.getTicketAdminService();
Ticket ticketUpdated = tas.compareGivenTicketToActualAndUpdateAsNeeded(convertDataGridTicketToTicket(t));
dgTicket = convertTicketToDataGridTicket(ticketUpdated);
dgTicket.setHosts(tas.listAllHostRestrictionsForSpecifiedTicket(ticketString, OFFSET));
dgTicket.setUsers(tas.listAllUserRestrictionsForSpecifiedTicket(ticketString, OFFSET));
dgTicket.setGroups(tas.listAllGroupRestrictionsForSpecifiedTicket(ticketString, OFFSET));
} catch (JargonException e) {
logger.error("Could not modify ticket");
throw new DataGridTicketException(e.getMessage());
}
return dgTicket;
}
use of com.emc.metalnx.core.domain.entity.DataGridTicket in project metalnx-web by irods-contrib.
the class TicketServiceImpl method convertDataGridTicketToTicket.
private Ticket convertDataGridTicketToTicket(DataGridTicket dgTicket) {
Ticket ticket = new Ticket();
ticket.setTicketString(dgTicket.getTicketString());
ticket.setOwnerName(dgTicket.getOwner());
ticket.setIrodsAbsolutePath(dgTicket.getPath());
ticket.setTicketString(dgTicket.getTicketString());
ticket.setExpireTime(dgTicket.getExpirationDate());
ticket.setUsesLimit(dgTicket.getUsesLimit());
ticket.setUsesCount(dgTicket.getUsesCount());
ticket.setWriteByteLimit(dgTicket.getWriteByteLimit());
ticket.setWriteByteCount(dgTicket.getWriteByteCount());
ticket.setWriteFileLimit(dgTicket.getWriteFileLimit());
ticket.setWriteFileCount(dgTicket.getWriteFileCount());
TicketCreateModeEnum ticketMode;
if (dgTicket.getType() == DataGridTicket.TicketType.READ)
ticketMode = TicketCreateModeEnum.READ;
else if (dgTicket.getType() == DataGridTicket.TicketType.WRITE)
ticketMode = TicketCreateModeEnum.WRITE;
else
ticketMode = TicketCreateModeEnum.UNKNOWN;
ticket.setType(ticketMode);
if (dgTicket.isCollection())
ticket.setObjectType(Ticket.TicketObjectType.COLLECTION);
return ticket;
}
use of com.emc.metalnx.core.domain.entity.DataGridTicket in project metalnx-web by irods-contrib.
the class TicketServiceImpl method convertTicketToDataGridTicket.
private DataGridTicket convertTicketToDataGridTicket(Ticket t) {
DataGridTicket dgTicket = new DataGridTicket();
dgTicket.setTicketString(t.getTicketString());
dgTicket.setOwner(t.getOwnerName());
dgTicket.setPath(t.getIrodsAbsolutePath());
dgTicket.setTicketString(t.getTicketString());
dgTicket.setExpirationDate(t.getExpireTime());
dgTicket.setUsesLimit(t.getUsesLimit());
dgTicket.setUsesCount(t.getUsesCount());
dgTicket.setWriteByteLimit(t.getWriteByteLimit());
dgTicket.setWriteByteCount(t.getWriteByteCount());
dgTicket.setWriteFileLimit(t.getWriteFileLimit());
dgTicket.setWriteFileCount(t.getWriteFileCount());
DataGridTicket.TicketType dgTicketType;
if (t.getType() == TicketCreateModeEnum.READ) {
dgTicketType = DataGridTicket.TicketType.READ;
} else if (t.getType() == TicketCreateModeEnum.WRITE) {
dgTicketType = DataGridTicket.TicketType.WRITE;
} else {
dgTicketType = DataGridTicket.TicketType.UNKNOWN;
}
dgTicket.setType(dgTicketType);
if (t.getObjectType() == Ticket.TicketObjectType.COLLECTION)
dgTicket.setIsCollection(true);
return dgTicket;
}
use of com.emc.metalnx.core.domain.entity.DataGridTicket in project metalnx-web by irods-contrib.
the class HostInfo method findAll.
/**
* Finds all tickets in the grid.
*
* @return List of tickets in JSON
* @throws DataGridConnectionRefusedException
* if Metalnx cannot connect to the grid
* @throws UnsupportedDataGridFeatureException
*/
@RequestMapping(value = "/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public String findAll() throws DataGridConnectionRefusedException, JsonProcessingException, UnsupportedDataGridFeatureException {
logger.info("Find all tickets");
if (!configService.getGlobalConfig().isTicketsEnabled()) {
logger.error("tickets are not enabled");
throw new UnsupportedDataGridFeatureException("tickets disabled");
}
List<DataGridTicket> tickets = ticketService.findAll();
Map<String, Object> ticketsAsJSON = new HashMap<>();
ticketsAsJSON.put("data", tickets);
return new ObjectMapper().writeValueAsString(ticketsAsJSON);
}
use of com.emc.metalnx.core.domain.entity.DataGridTicket in project metalnx-web by irods-contrib.
the class HostInfo method find.
/**
* Finds a specific ticket in the grid by its id or string
*
* @param ticketId
* ticket id or string
* @return Ticket as JSON
* @throws DataGridConnectionRefusedException
* if Metalnx cannot connect to the grid
* @throws UnsupportedDataGridFeatureException
*/
@RequestMapping(value = "/{ticketid}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public ResponseEntity<DataGridTicket> find(@PathVariable("ticketid") final String ticketId) throws DataGridConnectionRefusedException, DataGridTicketNotFoundException, UnsupportedDataGridFeatureException {
logger.info("Find ticket by its ID or String");
if (!configService.getGlobalConfig().isTicketsEnabled()) {
logger.error("tickets are not enabled");
throw new UnsupportedDataGridFeatureException("tickets disabled");
}
DataGridTicket dgTicket = ticketService.find(ticketId);
return new ResponseEntity<>(dgTicket, HttpStatus.OK);
}
Aggregations