Geoserver dynamically set bounding box / referencedEnvelope of datastore/layer when creating - java

I am using geoserver. I extended ContentDataStore plugin to add csv data types as layers. I am using geoserver rest api, HTTPUtils.put method actually. When I do this the datastore gets created without boundingbox defined, unlike when it is created manually on geoserver web application. Therefore I get an exception when I try to use wms-getCapabilities method, because there is no boundingbox defined.
The getCapabilities query is below:
localhost:8090/geoserver/wms?Service=WMS&Version=1.1.1&Request=GetCapabilities
The inner exception is below:
Caused by: java.lang.NullPointerException
at org.geoserver.wms.capabilities.GetCapabilitiesTransformer$CapabilitiesTranslator.handleLatLonBBox(GetCapabilitiesTransformer.java:1349)
at org.geoserver.wms.capabilities.GetCapabilitiesTransformer$CapabilitiesTranslator.handleLayer(GetCapabilitiesTransformer.java:901)
at org.geoserver.wms.capabilities.GetCapabilitiesTransformer$CapabilitiesTranslator.handleLayerTree(GetCapabilitiesTransformer.java:826)
... 90 more
Is there a way to define boundingbox for a datastore/layer in xxxDataStore or xxxDataStoreFactory classes. So far I couldn't find any way to define while creating the datastore.
Thanks in advance

I found the answer to it. I changed 2 classes. The first one is xxxFeatureSource which extends ContentFeatureSource (it's in ContentDataStore plugin) and the second one is DataStoreFileResource.
In xxxFeatureSource I overrided ReferencedEnvelope getBoundsInternal() method and implemented code which calculates my boundingBox.
In DataStoreFileResource I added this line;
ftInfo.setLatLonBoundingBox( bounds );
into the void handlePut() method, right after ftInfo.setNativeBoundingBox( bounds ).
Now I can use getCapabilities method after adding my DataStore via GeoServer rest api.
Hope it helps others too.

Related

Need to understand broadleaf commerce custom annotation implementation

I have been trying go through code of Broadleaf Commerce. There were multiple Custom Annotations used however I was not able to locate there Processor. Can anyone help me here. To take example #AdminPresentation it a custom annotation in package org.broadleafcommerce.common.presentation;
However how this is processed throughout the app, I was not able to locate. What I have understood till now we can use Reflection or AOP for its processing. But There was nothing for this.
Please help.
Source code - https://github.com/BroadleafCommerce/BroadleafCommerce
For a short answer, org.broadleafcommerce.openadmin.server.dao.provider.metadata.BasicFieldMetadataProvider#addMetadata is one place that processes those annotations.
On a broader level, the controllers in the openadmin will use the AdminEntityService to get ClassMetaData (all data about how a class should be displayed to an admin user). The #AdminPresentation annotation is one source of this data. The method AdminEntityServiceImpl#getClassMetadata is the main gateway for getting the ClassMetaData.
#getClassMetadata calls #inspect and eventually gets to PersistenceManager#inspect. This method uses the DynamicEntityDao to eventually get to Metadata#getFieldMetadataForTargetClass. That method gets each field of a class via reflection, and then each of those Fields is processed through the available FieldMetadataProviders. The FieldMetadataProviders turn a java.lang.reflect.Field into org.broadleafcommerce.openadmin.dto.FieldMetadata.
Any provided FieldMetadataProvider can contribute field metadata. This metadata is used in the FormBuilderService to construct the admin page.
Class References:
AdminEntityService - org.broadleafcommerce.openadmin.server.service.AdminEntityServiceImpl
PersistenceManager - org.broadleafcommerce.openadmin.server.service.persistence.PersistenceManagerImpl#inspect
DynamicEntityDao - org.broadleafcommerce.openadmin.server.dao.DynamicEntityDaoImpl#getPropertiesForEntityClass
Metadata - org.broadleafcommerce.openadmin.server.dao.Metadata#getFieldMetadataForTargetClass
FieldMetadataProvider - org.broadleafcommerce.openadmin.server.dao.provider.metadata.FieldMetadataProvider, org.broadleafcommerce.openadmin.server.dao.DynamicEntityDaoImpl#fieldMetadataProviders
FormBuilderService - org.broadleafcommerce.openadmin.web.service.FormBuilderServiceImpl
Have a look to :
https://www.baeldung.com/java-custom-annotation
You will get explanations about : "default" in the Custom Annotations.
Florent COUDERT.

Use Spring multiDataSource in chaos

In my project, I want method A,B use database1, and all other methods use database2.
Now I write like this in controller
DataSourceHolder.putDataSource("db1");
String code = methodA();//for get some
DataSourceHolder.putDataSource("db2");
methodC(code);
...
DataSourceHolder.putDataSource("db1");
methodB(code);//for set some
DataSourceHolder.putDataSource("db2");
In most cases, it runs normally. But while many people visit my webset, it may use wrong dataSource. Some data can not be saved or updated.

Oracle BPM Human Task Comments Callback Errors When Instantiating AppModule in Called Class

Oracle BPM Version 11.1.1.7. In a Humantask.task, Events tab, Content Change Callbacks section, I have entered the fully qualified class name of a class that implements NotesStore and the addNote and getNotes methods.
The class uses public methods in an AppModule to write and read comments using our custom table and these methods were well tested during development using the the BC tester and a temporary main in the callback class.
The project is compiled to a jar and placed in the BPM project's SCA-INF/lib folder, then the SCA and related ADF human task forms are deployed.
When a comment is made in the out of box human task comments section during a process instance, the class is called, but an exception occurs in the getNotes method at the line the AppModule is created:
java.lang.ClassCastException: oracle.jbo.common.ampool.PoolMgr
In the class, the AppModule is created as so:
AuditModule service = (AuditModule)Configuration.createRootApplicationModule("com.co.modules.AuditModule", "AuditModuleLocal");
I've tried adding a web.xml config file to the SCA BPM project with a filter as discussed in this post (last answer). This discusses triggering the ADF Context initialization, but I'm still getting the error.
The question is, how can I use a call back from a human task to call a method that uses AppModule public methods to do the DB work? Oracle's documentation is very sparse in this area (29.11.1).
UPDATE
Turns out that the stack trace shows that it is having problems looking up the data source name and is actually throwing a JBO error. If anyone runs in to this, check the stack trace for other issues.
UPDATE2
Finally got this to write task comments into the custom comments table. It turns out it doesn't seem possible to use an AppModule/Model approach in a comments callback class as there appears no way to initiate the needed ADF context when the class is called. By rewriting the class to access the DB directly in code the comment callback class does write the table. But, I am getting the same error as this post. Namely:
Exception invoking method from XML data control. Cause:oracle.bpel.services.workflow.client.WorkflowServiceClientException: java.rmi.UnmarshalException: cannot unmarshaling return; nested exception is:
Supplemental Detail java.io.IOException: Error: Unexpected type encountered in writeExternal oracle.bpel.services.workflow.client.WorkflowServiceClientException: java.rmi.UnmarshalException: cannot unmarshaling return; nested exception is:
java.io.IOException: Error: Unexpected type encountered in writeExternal
I suspect this is an Oracle framework issue as the types that are passed back are from the NotesStore implementation which are all passed back to the framework:
public class CommentsCallback implements NotesStore, Serializable...
public List<CommentType> getNotes(Task task)
Has anyone solved this? Full stacktrace at:
https://community.oracle.com/thread/3638940
After discussion with Oracle, the key to avoiding the unexpected type error is to use an ObjectFactory to populate the CommentType object. While we took a different approach ultimately, the below code was provided by Oracle as an example and might help someone trying to do this:
import oracle.bpel.services.workflow.task.model.ObjectFactory; 
import oracle.bpel.services.workflow.task.model.CommentType; 
import oracle.bpel.services.workflow.task.model.IdentityType; 
...
ObjectFactory factory = new ObjectFactory() 
CommentType commentType = factory.createCommentType(); 
IdentityType updatedBy = factory.createIdentityType(); 
updatedBy.setId("some user"); 
updatedBy.setType(IWorkflowConstants.IDENTITY_TYPE_USER); 
updatedBy.setDisplayName("some user display name"); 
commentType.setUpdatedBy(updatedBy); 
commentType.setComment("some comment"); 
...set the rest of the comment fields as necessary... 

Eclipse RCP - Strange behaviour using a Wizard

I've got an Eclipse RCP application and a strange behaviour while using a wizard page. Following situation:
I've got a wizard page which is part of a multi-page-wizard. At this page I override the createContent(...) method to create my widgets, etc. After creating my widgets 2 private methods addListeners() and init() are called which initializes my widgets out of the model and add some listeners (e.g. a ModifyListener). The obscure behaviour is the following: When I first call init() and after that call addListeners() everything works fine. But if I do it the vice versa I got a NullPointerException in the WizardDialog.updateButtons() method which is part of RCP framework: There is a variable called currentPage as the following code excerpt shows. This variable causes the NPE mentioned above. If I do it the right way, the variable is correctly set.
...
if (backButton != null) {
backButton.setEnabled(currentPage.getPreviousPage() != null);
}
...
I don't get this behaviour. Can someony explain it to me? Within the 2 private methods mentioned above no framework-calls are done. Maybe it's some timing issue?
Best regards,
AnarchoEnte

Webservice problem - methods can't take more than 1 parameter

I'm using IntelliJ IDEA 8 and Axis to set up a webservice that's deployed on Tomcat5.5. The generated wsdl looks like this: http://track.priskick.se/Tracker.wsdl
A method is declared as
public void storeImpressionReport(int siteId, int adId, int zoneId, int count,
int excludeCount) { ... }
and exposed in the webservice. Next, I build the client (also Java) using Axis, but as a runtime call to the method is made with the parameters 0,0,0,0,0, I get this:
Tried to invoke method public void com.xxxxx.xxxx.xxxx.xxxxx.storeImpressionReport(int,int,int,int,int) with arguments java.lang.Integer,null,null,null,null. The arguments do not match the signature.; nested exception is: java.lang.IllegalArgumentException
Reducing the number of parameters of the method to 1 makes it work, however this feels like a pretty silly limitation and strange behaviour. Please help me if you know what might be wrong here - why can't I expose methods and have them take more than one parameter?
=== UPDATE
I now tried generating the client java using wsdl generated from IntelliJ instead of calling the service with the ?wsdl option. This wsdl keeps the correct parameter names, maybe because the generator has access to the source. Now I get
No such operation 'siteId'
AxisFault
These are the relevant files:
http://track.priskick.se/Tracker/TrackerSoapBindingStub.java
http://track.priskick.se/Tracker/TrackerServiceTestCase.java
http://track.priskick.se/Tracker/Tracker_PortType.java
http://track.priskick.se/Tracker/TrackerService.java
http://track.priskick.se/Tracker/TrackerServiceLocator.java
the wsdl used for the client is found at
http://track.priskick.se/Tracker.wsdl
the service is found at
http://stage.klikki.com/services/Tracker
Cheers
Marcus Johansson
Oh the joy. I changed the service style to WRAPPED, and this seems to have solved the problem.

Categories

Resources