* @param oemName
* @return
*/
public String deleteMle(String mleName, String mleVersion, String osName, String osVersion, String oemName) {
try {
TblMle tblMle = getMleDetails(mleName, mleVersion, osName, osVersion, oemName);
if (tblMle == null) {
throw new ASException(ErrorCode.WS_MLE_DOES_NOT_EXIST, mleName, mleVersion);
}
Collection<TblHosts> tblHostsCollection;
if (oemName == null || oemName.isEmpty()) {
tblHostsCollection = tblMle.getTblHostsCollection();
} else {
tblHostsCollection = tblMle.getTblHostsCollection1();
}
if( tblHostsCollection != null ) {
log.info(String.format("MLE '%s' is currently associated with '%d' hosts. ", mleName, tblHostsCollection.size()));
if (!tblHostsCollection.isEmpty()) {
throw new ASException(ErrorCode.WS_MLE_ASSOCIATION_EXISTS, mleName, mleVersion, tblHostsCollection.size());
}
}
for (TblPcrManifest manifest : tblMle.getTblPcrManifestCollection()) {
pcrManifestJpaController.destroy(manifest.getId());
}
// We also need to delete entries in the MleSource table for the MLE. This table would store the host
// name that was used to white list the MLE.
deleteMleSource(mleName, mleVersion, osName, osVersion, oemName);
mleJpaController.destroy(tblMle.getId());
} catch (ASException ase) {
throw ase;
} catch (Exception e) {
throw new ASException(e);