Skip to content

Commit

Permalink
Improvement jan 24 (#18)
Browse files Browse the repository at this point in the history
* adding REST api endpoints
* adding verification for object version and an About button
  • Loading branch information
valentin-gauthier-geosiris authored Jan 25, 2024
1 parent a86aaff commit b2f1c52
Show file tree
Hide file tree
Showing 32 changed files with 530 additions and 165 deletions.
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ The WebStudio is a web application that allows to manipulate energyml file (such
- Sometimes export the EPC file was failing from the interface. It was due to specific entities that were not supported for export.
- Witsml/Prodml objects (like **Log**) can contain as *sub-objects* other *AbstractObject*. They are now detected during validation/auto-correction.

- 1.0.15:
- Bugfix
- About button added in the interface to link to github
- Verifications:
- Verification on objectVerion in DOR

## License

This project is licensed under the Apache 2.0 License - see the `LICENSE` file for details
Expand Down Expand Up @@ -214,4 +220,13 @@ For now the only correction done is on DOR information. If an object refers to a
**Export version:** The resulting EPC can follow the old file naming convention "/[ENERGYML_TYPE]\_[UUID].xml" but also the new one : "/[PACKAGE][PACKAGE\_VERSION]/[ENERGYML\_TYPE]_[UUID].xml". The new version is obtainable by sending a parameter called "version" with the value **EXPANDED** (uppercase).

Example with postman :
![POSTMAN-correction-request](doc/image/REST/postman-energyml-fix.png)
![POSTMAN-correction-request](doc/image/REST/postman-energyml-fix.png)

### Correction : "/ETPSurfaceToFile"

A post request on the endpoint "/ETPSurfaceToFile" with files inside "form-data" will return a 3D surface file in text format.

**Format:** The format can be "off" or "obj".

Example with postman :
![POSTMAN-correction-request](doc/image/REST/postman-etp-surface-to-file.png)
Binary file added doc/image/REST/postman-etp-surface-to-file.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion docker/data/resqmlAccessibleDORMapping.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,7 @@
"SubRepresentation" : ["AbstractRepresentation"],
"WellBoreFrameRepresentation" : ["WellBoretrajectoryRepresentation"],
"WellBoreMarkerFrameRepresentation" : ["WellboreMarker" ,"HorizonInterpretation", "GeobodyBoundaryInterpretation", "FluidBoundaryInterpretation" , "FaultInterpretation"],
"WellTrajectoryRepresentation" : ["DeviationSurveyRepresentation", "MdDatum"]
"WellTrajectoryRepresentation" : ["DeviationSurveyRepresentation", "MdDatum"],
"Operator" : ["BusinessAssociate"],
"BusinessAssociate" : ["BusinessAssociate"]
}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>com.geosiris</groupId>
<artifactId>webstudio</artifactId>
<name>${project.groupId}:${project.artifactId}</name>
<version>1.0.14</version>
<version>1.0.15</version>
<organization>
<name>Geosiris</name>
<url>http://www.geosiris.com</url>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import com.geosiris.etp.communication.Message;
import com.geosiris.etp.protocols.handlers.StoreHandler;
import com.geosiris.webstudio.logs.ServerLogMessage;
import com.geosiris.webstudio.servlet.FileReciever;
import com.geosiris.webstudio.servlet.editing.FileReciever;
import com.geosiris.webstudio.utils.SessionUtility;
import jakarta.servlet.http.HttpSession;
import org.apache.logging.log4j.LogManager;
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/com/geosiris/webstudio/model/ETP3DObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,12 @@ public String toString(){
Gson gson = new Gson();
return gson.toJson(this);
}

public String getData() {
return data;
}

public String getFileType() {
return fileType;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import com.geosiris.webstudio.model.WorkspaceContent;
import com.geosiris.webstudio.property.WorkspaceProperties;
import com.geosiris.webstudio.servlet.Editor;
import com.geosiris.webstudio.servlet.FileReciever;
import com.geosiris.webstudio.servlet.editing.FileReciever;
import com.geosiris.webstudio.utils.SessionUtility;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
*/
package com.geosiris.webstudio.servlet;
package com.geosiris.webstudio.servlet.editing;

import com.geosiris.energyml.utils.EPCGenericManager;
import com.geosiris.energyml.utils.ObjectController;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
*/
package com.geosiris.webstudio.servlet;
package com.geosiris.webstudio.servlet.editing;

import com.geosiris.energyml.utils.Pair;
import com.geosiris.webstudio.logs.ServerLogMessage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
See the License for the specific language governing permissions and
limitations under the License.
*/
package com.geosiris.webstudio.servlet;
package com.geosiris.webstudio.servlet.editing;

import com.geosiris.webstudio.servlet.Editor;
import com.geosiris.webstudio.utils.SessionUtility;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.MultipartConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
*/
package com.geosiris.webstudio.servlet;
package com.geosiris.webstudio.servlet.editing;

import com.geosiris.energyml.exception.NoSuchAccessibleParameterFound;
import com.geosiris.energyml.exception.NoSuchEditableParameterFound;
Expand All @@ -23,6 +23,7 @@
import com.geosiris.energyml.utils.ObjectController;
import com.geosiris.energyml.utils.Utils;
import com.geosiris.webstudio.property.ConfigurationType;
import com.geosiris.webstudio.servlet.Editor;
import com.geosiris.webstudio.servlet.db.workspace.LoadWorkspace;
import com.geosiris.webstudio.utils.ResQMLConverter;
import com.geosiris.webstudio.utils.ResqmlObjectControler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
*/
package com.geosiris.webstudio.servlet;
package com.geosiris.webstudio.servlet.energyml;

import com.geosiris.energyml.utils.Utils;
import com.geosiris.webstudio.utils.SessionUtility;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
See the License for the specific language governing permissions and
limitations under the License.
*/
package com.geosiris.webstudio.servlet;
package com.geosiris.webstudio.servlet.energyml;

import com.geosiris.energyml.utils.ExportVersion;
import com.geosiris.webstudio.model.WorkspaceContent;
import com.geosiris.webstudio.servlet.editing.FileReciever;
import com.geosiris.webstudio.utils.HttpSender;
import com.geosiris.webstudio.utils.SessionUtility;
import jakarta.servlet.ServletContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,12 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)

logger.info("#ETP : host " + host_uri);
logger.info(request.getSession(false));
Boolean isConnected = ETPUtils.establishConnexion(request.getSession(false), host_uri, userName, password, askConnection);
ETPClient client = ETPUtils.establishConnexion(request.getSession(false), host_uri, userName, password, askConnection);

PrintWriter out = response.getWriter();
response.setContentType("application/text");
response.setCharacterEncoding("UTF-8");
out.write("" + isConnected);
out.write(String.valueOf(client != null));
out.flush();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.geosiris.webstudio.logs.ServerLogMessage;
import com.geosiris.webstudio.model.ETP3DObject;
import com.geosiris.webstudio.utils.ETPUtils;
import com.geosiris.webstudio.utils.File3DType;
import com.geosiris.webstudio.utils.SessionUtility;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
Expand Down Expand Up @@ -107,7 +108,7 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
List<ETP3DObject> surfaces = new ArrayList<>();
for(ETPUri etpUri: mapUri.values()) {
try {
surfaces.add(ETPUtils.get3DFileFromETP(session, etpUri.toString(), false));
surfaces.add(ETPUtils.get3DFileFromETP((ETPClient) session.getAttribute(SessionUtility.SESSION_ETP_CLIENT_ID), session, etpUri.toString(), File3DType.OFF, false));
} catch (JAXBException e) {
logger.error(e.getMessage(), e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import com.geosiris.webstudio.logs.ServerLogMessage.MessageType;
import com.geosiris.webstudio.property.ConfigurationType;
import com.geosiris.webstudio.servlet.Editor;
import com.geosiris.webstudio.servlet.FileReciever;
import com.geosiris.webstudio.servlet.editing.FileReciever;
import com.geosiris.webstudio.utils.ETPRequestUtils;
import com.geosiris.webstudio.utils.ETPUtils;
import com.geosiris.webstudio.utils.SessionUtility;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
*/
package com.geosiris.webstudio.servlet;
package com.geosiris.webstudio.servlet.global;

import com.geosiris.webstudio.utils.SessionUtility;
import com.google.gson.Gson;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
*/
package com.geosiris.webstudio.servlet;
package com.geosiris.webstudio.servlet.global;

import com.geosiris.energyml.utils.ObjectController;
import com.geosiris.webstudio.utils.SessionUtility;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
*/
package com.geosiris.webstudio.servlet;
package com.geosiris.webstudio.servlet.global;

import com.geosiris.energyml.utils.EPCGenericManager;
import com.geosiris.energyml.utils.ObjectController;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
*/
package com.geosiris.webstudio.servlet;
package com.geosiris.webstudio.servlet.global;

import com.geosiris.energyml.utils.ExportVersion;
import com.geosiris.webstudio.model.WorkspaceContent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
*/
package com.geosiris.webstudio.servlet;
package com.geosiris.webstudio.servlet.global;

import com.geosiris.energyml.utils.Pair;
import com.geosiris.webstudio.servlet.db.workspace.LoadWorkspace;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
*/
package com.geosiris.webstudio.servlet;
package com.geosiris.webstudio.servlet.global;

import com.geosiris.webstudio.utils.SessionUtility;
import jakarta.servlet.ServletException;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
/*
Copyright 2019 GEOSIRIS
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package com.geosiris.webstudio.servlet.rest;

import com.geosiris.etp.utils.ETPUri;
import com.geosiris.etp.websocket.ETPClient;
import com.geosiris.webstudio.model.ETP3DObject;
import com.geosiris.webstudio.utils.ETPUtils;
import com.geosiris.webstudio.utils.File3DType;
import com.geosiris.webstudio.utils.SessionUtility;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.xml.bind.JAXBException;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.*;

/**
* Servlet implementation class ETPSurfaceToOff
*/
@WebServlet(urlPatterns = {"/ETPSurfaceToFile", "/ETPSurfaceToObj", "/ETPSurfaceToOff"})
public class ETPSurfaceToFile extends HttpServlet {
private static final long serialVersionUID = 1L;

public static Logger logger = LogManager.getLogger(ETPSurfaceToFile.class);


/**
* @see HttpServlet#HttpServlet()
*/
public ETPSurfaceToFile() {
super();
}

/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
* response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
if (!SessionUtility.tryConnectServlet(request, response)) {
return;
}

PrintWriter out = response.getWriter();
response.setContentType("application/text");
response.setCharacterEncoding("UTF-8");
out.write("Please use POST with parameters : uri, serverUrl, [serverLogin], [serverPassword], [format]");
out.flush();
}

/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
* response)
*/
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
StringBuilder jb = new StringBuilder();
String line;
try {
BufferedReader reader = request.getReader();
while ((line = reader.readLine()) != null)
jb.append(line);
} catch (Exception e) { /*report an error*/ }
String requestUri = request.getRequestURI().toLowerCase();
JsonObject parameters = new Gson().fromJson(jb.toString(), JsonObject.class);

String serverUrl = parameters.get("serverUrl").getAsString();
String username = parameters.get("username").getAsString();
String password = parameters.get("password").getAsString();
// String serverToken = parameters.get("serverToken").getAsString();

String fileFormat_param = parameters.get("format").getAsString();
File3DType fileFormat = File3DType.OFF;
if(fileFormat_param != null){
if(fileFormat_param.equalsIgnoreCase("obj")){
fileFormat = File3DType.OBJ;
}
} else if (requestUri.contains("obj")) {
fileFormat = File3DType.OBJ;
}else if (requestUri.contains("off")) {
fileFormat = File3DType.OFF;
}


System.out.println(serverUrl + "- " + username + "- " + password);
ETPClient etpClient = ETPUtils.establishConnexion(null, ETPUtils.getHttpUriETP(serverUrl), username, password, true);

Map<String, ETPUri> mapUri = new HashMap<>();
ETPUri etpuri = ETPUri.parse(parameters.get("uri").getAsString());
mapUri.put("0", etpuri);

List<ETP3DObject> surfaces = new ArrayList<>();
for(ETPUri etpUri: mapUri.values()) {
try {
surfaces.add(ETPUtils.get3DFileFromETP(etpClient, null, etpUri.toString(), fileFormat, false));
} catch (JAXBException e) {
logger.error(e.getMessage(), e);
}
}
PrintWriter out = response.getWriter();
response.setContentType("application/text");
response.setCharacterEncoding("UTF-8");
out.write(Objects.requireNonNullElse(surfaces.get(0).getData(), ""));
out.flush();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
See the License for the specific language governing permissions and
limitations under the License.
*/
package com.geosiris.webstudio.servlet.energyml;
package com.geosiris.webstudio.servlet.rest;

import com.geosiris.energyml.utils.ExportVersion;
import com.geosiris.energyml.utils.Pair;
Expand Down
Loading

0 comments on commit b2f1c52

Please sign in to comment.