use of com.vmware.flowgate.common.model.FacilitySoftwareConfig in project flowgate by vmware.
the class FacilitySoftwareController method queryFacilitySoftwareConfigByPage.
@RequestMapping(value = "/page/{pageNumber}/pagesize/{pageSize}", method = RequestMethod.GET)
public Page<FacilitySoftwareConfig> queryFacilitySoftwareConfigByPage(@PathVariable("pageNumber") int currentPage, @PathVariable("pageSize") int pageSize, HttpServletRequest request, @RequestParam(required = false) SoftwareType[] softwaretypes) {
WormholeUserDetails user = accessTokenService.getCurrentUser(request);
if (currentPage < FlowgateConstant.defaultPageNumber) {
currentPage = FlowgateConstant.defaultPageNumber;
} else if (pageSize <= 0) {
pageSize = FlowgateConstant.defaultPageSize;
} else if (pageSize > FlowgateConstant.maxPageSize) {
pageSize = FlowgateConstant.maxPageSize;
}
PageRequest pageRequest = PageRequest.of(currentPage - 1, pageSize);
Optional<WormholeUser> currentUserOptional = userRepository.findById(user.getUserId());
WormholeUser currentUser = currentUserOptional.get();
Page<FacilitySoftwareConfig> result = null;
List<String> types = new ArrayList<String>();
if (softwaretypes != null && softwaretypes.length > 0) {
for (SoftwareType type : softwaretypes) {
types.add(type.name());
}
}
if (currentUser.getRoleNames().contains(FlowgateConstant.Role_admin)) {
if (types.isEmpty()) {
result = repository.findAll(pageRequest);
} else {
result = repository.findAllByTypeIn(types, pageRequest);
}
} else {
if (types.isEmpty()) {
result = repository.findALlByUserId(user.getUserId(), pageRequest);
} else {
result = repository.findAllByUserIdAndTypeIn(user.getUserId(), types, pageRequest);
}
}
if (result != null) {
for (FacilitySoftwareConfig facilitySoftwareConfig : result.getContent()) {
facilitySoftwareConfig.setPassword(null);
}
}
return result;
}
use of com.vmware.flowgate.common.model.FacilitySoftwareConfig in project flowgate by vmware.
the class FacilitySoftwareController method getInternalFacilitySoftwareConfigByID.
@RequestMapping(value = "/internal/{id}", method = RequestMethod.GET)
public FacilitySoftwareConfig getInternalFacilitySoftwareConfigByID(@PathVariable String id) {
Optional<FacilitySoftwareConfig> serverOptional = repository.findById(id);
FacilitySoftwareConfig server = serverOptional.get();
decryptServerPassword(server);
return server;
}
use of com.vmware.flowgate.common.model.FacilitySoftwareConfig in project flowgate by vmware.
the class AggregatorServiceTest method getFacilitySoftware.
private ResponseEntity<FacilitySoftwareConfig[]> getFacilitySoftware() {
FacilitySoftwareConfig[] facilitySoftwareConfigs = new FacilitySoftwareConfig[1];
FacilitySoftwareConfig facilitySoftwareConfig = new FacilitySoftwareConfig();
facilitySoftwareConfig.setId("QWENBADJWRTUIJWJAYQY");
facilitySoftwareConfig.setPassword("O75xginpkAD748w=Lc20CrTzd1lEpvDTdJqH5IXBZTb5gYp7P8awDAs19F0=");
facilitySoftwareConfig.setServerURL("https://10.161.71.133");
facilitySoftwareConfig.setName("powerIQ-1");
facilitySoftwareConfig.setVerifyCert(false);
IntegrationStatus integrationStatus = new IntegrationStatus();
integrationStatus.setRetryCounter(0);
integrationStatus.setDetail("");
integrationStatus.setStatus(IntegrationStatus.Status.ACTIVE);
facilitySoftwareConfig.setIntegrationStatus(integrationStatus);
facilitySoftwareConfig.setUserName("admin");
facilitySoftwareConfig.setType(FacilitySoftwareConfig.SoftwareType.PowerIQ);
facilitySoftwareConfig.setUserId("e1edfv8953002379827896a1aaiqoose");
facilitySoftwareConfigs[0] = facilitySoftwareConfig;
return new ResponseEntity<>(facilitySoftwareConfigs, HttpStatus.OK);
}
use of com.vmware.flowgate.common.model.FacilitySoftwareConfig in project flowgate by vmware.
the class MessageProcessingTest method testExecuteCustomerSendMessageJob2.
@Test
public void testExecuteCustomerSendMessageJob2() throws JobExecutionException {
FacilitySoftwareConfig fac1 = createFacilitySoftware();
String unique_value1 = UUID.randomUUID().toString();
fac1.setSubCategory("OtherDCIM_" + unique_value1);
when(restClient.getFacilitySoftwareInternalByType(FacilitySoftwareConfig.SoftwareType.OtherDCIM)).thenReturn(getFacilitySoftwareByType(fac1));
when(restClient.getFacilitySoftwareInternalByType(FacilitySoftwareConfig.SoftwareType.OtherCMDB)).thenReturn(new ResponseEntity<FacilitySoftwareConfig[]>(new FacilitySoftwareConfig[0], HttpStatus.OK));
FacilityAdapter adapter = new FacilityAdapter();
adapter.setSubCategory("OtherDCIM_" + unique_value1);
AdapterJobCommand command1 = new AdapterJobCommand();
command1.setCommand("syncmetadata");
command1.setTriggerCycle(20);
List<AdapterJobCommand> commands = new ArrayList<AdapterJobCommand>();
commands.add(command1);
adapter.setCommands(commands);
adapter.setTopic(unique_value1);
adapter.setQueueName(unique_value1 + ":joblist");
FacilityAdapter[] adapters = new FacilityAdapter[1];
adapters[0] = adapter;
when(restClient.getAllCustomerFacilityAdapters()).thenReturn(new ResponseEntity<FacilityAdapter[]>(new FacilityAdapter[0], HttpStatus.OK));
customerAdapter.execute(null);
}
use of com.vmware.flowgate.common.model.FacilitySoftwareConfig in project flowgate by vmware.
the class MessageProcessingTest method testExecuteCustomerSendMessageJob3.
@Test
public void testExecuteCustomerSendMessageJob3() throws JobExecutionException {
ListOperations<String, String> listOp = Mockito.mock(ListOperations.class);
ValueOperations<String, String> valueOp = Mockito.mock(ValueOperations.class);
when(template.opsForList()).thenReturn(listOp);
when(listOp.leftPushAll(anyString(), anyString())).thenReturn(1L);
when(template.hasKey(anyString())).thenReturn(true);
when(template.opsForValue()).thenReturn(valueOp);
when(valueOp.increment(anyString())).thenReturn(4l);
FacilitySoftwareConfig fac1 = createFacilitySoftware();
String unique_value1 = UUID.randomUUID().toString();
fac1.setSubCategory("OtherDCIM_" + unique_value1);
when(restClient.getFacilitySoftwareInternalByType(FacilitySoftwareConfig.SoftwareType.OtherDCIM)).thenReturn(new ResponseEntity<FacilitySoftwareConfig[]>(new FacilitySoftwareConfig[0], HttpStatus.OK));
when(restClient.getFacilitySoftwareInternalByType(FacilitySoftwareConfig.SoftwareType.OtherCMDB)).thenReturn(new ResponseEntity<FacilitySoftwareConfig[]>(new FacilitySoftwareConfig[0], HttpStatus.OK));
FacilityAdapter adapter = new FacilityAdapter();
adapter.setSubCategory("OtherDCIM_" + unique_value1);
AdapterJobCommand command1 = new AdapterJobCommand();
command1.setCommand("syncmetadata");
command1.setTriggerCycle(20);
List<AdapterJobCommand> commands = new ArrayList<AdapterJobCommand>();
commands.add(command1);
adapter.setCommands(commands);
adapter.setTopic(unique_value1);
adapter.setQueueName(unique_value1 + ":joblist");
FacilityAdapter[] adapters = new FacilityAdapter[1];
adapters[0] = adapter;
when(restClient.getAllCustomerFacilityAdapters()).thenReturn(new ResponseEntity<FacilityAdapter[]>(adapters, HttpStatus.OK));
customerAdapter.execute(null);
}
Aggregations