/** * Add a token to the id field of the ResourceAllocation inside the ActionDescription. * This method does nothing if the id already contains a token. * * @param actionDescription the ActionDescription which is updated * @return the updated ActionDescription */ public static ActionDescription.Builder generateToken(final ActionDescription.Builder actionDescription) { ResourceAllocation.Builder resourceAllocation = actionDescription.getResourceAllocationBuilder(); if (hasResourceAllocationToken(actionDescription)) { return actionDescription; } else { String token = UUID.randomUUID().toString(); resourceAllocation.setId(resourceAllocation.getId() + TOKEN_SEPERATOR + token); return actionDescription; } }
/** * Get a new id value for the id field in the ResourceAllocation of an ActionDescription * while keeping the token if there si one. * * @param actionDescription the action description which is updated as described above * @return the action description which is updated as described above */ public static ActionDescription.Builder updateResourceAllocationId(final ActionDescription.Builder actionDescription) { ResourceAllocation.Builder resourceAllocation = actionDescription.getResourceAllocationBuilder(); String newId = UUID.randomUUID().toString(); if (!hasResourceAllocationToken(actionDescription)) { resourceAllocation.setId(newId); } else { String token = resourceAllocation.getId().split(TOKEN_SEPERATOR)[1]; resourceAllocation.setId(newId + TOKEN_SEPERATOR + token); } return actionDescription; }