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


Adds a List of uuid to an existing Tag . In the event of a duplicate nothing is added .
public List<TaggedResource> addAllToTag(JsonNode json, String username) 
	throws TagValidationException, TagException, DuplicateTaggedResourceException 
	{		
		if (tag == null) {
			throw new TagException("No tag specifed");
		}
		List<TaggedResource> newTaggedResources = new ArrayList<TaggedResource>();
		if (json.isArray()) {
			if(json.size() > 0) {
				for(Iterator<JsonNode> iter = json.iterator(); iter.hasNext();) {
					TaggedResource tr = new TaggedResource(iter.next().textValue(), getTag());
					if (StringUtils.isNotBlank(tr.getUuid())) {
						newTaggedResources.add(tr);
					}	
				}
				ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
		        Validator validator = factory.getValidator();
		        Set<ConstraintViolation<List<TaggedResource>>> violations = validator.validate(newTaggedResources);
				if (violations.isEmpty()) {
					List<TaggedResource> oldTaggedResources = getTag().getTaggedResources();
					for(TaggedResource tr: newTaggedResources) {
						getTag().addTaggedResource(tr);
					}
    				getDao().persist(getTag());
    				try {
						eventProcessor.processAssociatedUuidUpdateEvent(getTag(), oldTaggedResources,  
								new TagEvent(getTag().getUuid(),
										TagEventType.UPDATED,
										"The following resources were tagged: " + 
												newTaggedResources.toString(),
										username));
    				} catch (TagEventProcessingException e) {
						log.error("Failed to send tag resource update event for " + getTag().getUuid(), e);
					}
	        	} 
				else {
	        		throw new TagValidationException(violations.iterator().next().getMessage()); 
	        	}
			}
			else {
			}
		}
		else {
			throw new TagValidationException("Invalid associationIds. "
					+ "Please provide an array of uuid for the associationIds field.");
		}
		return newTaggedResources;
	}
public List < TaggedResource > addAllToTag ( JsonNode json , String username ) throws TagValidationException , TagException , DuplicateTaggedResourceException { if ( tag == null ) { throw new TagException ( "No tag specifed" ) ; } List < TaggedResource > newTaggedResources = new ArrayList < TaggedResource > ( ) ; if ( json . isArray ( ) ) { if ( json . size ( ) > 0 ) { for ( Iterator < JsonNode > iter = json . iterator ( ) ; iter . hasNext ( ) ; ) { TaggedResource tr = new TaggedResource ( iter . next ( ) . textValue ( ) , getTag ( ) ) ; if ( StringUtils . isNotBlank ( tr . getUuid ( ) ) ) { newTaggedResources . add ( tr ) ; } } ValidatorFactory factory = Validation . buildDefaultValidatorFactory ( ) ; Validator validator = factory . getValidator ( ) ; Set < ConstraintViolation < List < TaggedResource > > > violations = validator . validate ( newTaggedResources ) ; if ( violations . isEmpty ( ) ) { List < TaggedResource > oldTaggedResources = getTag ( ) . getTaggedResources ( ) ; for ( TaggedResource tr : newTaggedResources ) { getTag ( ) . addTaggedResource ( tr ) ; } getDao ( ) . persist ( getTag ( ) ) ; try { eventProcessor . processAssociatedUuidUpdateEvent ( getTag ( ) , oldTaggedResources , new TagEvent ( getTag ( ) . getUuid ( ) , TagEventType . UPDATED , "The following resources were tagged: " + newTaggedResources . toString ( ) , username ) ) ; } catch ( TagEventProcessingException e ) { log . error ( "Failed to send tag resource update event for " + getTag ( ) . getUuid ( ) , e ) ; } } else { throw new TagValidationException ( violations . iterator ( ) . next ( ) . getMessage ( ) ) ; } } else { } } else { throw new TagValidationException ( "Invalid associationIds. " + "Please provide an array of uuid for the associationIds field." ) ; } return newTaggedResources ; }
Adds a {@link List<String>} of uuid to an existing {@link Tag}.
Adds a { @link List<String > } of uuid to an existing { @link Tag } .
// we are expecting a json array of tags // provided there are actually values present, we proceed // validate each uuid, ignoring blanks prior to adding // remember the old TaggedResource list so we don't send out unnecesary events // process the events for the new associated UUIDS // we do nothing if no values were provided, the  // returned array will be empty