Search in sources :

Example 16 with DataGridTicket

use of com.emc.metalnx.core.domain.entity.DataGridTicket in project metalnx-web by irods-contrib.

the class TestModifyTicket method testModifyTicketUsesLimit.

@Test
public void testModifyTicketUsesLimit() throws DataGridConnectionRefusedException, DataGridTicketException {
    int newUsesLimit = USES_LIMIT + 1;
    DataGridTicket dgt = new DataGridTicket(targetPath);
    dgt.setTicketString(ticketString);
    dgt.setUsesLimit(newUsesLimit);
    DataGridTicket ticketModified = ticketService.modify(dgt);
    assertEquals(newUsesLimit, ticketModified.getUsesLimit());
    assertFalse(ticketModified.getTicketString().isEmpty());
    assertTrue(ticketModified.getPath().equals(targetPath));
    assertTrue(ticketModified.getOwner().equals(username));
}
Also used : DataGridTicket(com.emc.metalnx.core.domain.entity.DataGridTicket) Test(org.junit.Test)

Example 17 with DataGridTicket

use of com.emc.metalnx.core.domain.entity.DataGridTicket in project metalnx-web by irods-contrib.

the class TestModifyTicket method testModifyTicketHosts.

@Test
public void testModifyTicketHosts() throws DataGridConnectionRefusedException, DataGridTicketException {
    DataGridTicket dgt = new DataGridTicket(targetPath);
    dgt.setTicketString(ticketString);
    dgt.addHost(host);
    DataGridTicket ticketModified = ticketService.modify(dgt);
    assertEquals(1, ticketModified.getHosts().size());
    assertFalse(ticketModified.getTicketString().isEmpty());
    assertTrue(ticketModified.getPath().equals(targetPath));
    assertTrue(ticketModified.getOwner().equals(username));
}
Also used : DataGridTicket(com.emc.metalnx.core.domain.entity.DataGridTicket) Test(org.junit.Test)

Example 18 with DataGridTicket

use of com.emc.metalnx.core.domain.entity.DataGridTicket in project metalnx-web by irods-contrib.

the class TestModifyTicket method testModifyTicketExpireDate.

@Test
public void testModifyTicketExpireDate() throws DataGridConnectionRefusedException, DataGridTicketException {
    Date date = new Date();
    DataGridTicket dgt = new DataGridTicket(targetPath);
    dgt.setTicketString(ticketString);
    dgt.setExpirationDate(date);
    DataGridTicket dgtModified = ticketService.modify(dgt);
    String currDate = dateFormat.format(date);
    String ticketModifiedDate = dateFormat.format(dgtModified.getExpirationDate());
    assertEquals(currDate, ticketModifiedDate);
    assertFalse(dgtModified.getTicketString().isEmpty());
    assertTrue(dgtModified.getPath().equals(targetPath));
    assertTrue(dgtModified.getOwner().equals(username));
}
Also used : DataGridTicket(com.emc.metalnx.core.domain.entity.DataGridTicket) Date(java.util.Date) Test(org.junit.Test)

Example 19 with DataGridTicket

use of com.emc.metalnx.core.domain.entity.DataGridTicket in project metalnx-web by irods-contrib.

the class HostInfo method createTicketForm.

@RequestMapping(value = "/ticketForm", method = RequestMethod.GET)
public String createTicketForm(final Model model, @RequestParam(value = "ticketstring", required = false) final String ticketString) throws DataGridConnectionRefusedException, DataGridTicketNotFoundException, UnsupportedDataGridFeatureException {
    if (!configService.getGlobalConfig().isTicketsEnabled()) {
        logger.error("tickets are not enabled");
        throw new UnsupportedDataGridFeatureException("tickets disabled");
    }
    DataGridTicket ticket;
    if (ticketString != null && !ticketString.isEmpty()) {
        ticket = ticketService.find(ticketString);
    } else {
        ticket = new DataGridTicket();
    }
    model.addAttribute("ticket", ticket);
    model.addAttribute("requestMapping", "tickets/");
    return "tickets/ticketForm";
}
Also used : UnsupportedDataGridFeatureException(com.emc.metalnx.core.domain.exceptions.UnsupportedDataGridFeatureException) DataGridTicket(com.emc.metalnx.core.domain.entity.DataGridTicket) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 20 with DataGridTicket

use of com.emc.metalnx.core.domain.entity.DataGridTicket in project metalnx-web by irods-contrib.

the class TicketServiceImpl method find.

@Override
public DataGridTicket find(String ticketId) throws DataGridConnectionRefusedException, DataGridTicketNotFoundException {
    logger.info("Find ticket {}", ticketId);
    DataGridTicket dgTicket = null;
    TicketAdminService tas = irodsServices.getTicketAdminService();
    try {
        Ticket t = tas.getTicketForSpecifiedTicketString(ticketId);
        dgTicket = convertTicketToDataGridTicket(t);
        dgTicket.setHosts(tas.listAllHostRestrictionsForSpecifiedTicket(ticketId, OFFSET));
        dgTicket.setUsers(tas.listAllUserRestrictionsForSpecifiedTicket(ticketId, OFFSET));
        dgTicket.setGroups(tas.listAllGroupRestrictionsForSpecifiedTicket(ticketId, OFFSET));
    } catch (DataNotFoundException e) {
        throw new DataGridTicketNotFoundException("Ticket does not exist");
    } catch (JargonException e) {
        logger.error("Could not find ticket with string: {}", ticketId);
    }
    return dgTicket;
}
Also used : DataGridTicket(com.emc.metalnx.core.domain.entity.DataGridTicket) Ticket(org.irods.jargon.ticket.Ticket) DataNotFoundException(org.irods.jargon.core.exception.DataNotFoundException) JargonException(org.irods.jargon.core.exception.JargonException) DataGridTicket(com.emc.metalnx.core.domain.entity.DataGridTicket) DataGridTicketNotFoundException(com.emc.metalnx.core.domain.exceptions.DataGridTicketNotFoundException) TicketAdminService(org.irods.jargon.ticket.TicketAdminService)

Aggregations

DataGridTicket (com.emc.metalnx.core.domain.entity.DataGridTicket)25 Test (org.junit.Test)10 Before (org.junit.Before)7 Ticket (org.irods.jargon.ticket.Ticket)4 UnsupportedDataGridFeatureException (com.emc.metalnx.core.domain.exceptions.UnsupportedDataGridFeatureException)3 JargonException (org.irods.jargon.core.exception.JargonException)3 TicketAdminService (org.irods.jargon.ticket.TicketAdminService)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 Date (java.util.Date)2 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)2 DataGridTicketException (com.emc.metalnx.core.domain.exceptions.DataGridTicketException)1 DataGridTicketNotFoundException (com.emc.metalnx.core.domain.exceptions.DataGridTicketNotFoundException)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 DataNotFoundException (org.irods.jargon.core.exception.DataNotFoundException)1 TicketCreateModeEnum (org.irods.jargon.ticket.packinstr.TicketCreateModeEnum)1 ResponseEntity (org.springframework.http.ResponseEntity)1