use of com.netsuite.webservices.v2016_2.platform.core.CustomizationRef in project components by Talend.
the class CustomMetaDataRetrieverImpl method retrieveCustomizations.
public List<?> retrieveCustomizations(final List<NsRef> nsCustomizationRefs) throws NetSuiteException {
if (nsCustomizationRefs.isEmpty()) {
return Collections.emptyList();
}
final List<CustomizationRef> customizationRefs = new ArrayList<>(nsCustomizationRefs.size());
for (NsRef nsCustomizationRef : nsCustomizationRefs) {
CustomizationRef customizationRef = new CustomizationRef();
customizationRef.setType(RecordType.fromValue(nsCustomizationRef.getType()));
customizationRef.setScriptId(nsCustomizationRef.getScriptId());
customizationRef.setInternalId(nsCustomizationRef.getInternalId());
customizationRefs.add(customizationRef);
}
List<NsReadResponse<Record>> result = clientService.execute(new NetSuiteClientService.PortOperation<List<NsReadResponse<Record>>, NetSuitePortType>() {
@Override
public List<NsReadResponse<Record>> execute(NetSuitePortType port) throws Exception {
logger.debug("Retrieving customizations: {}", nsCustomizationRefs.size());
StopWatch stopWatch = new StopWatch();
try {
stopWatch.start();
final GetListRequest request = new GetListRequest();
request.getBaseRef().addAll(customizationRefs);
return toNsReadResponseList(port.getList(request).getReadResponseList());
} finally {
stopWatch.stop();
logger.debug("Retrieved customizations: {}, {}", nsCustomizationRefs.size(), stopWatch);
}
}
});
if (!result.isEmpty()) {
List<Record> customizations = new ArrayList<>(result.size());
for (NsReadResponse<Record> response : result) {
if (response.getStatus().isSuccess()) {
customizations.add(response.getRecord());
} else {
throw new NetSuiteException("Retrieving of customization was not successful: " + response.getStatus());
}
}
return customizations;
} else {
return Collections.emptyList();
}
}
Aggregations