本文整理汇总了Java中org.geomajas.global.ExceptionCode类的典型用法代码示例。如果您正苦于以下问题:Java ExceptionCode类的具体用法?Java ExceptionCode怎么用?Java ExceptionCode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ExceptionCode类属于org.geomajas.global包,在下文中一共展示了ExceptionCode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: dtoAttributeCriterionToFilters
import org.geomajas.global.ExceptionCode; //导入依赖的package包/类
private Map<VectorLayer, Filter> dtoAttributeCriterionToFilters(AttributeCriterion criterion)
throws GeomajasException {
Map<VectorLayer, Filter> filters = new LinkedHashMap<VectorLayer, Filter>();
Filter f;
VectorLayer l = configurationService.getVectorLayer(criterion.getServerLayerId());
if (l == null) {
throw new GeomajasException(ExceptionCode.LAYER_NOT_FOUND, criterion.getServerLayerId());
}
String operator = criterion.getOperator();
if ("LIKE".equals(operator.toUpperCase())) {
f = filterService.createLikeFilter(criterion.getAttributeName(), criterion.getValue());
} else if ("DURING".equals(operator.toUpperCase()) || "BEFORE".equals(operator.toUpperCase())
|| "AFTER".equals(operator.toUpperCase())) {
f = filterService.parseFilter(criterion.toString()); // In case of a date filter
} else {
f = filterService.createCompareFilter(criterion.getAttributeName(), criterion.getOperator(),
criterion.getValue());
}
filters.put(l, f);
return filters;
}
示例2: testPutGet
import org.geomajas.global.ExceptionCode; //导入依赖的package包/类
@Test
public void testPutGet() throws Exception {
PipelineContext context = new PipelineContextImpl();
context.put("text", "SomeText");
context.put("int", 17);
context.put("list", new ArrayList<String>());
Assert.assertNull(context.getOptional("unknown"));
try {
context.get("unknown");
Assert.fail("should have thrown an exception");
} catch (GeomajasException ge) {
Assert.assertEquals(ExceptionCode.PIPELINE_CONTEXT_MISSING, ge.getExceptionCode());
}
Assert.assertEquals("SomeText", context.get("text"));
Assert.assertEquals(17, context.get("int"));
Assert.assertEquals(0, ((List<?>)context.get("list")).size());
Assert.assertEquals("SomeText", context.get("text", String.class));
Assert.assertEquals(17, (int)context.get("int", Integer.class));
Assert.assertEquals(0, context.get("list", List.class).size());
Assert.assertEquals(0, context.get("list", ArrayList.class).size());
Assert.assertEquals("SomeText", context.put("text", "someOtherText"));
Assert.assertEquals("someOtherText", context.get("text"));
}
示例3: delete
import org.geomajas.global.ExceptionCode; //导入依赖的package包/类
@Override
@Transactional(rollbackFor = { Throwable.class })
public void delete(String featureId) throws LayerException {
SimpleFeatureSource source = getFeatureSource();
if (source instanceof SimpleFeatureStore) {
SimpleFeatureStore store = (SimpleFeatureStore) source;
Filter filter = filterService.createFidFilter(new String[] { featureId });
transactionSynchronization.synchTransaction(store);
try {
store.removeFeatures(filter);
if (log.isDebugEnabled()) {
log.debug("Deleted feature {} in {}", featureId, getFeatureSourceName());
}
} catch (IOException ioe) {
featureModelUsable = false;
throw new LayerException(ioe, ExceptionCode.LAYER_MODEL_IO_EXCEPTION);
}
} else {
log.error("Don't know how to delete from " + getFeatureSourceName() + ", class "
+ source.getClass().getName() + " does not implement SimpleFeatureStore");
throw new LayerException(ExceptionCode.DELETE_NOT_IMPLEMENTED, getFeatureSourceName(), source.getClass()
.getName());
}
}
示例4: getBounds
import org.geomajas.global.ExceptionCode; //导入依赖的package包/类
@Override
public Envelope getBounds(Filter filter) throws LayerException {
FeatureSource<SimpleFeatureType, SimpleFeature> source = getFeatureSource();
if (source instanceof FeatureStore<?, ?>) {
SimpleFeatureStore store = (SimpleFeatureStore) source;
transactionSynchronization.synchTransaction(store);
}
try {
FeatureCollection<SimpleFeatureType, SimpleFeature> fc;
if (null == filter) {
fc = source.getFeatures();
} else {
fc = source.getFeatures(filter);
}
FeatureIterator<SimpleFeature> it = fc.features();
transactionSynchronization.addIterator(it);
return fc.getBounds();
} catch (Throwable t) { // NOSONAR avoid errors (like NPE) as well
throw new LayerException(t, ExceptionCode.UNEXPECTED_PROBLEM);
}
}
示例5: execute
import org.geomajas.global.ExceptionCode; //导入依赖的package包/类
@Override
public void execute(GetRasterTilesRequest request, GetRasterTilesResponse response) throws Exception {
log.debug("request start layer {}, crs {}", request.getLayerId(), request.getCrs());
String layerId = request.getLayerId();
if (null == layerId) {
throw new GeomajasException(ExceptionCode.PARAMETER_MISSING, "layer");
}
if (null == request.getCrs()) {
throw new GeomajasException(ExceptionCode.PARAMETER_MISSING, "crs");
}
if (!securityContext.isLayerVisible(layerId)) {
throw new GeomajasSecurityException(ExceptionCode.LAYER_NOT_VISIBLE, layerId, securityContext.getUserId());
}
log.debug("execute() : bbox {}", request.getBbox());
List<RasterTile> images = layerService.getTiles(layerId, geoService.getCrs2(request.getCrs()),
converterService.toInternal(request.getBbox()), request.getScale());
log.debug("execute() : returning {} images", images.size());
response.setRasterData(images);
if (images.size() > 0) {
response.setNodeId(layerId + "." + images.get(0).getCode().getTileLevel());
}
}
示例6: getCrs2Test
import org.geomajas.global.ExceptionCode; //导入依赖的package包/类
@Test
public void getCrs2Test() throws Exception {
Crs crs = geoService.getCrs2(MERCATOR);
Assert.assertNotNull(crs);
Assert.assertEquals(900913, geoService.getSridFromCrs(crs));
Assert.assertEquals(MERCATOR, geoService.getCodeFromCrs(crs));
crs = geoService.getCrs2(LONLAT);
Assert.assertNotNull(crs);
Assert.assertEquals(4326, geoService.getSridFromCrs(crs));
Assert.assertEquals(LONLAT, geoService.getCodeFromCrs(crs));
try {
geoService.getCrs2("BLA:4326");
Assert.fail("authority should not exist");
} catch (GeomajasException ge) {
Assert.assertEquals(ExceptionCode.CRS_DECODE_FAILURE_FOR_MAP, ge.getExceptionCode());
}
}
示例7: retryInit
import org.geomajas.global.ExceptionCode; //导入依赖的package包/类
private void retryInit() throws GeomajasException {
// do not hammer the service
long now = System.currentTimeMillis();
if (now > lastInitRetry + cooldownTimeBetweenInitializationRetries) {
lastInitRetry = now;
try {
log.debug("Retrying to (re-)initialize layer {}", getId());
postConstruct();
} catch (Exception e) { // NOSONAR
log.warn("Failed initializing layer: ", e.getMessage());
}
}
if (!usable) {
throw new GeomajasException(ExceptionCode.LAYER_CONFIGURATION_PROBLEM);
}
}
示例8: readProperty
import org.geomajas.global.ExceptionCode; //导入依赖的package包/类
private Object readProperty(Object object, String name) throws LayerException {
if (object != null) {
PropertyDescriptor d = BeanUtils.getPropertyDescriptor(object.getClass(), name);
if (d != null && d.getReadMethod() != null) {
BeanUtils.getPropertyDescriptor(object.getClass(), name);
Method m = d.getReadMethod();
if (!Modifier.isPublic(m.getDeclaringClass().getModifiers())) {
m.setAccessible(true);
}
Object value;
try {
value = m.invoke(object);
} catch (Throwable t) {
throw new LayerException(t, ExceptionCode.FEATURE_MODEL_PROBLEM);
}
return value;
} else {
return null;
}
} else {
return null;
}
}
示例9: testInValidToken
import org.geomajas.global.ExceptionCode; //导入依赖的package包/类
@Test
public void testInValidToken() {
securityService.put("someToken", createTestAuthentication());
CommandResponse response = commandDispatcher.execute("test.SecurityTestCommand", null, "invalid", null);
Assert.assertEquals(1, response.getErrors().size());
Throwable error = response.getErrors().get(0);
Assert.assertTrue(error instanceof GeomajasSecurityException);
Assert.assertEquals(ExceptionCode.CREDENTIALS_MISSING_OR_INVALID,
((GeomajasSecurityException) error).getExceptionCode());
Assert.assertEquals(1, response.getExceptions().size());
ExceptionDto exceptionDto = response.getExceptions().get(0);
Assert.assertEquals(exceptionDto.getExceptionCode(),((GeomajasSecurityException) error).getExceptionCode());
Assert.assertEquals(exceptionDto.getClassName(),error.getClass().getName());
}
示例10: execute
import org.geomajas.global.ExceptionCode; //导入依赖的package包/类
@Override
public void execute(GeometryBufferRequest request, GeometryBufferResponse response) throws Exception {
List<org.geomajas.geometry.Geometry> clientGeometries = request.getGeometries();
if (clientGeometries == null || clientGeometries.size() == 0) {
throw new GeomajasException(ExceptionCode.PARAMETER_MISSING, "request");
}
// Convert to internal, apply buffer and convert back to DTO
List<org.geomajas.geometry.Geometry> result = new ArrayList<org.geomajas.geometry.Geometry>();
double buffer = request.getBufferDistance();
int quadrantSegments = request.getQuadrantSegments();
for (Geometry clientGeometry : clientGeometries) {
result.add(converter.toDto(converter.toInternal(clientGeometry).buffer(buffer, quadrantSegments)));
}
response.setGeometries(result);
}
示例11: getClientMaxExtent
import org.geomajas.global.ExceptionCode; //导入依赖的package包/类
public Bbox getClientMaxExtent(String mapCrsKey, String layerCrsKey, Bbox serverBbox, String layer)
throws LayerException {
if (mapCrsKey.equals(layerCrsKey)) {
return serverBbox;
}
try {
Crs mapCrs = geoService.getCrs2(mapCrsKey);
Crs layerCrs = geoService.getCrs2(layerCrsKey);
Envelope serverEnvelope = converterService.toInternal(serverBbox);
CrsTransform transformer = geoService.getCrsTransform(layerCrs, mapCrs);
Bbox res = converterService.toDto(geoService.transform(serverEnvelope, transformer));
if (Double.isNaN(res.getX()) || Double.isNaN(res.getY()) || Double.isNaN(res.getWidth())
|| Double.isNaN(res.getHeight())) {
throw new LayerException(ExceptionCode.LAYER_EXTENT_CANNOT_CONVERT, layer, mapCrsKey);
}
return res;
} catch (GeomajasException e) {
throw new LayerException(e, ExceptionCode.TRANSFORMER_CREATE_LAYER_TO_MAP_FAILED);
}
}
示例12: getAssociationValue
import org.geomajas.global.ExceptionCode; //导入依赖的package包/类
private AssociationValue getAssociationValue(Entity entity, AssociationAttributeInfo associationAttributeInfo)
throws LayerException {
if (entity == null) {
return null;
}
AbstractAttributeInfo idInfo = associationAttributeInfo.getFeature().getIdentifier();
FeatureInfo childInfo = associationAttributeInfo.getFeature();
PrimitiveAttribute<?> id;
try {
id = (PrimitiveAttribute) dtoConverterService.toDto(entity.getId(idInfo.getName()), idInfo);
} catch (GeomajasException e) {
throw new LayerException(e, ExceptionCode.CONVERSION_PROBLEM);
}
Map<String, Attribute<?>> attributes = new HashMap<String, Attribute<?>>();
for (AbstractAttributeInfo attributeInfo : childInfo.getAttributes()) {
attributes.put(attributeInfo.getName(),
getRecursiveAttribute(entity, childInfo, new String[] { attributeInfo.getName() }));
}
return new AssociationValue(id, attributes, false);
}
示例13: getAttributes
import org.geomajas.global.ExceptionCode; //导入依赖的package包/类
@Override
@SuppressWarnings("rawtypes")
public Map<String, Attribute> getAttributes(Object feature) throws LayerException {
try {
Map<String, Attribute> attribs = new HashMap<String, Attribute>();
for (AttributeInfo attribute : getFeatureInfo().getAttributes()) {
String name = attribute.getName();
if (!name.equals(getGeometryAttributeName())) {
Attribute value = getAttribute(feature, name);
attribs.put(name, value);
}
}
return attribs;
} catch (Exception e) { // NOSONAR
throw new LayerException(e, ExceptionCode.HIBERNATE_ATTRIBUTE_ALL_GET_FAILED, feature);
}
}
示例14: execute
import org.geomajas.global.ExceptionCode; //导入依赖的package包/类
public void execute(PipelineContext context, Object response) throws GeomajasException {
InternalFeature oldFeature = context.getOptional(PipelineCode.OLD_FEATURE_KEY, InternalFeature.class);
InternalFeature newFeature = context.get(PipelineCode.FEATURE_KEY, InternalFeature.class);
if (null != oldFeature) {
String layerId = context.get(PipelineCode.LAYER_ID_KEY, String.class);
VectorLayer layer = context.get(PipelineCode.LAYER_KEY, VectorLayer.class);
if (securityContext.isFeatureUpdateAuthorized(layerId, oldFeature, newFeature)) {
if (null == context.getOptional(PipelineCode.FEATURE_DATA_OBJECT_KEY)) {
context.put(PipelineCode.FEATURE_DATA_OBJECT_KEY, layer.read(newFeature.getId()));
}
} else {
throw new GeomajasSecurityException(ExceptionCode.FEATURE_UPDATE_PROHIBITED,
oldFeature.getId(), securityContext.getUserId());
}
}
}
示例15: execute
import org.geomajas.global.ExceptionCode; //导入依赖的package包/类
@Override
public void execute(GetConfigurationRequest request, GetConfigurationResponse response) throws Exception {
if (null == request.getApplicationId()) {
throw new GeomajasException(ExceptionCode.PARAMETER_MISSING, "applicationId");
}
// the data is explicitly copied as this assures the security is considered when copying.
ClientApplicationInfo original = context.getBean(request.getApplicationId(), ClientApplicationInfo.class);
if (original == null) {
throw new GeomajasException(ExceptionCode.APPLICATION_NOT_FOUND, request.getApplicationId());
}
ClientApplicationInfo client = new ClientApplicationInfo();
client.setId(original.getId());
if (!(original.getUserData() instanceof ServerSideOnlyInfo)) {
client.setUserData(original.getUserData());
}
client.setWidgetInfo(mapConfigurationCommand.securityClone(original.getWidgetInfo()));
client.setScreenDpi(original.getScreenDpi());
List<ClientMapInfo> maps = new ArrayList<ClientMapInfo>();
client.setMaps(maps);
for (ClientMapInfo map : original.getMaps()) {
maps.add(mapConfigurationCommand.securityClone(map));
}
response.setApplication(client);
}