agave-tags/tags-core/src/main/java/org/iplantc/service/tags/managers/TagManager.java
/**
	 * Inserts a tag and sends the appropriate notifications. Permissions
	 * are verified prior to deletion.
	 * 
	 * @param json the json representation of the tag to add
	 * @param username the new tag owner
	 * @throws TagException if unable to add the tag
	 * @throws TagPermissionException if user does not have permission to add a tag
	 */
Inserts a tag and sends the appropriate notifications. Permissions
are verified prior to deletion.

@param json the json representation of the tag to add
@param username the new tag owner
@throws TagException if unable to add the tag
@throws TagPermissionException if user does not have permission to add a tag
Inserts a tag and sends the appropriate notifications . Permissions are verified prior to deletion . @param json the json representation of the tag to add @param username the new tag owner @throws TagException if unable to add the tag @throws TagPermissionException if user does not have permission to add a tag
public Tag addTagForUser(JsonNode json, String username) 
	throws TagValidationException, TagException 
	{	
		Tag tag = Tag.fromJSON(json);
		tag.setOwner(username);
    	if (getDao().doesTagNameExistForUser(tag.getName(), username)) {
    		throw new TagValidationException("Tag with the name " + 
    				tag.getName() + " already exists. " +
    				"Tag names must be unique per user.");
    	}
    	else {
    		getDao().persist(tag);
    		try {
				getEventProcessor().processContentEvent(tag, 
						new TagEvent(tag.getUuid(),
								TagEventType.CREATED,
								"Tag was created by " + username,
								username));
			} catch (TagEventProcessingException e) {
				log.error("Failed to send tag creation event for " + tag.getUuid(), e);
			}
    	}
    	return tag;
	}
public Tag addTagForUser ( JsonNode json , String username ) throws TagValidationException , TagException { Tag tag = Tag . fromJSON ( json ) ; tag . setOwner ( username ) ; if ( getDao ( ) . doesTagNameExistForUser ( tag . getName ( ) , username ) ) { throw new TagValidationException ( "Tag with the name " + tag . getName ( ) + " already exists. " + "Tag names must be unique per user." ) ; } else { getDao ( ) . persist ( tag ) ; try { getEventProcessor ( ) . processContentEvent ( tag , new TagEvent ( tag . getUuid ( ) , TagEventType . CREATED , "Tag was created by " + username , username ) ) ; } catch ( TagEventProcessingException e ) { log . error ( "Failed to send tag creation event for " + tag . getUuid ( ) , e ) ; } } return tag ; }
Inserts a tag and sends the appropriate notifications.
Inserts a tag and sends the appropriate notifications .
// check for uniqueness. We could just catch the uniqueness  // exception from hibernate, but we'll defensively check against  // db/hibernate stupidity // alert any subscribers