use of com.vmware.flowgate.common.model.FacilitySoftwareConfig in project flowgate by vmware.
the class FacilitySoftwareController method getFacilitySoftwareConfigByID.
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
public FacilitySoftwareConfig getFacilitySoftwareConfigByID(@PathVariable String id) {
Optional<FacilitySoftwareConfig> serverOptional = repository.findById(id);
FacilitySoftwareConfig server = serverOptional.get();
server.setPassword(null);
return server;
}
use of com.vmware.flowgate.common.model.FacilitySoftwareConfig in project flowgate by vmware.
the class FacilitySoftwareController method updateStatus.
// only modify the status of integration,and not verify information of server.
@ResponseStatus(HttpStatus.OK)
@RequestMapping(value = "/status", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE)
public void updateStatus(@RequestBody FacilitySoftwareConfig server) {
Optional<FacilitySoftwareConfig> oldServerOptional = repository.findById(server.getId());
if (!oldServerOptional.isPresent()) {
throw WormholeRequestException.NotFound("FacilitySoftwareConfig", "id", server.getId());
}
FacilitySoftwareConfig old = oldServerOptional.get();
old.setIntegrationStatus(server.getIntegrationStatus());
repository.save(old);
}
use of com.vmware.flowgate.common.model.FacilitySoftwareConfig in project flowgate by vmware.
the class CustomerAdapterJobDispatcher method execute.
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
restClient.setServiceKey(serviceKeyConfig.getServiceKey());
Map<String, FacilityAdapter> facilityAdapterMap = initFacilityAdapterMap();
if (facilityAdapterMap.isEmpty()) {
return;
}
List<FacilitySoftwareConfig> facilityIntegrations = getIntegrations();
if (facilityIntegrations.isEmpty()) {
return;
}
String execountString = template.opsForValue().get(EventMessageUtil.CUSTOMER_ADAPTER_EXECOUNT);
if (execountString == null || "".equals(execountString)) {
execountString = "0";
}
long execount = Long.valueOf(execountString);
execount++;
template.opsForValue().set(EventMessageUtil.CUSTOMER_ADAPTER_EXECOUNT, String.valueOf(execount));
for (FacilitySoftwareConfig integration : facilityIntegrations) {
String subcategory = integration.getSubCategory();
FacilityAdapter adapter = facilityAdapterMap.get(subcategory);
sendMessage(execount, integration, adapter);
}
logger.info("Send customer adapter job finished");
}
use of com.vmware.flowgate.common.model.FacilitySoftwareConfig in project flowgate by vmware.
the class CustomerAdapterJobDispatcher method sendMessage.
private void sendMessage(long execount, FacilitySoftwareConfig integration, FacilityAdapter adapter) {
String topic = adapter.getTopic();
String queue = adapter.getQueueName();
List<AdapterJobCommand> commands = adapter.getCommands();
for (AdapterJobCommand command : commands) {
int executeCycle = command.getTriggerCycle() / EVERY_CYCLE;
if (execount % executeCycle == 0) {
try {
template.opsForList().leftPushAll(queue, EventMessageUtil.generateFacilityMessageListByType(null, command.getCommand(), new FacilitySoftwareConfig[] { integration }));
EventMessage message = EventMessageUtil.createEventMessage(null, null, NODIFY_MESSAGE);
publisher.publish(topic, EventMessageUtil.convertEventMessageAsString(message));
logger.info("Send " + command.getCommand() + " of " + integration.getName() + " success");
} catch (IOException e) {
logger.error("Failed to send out message", e);
}
}
}
}
use of com.vmware.flowgate.common.model.FacilitySoftwareConfig in project flowgate by vmware.
the class AdapterJobService method executeAsync.
@Override
public void executeAsync(EventMessage message) {
// TODO Auto-generated method stub
logger.info("message received");
String messageString = null;
while ((messageString = template.opsForList().rightPop(queueName)) != null) {
EventMessage payloadMessage = null;
try {
payloadMessage = mapper.readValue(messageString, EventMessageImpl.class);
} catch (IOException e) {
logger.error("Cannot process message", e);
}
if (payloadMessage == null) {
continue;
}
FacilitySoftwareConfig integration = null;
try {
integration = mapper.readValue(payloadMessage.getContent(), FacilitySoftwareConfig.class);
} catch (IOException e) {
logger.error("Cannot process message", e);
}
if (null == integration) {
continue;
}
if (!integration.checkIsActive()) {
continue;
}
for (EventUser payloadCommand : payloadMessage.getTarget().getUsers()) {
excuteJob(payloadCommand.getId(), integration);
}
}
}
Aggregations