forked from opensearch-project/security-analytics
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
renamed source config dao to service and service to management service (
opensearch-project#1052) Signed-off-by: Joanne Wang <jowg@amazon.com>
- Loading branch information
1 parent
4fc0d84
commit cf2c051
Showing
7 changed files
with
316 additions
and
320 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
216 changes: 0 additions & 216 deletions
216
src/main/java/org/opensearch/securityanalytics/threatIntel/dao/SATIFSourceConfigDao.java
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
...tel/sacommons/TIFSourceConfigService.java → ...ons/TIFSourceConfigManagementService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
119 changes: 119 additions & 0 deletions
119
.../opensearch/securityanalytics/threatIntel/service/SATIFSourceConfigManagementService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
package org.opensearch.securityanalytics.threatIntel.service; | ||
|
||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.opensearch.common.inject.Inject; | ||
import org.opensearch.common.unit.TimeValue; | ||
import org.opensearch.core.action.ActionListener; | ||
import org.opensearch.jobscheduler.spi.LockModel; | ||
import org.opensearch.securityanalytics.threatIntel.common.TIFJobState; | ||
import org.opensearch.securityanalytics.threatIntel.common.TIFLockService; | ||
import org.opensearch.securityanalytics.threatIntel.model.SATIFSourceConfig; | ||
import org.opensearch.securityanalytics.threatIntel.model.SATIFSourceConfigDto; | ||
|
||
/** | ||
* Service class for threat intel feed source config object | ||
*/ | ||
public class SATIFSourceConfigManagementService { | ||
private static final Logger log = LogManager.getLogger(SATIFSourceConfigManagementService.class); | ||
private final SATIFSourceConfigService SaTifSourceConfigService; | ||
private final TIFLockService lockService; | ||
|
||
/** | ||
* Default constructor | ||
* @param SaTifSourceConfigService the tif source config dao | ||
* @param lockService the lock service | ||
*/ | ||
@Inject | ||
public SATIFSourceConfigManagementService( | ||
final SATIFSourceConfigService SaTifSourceConfigService, | ||
final TIFLockService lockService | ||
) { | ||
this.SaTifSourceConfigService = SaTifSourceConfigService; | ||
this.lockService = lockService; | ||
} | ||
|
||
/** | ||
* | ||
* Creates the job index if it doesn't exist and indexes the tif source config object | ||
* | ||
* @param SaTifSourceConfigDto the tif source config dto | ||
* @param lock the lock object | ||
* @param indexTimeout the index time out | ||
* @param listener listener that accepts a tif source config if successful | ||
*/ | ||
public void createIndexAndSaveTIFSourceConfig( | ||
final SATIFSourceConfigDto SaTifSourceConfigDto, | ||
final LockModel lock, | ||
final TimeValue indexTimeout, | ||
final ActionListener<SATIFSourceConfig> listener | ||
) { | ||
try { | ||
SATIFSourceConfig SaTifSourceConfig = convertToSATIFConfig(SaTifSourceConfigDto); | ||
SaTifSourceConfig.setState(TIFJobState.AVAILABLE); | ||
SaTifSourceConfigService.indexTIFSourceConfig(SaTifSourceConfig, indexTimeout, lock, new ActionListener<>() { | ||
@Override | ||
public void onResponse(SATIFSourceConfig response) { | ||
SaTifSourceConfig.setId(response.getId()); | ||
SaTifSourceConfig.setVersion(response.getVersion()); | ||
listener.onResponse(SaTifSourceConfig); | ||
} | ||
@Override | ||
public void onFailure(Exception e) { | ||
listener.onFailure(e); | ||
} | ||
}); | ||
} catch (Exception e) { | ||
listener.onFailure(e); | ||
} | ||
} | ||
|
||
public void getTIFSourceConfig( | ||
final String SaTifSourceConfigId, | ||
final Long version, | ||
final ActionListener<SATIFSourceConfig> listener | ||
) { | ||
try { | ||
SaTifSourceConfigService.getTIFSourceConfig(SaTifSourceConfigId, version, new ActionListener<>() { | ||
@Override | ||
public void onResponse(SATIFSourceConfig SaTifSourceConfig) { | ||
listener.onResponse(SaTifSourceConfig); | ||
} | ||
@Override | ||
public void onFailure(Exception e) { | ||
listener.onFailure(e); | ||
} | ||
}); | ||
} catch (Exception e) { | ||
listener.onFailure(e); | ||
} | ||
} | ||
|
||
/** | ||
* Converts the DTO to entity | ||
* @param SaTifSourceConfigDto | ||
* @return SaTifSourceConfig | ||
*/ | ||
public SATIFSourceConfig convertToSATIFConfig(SATIFSourceConfigDto SaTifSourceConfigDto) { | ||
return new SATIFSourceConfig( | ||
SaTifSourceConfigDto.getId(), | ||
SaTifSourceConfigDto.getVersion(), | ||
SaTifSourceConfigDto.getName(), | ||
SaTifSourceConfigDto.getFeedFormat(), | ||
SaTifSourceConfigDto.getFeedType(), | ||
SaTifSourceConfigDto.getCreatedByUser(), | ||
SaTifSourceConfigDto.getCreatedAt(), | ||
SaTifSourceConfigDto.getEnabledTime(), | ||
SaTifSourceConfigDto.getLastUpdateTime(), | ||
SaTifSourceConfigDto.getSchedule(), | ||
SaTifSourceConfigDto.getState(), | ||
SaTifSourceConfigDto.getRefreshType(), | ||
SaTifSourceConfigDto.getLastRefreshedTime(), | ||
SaTifSourceConfigDto.getLastRefreshedUser(), | ||
SaTifSourceConfigDto.isEnabled(), | ||
SaTifSourceConfigDto.getIocMapStore(), | ||
SaTifSourceConfigDto.getIocTypes() | ||
); | ||
} | ||
|
||
} |
Oops, something went wrong.