-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from KPMP/develop
Merge for v 3.0
- Loading branch information
Showing
6 changed files
with
113 additions
and
3 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
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,34 @@ | ||
package org.kpmp.cache; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.cache.CacheManager; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestMethod; | ||
import org.springframework.web.bind.annotation.ResponseBody; | ||
|
||
import java.util.Collection; | ||
|
||
@Controller | ||
public class CacheController { | ||
|
||
@Autowired | ||
private CacheManager cacheManager; | ||
|
||
@RequestMapping(value = "/v1/clearCache", method = RequestMethod.GET) | ||
public @ResponseBody CacheResponse clearCache(){ | ||
Collection<String> cacheNames = cacheManager.getCacheNames(); | ||
CacheResponse clearCacheResponse = new CacheResponse(); | ||
clearCacheResponse.setMessage("Caches successfully cleared!"); | ||
for(String name:cacheNames){ | ||
if (cacheManager.getCache(name) != null) { | ||
cacheManager.getCache(name).clear(); | ||
} else { | ||
clearCacheResponse.setMessage("There was a problem getting the " + name + " cache."); | ||
break; | ||
} | ||
} | ||
clearCacheResponse.setCacheNames(cacheNames); | ||
return clearCacheResponse; | ||
} | ||
} |
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,25 @@ | ||
package org.kpmp.cache; | ||
|
||
import java.util.Collection; | ||
|
||
public class CacheResponse { | ||
|
||
private String message; | ||
private Collection<String> cacheNames; | ||
|
||
public String getMessage() { | ||
return message; | ||
} | ||
|
||
public void setMessage(String message) { | ||
this.message = message; | ||
} | ||
|
||
public Collection<String> getCacheNames() { | ||
return cacheNames; | ||
} | ||
|
||
public void setCacheNames(Collection<String> cacheNames) { | ||
this.cacheNames = cacheNames; | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
src/main/java/org/kpmp/stateManager/DluPackageInventoryService.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,40 @@ | ||
package org.kpmp.stateManager; | ||
|
||
import org.apache.commons.logging.Log; | ||
import org.apache.commons.logging.LogFactory; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.web.client.RestTemplate; | ||
|
||
import java.util.HashMap; | ||
|
||
@Service | ||
public class DluPackageInventoryService { | ||
|
||
@Value("${data-manager.service.host}") | ||
private String dataManagerHost; | ||
@Value("${data-manager.service.endpoint}") | ||
private String dataManagerEndpoint; | ||
private RestTemplate restTemplate; | ||
|
||
private static final Log log = LogFactory.getLog(DluPackageInventoryService.class); | ||
|
||
@Autowired | ||
public DluPackageInventoryService(RestTemplate restTemplate) { | ||
this.restTemplate = restTemplate; | ||
} | ||
|
||
public String setPackageInError(String packageId) { | ||
HashMap payload = new HashMap<>(); | ||
payload.put("dlu_error", true); | ||
String retPackageId = null; | ||
String url = dataManagerHost + dataManagerEndpoint + "/package/" + packageId; | ||
try { | ||
retPackageId = restTemplate.postForObject(url, payload, String.class); | ||
} catch (Exception e) { | ||
log.error("URI: " + url + " | PKGID: " + packageId + " | MSG: Setting DMD package error"); | ||
} | ||
return retPackageId; | ||
} | ||
} |
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
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