Search in sources :

Example 1 with Ticket

use of org.irods.jargon.ticket.Ticket 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;
}
Also used : DataGridTicket(com.emc.metalnx.core.domain.entity.DataGridTicket) Ticket(org.irods.jargon.ticket.Ticket) JargonException(org.irods.jargon.core.exception.JargonException) DataGridTicket(com.emc.metalnx.core.domain.entity.DataGridTicket) DataGridTicketException(com.emc.metalnx.core.domain.exceptions.DataGridTicketException) TicketAdminService(org.irods.jargon.ticket.TicketAdminService)

Example 2 with Ticket

use of org.irods.jargon.ticket.Ticket 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;
}
Also used : TicketCreateModeEnum(org.irods.jargon.ticket.packinstr.TicketCreateModeEnum) DataGridTicket(com.emc.metalnx.core.domain.entity.DataGridTicket) Ticket(org.irods.jargon.ticket.Ticket)

Example 3 with Ticket

use of org.irods.jargon.ticket.Ticket in project metalnx-web by irods-contrib.

the class TestCreateTicketWithFilesLimit method testCreateTicketWithWriteFileLimit.

@Test
public void testCreateTicketWithWriteFileLimit() throws DataGridConnectionRefusedException, DataGridTicketException, JargonException {
    ticketString = ticketService.create(dgt);
    Ticket ticketWithFileLimit = ticketUtils.findTicket(ticketString);
    assertEquals(WRITE_FILE_LIMIT, ticketWithFileLimit.getWriteFileLimit());
    assertFalse(ticketWithFileLimit.getTicketString().isEmpty());
    assertTrue(ticketWithFileLimit.getIrodsAbsolutePath().equals(targetPath));
    assertTrue(ticketWithFileLimit.getOwnerName().equals(username));
}
Also used : DataGridTicket(com.emc.metalnx.core.domain.entity.DataGridTicket) Ticket(org.irods.jargon.ticket.Ticket) Test(org.junit.Test)

Example 4 with Ticket

use of org.irods.jargon.ticket.Ticket in project metalnx-web by irods-contrib.

the class TestCreateTicketWithUsesLimit method testCreateTicketWithExpirationDate.

@Test
public void testCreateTicketWithExpirationDate() throws DataGridConnectionRefusedException, DataGridTicketException, JargonException {
    ticketString = ticketService.create(dgt);
    Ticket ticketWithUses = ticketUtils.findTicket(ticketString);
    assertEquals(USES_LIMIT, ticketWithUses.getUsesLimit());
    assertFalse(ticketWithUses.getTicketString().isEmpty());
    assertTrue(ticketWithUses.getIrodsAbsolutePath().equals(targetPath));
    assertTrue(ticketWithUses.getOwnerName().equals(username));
}
Also used : DataGridTicket(com.emc.metalnx.core.domain.entity.DataGridTicket) Ticket(org.irods.jargon.ticket.Ticket) Test(org.junit.Test)

Example 5 with Ticket

use of org.irods.jargon.ticket.Ticket in project metalnx-web by irods-contrib.

the class TestCreateTicketWithByteLimit method testCreateTicketWithWriteByteLimit.

@Test
public void testCreateTicketWithWriteByteLimit() throws DataGridConnectionRefusedException, DataGridTicketException, JargonException {
    ticketString = ticketService.create(dgt);
    Ticket ticketWithByteLimit = ticketUtils.findTicket(ticketString);
    assertEquals(WRITE_BYTE_LIMIT, ticketWithByteLimit.getWriteByteLimit());
    assertFalse(ticketWithByteLimit.getTicketString().isEmpty());
    assertTrue(ticketWithByteLimit.getIrodsAbsolutePath().equals(targetPath));
    assertTrue(ticketWithByteLimit.getOwnerName().equals(username));
}
Also used : DataGridTicket(com.emc.metalnx.core.domain.entity.DataGridTicket) Ticket(org.irods.jargon.ticket.Ticket) Test(org.junit.Test)

Aggregations

DataGridTicket (com.emc.metalnx.core.domain.entity.DataGridTicket)8 Ticket (org.irods.jargon.ticket.Ticket)8 Test (org.junit.Test)4 JargonException (org.irods.jargon.core.exception.JargonException)3 TicketAdminService (org.irods.jargon.ticket.TicketAdminService)3 DataGridTicketException (com.emc.metalnx.core.domain.exceptions.DataGridTicketException)1 DataGridTicketNotFoundException (com.emc.metalnx.core.domain.exceptions.DataGridTicketNotFoundException)1 ArrayList (java.util.ArrayList)1 DataNotFoundException (org.irods.jargon.core.exception.DataNotFoundException)1 TicketCreateModeEnum (org.irods.jargon.ticket.packinstr.TicketCreateModeEnum)1