package com.k_int.aggregator.dpp.util;

import com.k_int.discover.datamodel.AttachedResourceHDO;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.HibernateException;
import org.hibernate.Session;

/**
 * Utility methods for dealing with file attachments
 * @author rpb rich@k-int.com
 * @version 1.0 03.09.10
 */
public class AttachmentUtils {

    private static Log log = LogFactory.getLog(AttachmentUtils.class);
    
    public static List<AttachedResourceHDO> getAttachedResources(Session sess, Long resourceId) {

	  List<AttachedResourceHDO> returnValue = null;
	  try {
		  returnValue = AttachedResourceHDO.lookupByResourceId(sess, resourceId);
	  } catch (HibernateException he) {
		  log.error("HibernateException thrown when looking up associated resources: " + he.getMessage());
		  he.printStackTrace();
	  }

	  return returnValue;
  }
}
