class TemplateResource {

	protected void orphanOriginalStormTemplate(String originalTemplateId, ItemManager itemMan) {
		//can only orphan the original if there was an original
		if (!StringUtils.isEmpty(originalTemplateId)) {
			Item originalTemplate = itemMan.load(originalTemplateId);
			if (null == originalTemplate) {
				throw new EntityNotFoundException(String.format(
					"Could not find template with ID '%s'. "
					+ "Perhaps the template Item was deleted "
					+ "between the time it was persisted and the time it was read?",
					originalTemplateId));
			} else {
				//only orphan original template if it was a storm template
				if (Type.storms.equals(originalTemplate.getType())) {
					boolean success = itemMan.orphan(originalTemplate);
					if (!success) {
						throw new PersistenceException(
							String.format(
								"Could not orphan template with ID '%s'",
								originalTemplateId
							)
						);
					}
				}
			}
		}
	}

}