本文整理汇总了Java中org.edgexfoundry.exception.controller.NotFoundException类的典型用法代码示例。如果您正苦于以下问题:Java NotFoundException类的具体用法?Java NotFoundException怎么用?Java NotFoundException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NotFoundException类属于org.edgexfoundry.exception.controller包,在下文中一共展示了NotFoundException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: delete
import org.edgexfoundry.exception.controller.NotFoundException; //导入依赖的package包/类
/**
* Delete an event and all its readings given its database generated id. NotFoundException (HTTP
* 404) if the event cannot be found by id. ServiceException (HTTP 503) for unknown or
* unanticipated issues.
*
* @param id database id for the event
* @return boolean on success of deletion request
* @throws ServiceException (HTTP 503) for unknown or unanticipated issues
* @throws NotFoundException (HTTP 404) when the event cannot be found by the id
*/
@RequestMapping(value = "/id/{id}", method = RequestMethod.DELETE)
@Override
public boolean delete(@PathVariable String id) {
try {
Event event = eventRepos.findOne(id);
if (event != null) {
deleteEvent(event);
return true;
} else {
logger.error("Request to delete with non-existent event: " + id);
throw new NotFoundException(Event.class.toString(), id);
}
} catch (NotFoundException nE) {
throw nE;
} catch (Exception e) {
logger.error("Error removing an event: " + e.getMessage());
throw new ServiceException(e);
}
}
示例2: checkDevice
import org.edgexfoundry.exception.controller.NotFoundException; //导入依赖的package包/类
private void checkDevice(String deviceId) {
if (deviceId == null) {
logger.error("Event must be associated to a device");
throw new DataValidationException("Event must be associated to a device");
}
try {
if (metaCheck && (deviceClient.deviceForName(deviceId) == null
&& deviceClient.device(deviceId) == null)) {
logger.error("No device found for associated device id");
throw new NotFoundException(Device.class.toString(), deviceId);
}
} catch (NotFoundException nE) {
throw nE;
} catch (Exception e) {
logger.error(
"Unknown issue when trying to find associated device for: " + deviceId + e.getMessage());
throw new ServiceException(e);
}
}
示例3: delete
import org.edgexfoundry.exception.controller.NotFoundException; //导入依赖的package包/类
/**
* Delete the reading from persistent storage. NotFoundException (HTTP 404) if the reading cannot
* be found by id. ServiceException (HTTP 503) for unknown or unanticipated issues.
*
* @param id - database generated id of the reading to be deleted
* @return boolean indicating success of the delete operation
* @throws ServiceException (HTTP 503) for unknown or unanticipated issues
* @throws NotFoundException (HTTP 404) if the reading cannot be located by the provided id in the
* reading.
*/
@RequestMapping(value = "/id/{id}", method = RequestMethod.DELETE)
@Override
public boolean delete(@PathVariable String id) {
try {
Reading reading = readingRepos.findOne(id);
if (reading != null) {
readingRepos.delete(reading);
return true;
} else {
logger.error("Request to delete with non-existent reading: " + id);
throw new NotFoundException(Reading.class.toString(), id);
}
} catch (NotFoundException nE) {
throw nE;
} catch (Exception e) {
logger.error("Error removing reading: " + e.getMessage());
throw new ServiceException(e);
}
}
示例4: valueDescriptor
import org.edgexfoundry.exception.controller.NotFoundException; //导入依赖的package包/类
/**
* Fetch a specific ValueDescriptor by its database generated id. NotFoundException (HTTP 404) if
* no value descriptor can be found by the id provided. ServcieException (HTTP 503) for unknown or
* unanticipated issues
*
* @param String ValueDescriptor id (ObjectId)
*
* @return ValueDescriptor
* @throws ServcieException (HTTP 503) for unknown or unanticipated issues NotFoundException (HTTP
* 404) if not found by id.
*/
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@Override
public ValueDescriptor valueDescriptor(@PathVariable String id) {
try {
ValueDescriptor valuDes = valDescRepos.findOne(id);
if (valuDes == null)
throw new NotFoundException(ValueDescriptor.class.toString(), id);
return valuDes;
} catch (NotFoundException nfE) {
throw nfE;
} catch (Exception e) {
logger.error(ERR_GETTING + e.getMessage());
throw new ServiceException(e);
}
}
示例5: valueDescriptorByName
import org.edgexfoundry.exception.controller.NotFoundException; //导入依赖的package包/类
/**
* Return ValueDescriptor object with given name. ServcieException (HTTP 503) for unknown or
* unanticipated issues.
*
* @param name of the value descriptor to locate and return
* @return ValueDescriptor having the provided name, could be null if none are found.
* @throws ServcieException (HTTP 503) for unknown or unanticipated issues
*/
@RequestMapping(value = "/name/{name:.+}", method = RequestMethod.GET)
@Override
public ValueDescriptor valueDescriptorByName(@PathVariable String name) {
try {
ValueDescriptor valuDes = valDescRepos.findByName(name);
if (valuDes == null)
throw new NotFoundException(ValueDescriptor.class.toString(), name);
return valuDes;
} catch (NotFoundException nfE) {
throw nfE;
} catch (Exception e) {
logger.error(ERR_GETTING + e.getMessage());
throw new ServiceException(e);
}
}
示例6: valueDescriptorsForDeviceByName
import org.edgexfoundry.exception.controller.NotFoundException; //导入依赖的package包/类
/**
* Retrieve value descriptors associated to a device where the device is identified by name - that
* is value descriptors that are listed as part of a devices parameter names on puts or expected
* values on get or put commands. Throws a ServcieException (HTTP 503) for unknown or
* unanticipated issues. Throws NotFoundExcetption (HTTP 404) if a device cannot be found for the
* name provided.
*
* @param name - name of the device
* @return list of value descriptors associated to the device.
* @throws ServcieException (HTTP 503) for unknown or unanticipated issues
* @throws NotFoundException (HTTP 404) for device not found by name
*/
@RequestMapping(value = "/devicename/{name:.+}", method = RequestMethod.GET)
@Override
public List<ValueDescriptor> valueDescriptorsForDeviceByName(@PathVariable String name) {
try {
Device device = deviceClient.deviceForName(name);
Set<String> vdNames = device.getProfile().getCommands().stream()
.map((Command cmd) -> cmd.associatedValueDescriptors()).flatMap(l -> l.stream())
.collect(Collectors.toSet());
return vdNames.stream().map(s -> this.valDescRepos.findByName(s))
.collect(Collectors.toList());
} catch (javax.ws.rs.NotFoundException nfE) {
throw new NotFoundException(Device.class.toString(), name);
} catch (Exception e) {
logger.error("Error getting value descriptor by device name: " + e.getMessage());
throw new ServiceException(e);
}
}
示例7: valueDescriptorsForDeviceById
import org.edgexfoundry.exception.controller.NotFoundException; //导入依赖的package包/类
/**
* Retrieve value descriptors associated to a device where the device is identified by id - that
* is value descriptors that are listed as part of a devices parameter names on puts or expected
* values on get or put commands. Throws a ServcieException (HTTP 503) for unknown or
* unanticipated issues. Throws NotFoundExcetption (HTTP 404) if a device cannot be found for the
* id provided.
*
* @param name - name of the device
* @return list of value descriptors associated to the device.
* @throws ServcieException (HTTP 503) for unknown or unanticipated issues
* @throws NotFoundException (HTTP 404) for device not found by id
*/
@RequestMapping(value = "/deviceid/{id}", method = RequestMethod.GET)
@Override
public List<ValueDescriptor> valueDescriptorsForDeviceById(@PathVariable String id) {
try {
Device device = deviceClient.device(id);
Set<String> vdNames = device.getProfile().getCommands().stream()
.map((Command cmd) -> cmd.associatedValueDescriptors()).flatMap(l -> l.stream())
.collect(Collectors.toSet());
return vdNames.stream().map(s -> this.valDescRepos.findByName(s))
.collect(Collectors.toList());
} catch (javax.ws.rs.NotFoundException nfE) {
throw new NotFoundException(Device.class.toString(), id);
} catch (Exception e) {
logger.error("Error getting value descriptor by device name: " + e.getMessage());
throw new ServiceException(e);
}
}
示例8: update
import org.edgexfoundry.exception.controller.NotFoundException; //导入依赖的package包/类
/**
* Update the ValueDescriptor identified by the id or name in the object provided. Id is used
* first, name is used second for identification purposes. ServcieException (HTTP 503) for unknown
* or unanticipated issues. DataValidationException (HTTP 409) if the a formatting string of the
* value descriptor is not a valid printf format. NotFoundException (404) if the value descriptor
* cannot be located by the identifier.
*
* @param valueDescriptor2 - object holding the identifier and new values for the ValueDescriptor
* @return boolean indicating success of the update
* @throws ServcieException (HTTP 503) for unknown or unanticipated issues
* @throws DataValidationException (HTTP 409) if the format string is not valid
* @throws NotFoundException (HTTP 404) when the value descriptor cannot be found by the id
*/
@RequestMapping(method = RequestMethod.PUT)
@Override
public boolean update(@RequestBody ValueDescriptor valueDescriptor2) {
try {
ValueDescriptor valueDescriptor =
getValueDescriptorByIdOrName(valueDescriptor2.getId(), valueDescriptor2.getName());
if (valueDescriptor != null) {
updateValueDescriptor(valueDescriptor2, valueDescriptor);
return true;
} else {
logger.error(
"Request to update with non-existent or unidentified value descriptor (id/name): "
+ valueDescriptor2.getId() + "/" + valueDescriptor2.getName());
throw new NotFoundException(ValueDescriptor.class.toString(), valueDescriptor2.getId());
}
} catch (DataValidationException dE) {
throw dE;
} catch (NotFoundException nE) {
throw nE;
} catch (Exception e) {
logger.error("Error updating value descriptor: " + e.getMessage());
throw new ServiceException(e);
}
}
示例9: delete
import org.edgexfoundry.exception.controller.NotFoundException; //导入依赖的package包/类
/**
* Remove the ValueDescriptor designated by database generated identifier. ServcieException (HTTP
* 503) for unknown or unanticipated issues. DataValidationException (HTTP 409) if the value
* descriptor is still referenced in Readings. NotFoundException (404) if the value descriptor
* cannot be located by the identifier.
*
* @param identifier (database generated) of the value descriptor to be deleted
* @return boolean indicating success of the remove operation
* @throws ServcieException (HTTP 503) for unknown or unanticipated issues
* @throws DataValidationException (HTTP 409) if the value descriptor is still referenced by
* readings
* @throws NotFoundException (HTTP 404) when the value descriptor cannot be found by the id
*/
@RequestMapping(value = "/id/{id}", method = RequestMethod.DELETE)
@Override
public boolean delete(@PathVariable String id) {
try {
ValueDescriptor valueDescriptor = valDescRepos.findOne(id);
if (valueDescriptor != null)
return deleteValueDescriptor(valueDescriptor);
else {
logger.error("Request to delete with non-existent value descriptor id: " + id);
throw new NotFoundException(ValueDescriptor.class.toString(), id);
}
} catch (DataValidationException dE) {
throw dE;
} catch (NotFoundException nE) {
throw nE;
} catch (Exception e) {
logger.error("Error removing value descriptor: " + e.getMessage());
throw new ServiceException(e);
}
}
示例10: deleteByName
import org.edgexfoundry.exception.controller.NotFoundException; //导入依赖的package包/类
/**
* Remove the ValueDescriptor designated by name. ServcieException (HTTP 503) for unknown or
* unanticipated issues. DataValidationException (HTTP 409) if the value descriptor is still
* referenced in Readings. NotFoundException (404) if the value descriptor cannot be located by
* the identifier.
*
* @param name of the value descriptor to be removed.
* @return boolean indicating success of the remove operation
* @throws ServcieException (HTTP 503) for unknown or unanticipated issues
* @throws DataValidationException (HTTP 409) if the value descriptor is still referenced by
* readings
* @throws NotFoundException (HTTP 404) when the value descriptor cannot be found by the id
*/
@RequestMapping(value = "/name/{name:.+}", method = RequestMethod.DELETE)
@Override
public boolean deleteByName(@PathVariable String name) {
try {
ValueDescriptor valueDescriptor = valDescRepos.findByName(name);
if (valueDescriptor != null)
return deleteValueDescriptor(valueDescriptor);
else {
logger.error("Request to delete with unknown value descriptor name: " + name);
throw new NotFoundException(ValueDescriptor.class.toString(), name);
}
} catch (DataValidationException dE) {
throw dE;
} catch (NotFoundException nE) {
throw nE;
} catch (Exception e) {
logger.error("Error removing value descriptor: " + e.getMessage());
throw new ServiceException(e);
}
}
示例11: getResponse
import org.edgexfoundry.exception.controller.NotFoundException; //导入依赖的package包/类
public String getResponse(String deviceId, String cmd, String arguments) {
if (init.isServiceLocked()) {
logger.error("GET request cmd: " + cmd + " with device service locked on: " + deviceId);
throw new LockedException(
"GET request cmd: " + cmd + " with device service locked on: " + deviceId);
}
if (devices.isDeviceLocked(deviceId)) {
logger.error("GET request cmd: " + cmd + " with device locked on: " + deviceId);
throw new LockedException("GET request cmd: " + cmd + " with device locked on: " + deviceId);
}
Device device = devices.getDeviceById(deviceId);
if (OPCUA.commandExists(device, cmd)) {
EdgeData resultData = new EdgeData(EdgeFormatIdentifier.DEFAULT_VERSION.getValue(),
EdgeFormatIdentifier.OPCUA_TYPE.getValue(), OPCUA.executeCommand(device, cmd, arguments));
return EdgeJsonFormatter.encodeEdgeDataToJsonString(resultData);
} else {
logger.error("Command: " + cmd + " does not exist for device with id: " + deviceId);
throw new NotFoundException("Command", cmd);
}
}
示例12: getResponse
import org.edgexfoundry.exception.controller.NotFoundException; //导入依赖的package包/类
public Map<String,String> getResponse(String deviceId, String cmd, String arguments) {
if (init.isServiceLocked()) {
logger.error("GET request cmd: " + cmd + " with device service locked on: " + deviceId);
throw new LockedException("GET request cmd: " + cmd + " with device service locked on: " + deviceId);
}
if (devices.isDeviceLocked(deviceId)) {
logger.error("GET request cmd: " + cmd + " with device locked on: " + deviceId);
throw new LockedException("GET request cmd: " + cmd + " with device locked on: " + deviceId);
}
BACNetDevice device = devices.getBACNetDeviceById(deviceId);
if (BACNet.commandExists(device, cmd)) {
return BACNet.executeCommand(device, cmd, arguments);
} else {
logger.error("Command: " + cmd + " does not exist for device with id: " + deviceId);
throw new NotFoundException("Command", cmd);
}
}
示例13: getResponses
import org.edgexfoundry.exception.controller.NotFoundException; //导入依赖的package包/类
public List<Reading> getResponses(Device device, ResourceOperation operation) {
String deviceId = device.getId();
List<MqttObject> objectsList = createObjectsList(operation, device);
if (objectsList == null) {
throw new NotFoundException("device", deviceId);
}
String operationId =
objectsList.stream().map(o -> o.getName()).collect(Collectors.toList()).toString();
if (responseCache.get(deviceId) == null
|| responseCache.get(deviceId).get(operationId) == null) {
return new ArrayList<>();
}
return responseCache.get(deviceId).get(operationId);
}
示例14: getResponse
import org.edgexfoundry.exception.controller.NotFoundException; //导入依赖的package包/类
public Map<String, String> getResponse(String deviceId, String cmd, String arguments) {
if (init.isServiceLocked()) {
logger.error("GET request cmd: " + cmd + " with device service locked on: " + deviceId);
throw new LockedException(
"GET request cmd: " + cmd + " with device service locked on: " + deviceId);
}
if (devices.isDeviceLocked(deviceId)) {
logger.error("GET request cmd: " + cmd + " with device locked on: " + deviceId);
throw new LockedException("GET request cmd: " + cmd + " with device locked on: " + deviceId);
}
Device device = devices.getDeviceById(deviceId);
if (mqtt.commandExists(device, cmd)) {
return mqtt.executeCommand(device, cmd, arguments);
} else {
logger.error("Command: " + cmd + " does not exist for device with id: " + deviceId);
throw new NotFoundException("Command", cmd);
}
}
示例15: getResponses
import org.edgexfoundry.exception.controller.NotFoundException; //导入依赖的package包/类
public List<Reading> getResponses(Device device, ResourceOperation operation) {
String deviceId = device.getId();
List<BleObject> objectsList = createObjectsList(operation, device);
if (objectsList == null) {
throw new NotFoundException("device", deviceId);
}
String operationId = objectsList.stream().map(o -> o.getName())
.collect(Collectors.toList()).toString();
if (responseCache.get(deviceId) == null
|| responseCache.get(deviceId).get(operationId) == null) {
return new ArrayList<Reading>();
}
return responseCache.get(deviceId).get(operationId);
}