use of com.intel.mtwilson.as.controller.TblHostsJpaController in project OpenAttestation by OpenAttestation.
the class HostBO method queryForHosts.
/**
* Author: Sudhir
*
* Searches for the hosts using the criteria specified.
*
* @param searchCriteria: If in case the user has not provided any search criteria, then all the hosts
* would be returned back to the caller
* @return
*/
public List<TxtHostRecord> queryForHosts(String searchCriteria) {
try {
TblHostsJpaController tblHostsJpaController = new TblHostsJpaController(getEntityManagerFactory());
List<TxtHostRecord> txtHostList = new ArrayList<TxtHostRecord>();
List<TblHosts> tblHostList;
if (searchCriteria != null && !searchCriteria.isEmpty()) {
log.info("searchCriteria is not null -- calling tblHostsJpaController.findHostsByNameSearchCriteria(searchCriteria)");
tblHostList = tblHostsJpaController.findHostsByNameSearchCriteria(searchCriteria);
log.info(new Integer(tblHostList.size()).toString());
} else {
log.info("calling tblHostsJpaController.findTblHostsEntities()");
tblHostList = tblHostsJpaController.findTblHostsEntities();
log.info(new Integer(tblHostList.size()).toString());
}
// if (tblHostList != null) {
log.info(String.format("Found [%d] host results for search criteria [%s]", tblHostList.size(), searchCriteria));
for (TblHosts tblHosts : tblHostList) {
TxtHostRecord hostObj = createTxtHostFromDatabaseRecord(tblHosts);
txtHostList.add(hostObj);
}
return txtHostList;
} catch (ASException e) {
throw e;
} catch (CryptographyException e) {
throw new ASException(e, ErrorCode.AS_ENCRYPTION_ERROR, e.getCause() == null ? e.getMessage() : e.getCause().getMessage());
} catch (Exception e) {
throw new ASException(e);
}
}
use of com.intel.mtwilson.as.controller.TblHostsJpaController in project OpenAttestation by OpenAttestation.
the class HostBO method saveHostInDatabase.
private void saveHostInDatabase(TblHosts newRecordWithTlsPolicyAndKeystore, TxtHost host, String certificate, String location, HashMap<String, ? extends IManifest> pcrMap, List<TblHostSpecificManifest> tblHostSpecificManifests, TblMle biosMleId, TblMle vmmMleId) throws CryptographyException, IOException {
// Building objects and validating that manifests are created ahead of create of host
// new TblHosts();
TblHosts tblHosts = newRecordWithTlsPolicyAndKeystore;
log.info("saveHostInDatabase with tls policy {} and keystore size {}", tblHosts.getTlsPolicyName(), tblHosts.getTlsKeystore() == null ? "null" : tblHosts.getTlsKeystore().length);
log.error("saveHostInDatabase with tls policy {} and keystore size {}", tblHosts.getTlsPolicyName(), tblHosts.getTlsKeystore() == null ? "null" : tblHosts.getTlsKeystore().length);
TblHostsJpaController hostController = getHostsJpaController();
tblHosts.setAddOnConnectionInfo(host.getAddOn_Connection_String());
tblHosts.setBiosMleId(biosMleId);
tblHosts.setDescription(host.getDescription());
tblHosts.setEmail(host.getEmail());
if (host.getIPAddress() != null) {
// datatype.IPAddress
tblHosts.setIPAddress(host.getIPAddress().toString());
}
// datatype.Hostname
tblHosts.setName(host.getHostName().toString());
if (host.getPort() != null) {
tblHosts.setPort(host.getPort());
}
tblHosts.setVmmMleId(vmmMleId);
// null is ok
tblHosts.setAIKCertificate(certificate);
if (location != null) {
tblHosts.setLocation(location);
}
tblHosts.setBios_mle_uuid_hex(biosMleId.getUuid_hex());
tblHosts.setVmm_mle_uuid_hex(vmmMleId.getUuid_hex());
tblHosts.setUuid_hex(new UUID().toString());
// create the host
log.debug("COMMITING NEW HOST DO DATABASE");
hostController.create(tblHosts);
log.debug("Save host specific manifest if any");
createHostSpecificManifest(tblHostSpecificManifests, tblHosts);
}
Aggregations