Class DefaultResourceDao

  • All Implemented Interfaces:
    ResourceDao, org.springframework.beans.factory.InitializingBean

    public class DefaultResourceDao
    extends java.lang.Object
    implements ResourceDao, org.springframework.beans.factory.InitializingBean
    Retrieves and enumerates elements from the resource tree. This class is responsible for maintaining the list of resource types and coordinating amongst these. All resource type specific logic should be contained in the resource type implementations rather than this class.
    Author:
    Jesse White, Seth Leger , Lawrence Karnowski , DJ Gregor
    • Field Detail

      • MAXIMUM_NODE_METRIC_RESOURCE_DEPTH

        public static final int MAXIMUM_NODE_METRIC_RESOURCE_DEPTH
        Largest depth at which we will find node related metrics: [0] will catch node-level resources [1] will catch interface-level resources [2] will catch generic index type resources
        See Also:
        Constant Field Values
    • Constructor Detail

      • DefaultResourceDao

        public DefaultResourceDao()

        Constructor for DefaultResourceDao.

    • Method Detail

      • setResourceTypesDao

        public void setResourceTypesDao​(ResourceTypesDao resourceTypesDao)
      • getNodeDao

        public NodeDao getNodeDao()

        getNodeDao

        Returns:
        a NodeDao object.
      • setNodeDao

        public void setNodeDao​(NodeDao nodeDao)

        setNodeDao

        Parameters:
        nodeDao - a NodeDao object.
      • setIpInterfaceDao

        public void setIpInterfaceDao​(IpInterfaceDao ipInterfaceDao)
      • setResourceStorageDao

        public void setResourceStorageDao​(ResourceStorageDao resourceStorageDao)
      • afterPropertiesSet

        public void afterPropertiesSet()

        afterPropertiesSet

        Specified by:
        afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
      • findTopLevelResources

        @Transactional(readOnly=true)
        public java.util.List<OnmsResource> findTopLevelResources()

        findTopLevelResources

        Specified by:
        findTopLevelResources in interface ResourceDao
        Returns:
        a List object.
      • hasAnyChildResources

        protected boolean hasAnyChildResources​(OnmsResource resource)
        Used to determine whether or not the given (parent) resource has any child resources.
      • getResourceById

        @Transactional(readOnly=true)
        public OnmsResource getResourceById​(ResourceId id)
        Fetch a specific resource by string ID.
        Specified by:
        getResourceById in interface ResourceDao
        Parameters:
        id - a String object.
        Returns:
        Resource or null if resource cannot be found.
        Throws:
        java.lang.IllegalArgumentException - When the resource ID string does not match the expected regex pattern
        org.springframework.orm.ObjectRetrievalFailureException - If any exceptions are thrown while searching for the resource
      • deleteResourceById

        public boolean deleteResourceById​(ResourceId resourceId)
        Description copied from interface: ResourceDao
        Deletes the resource identified by the given resource ID.
        Specified by:
        deleteResourceById in interface ResourceDao
        Parameters:
        resourceId - the ID of the resource to delete
        Returns:
        true iff, the resource was found and deleted
      • deleteResource

        public boolean deleteResource​(OnmsResource resource,
                                      boolean recursive)
      • getChildResource

        protected OnmsResource getChildResource​(OnmsResource parentResource,
                                                java.lang.String resourceType,
                                                java.lang.String resource)

        getChildResource

        Parameters:
        parentResource - a OnmsResource object.
        resourceType - a String object.
        resource - a String object.
        Returns:
        a OnmsResource object.
      • decode

        public static java.lang.String decode​(java.lang.String string)
        Encapsulate the deprecated decode method to fix it in one place.
        Parameters:
        string - string to be decoded
        Returns:
        decoded string