Search in sources :

Example 1 with DataNotFoundException

use of net.geoprism.registry.DataNotFoundException in project geoprism-registry by terraframe.

the class ServerGeoObjectService method getGeoObjectByCode.

public ServerGeoObjectIF getGeoObjectByCode(String code, ServerGeoObjectType type, boolean throwException) {
    this.permissionService.enforceCanRead(type.getOrganization().getCode(), type);
    ServerGeoObjectStrategyIF strategy = this.getStrategy(type);
    ServerGeoObjectIF geoObject = strategy.getGeoObjectByCode(code);
    if (geoObject == null && throwException) {
        DataNotFoundException ex = new DataNotFoundException();
        ex.setTypeLabel(GeoObjectMetadata.get().getClassDisplayLabel());
        ex.setDataIdentifier(code);
        ex.setAttributeLabel(GeoObjectMetadata.get().getAttributeDisplayLabel(DefaultAttribute.CODE.getName()));
        throw ex;
    }
    return geoObject;
}
Also used : DataNotFoundException(net.geoprism.registry.DataNotFoundException) ServerGeoObjectIF(net.geoprism.registry.model.ServerGeoObjectIF) ServerGeoObjectStrategyIF(net.geoprism.registry.conversion.ServerGeoObjectStrategyIF)

Aggregations

DataNotFoundException (net.geoprism.registry.DataNotFoundException)1 ServerGeoObjectStrategyIF (net.geoprism.registry.conversion.ServerGeoObjectStrategyIF)1 ServerGeoObjectIF (net.geoprism.registry.model.ServerGeoObjectIF)1