DeviceManager
that stores the devices
- * in a database.
- */
-@Service
-public class DBDeviceManager extends DBManagerDBDeviceManager
that uses the default
- * database. The default database is used to store all of the
- * Device
s.
- *
- * @param em entity manager used to access database connections
- */
- public DBDeviceManager(final EntityManager em) {
- super(Device.class, em);
- }
-
- /**
- * Saves the Device
in the database. This creates a new
- * database session and saves the device. If the Device
had
- * previously been saved then a DeviceManagerException
is
- * thrown.
- *
- * @param device
- * device to save
- * @return reference to saved device
- * @throws hirs.persist.DeviceManagerException
- * if device has previously been saved or an error occurs
- * while trying to save it to the database
- */
- @Override
- public final Device saveDevice(final Device device)
- throws DeviceManagerException {
- LOGGER.debug("saving device: {}", device);
- try {
- return super.save(device);
- } catch (DBManagerException e) {
- throw new DeviceManagerException(e);
- }
- }
-
- /**
- * Updates a Device
. This updates the database entries to
- * reflect the new values that should be set.
- *
- * @param device
- * device
- * @throws DeviceManagerException
- * if device has not previously been saved or an error occurs
- * while trying to save it to the database
- */
- @Override
- public final void updateDevice(final Device device)
- throws DeviceManagerException {
- LOGGER.debug("updating device: {}", device);
- try {
- super.update(device);
- } catch (DBManagerException e) {
- throw new DeviceManagerException(e);
- }
- }
-
- /**
- * Updates list of Device
s. This updates the database entries
- * to reflect the new values that should be set. Commonly used when
- * deleting a DeviceGroup.
- *
- * @param deviceList
- * list of devices that should be updated in single transaction
- * @throws DeviceManagerException
- * if device has not previously been saved or an error occurs
- * while trying to save it to the database
- */
- @Override
- public final void updateDeviceList(final SetDevices
. This searches through
- * the database for this information.
- *
- * @return list of Devices
- * @throws DeviceManagerException
- * if unable to search the database
- */
- @Override
- public final SetDevice
names. This searches through
- * the database for this information.
- *
- * @return list of Device
names
- * @throws DeviceManagerException
- * if unable to search the database
- */
- @Override
- public final ListDevice
s that are ordered by a column
- * and direction (ASC, DESC) that is provided by the user. This method
- * helps support the server-side processing in the JQuery DataTables.
- *
- * @param columnToOrder Column to be ordered
- * @param ascending direction of sort
- * @param firstResult starting point of first result in set
- * @param maxResults total number we want returned for display in table
- * @param search string of criteria to be matched to visible columns
- *
- * @return FilteredRecordsList object with fields for DataTables
- * @throws DeviceManagerException
- * if unable to create the list
- */
- @Override
- public final FilteredRecordsListDevice
from the database. This searches the
- * database for an entry whose name matches name
. It then
- * reconstructs a Device
object from the database entry
- *
- * @param name
- * name of the device
- * @return device if found, otherwise null.
- * @throws DeviceManagerException
- * if unable to search the database or recreate the
- * Device
- */
- @Override
- public final Device getDevice(final String name)
- throws DeviceManagerException {
- LOGGER.debug("getting device: {}", name);
- try {
- return super.get(name);
- } catch (DBManagerException e) {
- throw new DeviceManagerException(e);
- }
- }
-
- /**
- * Used to produce a list of all Device
s associated with the Default Group.
- *
- * @return list of Devices that are part of the Default Group
- * @throws DeviceManagerException
- * if unable to find the device or delete it from the database
- */
- @Override
- public final ListDevice
from the database. This removes all
- * of the database entries that stored information with regards to the
- * Device
with a foreign key relationship.
- *
- * @param name of the device to be deleted
- * @return true if successfully found and deleted, false if otherwise
- */
- @Override
- public final boolean deleteDevice(final String name)
- throws DeviceManagerException {
- LOGGER.debug("deleting device: {}", name);
- try {
- return super.delete(name);
- } catch (DBManagerException e) {
- throw new DeviceManagerException(e);
- }
- }
-
-}
diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/servicemanager/DBPortalInfoManager.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/servicemanager/DBPortalInfoManager.java
deleted file mode 100644
index 034b6e11..00000000
--- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/servicemanager/DBPortalInfoManager.java
+++ /dev/null
@@ -1,159 +0,0 @@
-package hirs.attestationca.servicemanager;
-
-import hirs.data.persist.enums.PortalScheme;
-import hirs.data.persist.info.PortalInfo;
-import hirs.persist.DBManagerException;
-import hirs.persist.PortalInfoManagerException;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
-import org.springframework.stereotype.Service;
-
-import javax.persistence.EntityManager;
-import java.net.URI;
-import java.net.URISyntaxException;
-
-/**
- * A DBPortalInfoManager
is a service (extends DBManager
) that
- * implements the PortalInfoManager
that stores and retrieves Portal Info objects.
- */
-@Service
-public class DBPortalInfoManager extends DBManagerDBPortalInfoManager
. The optional SessionFactory parameter is
- * used to manage sessions with a hibernate db.
- *
- * @param em a hibernate session
- */
- public DBPortalInfoManager(final EntityManager em) {
- super(PortalInfo.class, em);
- }
-
- /**
- * Saves the PortalInfo
in the database. This creates a new database
- * session and saves the PortalInfo. If the PortalInfo
had previously
- * been saved then a PortalInfoManagerException
is thrown.
- *
- * @param info PortalInfo to save
- * @return reference to saved PortalInfo
- * @throws hirs.persist.PortalInfoManagerException if PortalInfo has previously been saved or an
- * error occurs while trying to save it to the database
- */
- @Override
- public final PortalInfo savePortalInfo(final PortalInfo info)
- throws PortalInfoManagerException {
- LOGGER.debug("saving Portal Info {}", info);
- try {
- return super.save(info);
- } catch (DBManagerException e) {
- throw new PortalInfoManagerException(e);
- }
- }
-
- /**
- * Updates a PortalInfo
. This updates the database entries to reflect the new
- * values that should be set.
- *
- * @param info PortalInfo
- * @throws PortalInfoManagerException if PortalInfo has not previously been saved or
- * an error occurs while trying to save it to the database
- */
- @Override
- public final void updatePortalInfo(final PortalInfo info)
- throws PortalInfoManagerException {
- LOGGER.debug("updating Portal Info: {}", info);
- try {
- super.update(info);
- } catch (DBManagerException e) {
- throw new PortalInfoManagerException(e);
- }
- }
-
- /**
- * Retrieves the PortalInfo
from the database. This searches the database for an
- * entry whose name matches name
. It then reconstructs a PortalInfo
- * object from the database entry.
- *
- * @param scheme PortalInfo.Scheme of the PortalInfo
- * @return PortalInfo if found, otherwise null.
- * @throws PortalInfoManagerException if unable to search the database or recreate the
- * PortalInfo
- */
- @Override
- public final PortalInfo getPortalInfo(final PortalScheme scheme)
- throws PortalInfoManagerException {
- LOGGER.debug("getting Portal Info: {}", scheme.name());
- try {
- return super.get(scheme.name());
- } catch (DBManagerException e) {
- throw new PortalInfoManagerException(e);
- }
- }
-
- /**
- * Deletes the PortalInfo
from the database. This removes all of the database
- * entries that stored information with regards to the this PortalInfo
.
- * Currently, iterates over Policy
entries and removes the selected
- * PortalInfo
from them if it exists. This needs to be fixed as this should not
- * be performed without user action. Update is expected soon.
- *
- * @param scheme PortalInfo.Scheme of the PortalInfo
to delete
- * @return true if successfully found and deleted PortalInfo
- * @throws PortalInfoManagerException if unable to find the PortalInfo or delete it
- * from the database
- */
- @Override
- public final boolean deletePortalInfo(final PortalScheme scheme)
- throws PortalInfoManagerException {
- LOGGER.debug("deleting Portal Info: {}", scheme.name());
- try {
- return super.delete(scheme.name());
- } catch (DBManagerException e) {
- throw new PortalInfoManagerException(e);
- }
- }
-
- /**
- * Retrieve the PortalInfo
object stored into the repo
- * and return the url it represents.
- *
- * @return the URL represented by the PortalInfo
object.
- */
- @Override
- public final String getPortalUrlBase() {
- PortalInfo info;
-
- try {
- // Prefer HIRS to use HTTPS, but check HTTP if needed
- info = getPortalInfo(PortalScheme.HTTPS);
- if (info == null) {
- info = getPortalInfo(PortalScheme.HTTP);
- }
- } catch (Exception e) {
- info = null;
- }
-
- // The default base url
- String url = "Your_HIRS_Portal/";
-
- try {
- if (info != null && info.getIpAddress() != null) {
- String context = "/";
- if (info.getContextName() != null) {
- context += info.getContextName() + "/";
- }
- URI uri = new URI(info.getSchemeName().toLowerCase(), null,
- info.getIpAddress().getHostName(), info.getPort(),
- context, null, null);
- url = uri.toString();
- }
- } catch (URISyntaxException e) {
- LOGGER.error("DBPortalInfoManager.getPortalUrlBase():"
- + " Could not create the URI. Returning the default.");
- }
-
- return url;
- }
-}
diff --git a/HIRS_AttestationCA/src/main/java/hirs/attestationca/servicemanager/DBReportManager.java b/HIRS_AttestationCA/src/main/java/hirs/attestationca/servicemanager/DBReportManager.java
deleted file mode 100755
index 6d9f7bf3..00000000
--- a/HIRS_AttestationCA/src/main/java/hirs/attestationca/servicemanager/DBReportManager.java
+++ /dev/null
@@ -1,195 +0,0 @@
-package hirs.attestationca.servicemanager;
-
-import hirs.data.persist.Report;
-import hirs.persist.DBManagerException;
-import hirs.persist.ReportManagerException;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.logging.log4j.Logger;
-import org.hibernate.criterion.Conjunction;
-import org.hibernate.criterion.Disjunction;
-import org.hibernate.criterion.MatchMode;
-import org.hibernate.criterion.Restrictions;
-import org.springframework.stereotype.Service;
-
-import javax.persistence.EntityManager;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-import static org.apache.logging.log4j.LogManager.getLogger;
-import static org.hibernate.criterion.Restrictions.ilike;
-
-/**
- * This class defines a ReportManager
that stores the reports in a
- * database.
- */
-@Service
-public class DBReportManager extends DBManagerDBReportManager
that uses the provided sessionFactory
- * to interact with a database.
- *
- * @param em entity manager used to access database connections
- */
- public DBReportManager(final EntityManager em) {
- super(Report.class, em);
- }
-
- /**
- * Saves the Report
in the database and returns it.
- *
- * @param report
- * report to save
- * @return Report
that was saved
- * @throws hirs.persist.DBManagerException
- * if Report has previously been saved or an error occurs while
- * trying to save it to the database
- */
- @Override
- public final Report saveReport(final Report report)
- throws DBManagerException {
- LOGGER.debug("Saving report: {}", report);
- try {
- return super.save(report);
- } catch (DBManagerException e) {
- throw new ReportManagerException(e);
- }
- }
-
- /**
- * Returns a list of all Report
s of type clazz
.
- * This searches through the database for this information.
- *
- * All Reports will be returned without measurement records as they are
- * lazily loaded for performance. If the records of a report are necessary,
- * a method will need to be written to return the records inside of a
- * transaction.
- *
- * @param clazz
- * class type of Report
s to return (may be null)
- * @return list of Report
s
- * @throws ReportManagerException
- * if unable to search the database
- */
- @Override
- public final ListReport
from the database. This searches the
- * database for an entry whose id matches id
. It then
- * reconstructs a Report
object from the database entry.
- *
- * Note: IMAMeasurementRecords
are lazily loaded so the object
- * returned will not contain them for performance purposes. If the whole
- * report needs to be retrieved a method will need to be written to return
- * the records inside of a transaction.
- *
- * @param id id of the report
- * @return report
- * @throws ReportManagerException
- * if unable to search the database or recreate the Report
- */
- @Override
- public final Report getReport(final UUID id) throws ReportManagerException {
- LOGGER.debug("getting report: {}", id);
- try {
- return super.get(id);
- } catch (DBManagerException e) {
- throw new ReportManagerException(e);
- }
- }
-
- @Override
- public final Report getCompleteReport(final UUID id) throws ReportManagerException {
- LOGGER.debug("getting full report: {}", id);
- try {
- return super.getAndLoadLazyFields(id, true);
- } catch (DBManagerException e) {
- throw new ReportManagerException(e);
- }
- }
-
- /**
- * Updates a Report
. This updates the database entries
- * to reflect the new values that should be set.
- *
- * @param report
- * report to be updated
- * @throws ReportManagerException
- * if Report an error occurs while updating the report or
- * while trying to save it to the database
- */
- @Override
- public void updateReport(final Report report) throws ReportManagerException {
- LOGGER.debug("updating report: {}", report);
- try {
- super.update(report);
- } catch (DBManagerException e) {
- throw new ReportManagerException(e);
- }
- }
-
- /**
- * Deletes the Report
from the database. This removes all of
- * the database entries that stored information with regards to the this
- * Report
.
- *
- * If the Report
is referenced by any other tables then this
- * will throw a ReportManagerException
.
- *
- * @param id
- * id of the Report
to delete
- * @return true if successfully found and deleted the Report
- * @throws ReportManagerException
- * if unable to find the baseline or delete it from the
- * database
- */
- @Override
- public final boolean deleteReport(final UUID id)
- throws ReportManagerException {
- LOGGER.debug("deleting baseline: {}", id);
- try {
- return false; //super.delete(id);
- } catch (DBManagerException e) {
- throw new ReportManagerException(e);
- }
- }
-
- private Conjunction buildImaRecordSearchFilter(final String search, final
- MapReportRequestStateManager
that stores ReportRequestStates in a
- * database.
- */
-@Service
-public class DBReportRequestStateManager extends DBManagerDBReportRequestStateManager
that uses the default database. The
- * default database is used to store all of the ReportRequestState
s.
- *
- * @param em entity manager used to access database connections
- */
- public DBReportRequestStateManager(final EntityManager em) {
- super(ReportRequestState.class, em);
- }
-
- /**
- * Retrieves the state of a device, if the device and state exists.
- *
- * @param device the Device whose state should be retrieved
- * @return the associated ReportRequestState, or null if no associated state was found
- */
- @Override
- public final ReportRequestState getState(final Device device) {
- CriteriaBuilder builder = this.getSession().getCriteriaBuilder();
- Root