agave-tags/tags-core/src/main/java/org/iplantc/service/tags/managers/TaggedResourceManager.java
/**
	 * Adds a {@link TaggedResource} to an existing {@link Tag}. In the event of a duplicate,
	 * nothing is added.
	 * 
	 * @param uuid a uuid to add to the given tag
	 * @param username
	 * @return the newly added {@link TaggedResource} for the {@code uuid}
	 * @throws TagValidationException
	 * @throws TagException
	 * @throws DuplicateTaggedResourceException 
	 */
Adds a  TaggedResource to an existing  Tag. In the event of a duplicate,
nothing is added.


Adds a TaggedResource to an existing Tag . In the event of a duplicate nothing is added .
public TaggedResource addToTag(String uuid, String username) 
	throws TagValidationException, TagException, DuplicateTaggedResourceException 
	{	
		if (tag == null) {
			throw new TagException("No tag specifed");
		}
		if (StringUtils.isBlank(uuid)) {
			throw new TagValidationException("Resource id cannot be null. "
					+ "Please provide a valid uuid to tag with " + getTag().getName());
		}
		TaggedResource newTaggedResource = new TaggedResource(uuid, getTag());
		ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
        Validator validator = factory.getValidator();
        Set<ConstraintViolation<TaggedResource>> violations = validator.validate(newTaggedResource);
		if (violations.isEmpty()) {
			List<TaggedResource> oldTaggedResources = getTag().getTaggedResources();
			if (getTag().addTaggedResource(newTaggedResource)) {
				getDao().persist(getTag());
				try {
					eventProcessor.processAssociatedUuidUpdateEvent(getTag(), oldTaggedResources,  
							new TagEvent(getTag().getUuid(),
									TagEventType.UPDATED,
									"The following resources were tagged: " + 
											StringUtils.join(getTag().getTaggedResourcesAsArray()),
									username));
				} catch (TagEventProcessingException e) {
					log.error("Failed to send tag resource update event for " + getTag().getUuid(), e);
				}
			}
			else {
				return getTag().getTaggedResource(uuid);
			}
    	} 
		else {
    		throw new TagValidationException(violations.iterator().next().getMessage()); 
    	}
		return newTaggedResource;
	}
public TaggedResource addToTag ( String uuid , String username ) throws TagValidationException , TagException , DuplicateTaggedResourceException { if ( tag == null ) { throw new TagException ( "No tag specifed" ) ; } if ( StringUtils . isBlank ( uuid ) ) { throw new TagValidationException ( "Resource id cannot be null. " + "Please provide a valid uuid to tag with " + getTag ( ) . getName ( ) ) ; } TaggedResource newTaggedResource = new TaggedResource ( uuid , getTag ( ) ) ; ValidatorFactory factory = Validation . buildDefaultValidatorFactory ( ) ; Validator validator = factory . getValidator ( ) ; Set < ConstraintViolation < TaggedResource > > violations = validator . validate ( newTaggedResource ) ; if ( violations . isEmpty ( ) ) { List < TaggedResource > oldTaggedResources = getTag ( ) . getTaggedResources ( ) ; if ( getTag ( ) . addTaggedResource ( newTaggedResource ) ) { getDao ( ) . persist ( getTag ( ) ) ; try { eventProcessor . processAssociatedUuidUpdateEvent ( getTag ( ) , oldTaggedResources , new TagEvent ( getTag ( ) . getUuid ( ) , TagEventType . UPDATED , "The following resources were tagged: " + StringUtils . join ( getTag ( ) . getTaggedResourcesAsArray ( ) ) , username ) ) ; } catch ( TagEventProcessingException e ) { log . error ( "Failed to send tag resource update event for " + getTag ( ) . getUuid ( ) , e ) ; } } else { return getTag ( ) . getTaggedResource ( uuid ) ; } } else { throw new TagValidationException ( violations . iterator ( ) . next ( ) . getMessage ( ) ) ; } return newTaggedResource ; }
Adds a {@link TaggedResource} to an existing {@link Tag}.
Adds a { @link TaggedResource } to an existing { @link Tag } .
// create and validate the new TaggedResource // returns true on insert, false on duplicate // process the events for the new associated UUIDS //				throw new DuplicateTaggedResourceException("Resource " + uuid + " is already tagged with " + getTag().getName());