Skip to content

Commit

Permalink
#400 version-sensitive addition of condinput
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-conway committed Jan 25, 2022
1 parent fd3abaf commit 08fa6ca
Show file tree
Hide file tree
Showing 5 changed files with 360 additions and 29 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,13 @@ Added unit test to verify IRODSFile and DataObject dates agree as part of explai
#### Temporarily calm unit tests for tickets until resolved #376

Temporarily turned off certain ticket unit tests that are failing for follow up in a maintenance release

#### fixed StringIndexOutOfBoundsException and allowed quota values to be 0 #395

A pull request from Shane-Park to address string out of bounds exceptions

#### Errors in ticket modification when date is set to 'none' or blank #401

This appears to be a new error in iRODS, setting an expires date from a non-blank value to a blank value. The unit test failures have been quieted for this release and a follow up will be done with iRODS developers to discern whether this is a server regression.


Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,22 @@ public boolean isSupportsSpecificQuery() {
return supports;
}

/**
* Is this server after 4.2.11, when cond input was added to the ticket admin
* packing instruction?
*
* @return {@code true} if server requires cond input in the ticket admin
* packing instruction
*/
public boolean isTicketAdminCondInput() {
boolean supports = false;

if (isTheIrodsServerAtLeastAtTheGivenReleaseVersion("rods4.2.11")) {
supports = true;
}
return supports;
}

/**
* Does the server (based on version) support composable resources
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.irods.jargon.core.packinstr.Tag;
import org.irods.jargon.core.protovalues.ErrorEnum;
import org.irods.jargon.core.pub.CollectionAO;
import org.irods.jargon.core.pub.EnvironmentalInfoAO;
import org.irods.jargon.core.pub.IRODSAccessObjectFactory;
import org.irods.jargon.core.pub.IRODSGenQueryExecutor;
import org.irods.jargon.core.pub.ProtocolExtensionPoint;
Expand All @@ -30,7 +31,9 @@
import org.irods.jargon.core.utils.IRODSDataConversionUtil;
import org.irods.jargon.ticket.Ticket.TicketObjectType;
import org.irods.jargon.ticket.packinstr.TicketAdminInp;
import org.irods.jargon.ticket.packinstr.TicketAdminInpNoCondInp;
import org.irods.jargon.ticket.packinstr.TicketCreateModeEnum;
import org.irods.jargon.ticket.packinstr.TicketInp;
import org.irods.jargon.ticket.packinstr.TicketModifyAddOrRemoveTypeEnum;
import org.irods.jargon.ticket.utils.TicketRandomString;
import org.slf4j.Logger;
Expand All @@ -44,6 +47,7 @@ public final class TicketAdminServiceImpl extends AbstractTicketService implemen
private static final String ERROR_IN_TICKET_QUERY = "error in ticket query";
private static final String TICKET_NOT_FOUND = "IRODS ticket not found";
public static final Logger log = LoggerFactory.getLogger(TicketAdminServiceImpl.class);
private final EnvironmentalInfoAO environmentalInfAO;

/**
* Default constructor takes the objects necessary to communicate with iRODS via
Expand All @@ -59,6 +63,7 @@ public final class TicketAdminServiceImpl extends AbstractTicketService implemen
throws JargonException {
this.irodsAccessObjectFactory = irodsAccessObjectFactory;
this.irodsAccount = irodsAccount;
this.environmentalInfAO = irodsAccessObjectFactory.getEnvironmentalInfoAO(irodsAccount);
}

/*
Expand Down Expand Up @@ -215,7 +220,12 @@ public String createTicket(final TicketCreateModeEnum mode, final IRODSFile file

}

TicketAdminInp ticketPI = TicketAdminInp.instanceForCreate(mode, file.getAbsolutePath(), myTicketId);
TicketInp ticketPI = null;
if (this.environmentalInfAO.getIRODSServerProperties().isTicketAdminCondInput()) {
ticketPI = TicketAdminInp.instanceForCreate(mode, file.getAbsolutePath(), myTicketId);
} else {
ticketPI = TicketAdminInpNoCondInp.instanceForCreate(mode, file.getAbsolutePath(), myTicketId);
}

ProtocolExtensionPoint pep = irodsAccessObjectFactory.getProtocolExtensionPoint(irodsAccount);
Tag ticketOperationResponse = pep.irodsFunction(ticketPI);
Expand Down Expand Up @@ -243,8 +253,12 @@ public boolean deleteTicket(final String ticketId) throws JargonException {

log.info("deleting ticket id/string:{}", ticketId);

TicketAdminInp ticketPI = TicketAdminInp.instanceForDelete(ticketId);
log.info(EXECUTING_TICKET_PI);
TicketInp ticketPI = null;
if (this.environmentalInfAO.getIRODSServerProperties().isTicketAdminCondInput()) {
ticketPI = TicketAdminInp.instanceForDelete(ticketId);
} else {
ticketPI = TicketAdminInpNoCondInp.instanceForDelete(ticketId);
}

ProtocolExtensionPoint pep = irodsAccessObjectFactory.getProtocolExtensionPoint(irodsAccount);
try {
Expand Down Expand Up @@ -692,8 +706,12 @@ public boolean setTicketUsesLimit(final String ticketId, final int usesLimit) th

log.info("modifying ticket id/string:{}", ticketId);

TicketAdminInp ticketPI = TicketAdminInp.instanceForModifyNumberOfUses(ticketId, usesLimit);
log.info(EXECUTING_TICKET_PI);
TicketInp ticketPI = null;
if (this.environmentalInfAO.getIRODSServerProperties().isTicketAdminCondInput()) {
ticketPI = TicketAdminInp.instanceForModifyNumberOfUses(ticketId, usesLimit);
} else {
ticketPI = TicketAdminInpNoCondInp.instanceForModifyNumberOfUses(ticketId, usesLimit);
}

ProtocolExtensionPoint pep = irodsAccessObjectFactory.getProtocolExtensionPoint(irodsAccount);
try {
Expand Down Expand Up @@ -732,8 +750,12 @@ public boolean setTicketFileWriteLimit(final String ticketId, final int fileWrit

log.info("modifying ticket id/string:{}", ticketId);

TicketAdminInp ticketPI = TicketAdminInp.instanceForModifyFileWriteNumber(ticketId, fileWriteLimit);
log.info(EXECUTING_TICKET_PI);
TicketInp ticketPI = null;
if (this.environmentalInfAO.getIRODSServerProperties().isTicketAdminCondInput()) {
ticketPI = TicketAdminInp.instanceForModifyFileWriteNumber(ticketId, fileWriteLimit);
} else {
ticketPI = TicketAdminInpNoCondInp.instanceForModifyFileWriteNumber(ticketId, fileWriteLimit);
}

ProtocolExtensionPoint pep = irodsAccessObjectFactory.getProtocolExtensionPoint(irodsAccount);
try {
Expand Down Expand Up @@ -772,8 +794,12 @@ public boolean setTicketByteWriteLimit(final String ticketId, final long byteWri

log.info("modifying ticket id/string:{}", ticketId);

TicketAdminInp ticketPI = TicketAdminInp.instanceForModifyByteWriteNumber(ticketId, byteWriteLimit);
log.info(EXECUTING_TICKET_PI);
TicketInp ticketPI = null;
if (this.environmentalInfAO.getIRODSServerProperties().isTicketAdminCondInput()) {
ticketPI = TicketAdminInp.instanceForModifyByteWriteNumber(ticketId, byteWriteLimit);
} else {
ticketPI = TicketAdminInpNoCondInp.instanceForModifyByteWriteNumber(ticketId, byteWriteLimit);
}

ProtocolExtensionPoint pep = irodsAccessObjectFactory.getProtocolExtensionPoint(irodsAccount);
try {
Expand Down Expand Up @@ -808,8 +834,12 @@ public boolean setTicketExpiration(final String ticketId, final Date expirationD

log.info("modifying ticket id/string:{}", ticketId);

TicketAdminInp ticketPI = TicketAdminInp.instanceForModifyExpiration(ticketId, expirationDate);
log.info(EXECUTING_TICKET_PI);
TicketInp ticketPI = null;
if (this.environmentalInfAO.getIRODSServerProperties().isTicketAdminCondInput()) {
ticketPI = TicketAdminInp.instanceForModifyExpiration(ticketId, expirationDate);
} else {
ticketPI = TicketAdminInpNoCondInp.instanceForModifyExpiration(ticketId, expirationDate);
}

ProtocolExtensionPoint pep = irodsAccessObjectFactory.getProtocolExtensionPoint(irodsAccount);
try {
Expand Down Expand Up @@ -851,9 +881,14 @@ public boolean addTicketUserRestriction(final String ticketId, final String user

log.info("modifying ticket id/string:{}", ticketId);

TicketAdminInp ticketPI = TicketAdminInp.instanceForModifyAddAccess(ticketId,
TicketModifyAddOrRemoveTypeEnum.TICKET_MODIFY_USER, userId);
log.info(EXECUTING_TICKET_PI);
TicketInp ticketPI = null;
if (this.environmentalInfAO.getIRODSServerProperties().isTicketAdminCondInput()) {
ticketPI = TicketAdminInp.instanceForModifyAddAccess(ticketId,
TicketModifyAddOrRemoveTypeEnum.TICKET_MODIFY_USER, userId);
} else {
ticketPI = TicketAdminInpNoCondInp.instanceForModifyAddAccess(ticketId,
TicketModifyAddOrRemoveTypeEnum.TICKET_MODIFY_USER, userId);
}

ProtocolExtensionPoint pep = irodsAccessObjectFactory.getProtocolExtensionPoint(irodsAccount);
try {
Expand Down Expand Up @@ -894,9 +929,14 @@ public boolean removeTicketUserRestriction(final String ticketId, final String u

log.info("modifying ticket id/string:{}", ticketId);

TicketAdminInp ticketPI = TicketAdminInp.instanceForModifyRemoveAccess(ticketId,
TicketModifyAddOrRemoveTypeEnum.TICKET_MODIFY_USER, userId);
log.info(EXECUTING_TICKET_PI);
TicketInp ticketPI = null;
if (this.environmentalInfAO.getIRODSServerProperties().isTicketAdminCondInput()) {
ticketPI = TicketAdminInp.instanceForModifyRemoveAccess(ticketId,
TicketModifyAddOrRemoveTypeEnum.TICKET_MODIFY_USER, userId);
} else {
ticketPI = TicketAdminInpNoCondInp.instanceForModifyRemoveAccess(ticketId,
TicketModifyAddOrRemoveTypeEnum.TICKET_MODIFY_USER, userId);
}

ProtocolExtensionPoint pep = irodsAccessObjectFactory.getProtocolExtensionPoint(irodsAccount);
try {
Expand Down Expand Up @@ -937,9 +977,14 @@ public boolean addTicketGroupRestriction(final String ticketId, final String gro

log.info("modifying ticket id/string:{}", ticketId);

TicketAdminInp ticketPI = TicketAdminInp.instanceForModifyAddAccess(ticketId,
TicketModifyAddOrRemoveTypeEnum.TICKET_MODIFY_GROUP, groupId);
log.info(EXECUTING_TICKET_PI);
TicketInp ticketPI = null;
if (this.environmentalInfAO.getIRODSServerProperties().isTicketAdminCondInput()) {
ticketPI = TicketAdminInp.instanceForModifyAddAccess(ticketId,
TicketModifyAddOrRemoveTypeEnum.TICKET_MODIFY_GROUP, groupId);
} else {
ticketPI = TicketAdminInpNoCondInp.instanceForModifyAddAccess(ticketId,
TicketModifyAddOrRemoveTypeEnum.TICKET_MODIFY_GROUP, groupId);
}

ProtocolExtensionPoint pep = irodsAccessObjectFactory.getProtocolExtensionPoint(irodsAccount);
try {
Expand Down Expand Up @@ -980,9 +1025,14 @@ public boolean removeTicketGroupRestriction(final String ticketId, final String

log.info("modifying ticket id/string:{}", ticketId);

TicketAdminInp ticketPI = TicketAdminInp.instanceForModifyRemoveAccess(ticketId,
TicketModifyAddOrRemoveTypeEnum.TICKET_MODIFY_GROUP, groupId);
log.info(EXECUTING_TICKET_PI);
TicketInp ticketPI = null;
if (this.environmentalInfAO.getIRODSServerProperties().isTicketAdminCondInput()) {
ticketPI = TicketAdminInp.instanceForModifyRemoveAccess(ticketId,
TicketModifyAddOrRemoveTypeEnum.TICKET_MODIFY_GROUP, groupId);
} else {
ticketPI = TicketAdminInpNoCondInp.instanceForModifyRemoveAccess(ticketId,
TicketModifyAddOrRemoveTypeEnum.TICKET_MODIFY_GROUP, groupId);
}

ProtocolExtensionPoint pep = irodsAccessObjectFactory.getProtocolExtensionPoint(irodsAccount);
try {
Expand Down Expand Up @@ -1023,9 +1073,14 @@ public boolean addTicketHostRestriction(final String ticketId, final String host

log.info("modifying ticket id/string:{}", ticketId);

TicketAdminInp ticketPI = TicketAdminInp.instanceForModifyAddAccess(ticketId,
TicketModifyAddOrRemoveTypeEnum.TICKET_MODIFY_HOST, host);
log.info(EXECUTING_TICKET_PI);
TicketInp ticketPI = null;
if (this.environmentalInfAO.getIRODSServerProperties().isTicketAdminCondInput()) {
ticketPI = TicketAdminInp.instanceForModifyAddAccess(ticketId,
TicketModifyAddOrRemoveTypeEnum.TICKET_MODIFY_HOST, host);
} else {
ticketPI = TicketAdminInpNoCondInp.instanceForModifyAddAccess(ticketId,
TicketModifyAddOrRemoveTypeEnum.TICKET_MODIFY_HOST, host);
}

ProtocolExtensionPoint pep = irodsAccessObjectFactory.getProtocolExtensionPoint(irodsAccount);
try {
Expand Down Expand Up @@ -1066,9 +1121,14 @@ public boolean removeTicketHostRestriction(final String ticketId, final String h

log.info("modifying ticket id/string:{}", ticketId);

TicketAdminInp ticketPI = TicketAdminInp.instanceForModifyRemoveAccess(ticketId,
TicketModifyAddOrRemoveTypeEnum.TICKET_MODIFY_HOST, host);
log.info(EXECUTING_TICKET_PI);
TicketInp ticketPI = null;
if (this.environmentalInfAO.getIRODSServerProperties().isTicketAdminCondInput()) {
ticketPI = TicketAdminInp.instanceForModifyRemoveAccess(ticketId,
TicketModifyAddOrRemoveTypeEnum.TICKET_MODIFY_HOST, host);
} else {
ticketPI = TicketAdminInpNoCondInp.instanceForModifyRemoveAccess(ticketId,
TicketModifyAddOrRemoveTypeEnum.TICKET_MODIFY_HOST, host);
}

ProtocolExtensionPoint pep = irodsAccessObjectFactory.getProtocolExtensionPoint(irodsAccount);
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.irods.jargon.core.exception.JargonException;
import org.irods.jargon.core.packinstr.KeyValuePair;
import org.irods.jargon.core.packinstr.Tag;

/**
* Packing instruction for admin functions for the ticket subsystem in iRODS.
Expand Down Expand Up @@ -206,4 +212,15 @@ private TicketAdminInp(final int apiNbr, final String arg1, final String arg2, f
super(apiNbr, arg1, arg2, arg3, arg4, arg5, arg6);
}

@Override
public Tag getTagValue() throws JargonException {
// FIXME: refactor for kvps
List<KeyValuePair> kvps = new ArrayList<KeyValuePair>();
Tag message = new Tag(PI_TAG, new Tag[] { new Tag(ARG1, arg1), new Tag(ARG2, arg2), new Tag(ARG3, arg3),
new Tag(ARG4, arg4), new Tag(ARG5, arg5), new Tag(ARG6, arg6) });
message.addTag(createKeyValueTag(kvps));

return message;
}

}
Loading

0 comments on commit 08fa6ca

Please sign in to comment.