This is an automated email from the ASF dual-hosted git repository. imesha pushed a commit to branch development in repository https://gitbox.apache.org/repos/asf/oodt.git
commit 6cdbbe648f8eb79c9347de148bb9022be94fc4dc Author: Imesha Sudasingha <[email protected]> AuthorDate: Sat Sep 21 12:58:02 2019 +0530 [OODT-1015] Minor code formatting changes --- .../BadRequestExceptionMapper.java | 4 +- .../CasWorkflowExceptionMapper.java | 4 +- .../InternalServerErrorExceptionMapper.java | 4 +- .../exceptionmappers/NotFoundExceptionMapper.java | 4 +- .../oodt/cas/wmservices/filters/CORSFilter.java | 11 ++- .../cas/wmservices/resources/MetadataResource.java | 80 ++++++++-------------- .../resources/WMRequestStatusResource.java | 4 +- .../resources/WorkflowStateResource.java | 22 +++--- .../cas/wmservices/services/WMJaxrsServiceV2.java | 16 ++--- .../cas/wmservices/servlets/WmServicesServlet.java | 43 ++++++------ 10 files changed, 80 insertions(+), 112 deletions(-) diff --git a/webapp/wmservices/src/main/java/org/apache/oodt/cas/wmservices/exceptionmappers/BadRequestExceptionMapper.java b/webapp/wmservices/src/main/java/org/apache/oodt/cas/wmservices/exceptionmappers/BadRequestExceptionMapper.java index bbdf2f5..f8d19cf 100644 --- a/webapp/wmservices/src/main/java/org/apache/oodt/cas/wmservices/exceptionmappers/BadRequestExceptionMapper.java +++ b/webapp/wmservices/src/main/java/org/apache/oodt/cas/wmservices/exceptionmappers/BadRequestExceptionMapper.java @@ -37,14 +37,14 @@ public class BadRequestExceptionMapper implements ExceptionMapper<BadRequestExce @Override public Response toResponse(BadRequestException exception) { - /** Initialising ErrorMessage Entity for Mapping to Response * */ + // Initialising ErrorMessage Entity for Mapping to Response ErrorMessage errorMessageEntity = new ErrorMessage( Response.Status.BAD_REQUEST.getStatusCode(), ErrorType.BAD_REQUEST_EXCEPTION.getErrorType(), exception.getMessage()); - /** Maps Error Status 400 to Response * */ + // Maps Error Status 400 to Response return Response.status(Response.Status.BAD_REQUEST) .entity(errorMessageEntity) .type(MediaType.APPLICATION_JSON) diff --git a/webapp/wmservices/src/main/java/org/apache/oodt/cas/wmservices/exceptionmappers/CasWorkflowExceptionMapper.java b/webapp/wmservices/src/main/java/org/apache/oodt/cas/wmservices/exceptionmappers/CasWorkflowExceptionMapper.java index 627d18a..f3aacf0 100644 --- a/webapp/wmservices/src/main/java/org/apache/oodt/cas/wmservices/exceptionmappers/CasWorkflowExceptionMapper.java +++ b/webapp/wmservices/src/main/java/org/apache/oodt/cas/wmservices/exceptionmappers/CasWorkflowExceptionMapper.java @@ -36,12 +36,12 @@ public class CasWorkflowExceptionMapper implements ExceptionMapper<WorkflowExcep @Override public Response toResponse(WorkflowException exception) { - /** Initialising ErrorMessage Entity for Mapping to Response * */ + // Initialising ErrorMessage Entity for Mapping to Response ErrorMessage errorMessageEntity = new ErrorMessage( Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), exception.getMessage()); - /** Maps Error Status 500 to Response * */ + // Maps Error Status 500 to Response return Response.status(Response.Status.INTERNAL_SERVER_ERROR) .entity(errorMessageEntity) .type(MediaType.APPLICATION_JSON) diff --git a/webapp/wmservices/src/main/java/org/apache/oodt/cas/wmservices/exceptionmappers/InternalServerErrorExceptionMapper.java b/webapp/wmservices/src/main/java/org/apache/oodt/cas/wmservices/exceptionmappers/InternalServerErrorExceptionMapper.java index a8fd511..daadf7a 100644 --- a/webapp/wmservices/src/main/java/org/apache/oodt/cas/wmservices/exceptionmappers/InternalServerErrorExceptionMapper.java +++ b/webapp/wmservices/src/main/java/org/apache/oodt/cas/wmservices/exceptionmappers/InternalServerErrorExceptionMapper.java @@ -37,12 +37,12 @@ public class InternalServerErrorExceptionMapper @Override public Response toResponse(InternalServerErrorException exception) { - /** Initialising ErrorMessage Entity for Mapping to Response * */ + // Initialising ErrorMessage Entity for Mapping to Response ErrorMessage errorMessageEntity = new ErrorMessage( Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), exception.getMessage()); - /** Maps Error Status 500 to Response * */ + // Maps Error Status 500 to Response return Response.status(Response.Status.INTERNAL_SERVER_ERROR) .entity(errorMessageEntity) .type(MediaType.APPLICATION_JSON) diff --git a/webapp/wmservices/src/main/java/org/apache/oodt/cas/wmservices/exceptionmappers/NotFoundExceptionMapper.java b/webapp/wmservices/src/main/java/org/apache/oodt/cas/wmservices/exceptionmappers/NotFoundExceptionMapper.java index 2462a29..d624cfb 100644 --- a/webapp/wmservices/src/main/java/org/apache/oodt/cas/wmservices/exceptionmappers/NotFoundExceptionMapper.java +++ b/webapp/wmservices/src/main/java/org/apache/oodt/cas/wmservices/exceptionmappers/NotFoundExceptionMapper.java @@ -37,14 +37,14 @@ public class NotFoundExceptionMapper implements ExceptionMapper<NotFoundExceptio @Override public Response toResponse(NotFoundException exception) { - /** Initialising ErrorMessage Entity for Mapping to Response * */ + // Initialising ErrorMessage Entity for Mapping to Response ErrorMessage errorMessageEntity = new ErrorMessage( Response.Status.NOT_FOUND.getStatusCode(), ErrorType.NOT_FOUND_EXCEPTION.getErrorType(), exception.getMessage()); - /** Maps Error Status 404 to Response * */ + // Maps Error Status 404 to Response return Response.status(Response.Status.NOT_FOUND) .entity(errorMessageEntity) .type(MediaType.APPLICATION_JSON) diff --git a/webapp/wmservices/src/main/java/org/apache/oodt/cas/wmservices/filters/CORSFilter.java b/webapp/wmservices/src/main/java/org/apache/oodt/cas/wmservices/filters/CORSFilter.java index 160cce1..5b16ab3 100644 --- a/webapp/wmservices/src/main/java/org/apache/oodt/cas/wmservices/filters/CORSFilter.java +++ b/webapp/wmservices/src/main/java/org/apache/oodt/cas/wmservices/filters/CORSFilter.java @@ -46,14 +46,13 @@ public class CORSFilter implements Filter { throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) servletRequest; - /** Authorize (allow) all domains to consume the content * */ - ((HttpServletResponse) servletResponse).addHeader("Access-Control-Allow-Origin", "*"); - ((HttpServletResponse) servletResponse) - .addHeader("Access-Control-Allow-Methods", "GET, OPTIONS, HEAD, PUT, POST"); - HttpServletResponse resp = (HttpServletResponse) servletResponse; - /** For HTTP OPTIONS verb/method reply with ACCEPTED status code -- per CORS handshake * */ + // Authorize (allow) all domains to consume the content + resp.addHeader("Access-Control-Allow-Origin", "*"); + resp.addHeader("Access-Control-Allow-Methods", "GET, OPTIONS, HEAD, PUT, POST"); + + // For HTTP OPTIONS verb/method reply with ACCEPTED status code -- per CORS handshake if (request.getMethod().equals("OPTIONS")) { resp.setStatus(HttpServletResponse.SC_ACCEPTED); return; diff --git a/webapp/wmservices/src/main/java/org/apache/oodt/cas/wmservices/resources/MetadataResource.java b/webapp/wmservices/src/main/java/org/apache/oodt/cas/wmservices/resources/MetadataResource.java index 443f316..a337e7d 100644 --- a/webapp/wmservices/src/main/java/org/apache/oodt/cas/wmservices/resources/MetadataResource.java +++ b/webapp/wmservices/src/main/java/org/apache/oodt/cas/wmservices/resources/MetadataResource.java @@ -13,7 +13,7 @@ * 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 org.apache.oodt.cas.wmservices.resources; @@ -28,120 +28,94 @@ import org.apache.oodt.cas.metadata.Metadata; /** * A JAX-RS resource representing a {@link Metadata} object. + * * @author rlaidlaw * @version $Revision$ */ @XmlRootElement(name = "metadata") @XmlAccessorType(XmlAccessType.NONE) -public class MetadataResource -{ +public class MetadataResource { private Metadata metadata; - /** - * Default constructor required by JAXB. - */ - public MetadataResource() - { - } - - + /** Default constructor required by JAXB. */ + public MetadataResource() {} /** * Constructor that sets the metadata for the resource. + * * @param metadata the metadata for the resource */ - public MetadataResource(Metadata metadata) - { + public MetadataResource(Metadata metadata) { this.metadata = metadata; } - - /** * Gets the metadata. + * * @return the metadata */ - public Metadata getMetadata() - { + public Metadata getMetadata() { return metadata; } - - /** * Gets a map of metadata keys and values. + * * @return a map of metadata keys and values */ @XmlElement(name = "keyval") - public List<MetadataEntry> getMetadataEntries() - { - List<MetadataEntry> entries = new ArrayList<MetadataEntry>(); - for (String key : metadata.getAllKeys()) - { - entries.add(new MetadataEntry(key, metadata.getAllMetadata(key))); - } - return entries; + public List<MetadataEntry> getMetadataEntries() { + List<MetadataEntry> entries = new ArrayList<MetadataEntry>(); + for (String key : metadata.getAllKeys()) { + entries.add(new MetadataEntry(key, metadata.getAllMetadata(key))); + } + return entries; } - - /** * Represents a metadata keyval entry. + * * @author rlaidlaw * @version $Revision$ */ @XmlRootElement @XmlType(propOrder = {"key", "values"}) @XmlAccessorType(XmlAccessType.NONE) - public static class MetadataEntry - { + public static class MetadataEntry { private String key; private List<String> values; - - - /** - * Default constructor required by JAXB. - */ - public MetadataEntry() - { - } - - + /** Default constructor required by JAXB. */ + public MetadataEntry() {} /** - * Constructor that creates a metadata entry using the supplied key and list - * of values. + * Constructor that creates a metadata entry using the supplied key and list of values. + * * @param key the key for the metadata entry * @param values the values for the metadata entry */ - public MetadataEntry(String key, List<String> values) - { + public MetadataEntry(String key, List<String> values) { this.key = key; this.values = values; } - - /** * Gets the key for the metadata entry. + * * @return the key for the metadata entry */ @XmlElement(name = "key") - public String getKey() - { + public String getKey() { return key; } - - /** * Gets the value(s) for the metadata entry + * * @return the value(s) for the metadata entry */ @XmlElement(name = "val") - public List<String> getValues() - { + public List<String> getValues() { return values; } } diff --git a/webapp/wmservices/src/main/java/org/apache/oodt/cas/wmservices/resources/WMRequestStatusResource.java b/webapp/wmservices/src/main/java/org/apache/oodt/cas/wmservices/resources/WMRequestStatusResource.java index 01102f0..15ed485 100644 --- a/webapp/wmservices/src/main/java/org/apache/oodt/cas/wmservices/resources/WMRequestStatusResource.java +++ b/webapp/wmservices/src/main/java/org/apache/oodt/cas/wmservices/resources/WMRequestStatusResource.java @@ -21,7 +21,7 @@ public class WMRequestStatusResource { public WMRequestStatusResource() {} - public WMRequestStatusResource(String url,String message) { + public WMRequestStatusResource(String url, String message) { this.url = url; this.message = message; } @@ -31,10 +31,8 @@ public class WMRequestStatusResource { return url; } - @XmlElement(name = "message") public String getMessage() { return message; } - } diff --git a/webapp/wmservices/src/main/java/org/apache/oodt/cas/wmservices/resources/WorkflowStateResource.java b/webapp/wmservices/src/main/java/org/apache/oodt/cas/wmservices/resources/WorkflowStateResource.java index b839a42..4e7501c 100644 --- a/webapp/wmservices/src/main/java/org/apache/oodt/cas/wmservices/resources/WorkflowStateResource.java +++ b/webapp/wmservices/src/main/java/org/apache/oodt/cas/wmservices/resources/WorkflowStateResource.java @@ -15,9 +15,10 @@ import org.apache.oodt.cas.workflow.lifecycle.WorkflowState; * @author ngimhana (Nadeeshan Gimhana) */ @XmlRootElement(name = "workflowState") -@XmlType(propOrder = {"name","description","message","startTime","category","prevState"}) +@XmlType(propOrder = {"name", "description", "message", "startTime", "category", "prevState"}) @XmlAccessorType(XmlAccessType.NONE) public class WorkflowStateResource { + private String name; private String description; private String message; @@ -25,15 +26,14 @@ public class WorkflowStateResource { private WorkflowLifecycleStage category; private WorkflowState prevState; - public WorkflowStateResource() { - } + public WorkflowStateResource() {} /** * Constructor that sets the workflowState to JAXRS resource. * * @param workflowState the workflowState associated with the resource */ - public WorkflowStateResource(WorkflowState workflowState){ + public WorkflowStateResource(WorkflowState workflowState) { this.name = workflowState.getName(); this.description = workflowState.getDescription(); this.message = workflowState.getMessage(); @@ -42,35 +42,33 @@ public class WorkflowStateResource { this.prevState = workflowState.getPrevState(); } - @XmlElement(name="name") + @XmlElement(name = "name") public String getName() { return name; } - @XmlElement(name="description") + @XmlElement(name = "description") public String getDescription() { return description; } - @XmlElement(name="message") + @XmlElement(name = "message") public String getMessage() { return message; } - @XmlElement(name="startTime") + @XmlElement(name = "startTime") public Date getStartTime() { return startTime; } - @XmlElement(name="category") + @XmlElement(name = "category") public WorkflowLifecycleStage getCategory() { return category; } - @XmlElement(name="prevState") + @XmlElement(name = "prevState") public WorkflowState getPrevState() { return prevState; } - - } diff --git a/webapp/wmservices/src/main/java/org/apache/oodt/cas/wmservices/services/WMJaxrsServiceV2.java b/webapp/wmservices/src/main/java/org/apache/oodt/cas/wmservices/services/WMJaxrsServiceV2.java index 89601d6..3c8c4ef 100644 --- a/webapp/wmservices/src/main/java/org/apache/oodt/cas/wmservices/services/WMJaxrsServiceV2.java +++ b/webapp/wmservices/src/main/java/org/apache/oodt/cas/wmservices/services/WMJaxrsServiceV2.java @@ -34,7 +34,7 @@ public class WMJaxrsServiceV2 { private static org.slf4j.Logger logger = LoggerFactory.getLogger(WMJaxrsServiceV2.class); - // The servlet context, which is used to retrieve context parameters. + /** The servlet context, which is used to retrieve context parameters. */ @Context private ServletContext context; /** @@ -44,9 +44,9 @@ public class WMJaxrsServiceV2 { * @throws Exception if an object cannot be retrieved from the context attribute */ public WorkflowManagerClient getContextClient() throws WorkflowException { - /** Get the workflow manager client from the servlet context.* */ + // Get the workflow manager client from the servlet context. Object clientObject = context.getAttribute("client"); - if (clientObject != null && clientObject instanceof WorkflowManagerClient) { + if (clientObject instanceof WorkflowManagerClient) { return (WorkflowManagerClient) clientObject; } @@ -64,8 +64,8 @@ public class WMJaxrsServiceV2 { @GET @Path("instance/{ID}") @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - public WorkflowInstanceResource getWorkflowInstanceById( - @PathParam("ID") String workflowInstId) throws WebApplicationException { + public WorkflowInstanceResource getWorkflowInstanceById(@PathParam("ID") String workflowInstId) + throws WebApplicationException { try { WorkflowManagerClient wmclient = getContextClient(); WorkflowInstance workflowInstanceById = wmclient.getWorkflowInstanceById(workflowInstId); @@ -166,8 +166,8 @@ public class WMJaxrsServiceV2 { @POST @Path("resume/{ID}") @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - public Response resumeWorkflowInstance( - @PathParam("ID") String workflowInstanceId) throws WebApplicationException { + public Response resumeWorkflowInstance(@PathParam("ID") String workflowInstanceId) + throws WebApplicationException { try { WorkflowManagerClient wmclient = getContextClient(); boolean workflowStatus = wmclient.stopWorkflowInstance(workflowInstanceId); @@ -223,4 +223,4 @@ public class WMJaxrsServiceV2 { throw new NotFoundException(e.getMessage()); } } -} \ No newline at end of file +} diff --git a/webapp/wmservices/src/main/java/org/apache/oodt/cas/wmservices/servlets/WmServicesServlet.java b/webapp/wmservices/src/main/java/org/apache/oodt/cas/wmservices/servlets/WmServicesServlet.java index 0ea958a..065611f 100644 --- a/webapp/wmservices/src/main/java/org/apache/oodt/cas/wmservices/servlets/WmServicesServlet.java +++ b/webapp/wmservices/src/main/java/org/apache/oodt/cas/wmservices/servlets/WmServicesServlet.java @@ -36,16 +36,19 @@ import org.slf4j.LoggerFactory; /** * Initialize workflow manager services servlet * - * Set the following Parameters in context.xml for the webapp: + * <p>Set the following Parameters in context.xml for the webapp: + * * <ul> - * <li>workflow.url - * <li>packagedRepo.dir.path + * <li>workflow.url + * <li>packagedRepo.dir.path * </ul> * * @author vratnakar */ public class WmServicesServlet extends CXFNonSpringJaxrsServlet { + private static Logger logger = LoggerFactory.getLogger(WmServicesServlet.class); + /** * The name of the servlet context attribute that holds a client for the workflow manager, a * {@link WorkflowManagerClient} object. @@ -57,7 +60,6 @@ public class WmServicesServlet extends CXFNonSpringJaxrsServlet { */ public static final String ATTR_NAME_PKG_REPO_DIR = "pkgRepoFilesDir"; - private static Logger logger = LoggerFactory.getLogger(WmServicesServlet.class); // Auto-generated ID for serialization. private static final long serialVersionUID = -7830210280506307805L; // Default URL for the workflow manager @@ -135,22 +137,19 @@ public class WmServicesServlet extends CXFNonSpringJaxrsServlet { /* Get the workflow manager URL from the context parameter. */ if (urlParameter != null) url = new URL(PathUtils.replaceEnvVariables(urlParameter)); else { - message = "Unable to find a servlet context parameter " - + "for the workflow manager URL."; + message = "Unable to find a servlet context parameter for the workflow manager URL."; /* Try the default URL for the Workflow manager. */ - logger.debug("WARNING Exception Thrown: {}", message); + logger.debug("WARNING Exception Thrown: {}", message); url = new URL(DEFAULT_WM_URL); } - /* - Attempt to connect the client to the workflow manager and if successful - store the client as a context attribute for other objects to access. - */ + // Attempt to connect the client to the workflow manager and if successful + // store the client as a context attribute for other objects to access. client = RpcCommunicationFactory.createClient(url); context.setAttribute("client", client); } catch (MalformedURLException e) { message = "Encountered a malformed URL for the workflow manager."; - logger.debug("Exception thrown: {}",message,e); + logger.debug("Exception thrown: {}", message, e); throw new ServletException(message); } } @@ -171,20 +170,20 @@ public class WmServicesServlet extends CXFNonSpringJaxrsServlet { File workingDir = new File(PathUtils.replaceEnvVariables(workingDirPath)); if (workingDir.exists() && workingDir.isDirectory()) { context.setAttribute(ATTR_NAME_PKG_REPO_DIR, workingDir); - message = "The workflow manager's working directory has been " - + "set up as " - + workingDir.getAbsolutePath(); - logger.debug("Exception thrown: {}",message); + message = + "The workflow manager's working directory has been " + + "set up as " + + workingDir.getAbsolutePath(); + logger.debug("Exception thrown: {}", message); } else { - message = "Unable to locate the working directory for " - + "the workflow manager."; - logger.debug("SEVERE Exception thrown: {}",message); + message = "Unable to locate the working directory for " + "the workflow manager."; + logger.debug("SEVERE Exception thrown: {}", message); } } else { message = "Unable to find a servlet context parameter for the workflow" + " manager working directory path."; - logger.debug("SEVERE Exception thrown: {}",message); + logger.debug("SEVERE Exception thrown: {}", message); throw new ServletException(message); } } @@ -197,10 +196,10 @@ public class WmServicesServlet extends CXFNonSpringJaxrsServlet { client = null; } catch (IOException e) { String message = "Unable to close WM Client: " + e.getMessage(); - logger.debug("SEVERE Exception thrown: {}",message); + logger.debug("SEVERE Exception thrown: {}", message); } } super.destroy(); } -} \ No newline at end of file +}
