@ExcludeDefaultInterceptors public Agent getAgentByID(int agentId) { Agent agent = entityManager.find(Agent.class, agentId); return agent; }
@SuppressWarnings("unchecked") @ExcludeDefaultInterceptors public List<Agent> getAllAgents() { return entityManager.createNamedQuery(Agent.QUERY_FIND_ALL).getResultList(); }
@ExcludeDefaultInterceptors public void createAgent(Agent agent) { entityManager.persist(agent); if (LOG.isDebugEnabled()) { LOG.debug("Persisted new agent: " + agent); } }
@ExcludeDefaultInterceptors public Agent updateAgent(Agent agent) { agent = entityManager.merge(agent); if (LOG.isDebugEnabled()) { LOG.debug("Updated agent: " + agent); } return agent; }
@ExcludeDefaultInterceptors public int getAgentCount() { return ((Number) entityManager.createNamedQuery(Agent.QUERY_COUNT_ALL).getSingleResult()).intValue(); }
@ExcludeDefaultInterceptors public Integer getAgentIdByResourceId(int resourceId) { Integer agentId; try { Query query = entityManager.createNamedQuery(Agent.QUERY_FIND_AGENT_ID_BY_RESOURCE_ID); query.setParameter("resourceId", resourceId); agentId = (Integer) query.getSingleResult(); } catch (NoResultException e) { if (LOG.isDebugEnabled()) { LOG.debug("Failed to lookup agent for resource with ID of [" + resourceId + "] : " + e); } agentId = null; } return agentId; }
@ExcludeDefaultInterceptors public Integer getAgentIdByScheduleId(int scheduleId) { Integer agentId; try { Query query = entityManager.createNamedQuery(Agent.QUERY_FIND_AGENT_ID_BY_SCHEDULE_ID); query.setParameter("scheduleId", scheduleId); agentId = (Integer) query.getSingleResult(); } catch (NoResultException e) { if (LOG.isDebugEnabled()) { LOG.debug("Failed to lookup agent for resource with ID of [" + scheduleId + "] : " + e); } agentId = null; } return agentId; }
@ExcludeDefaultInterceptors public Integer getAgentIdByName(String agentName) { Integer agentId; try { Query query = entityManager.createNamedQuery(Agent.QUERY_FIND_AGENT_ID_BY_NAME); query.setParameter("name", agentName); agentId = (Integer) query.getSingleResult(); } catch (NoResultException e) { if (LOG.isDebugEnabled()) { LOG.debug("Failed to lookup agent for name of [" + agentName + "] : " + e); } agentId = null; } return agentId; }
@ExcludeDefaultInterceptors public Agent getAgentByAgentToken(String token) { Agent agent; try { Query query = entityManager.createNamedQuery(Agent.QUERY_FIND_BY_AGENT_TOKEN); query.setParameter("agentToken", token); agent = (Agent) query.getSingleResult(); } catch (NoResultException e) { if (LOG.isDebugEnabled()) { LOG.debug("Failed to lookup agent - none exist with token [" + token + "] : " + e); } agent = null; } return agent; }
@ExcludeDefaultInterceptors public Agent getAgentByName(String agentName) { Agent agent; try { Query query = entityManager.createNamedQuery(Agent.QUERY_FIND_BY_NAME); query.setParameter("name", agentName); agent = (Agent) query.getSingleResult(); } catch (NoResultException e) { if (LOG.isDebugEnabled()) { LOG.debug("Failed to lookup agent - none exist with name [" + agentName + "] : " + e); } agent = null; } return agent; }
/** * <code>ClassInterceptor</code> should not intercept this. * * @return the contextData */ @ExcludeDefaultInterceptors @ExcludeClassInterceptors public Map<String, Object> getContextData() { return contextData; }
/** * <code>ClassInterceptor</code> should not intercept this. * * @return the contextData */ @ExcludeDefaultInterceptors @ExcludeClassInterceptors public Map<String, Object> getContextData() { return contextData; }
@ExcludeDefaultInterceptors @Override public File getRemoteClientBinaryFile() throws Exception { File downloadDir = getDownloadDir(); for (File file : downloadDir.listFiles()) { if (file.getName().endsWith(".zip")) { return file; } } throw new FileNotFoundException("Missing CLI binary in [" + downloadDir + "]"); }
@ExcludeDefaultInterceptors public File getAgentUpdateBinaryFile() throws Exception { File agentDownloadDir = getAgentDownloadDir(); for (File file : agentDownloadDir.listFiles()) { if (file.getName().endsWith(".jar")) { return file; } } throw new FileNotFoundException("Missing agent update binary in [" + agentDownloadDir + "]"); }
/** * <code>ClassInterceptor</code> should not intercept this. * * @return the contextData */ @ExcludeDefaultInterceptors @ExcludeClassInterceptors public Map<String, Object> getContextData() { return contextData; }
/** * <code>ClassInterceptor</code> should not intercept this. * * @return the contextData */ @ExcludeDefaultInterceptors @ExcludeClassInterceptors public Map<String, Object> getContextData() { return contextData; }
/** * <code>ClassInterceptor</code> should not intercept this. * * @return the contextData */ @ExcludeDefaultInterceptors @ExcludeClassInterceptors public Map<String, Object> getContextData() { return contextData; }
/** * <code>ClassInterceptor</code> should not intercept this. * * @return the contextData */ @ExcludeDefaultInterceptors @ExcludeClassInterceptors public Map<String, Object> getContextData() { return contextData; }
@ExcludeDefaultInterceptors public Agent getAgentByAddressAndPort(String address, int port) { Agent agent; try { Query query = entityManager.createNamedQuery(Agent.QUERY_FIND_BY_ADDRESS_AND_PORT); query.setParameter("address", address); query.setParameter("port", port); agent = (Agent) query.getSingleResult(); } catch (NoResultException e) { if (LOG.isDebugEnabled()) { LOG.debug("Agent not found with address/port: " + address + "/" + port); } agent = null; } return agent; }
@ExcludeDefaultInterceptors public Properties getAgentUpdateVersionFileContent() throws Exception { FileInputStream stream = new FileInputStream(getAgentUpdateVersionFile()); try { Properties props = new Properties(); props.load(stream); return props; } finally { try { stream.close(); } catch (Exception e) { } } }