Refactor various methods to get session or blob handler

Use a single method to fetch the handler, if it can be found using
session ID.

Signed-off-by: Kun Yi <kunyi731@gmail.com>
Change-Id: I648cbc48ebfae479f63d34e8f2465d2c8cbe9d64
diff --git a/manager.hpp b/manager.hpp
index 7b169db..1c04c6a 100644
--- a/manager.hpp
+++ b/manager.hpp
@@ -234,21 +234,25 @@
     GenericBlobInterface* getHandler(const std::string& path);
 
     /**
-     * Given a session id will return associated handler.
+     * Given a session id, update session time and return a handle to take
+     * action
      *
-     * @param[in] session - the session.
-     * @return pointer to the handler or nullptr if not found.
+     * @param[in] session - session ID
+     * @param[in] requiredFlags - only return handle if the flags for this
+     *            session contain these flags; defaults to any flag
+     * @return session handler, nullptr if cannot get handler
      */
-    GenericBlobInterface* getHandler(uint16_t session);
-
-    /**
-     * Given a session id will return associated metadata, including
-     * the handler and the flags passed into open.
-     *
-     * @param[in] session - the session.
-     * @return pointer to the information or nullptr if not found.
-     */
-    SessionInfo* getSessionInfo(uint16_t session);
+    GenericBlobInterface* getActionHandle(
+        uint16_t session,
+        uint16_t requiredFlags = std::numeric_limits<uint16_t>::max())
+    {
+        if (auto item = sessions.find(session);
+            item != sessions.end() && (item->second.flags & requiredFlags))
+        {
+            return item->second.handler;
+        }
+        return nullptr;
+    }
 
     /**
      * Given a session id will return associated path.