diff options
| author | Stéphane Bégaudeau | 2018-04-19 08:22:05 +0000 |
|---|---|---|
| committer | Pierre-Charles David | 2018-04-24 15:39:23 +0000 |
| commit | aa052272035c2d439cb4499a1f51f770858c8ed6 (patch) | |
| tree | df3a7c69cc990941c8c0b61590c8b4f4a116ab88 | |
| parent | 089d38edf73aca61dd9ee44aedb8defb883bf117 (diff) | |
| download | org.eclipse.sirius-aa052272035c2d439cb4499a1f51f770858c8ed6.tar.gz org.eclipse.sirius-aa052272035c2d439cb4499a1f51f770858c8ed6.tar.xz org.eclipse.sirius-aa052272035c2d439cb4499a1f51f770858c8ed6.zip | |
[509735] Add first version of the HTTP API
Bug: 509735
Change-Id: I5214e521aa7a62c9f714b9fe405605eab12917e7
Signed-off-by: Stéphane Bégaudeau <stephane.begaudeau@obeo.fr>
62 files changed, 3280 insertions, 418 deletions
diff --git a/packaging/org.eclipse.sirius.parent/pom.xml b/packaging/org.eclipse.sirius.parent/pom.xml index c260cc5d76..7556f42c44 100644 --- a/packaging/org.eclipse.sirius.parent/pom.xml +++ b/packaging/org.eclipse.sirius.parent/pom.xml @@ -496,6 +496,9 @@ <module>../../plugins/org.eclipse.sirius.tests.rcptt.properties.edit</module> <module>../../plugins/org.eclipse.sirius.tests.rcptt.properties.editor</module> <module>../../plugins/org.eclipse.sirius.tests.rcptt.properties.samples</module> + + <module>../../plugins/org.eclipse.sirius.tests.server.backend</module> + <!-- features --> <module>../../packaging/org.eclipse.sirius.tests</module> <module>../../packaging/org.eclipse.sirius.tests.rcptt.feature</module> diff --git a/plugins/org.eclipse.sirius.server.backend/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.sirius.server.backend/.settings/org.eclipse.jdt.core.prefs index 523c3d606b..e9b804fc3a 100644 --- a/plugins/org.eclipse.sirius.server.backend/.settings/org.eclipse.jdt.core.prefs +++ b/plugins/org.eclipse.sirius.server.backend/.settings/org.eclipse.jdt.core.prefs @@ -109,9 +109,10 @@ org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning org.eclipse.jdt.core.compiler.source=1.8 +org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 @@ -122,8 +123,11 @@ org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header=0 org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 +org.eclipse.jdt.core.formatter.alignment_for_module_statements=16 org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 +org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references=0 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 @@ -133,10 +137,12 @@ org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_type_arguments=0 +org.eclipse.jdt.core.formatter.alignment_for_type_parameters=0 org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16 org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 org.eclipse.jdt.core.formatter.blank_lines_after_package=1 -org.eclipse.jdt.core.formatter.blank_lines_before_field=0 +org.eclipse.jdt.core.formatter.blank_lines_before_field=1 org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 @@ -157,8 +163,9 @@ org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line -org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=true org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false +org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position=false org.eclipse.jdt.core.formatter.comment.format_block_comments=true org.eclipse.jdt.core.formatter.comment.format_header=false org.eclipse.jdt.core.formatter.comment.format_html=true @@ -169,7 +176,7 @@ org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true org.eclipse.jdt.core.formatter.comment.indent_root_tags=true org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert -org.eclipse.jdt.core.formatter.comment.line_length=120 +org.eclipse.jdt.core.formatter.comment.line_length=80 org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false @@ -191,6 +198,7 @@ org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false org.eclipse.jdt.core.formatter.indentation.size=4 +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enum_constant=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert @@ -200,17 +208,17 @@ org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=insert org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=do not insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=do not insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert @@ -380,17 +388,29 @@ org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false -org.eclipse.jdt.core.formatter.lineSplit=150 +org.eclipse.jdt.core.formatter.lineSplit=200 org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 -org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true -org.eclipse.jdt.core.formatter.tabulation.char=tab +org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_enum_constant_declaration=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_lambda_declaration=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_switch_statement=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause=common_lines +org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=false +org.eclipse.jdt.core.formatter.tabulation.char=space org.eclipse.jdt.core.formatter.tabulation.size=4 org.eclipse.jdt.core.formatter.use_on_off_tags=true org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false +org.eclipse.jdt.core.formatter.wrap_before_assignment_operator=false org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true +org.eclipse.jdt.core.formatter.wrap_before_conditional_operator=true org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true org.eclipse.jdt.core.incompatibleJDKLevel=ignore diff --git a/plugins/org.eclipse.sirius.server.backend/.settings/org.eclipse.jdt.ui.prefs b/plugins/org.eclipse.sirius.server.backend/.settings/org.eclipse.jdt.ui.prefs index 3e1d90bc04..31ae3f46ff 100644 --- a/plugins/org.eclipse.sirius.server.backend/.settings/org.eclipse.jdt.ui.prefs +++ b/plugins/org.eclipse.sirius.server.backend/.settings/org.eclipse.jdt.ui.prefs @@ -1,6 +1,7 @@ eclipse.preferences.version=1 editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true -formatter_settings_version=12 +formatter_profile=_Sirius +formatter_settings_version=13 org.eclipse.jdt.ui.ignorelowercasenames=true org.eclipse.jdt.ui.importorder=com;java;javax;org; org.eclipse.jdt.ui.javadoc=true diff --git a/plugins/org.eclipse.sirius.server.backend/META-INF/MANIFEST.MF b/plugins/org.eclipse.sirius.server.backend/META-INF/MANIFEST.MF index afe9802c53..f989dfbfc1 100644 --- a/plugins/org.eclipse.sirius.server.backend/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.sirius.server.backend/META-INF/MANIFEST.MF @@ -6,11 +6,24 @@ Bundle-Version: 6.0.0.qualifier Bundle-Vendor: %providerName Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Require-Bundle: org.eclipse.core.runtime;bundle-version="3.8.0", + org.eclipse.core.resources;bundle-version="3.8.0", + javax.servlet;bundle-version="3.1.0", org.eclipse.jetty.server;bundle-version="[9.0.0,10.0.0)", org.eclipse.jetty.servlet;bundle-version="[9.0.0,10.0.0)", + org.eclipse.jetty.util;bundle-version="[9.0.0,10.0.0)", + org.eclipse.emf.common;bundle-version="2.8.0", + org.eclipse.sirius;bundle-version="6.0.0", + org.eclipse.sirius.ext.base;bundle-version="6.0.0", + org.eclipse.sirius.diagram;bundle-version="6.0.0", + org.eclipse.sirius.table;bundle-version="6.0.0", + org.eclipse.sirius.tree;bundle-version="6.0.0", org.eclipse.sirius.server;bundle-version="6.0.0", - javax.servlet;bundle-version="3.1.0" + com.google.gson;bundle-version="2.7.0" Bundle-Localization: plugin -Export-Package: org.eclipse.sirius.server.backend.internal;x-internal:=true, - org.eclipse.sirius.server.backend.internal.servlets;x-internal:=true +Export-Package: org.eclipse.sirius.server.backend.internal;x-friends:="org.eclipse.sirius.tests.server.backend", + org.eclipse.sirius.server.backend.internal.services.dashboard;x-internal:=true, + org.eclipse.sirius.server.backend.internal.services.project;x-internal:=true, + org.eclipse.sirius.server.backend.internal.services.projects;x-internal:=true, + org.eclipse.sirius.server.backend.internal.utils;x-internal:=true Bundle-ActivationPolicy: lazy +Bundle-Activator: org.eclipse.sirius.server.backend.internal.SiriusServerBackendPlugin$Implementation diff --git a/plugins/org.eclipse.sirius.server.backend/plugin.properties b/plugins/org.eclipse.sirius.server.backend/plugin.properties index e9947b43b3..6d228f45cf 100644 --- a/plugins/org.eclipse.sirius.server.backend/plugin.properties +++ b/plugins/org.eclipse.sirius.server.backend/plugin.properties @@ -12,4 +12,6 @@ pluginName = Sirius Server Backend providerName = Eclipse Modeling Project SiriusServerBackendConfigurator_label = The SiriusServerConfigurator of the back-end -SiriusServerBackendConfigurator_description = Used to configure the API of the Sirius server
\ No newline at end of file +SiriusServerBackendConfigurator_description = Used to configure the API of the Sirius server + +SiriusServerProjectsService_projectAlreadyExists = The project {0} already exists
\ No newline at end of file diff --git a/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/ISiriusServerService.java b/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/ISiriusServerService.java new file mode 100644 index 0000000000..1468dae1e2 --- /dev/null +++ b/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/ISiriusServerService.java @@ -0,0 +1,145 @@ +/******************************************************************************* + * Copyright (c) 2018 Obeo. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.server.backend.internal; + +import java.util.Map; +import java.util.Optional; + +import javax.servlet.http.HttpServletRequest; + +/** + * Interface used to contribute to the Sirius server API. Implementations of + * this interface will have to be annotated with {@link SiriusServerPath} to + * indicate the path of the URLs that they support. + * + * @author sbegaudeau + */ +public interface ISiriusServerService { + /** The GET HTTP method. */ + String GET = "GET"; //$NON-NLS-1$ + + /** The PUT HTTP method. */ + String PUT = "PUT"; //$NON-NLS-1$ + + /** The POST HTTP method. */ + String POST = "POST"; //$NON-NLS-1$ + + /** The DELETE HTTP method. */ + String DELETE = "DELETE"; //$NON-NLS-1$ + + /** + * Process the given request. + * + * @param request + * The HTTP request to process + * @param variables + * The variables extracted from the request + * @param remainingPart + * The remaining part of the request + * @return The result to return + */ + default SiriusServerResponse process(HttpServletRequest request, Map<String, String> variables, String remainingPart) { + Optional<SiriusServerResponse> optionalResponse = Optional.empty(); + switch (request.getMethod()) { + case GET: + optionalResponse = Optional.ofNullable(this.doGet(request, variables, remainingPart)); + break; + case PUT: + optionalResponse = Optional.ofNullable(this.doPut(request, variables, remainingPart)); + break; + case POST: + optionalResponse = Optional.ofNullable(this.doPost(request, variables, remainingPart)); + break; + case DELETE: + optionalResponse = Optional.ofNullable(this.doDelete(request, variables, remainingPart)); + break; + default: + optionalResponse = Optional.ofNullable(this.doError(request, variables, remainingPart)); + break; + } + return optionalResponse.orElse(this.doError(request, variables, remainingPart)); + } + + /** + * Process the given GET request. + * + * @param request + * The HTTP request to process + * @param variables + * The variables extracted from the request + * @param remainingPart + * The remaining part of the request + * @return The result to return + */ + default SiriusServerResponse doGet(HttpServletRequest request, Map<String, String> variables, String remainingPart) { + return null; + } + + /** + * Process the given PUT request. + * + * @param request + * The HTTP request to process + * @param variables + * The variables extracted from the request + * @param remainingPart + * The remaining part of the request + * @return The result to return + */ + default SiriusServerResponse doPut(HttpServletRequest request, Map<String, String> variables, String remainingPart) { + return null; + } + + /** + * Process the given POST request. + * + * @param request + * The HTTP request to process + * @param variables + * The variables extracted from the request + * @param remainingPart + * The remaining part of the request + * @return The result to return + */ + default SiriusServerResponse doPost(HttpServletRequest request, Map<String, String> variables, String remainingPart) { + return null; + } + + /** + * Process the given DELETE request. + * + * @param request + * The HTTP request to process + * @param variables + * The variables extracted from the request + * @param remainingPart + * The remaining part of the request + * @return The result to return + */ + default SiriusServerResponse doDelete(HttpServletRequest request, Map<String, String> variables, String remainingPart) { + return null; + } + + /** + * Process the given invalid request. + * + * @param request + * The HTTP request to process + * @param variables + * The variables extracted from the request + * @param remainingPart + * The remaining part of the request + * @return The result to return + */ + default SiriusServerResponse doError(HttpServletRequest request, Map<String, String> variables, String remainingPart) { + return new SiriusServerResponse(SiriusServerResponse.STATUS_BAD_REQUEST); + } +} diff --git a/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/SiriusServerBackendConfigurator.java b/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/SiriusServerBackendConfigurator.java index af90a32298..8393c2a3bb 100644 --- a/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/SiriusServerBackendConfigurator.java +++ b/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/SiriusServerBackendConfigurator.java @@ -10,12 +10,16 @@ *******************************************************************************/ package org.eclipse.sirius.server.backend.internal; +import java.util.EnumSet; + +import javax.servlet.DispatcherType; +import javax.servlet.SessionCookieConfig; + import org.eclipse.jetty.server.Handler; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.handler.HandlerCollection; import org.eclipse.jetty.servlet.ServletContextHandler; import org.eclipse.sirius.server.api.ISiriusServerConfigurator; -import org.eclipse.sirius.server.backend.internal.servlets.APIServlet; /** * The entry point of the back-end used to configure the Sirius server. @@ -24,27 +28,31 @@ import org.eclipse.sirius.server.backend.internal.servlets.APIServlet; */ public class SiriusServerBackendConfigurator implements ISiriusServerConfigurator { - /** - * The context path of the Sirius back-end. - */ - private static final String CONTEXT_PATH = "/api"; //$NON-NLS-1$ - - /** - * {@inheritDoc} - * - * @see org.eclipse.sirius.server.api.ISiriusServerConfigurator#configure(org.eclipse.sirius.server.api.Server) - */ - @Override - public void configure(Server server) { - ServletContextHandler servletContextHandler = new ServletContextHandler(ServletContextHandler.SESSIONS | ServletContextHandler.GZIP); - servletContextHandler.setContextPath(CONTEXT_PATH); - servletContextHandler.addServlet(APIServlet.class, APIServlet.PATH); - - Handler handler = server.getHandler(); - if (handler instanceof HandlerCollection) { - HandlerCollection handlerCollection = (HandlerCollection) handler; - handlerCollection.addHandler(servletContextHandler); - } - } + /** + * The context path of the Sirius back-end. + */ + private static final String CONTEXT_PATH = "/api"; //$NON-NLS-1$ + + /** + * {@inheritDoc} + * + * @see org.eclipse.sirius.server.api.ISiriusServerConfigurator#configure(org.eclipse.sirius.server.api.Server) + */ + @Override + public void configure(Server server) { + ServletContextHandler servletContextHandler = new ServletContextHandler(ServletContextHandler.SESSIONS | ServletContextHandler.GZIP); + servletContextHandler.setContextPath(CONTEXT_PATH); + servletContextHandler.setErrorHandler(new SiriusServerErrorHandler()); + SessionCookieConfig sessionCookieConfig = servletContextHandler.getServletContext().getSessionCookieConfig(); + sessionCookieConfig.setHttpOnly(true); + + servletContextHandler.addFilter(SiriusServerBackendFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST, DispatcherType.INCLUDE)); //$NON-NLS-1$ + + Handler handler = server.getHandler(); + if (handler instanceof HandlerCollection) { + HandlerCollection handlerCollection = (HandlerCollection) handler; + handlerCollection.addHandler(servletContextHandler); + } + } } diff --git a/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/SiriusServerBackendFilter.java b/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/SiriusServerBackendFilter.java new file mode 100644 index 0000000000..661e5b32fe --- /dev/null +++ b/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/SiriusServerBackendFilter.java @@ -0,0 +1,213 @@ +/******************************************************************************* + * Copyright (c) 2018 Obeo. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.server.backend.internal; + +import com.google.gson.Gson; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.sirius.server.backend.internal.services.dashboard.SiriusServerDashboardService; +import org.eclipse.sirius.server.backend.internal.services.project.SiriusServerProjectService; +import org.eclipse.sirius.server.backend.internal.services.projects.SiriusServerProjectsService; + +/** + * Filter used to dynamically dispatch request to the appropriate service. + * + * @author sbegaudeau + */ +public class SiriusServerBackendFilter implements Filter { + + /** + * The default character encoding. + */ + private static final String UTF_8 = "UTF-8"; //$NON-NLS-1$ + + /** + * {@inheritDoc} + * + * @see javax.servlet.Filter#init(javax.servlet.FilterConfig) + */ + @Override + public void init(FilterConfig filterConfig) throws ServletException { + // Do nothing + } + + /** + * {@inheritDoc} + * + * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, + * javax.servlet.ServletResponse, javax.servlet.FilterChain) + */ + @Override + public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException { + if (req instanceof HttpServletRequest && resp instanceof HttpServletResponse) { + HttpServletRequest request = (HttpServletRequest) req; + HttpServletResponse response = (HttpServletResponse) resp; + + Optional<SiriusServerResponse> optionalResponse = this.processRequest(request); + if (optionalResponse.isPresent()) { + SiriusServerResponse httpServiceResponse = optionalResponse.get(); + Object payload = httpServiceResponse.getPayload(); + String jsonPayload = new Gson().toJson(payload); + + response.setStatus(httpServiceResponse.getStatus()); + response.setContentType(httpServiceResponse.getContentType()); + response.setCharacterEncoding(UTF_8); + response.getWriter().write(jsonPayload); + } else { + response.setStatus(500); + response.getWriter().write("Something went wrong..."); //$NON-NLS-1$ + } + } + } + + /** + * Process the given request by invoking the proper Sirius server service. + * + * @param request + * The request + * @return A proper response if a service supporting the given request has + * been found, an error response otherwise + */ + private Optional<SiriusServerResponse> processRequest(HttpServletRequest request) { + List<SiriusServerServiceDescriptor> descriptors = this.getDescriptors(request); + descriptors.sort((descriptor1, descriptor2) -> descriptor2.getResult().getVariables().size() - descriptor1.getResult().getVariables().size()); + + Optional<SiriusServerServiceDescriptor> optionalDescriptor = descriptors.stream().findFirst(); + return optionalDescriptor.flatMap(descriptor -> { + Optional<ISiriusServerService> optionalServiceInstance = this.createServiceInstance(descriptor.getServiceClass()); + + Map<String, String> variables = descriptor.getResult().getVariables(); + String remainingPart = descriptor.getResult().getRemainingPart(); + return optionalServiceInstance.map(service -> service.process(request, variables, remainingPart)); + }); + } + + /** + * Computes the best {@link SiriusServerServiceDescriptor} for the given + * request. + * + * @param request + * The request + * @return The list of {@link SiriusServerServiceDescriptor} which can + * handle the given request + */ + private List<SiriusServerServiceDescriptor> getDescriptors(HttpServletRequest request) { + List<Class<? extends ISiriusServerService>> serviceClasses = new ArrayList<>(); + serviceClasses.add(SiriusServerDashboardService.class); + serviceClasses.add(SiriusServerProjectsService.class); + serviceClasses.add(SiriusServerProjectService.class); + + List<SiriusServerServiceDescriptor> descriptors = new ArrayList<>(); + for (Class<? extends ISiriusServerService> serviceClass : serviceClasses) { + SiriusServerPath siriusServerPath = serviceClass.getAnnotation(SiriusServerPath.class); + String path = siriusServerPath.value(); + + SiriusServerPathMatcher matcher = new SiriusServerPathMatcher(path); + SiriusServerMatchResult result = matcher.match(request.getServletPath()); + if (result.hasMatched()) { + descriptors.add(new SiriusServerServiceDescriptor(serviceClass, result)); + } + } + return descriptors; + } + + /** + * Creates the service instance from the given service class. + * + * @param serviceClass + * The service class + * @return The service instance created + */ + private Optional<ISiriusServerService> createServiceInstance(Class<? extends ISiriusServerService> serviceClass) { + try { + ISiriusServerService httpService = serviceClass.newInstance(); + return Optional.of(httpService); + } catch (InstantiationException | IllegalAccessException exception) { + IStatus status = new Status(IStatus.ERROR, SiriusServerBackendPlugin.PLUGIN_ID, exception.getMessage(), exception); + SiriusServerBackendPlugin.getPlugin().log(status); + } + return Optional.empty(); + } + + /** + * {@inheritDoc} + * + * @see javax.servlet.Filter#destroy() + */ + @Override + public void destroy() { + // Do nothing + } + + /** + * Descriptor containing both a service class and a match result. + * + * @author sbegaudeau + */ + private static class SiriusServerServiceDescriptor { + /** + * The service class. + */ + private Class<? extends ISiriusServerService> serviceClass; + + /** + * The match result. + */ + private SiriusServerMatchResult result; + + /** + * The constructor. + * + * @param serviceClass + * The service class + * @param matcher + * The match result + */ + SiriusServerServiceDescriptor(Class<? extends ISiriusServerService> serviceClass, SiriusServerMatchResult result) { + this.serviceClass = serviceClass; + this.result = result; + } + + /** + * Return the serviceClass. + * + * @return the serviceClass + */ + public Class<? extends ISiriusServerService> getServiceClass() { + return this.serviceClass; + } + + /** + * Return the match result. + * + * @return the match result + */ + public SiriusServerMatchResult getResult() { + return this.result; + } + } +} diff --git a/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/SiriusServerBackendPlugin.java b/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/SiriusServerBackendPlugin.java new file mode 100644 index 0000000000..7a7a49aa5a --- /dev/null +++ b/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/SiriusServerBackendPlugin.java @@ -0,0 +1,93 @@ +/******************************************************************************* + * Copyright (c) 2018 Obeo. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.server.backend.internal; + +import org.eclipse.emf.common.EMFPlugin; +import org.eclipse.emf.common.util.ResourceLocator; +import org.osgi.framework.BundleContext; + +/** + * The plugin of the Sirius server backend plugin. + * + * @author sbegaudeau + */ +public class SiriusServerBackendPlugin extends EMFPlugin { + /** + * The identifier of the plugin. + */ + public static final String PLUGIN_ID = "org.eclipse.sirius.server.backend"; //$NON-NLS-1$ + + /** + * The sole instance of the plugin. + */ + public static final SiriusServerBackendPlugin INSTANCE = new SiriusServerBackendPlugin(); + + /** + * The sole instance of the bundle activator. + */ + private static Implementation plugin; + + /** + * The constructor. + */ + public SiriusServerBackendPlugin() { + super(new ResourceLocator[0]); + } + + @Override + public ResourceLocator getPluginResourceLocator() { + return plugin; + } + + /** + * Returns the singleton instance of the Eclipse plugin. + * + * @return the singleton instance. + */ + public static Implementation getPlugin() { + return plugin; + } + + /** + * The bundle activator. + * + * @author sbegaudeau + */ + public static class Implementation extends EclipsePlugin { + /** + * The constructor. + */ + public Implementation() { + super(); + SiriusServerBackendPlugin.plugin = this; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.core.runtime.Plugin#start(org.osgi.framework.BundleContext) + */ + @Override + public void start(BundleContext context) throws Exception { + super.start(context); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext) + */ + @Override + public void stop(BundleContext context) throws Exception { + super.stop(context); + } + } +} diff --git a/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/SiriusServerErrorHandler.java b/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/SiriusServerErrorHandler.java new file mode 100644 index 0000000000..4fbd116d41 --- /dev/null +++ b/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/SiriusServerErrorHandler.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright (c) 2018 Obeo. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.server.backend.internal; + +import java.io.IOException; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.eclipse.jetty.server.Request; +import org.eclipse.jetty.server.handler.ErrorHandler; + +/** + * The error handler of the Sirius server. + * + * @author sbegaudeau + */ +public class SiriusServerErrorHandler extends ErrorHandler { + /** + * {@inheritDoc} + * + * @see org.eclipse.jetty.server.handler.ErrorHandler#handle(java.lang.String, + * org.eclipse.jetty.server.Request, + * javax.servlet.http.HttpServletRequest, + * javax.servlet.http.HttpServletResponse) + */ + @Override + public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException { + super.handle(target, baseRequest, request, response); + } +} diff --git a/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/SiriusServerMatchResult.java b/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/SiriusServerMatchResult.java new file mode 100644 index 0000000000..340e1ffab2 --- /dev/null +++ b/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/SiriusServerMatchResult.java @@ -0,0 +1,81 @@ +/******************************************************************************* + * Copyright (c) 2018 Obeo. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.server.backend.internal; + +import java.util.Map; + +/** + * The result of the match performed by the {@link SiriusServerPathMatcher}. + * + * @author sbegaudeau + */ +public class SiriusServerMatchResult { + + /** + * The variables. + */ + private Map<String, String> variables; + + /** + * The remaining part. + */ + private String remainingPart; + + /** + * Indicates if the match has been successful. + */ + private boolean hasMatched; + + /** + * The constructor. + * + * @param variables + * The variables + * @param remainingPart + * The remaining part + * @param hasMatched + * Indicates if the match has been successful + */ + public SiriusServerMatchResult(Map<String, String> variables, String remainingPart, boolean hasMatched) { + this.variables = variables; + this.remainingPart = remainingPart; + this.hasMatched = hasMatched; + } + + /** + * Indicates if the result is matched. + * + * @return <code>true</code> if the matcher has found a (partial) match, + * <code>false</code> otherwise + */ + public boolean hasMatched() { + return this.hasMatched; + } + + /** + * Returns the variables found in the match. + * + * @return The variables found in the match + */ + public Map<String, String> getVariables() { + return this.variables; + } + + /** + * Returns the remaining part of the request. + * + * @return The remaining part of the request + */ + public String getRemainingPart() { + return this.remainingPart; + } + +} diff --git a/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/SiriusServerMessages.java b/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/SiriusServerMessages.java new file mode 100644 index 0000000000..920441604b --- /dev/null +++ b/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/SiriusServerMessages.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright (c) 2018 Obeo. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.server.backend.internal; + +import org.eclipse.sirius.ext.base.I18N; +import org.eclipse.sirius.ext.base.I18N.TranslatableMessage; + +/** + * Utility class used for the internationalization. + * + * @author sbegaudeau + */ +public final class SiriusServerMessages { + + static { + I18N.initializeMessages(SiriusServerMessages.class, SiriusServerBackendPlugin.INSTANCE); + } + + // CHECKSTYLE:OFF + + @TranslatableMessage + public static String SiriusServerProjectsService_projectAlreadyExists; + + // CHECKSTYLE:ON + + private SiriusServerMessages() { + // Prevents instantiation. + } +} diff --git a/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/SiriusServerPath.java b/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/SiriusServerPath.java new file mode 100644 index 0000000000..971e90d2c4 --- /dev/null +++ b/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/SiriusServerPath.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright (c) 2018 Obeo. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.server.backend.internal; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Used to indicate the path of the {@link ISiriusServerService}. + * + * @author sbegaudeau + */ +@Documented +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +public @interface SiriusServerPath { + /** + * Returns the path of the service. + * + * @return The path of the service + */ + String value(); +} diff --git a/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/SiriusServerPathMatcher.java b/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/SiriusServerPathMatcher.java new file mode 100644 index 0000000000..60995726d0 --- /dev/null +++ b/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/SiriusServerPathMatcher.java @@ -0,0 +1,161 @@ +/******************************************************************************* + * Copyright (c) 2018 Obeo. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.server.backend.internal; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.stream.IntStream; + +/** + * Utility class used to match the path of the services and the path of the + * requests. + * + * @author sbegaudeau + */ +public class SiriusServerPathMatcher { + /** + * The separator of the segments of the path. + */ + private static final char SLASH = '/'; + + /** + * The start of a variable. + */ + private static final char VARIABLE_START = '{'; + + /** + * The end of a variable. + */ + private static final char VARIABLE_END = '}'; + + /** + * The regular expression used to capture the variables of the path. + */ + private static final String VARIABLE_REGEXP = "([^/]+?)"; //$NON-NLS-1$ + + /** + * The regular expression used to capture the remaining content of the path. + */ + private static final String REMAINING_PATH_REGEXP = "(.*)"; //$NON-NLS-1$ + + /** + * The list of the variables expected in the path. + */ + private List<String> variableNames = new ArrayList<>(); + + /** + * The pattern used to match the path. + */ + private Pattern pathPattern; + + /** + * The constructor. + * + * @param path + * The path + */ + public SiriusServerPathMatcher(String path) { + this.initialize(path); + } + + /** + * Initializes the {@link SiriusServerPathMatcher}. + * + * @param path + * The path to match + */ + private void initialize(String path) { + StringBuilder stringBuilder = new StringBuilder(); + + int startIndex = this.computeStartIndex(path); + int index = startIndex; + while (index < path.length()) { + char character = path.charAt(index); + if (VARIABLE_START == character) { + int variableEndIndex = path.indexOf(VARIABLE_END, index); + String variable = path.substring(index + 1, variableEndIndex); + + this.variableNames.add(variable); + + stringBuilder.append(VARIABLE_REGEXP); + index = variableEndIndex + 1; + } else { + stringBuilder.append(character); + index = index + 1; + } + } + + if (!path.endsWith(String.valueOf(SLASH))) { + stringBuilder.append(SLASH); + } + stringBuilder.append(REMAINING_PATH_REGEXP); + + this.pathPattern = Pattern.compile(stringBuilder.toString()); + } + + /** + * Returns the index to consider to start the analysis of the given path. + * + * @param path + * The path + * @return 0 if the path does not start with a slash, 1 otherwise + */ + private int computeStartIndex(String path) { + if (path.length() > 0 && SLASH == path.charAt(0)) { + return 1; + } + return 0; + } + + /** + * Matches the path of the request against the path of the matcher. + * + * @param requestPath + * The path of the request + * @return A {@link SiriusServerMatchResult} + */ + public SiriusServerMatchResult match(String requestPath) { + String path = requestPath; + if (path.length() > 0 && SLASH == path.charAt(0)) { + path = path.substring(1); + } + if (path.length() > 0 && SLASH != path.charAt(path.length() - 1)) { + path = path + SLASH; + } + + Matcher matcher = this.pathPattern.matcher(path); + + Map<String, String> variables = new HashMap<>(); + String remainingPart = ""; //$NON-NLS-1$ + + if (matcher.matches()) { + if (this.variableNames.size() <= matcher.groupCount()) { + IntStream.range(1, matcher.groupCount()).forEach(index -> { + String variable = this.variableNames.get(index - 1); + variables.put(variable, matcher.group(index)); + }); + } + + if (matcher.groupCount() > 0) { + remainingPart = matcher.group(matcher.groupCount()); + if (remainingPart.length() > 0 && SLASH == remainingPart.charAt(remainingPart.length() - 1)) { + remainingPart = remainingPart.substring(0, remainingPart.length() - 1); + } + } + } + + return new SiriusServerMatchResult(variables, remainingPart, matcher.matches()); + } +} diff --git a/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/SiriusServerResponse.java b/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/SiriusServerResponse.java new file mode 100644 index 0000000000..da2b139844 --- /dev/null +++ b/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/SiriusServerResponse.java @@ -0,0 +1,116 @@ +/******************************************************************************* + * Copyright (c) 2018 Obeo. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.server.backend.internal; + +/** + * Class used to describe the response of the HTTP service. + * + * @author sbegaudeau + */ +public class SiriusServerResponse { + /** The application/json content type. */ + public static final String CONTENT_TYPE_APPLICATION_JSON = "application/json"; //$NON-NLS-1$ + + /** The OK status. */ + public static final int STATUS_OK = 200; + + /** The CREATED status. */ + public static final int STATUS_CREATED = 201; + + /** The BAD REQUEST status. */ + public static final int STATUS_BAD_REQUEST = 400; + + /** The NOT FOUND status. */ + public static final int STATUS_NOT_FOUND = 404; + + /** The INTERNAL SERVER ERROR status. */ + public static final int STATUS_INTERNAL_SERVER_ERROR = 500; + + /** + * The status. + */ + private int status; + + /** + * The payload. + */ + private Object payload; + + /** + * The content type. + */ + private String contentType; + + /** + * The constructor. + * + * @param status + * The status + */ + public SiriusServerResponse(int status) { + this(status, null, CONTENT_TYPE_APPLICATION_JSON); + } + + /** + * The constructor. + * + * @param status + * The status + * @param payload + * The payload + */ + public SiriusServerResponse(int status, Object payload) { + this(status, payload, CONTENT_TYPE_APPLICATION_JSON); + } + + /** + * The constructor. + * + * @param status + * The status + * @param payload + * The payload + * @param contentType + * The content type + */ + public SiriusServerResponse(int status, Object payload, String contentType) { + this.status = status; + this.payload = payload; + this.contentType = contentType; + } + + /** + * Return the status. + * + * @return the status + */ + public int getStatus() { + return this.status; + } + + /** + * Return the payload. + * + * @return the payload + */ + public Object getPayload() { + return this.payload; + } + + /** + * Return the contentType. + * + * @return the contentType + */ + public String getContentType() { + return this.contentType; + } +} diff --git a/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/services/dashboard/SiriusServerDashboardDto.java b/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/services/dashboard/SiriusServerDashboardDto.java new file mode 100644 index 0000000000..197b78f9e9 --- /dev/null +++ b/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/services/dashboard/SiriusServerDashboardDto.java @@ -0,0 +1,64 @@ +/******************************************************************************* + * Copyright (c) 2018 Obeo. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.server.backend.internal.services.dashboard; + +import java.util.List; + +/** + * The DTO used to return the state of the dashboard to the client. + * + * @author sbegaudeau + */ +@SuppressWarnings({ "checkstyle::javadocmethod", "checkstyle::javadocfield" }) +public class SiriusServerDashboardDto { + private int projectsCount; + + private int viewpointsCount; + + private List<SiriusServerDashboardProjectDto> projects; + + private int metamodelsCount; + + /** + * The constructor. + * + * @param projectsCount + * The number of projects + * @param viewpointsCount + * The number of viewpoints + * @param metamodelsCount + * The number of metamodels + * @param projects + * The projects + */ + public SiriusServerDashboardDto(int projectsCount, int viewpointsCount, int metamodelsCount, List<SiriusServerDashboardProjectDto> projects) { + this.projectsCount = projectsCount; + this.viewpointsCount = viewpointsCount; + this.metamodelsCount = metamodelsCount; + this.projects = projects; + } + + public int getProjectsCount() { + return this.projectsCount; + } + + public int getViewpointsCount() { + return this.viewpointsCount; + } + + public int getMetamodelsCount() { + return this.metamodelsCount; + } + + public List<SiriusServerDashboardProjectDto> getProjects() { + return this.projects; + } +} diff --git a/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/services/dashboard/SiriusServerDashboardProjectDto.java b/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/services/dashboard/SiriusServerDashboardProjectDto.java new file mode 100644 index 0000000000..fd3feb83cd --- /dev/null +++ b/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/services/dashboard/SiriusServerDashboardProjectDto.java @@ -0,0 +1,54 @@ +/******************************************************************************* + * Copyright (c) 2018 Obeo. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.server.backend.internal.services.dashboard; + +/** + * The DTO used to represent one project in the dashboard. + * + * @author sbegaudeau + */ +@SuppressWarnings({ "checkstyle::javadocmethod", "checkstyle::javadocfield" }) +public class SiriusServerDashboardProjectDto { + private String name; + + private int semanticResourcesCount; + + private int representationsCount; + + /** + * The constructor. + * + * @param name + * The name of the project + * @param semanticResourcesCount + * The number of semantic resources + * @param representationsCount + * The number of representations + */ + public SiriusServerDashboardProjectDto(String name, int semanticResourcesCount, int representationsCount) { + this.name = name; + this.semanticResourcesCount = semanticResourcesCount; + this.representationsCount = representationsCount; + } + + public String getName() { + return this.name; + } + + public int getSemanticResourcesCount() { + return this.semanticResourcesCount; + } + + public int getRepresentationsCount() { + return this.representationsCount; + } + +} diff --git a/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/services/dashboard/SiriusServerDashboardService.java b/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/services/dashboard/SiriusServerDashboardService.java new file mode 100644 index 0000000000..7e637759e6 --- /dev/null +++ b/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/services/dashboard/SiriusServerDashboardService.java @@ -0,0 +1,110 @@ +/******************************************************************************* + * Copyright (c) 2018 Obeo. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.server.backend.internal.services.dashboard; + +import static org.eclipse.sirius.server.backend.internal.SiriusServerResponse.STATUS_OK; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import javax.servlet.http.HttpServletRequest; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.sirius.business.api.componentization.ViewpointRegistry; +import org.eclipse.sirius.business.api.dialect.DialectManager; +import org.eclipse.sirius.business.api.modelingproject.ModelingProject; +import org.eclipse.sirius.business.api.session.Session; +import org.eclipse.sirius.server.backend.internal.ISiriusServerService; +import org.eclipse.sirius.server.backend.internal.SiriusServerPath; +import org.eclipse.sirius.server.backend.internal.SiriusServerResponse; +import org.eclipse.sirius.server.backend.internal.utils.SiriusServerUtils; + +/** + * Service used to interact with the dashboard. + * + * @author sbegaudeau + */ +@SiriusServerPath("/dashboard") +public class SiriusServerDashboardService implements ISiriusServerService { + + /** + * The number of projects to be displayed in the dashboard. + */ + private static final int DASHBOARD_PROJECT_COUNT = 7; + + @Override + public SiriusServerResponse doGet(HttpServletRequest request, Map<String, String> variables, String remainingPart) { + return new SiriusServerResponse(STATUS_OK, this.getDashboard()); + } + + /** + * Returns the dashboard. + * + * @return The dashboard + */ + private SiriusServerDashboardDto getDashboard() { + int projectsCount = Long.valueOf(this.getModelingProjects().count()).intValue(); + int viewpointsCount = ViewpointRegistry.getInstance().getViewpoints().size(); + int metamodelsCount = EPackage.Registry.INSTANCE.size(); + + // @formatter:off + List<SiriusServerDashboardProjectDto> projects = this.getModelingProjects() + .limit(DASHBOARD_PROJECT_COUNT) + .map(this::convertToProject) + .collect(Collectors.toList()); + // @formatter:on + + return new SiriusServerDashboardDto(projectsCount, viewpointsCount, metamodelsCount, projects); + } + + /** + * Returns a stream of the modeling projects of the workspace. + * + * @return A stream of the modeling projects of the workspace + */ + private Stream<ModelingProject> getModelingProjects() { + IProject[] allProjects = ResourcesPlugin.getWorkspace().getRoot().getProjects(); + // @formatter:off + return Arrays.stream(allProjects) + .filter(ModelingProject::hasModelingProjectNature) + .filter(IProject::isOpen) + .map(project -> ModelingProject.asModelingProject(project).get()); + // @formatter:on + } + + /** + * Converts the given {@link ModelingProject} into a + * {@link SiriusServerDashboardProjectDto}. + * + * @param modelingProject + * The {@link ModelingProject} + * @return The {@link SiriusServerDashboardProjectDto} + */ + private SiriusServerDashboardProjectDto convertToProject(ModelingProject modelingProject) { + Session session = SiriusServerUtils.getSession(modelingProject); + + String name = modelingProject.getProject().getName(); + int semanticResourcesCount = session.getSemanticResources().size(); + // @formatter:off + int representationsCount = DialectManager.INSTANCE.getAllRepresentationDescriptors(session).stream() + .filter(descriptor -> !descriptor.getDescription().eIsProxy()) + .mapToInt(e -> 1) + .sum(); + // @formatter:on + + return new SiriusServerDashboardProjectDto(name, semanticResourcesCount, representationsCount); + } +} diff --git a/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/services/project/AbstractSiriusServerRepresentationDto.java b/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/services/project/AbstractSiriusServerRepresentationDto.java new file mode 100644 index 0000000000..a1831fe43e --- /dev/null +++ b/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/services/project/AbstractSiriusServerRepresentationDto.java @@ -0,0 +1,61 @@ +/******************************************************************************* + * Copyright (c) 2018 Obeo. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.server.backend.internal.services.project; + +/** + * The superclass of all the representation DTOs. + * + * @author sbegaudeau + */ +@SuppressWarnings({ "checkstyle::javadocmethod", "checkstyle::javadocfield" }) +public abstract class AbstractSiriusServerRepresentationDto { + private String kind; + + private String viewpointName; + + private String descriptionName; + + private String name; + + /** + * The constructor. + * + * @param kind + * The kind + * @param viewpointName + * The name of the viewpoint + * @param descriptionName + * The name of the description + * @param name + * The name + */ + public AbstractSiriusServerRepresentationDto(String kind, String viewpointName, String descriptionName, String name) { + this.kind = kind; + this.descriptionName = descriptionName; + this.name = name; + } + + public String getKind() { + return this.kind; + } + + public String getViewpointName() { + return this.viewpointName; + } + + public String getDescriptionName() { + return this.descriptionName; + } + + public String getName() { + return this.name; + } +} diff --git a/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/services/project/SiriusServerDiagramDto.java b/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/services/project/SiriusServerDiagramDto.java new file mode 100644 index 0000000000..8c33a81b73 --- /dev/null +++ b/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/services/project/SiriusServerDiagramDto.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright (c) 2018 Obeo. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.server.backend.internal.services.project; + +/** + * The DTO used to represent a diagram. + * + * @author sbegaudeau + */ +@SuppressWarnings({ "checkstyle::javadocmethod", "checkstyle::javadocfield" }) +public class SiriusServerDiagramDto extends AbstractSiriusServerRepresentationDto { + + private static final String KIND = "diagram"; //$NON-NLS-1$ + + /** + * The constructor. + * + * @param viewpointName + * The name of the viewpoint + * @param descriptionName + * The name of the description + * @param name + * The name + */ + public SiriusServerDiagramDto(String viewpointName, String descriptionName, String name) { + super(KIND, viewpointName, descriptionName, name); + } + +} diff --git a/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/services/project/SiriusServerProjectDto.java b/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/services/project/SiriusServerProjectDto.java new file mode 100644 index 0000000000..951efaddfc --- /dev/null +++ b/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/services/project/SiriusServerProjectDto.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright (c) 2018 Obeo. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.server.backend.internal.services.project; + +import java.util.List; + +/** + * The DTO used to return a project to clients. + * + * @author sbegaudeau + */ +@SuppressWarnings({ "checkstyle::javadocmethod", "checkstyle::javadocfield" }) +public class SiriusServerProjectDto { + private String name; + + private List<AbstractSiriusServerRepresentationDto> representations; + + private List<SiriusServerSemanticResourceDto> semanticResources; + + /** + * The constructor. + * + * @param name + * The name of the project + * @param representations + * The representations + * @param semanticResources + * The semantic resources + */ + public SiriusServerProjectDto(String name, List<AbstractSiriusServerRepresentationDto> representations, List<SiriusServerSemanticResourceDto> semanticResources) { + this.name = name; + this.representations = representations; + this.semanticResources = semanticResources; + } + + public String getName() { + return this.name; + } + + public List<AbstractSiriusServerRepresentationDto> getRepresentations() { + return this.representations; + } + + public List<SiriusServerSemanticResourceDto> getSemanticResources() { + return this.semanticResources; + } + +} diff --git a/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/services/project/SiriusServerProjectService.java b/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/services/project/SiriusServerProjectService.java new file mode 100644 index 0000000000..041a948f3e --- /dev/null +++ b/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/services/project/SiriusServerProjectService.java @@ -0,0 +1,225 @@ +/******************************************************************************* + * Copyright (c) 2018 Obeo. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.server.backend.internal.services.project; + +import static org.eclipse.sirius.server.backend.internal.SiriusServerResponse.STATUS_NOT_FOUND; +import static org.eclipse.sirius.server.backend.internal.SiriusServerResponse.STATUS_OK; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.text.DecimalFormat; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.stream.Collectors; + +import javax.servlet.http.HttpServletRequest; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Status; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.sirius.business.api.dialect.DialectManager; +import org.eclipse.sirius.business.api.modelingproject.ModelingProject; +import org.eclipse.sirius.business.api.session.Session; +import org.eclipse.sirius.diagram.description.DiagramDescription; +import org.eclipse.sirius.server.backend.internal.ISiriusServerService; +import org.eclipse.sirius.server.backend.internal.SiriusServerBackendPlugin; +import org.eclipse.sirius.server.backend.internal.SiriusServerPath; +import org.eclipse.sirius.server.backend.internal.SiriusServerResponse; +import org.eclipse.sirius.server.backend.internal.utils.SiriusServerUtils; +import org.eclipse.sirius.table.metamodel.table.description.TableDescription; +import org.eclipse.sirius.tree.description.TreeDescription; +import org.eclipse.sirius.viewpoint.DRepresentationDescriptor; +import org.eclipse.sirius.viewpoint.description.RepresentationDescription; +import org.eclipse.sirius.viewpoint.description.Viewpoint; + +/** + * Service used to manipulate a specific project. + * + * @author sbegaudeau + */ +@SiriusServerPath("/projects/{projectName}") +public class SiriusServerProjectService implements ISiriusServerService { + + /** + * The name of the variable used to capture the name of the project. + */ + private static final Object PROJECT_NAME = "projectName"; //$NON-NLS-1$ + + @Override + public SiriusServerResponse doGet(HttpServletRequest request, Map<String, String> variables, String remainingPart) { + Optional<String> optionalProjectName = Optional.ofNullable(variables.get(PROJECT_NAME)); + Optional<ModelingProject> optionalModelingProject = optionalProjectName.flatMap(this::findModelingProjectByName); + Optional<SiriusServerProjectDto> optionalProject = optionalModelingProject.map(this::getProjectFromModelingProject); + + return optionalProject.map(project -> new SiriusServerResponse(STATUS_OK, project)).orElse(new SiriusServerResponse(STATUS_NOT_FOUND)); + } + + /** + * Finds the modeling project with the given name. + * + * @param projectName + * The name of the project + * @return An optional with the modeling project or an empty optional if it + * could not be found + */ + private Optional<ModelingProject> findModelingProjectByName(String projectName) { + Optional<IProject> optionalProject = Optional.ofNullable(ResourcesPlugin.getWorkspace().getRoot().getProject(projectName)); + // @formatter:off + return optionalProject.filter(ModelingProject::hasModelingProjectNature) + .filter(IProject::isOpen) + .map(iProject -> ModelingProject.asModelingProject(iProject).get()); // FIXME Sirius Optional removal! + // @formatter:on + } + + /** + * Converts the given modeling project into a project to be returned by the + * service. + * + * @param modelingProject + * The modeling project + * @return The project to be returned by the service + */ + private SiriusServerProjectDto getProjectFromModelingProject(ModelingProject modelingProject) { + Session session = SiriusServerUtils.getSession(modelingProject); + + String projectName = modelingProject.getProject().getName(); + List<AbstractSiriusServerRepresentationDto> representations = this.getRepresentations(session); + List<SiriusServerSemanticResourceDto> semanticResources = this.getSemanticResources(modelingProject.getProject(), session); + return new SiriusServerProjectDto(projectName, representations, semanticResources); + } + + /** + * Returns the list of representations from the given session. + * + * @param session + * The session + * @return The list of representations from the given session + */ + private List<AbstractSiriusServerRepresentationDto> getRepresentations(Session session) { + Collection<DRepresentationDescriptor> representationDescriptors = DialectManager.INSTANCE.getAllRepresentationDescriptors(session); + // @formatter:off + return representationDescriptors.stream() + .filter(descriptor -> !descriptor.getDescription().eIsProxy()) + .map(this::convertToRepresentation) + .collect(Collectors.toList()); + // @formatter:on + } + + /** + * Converts the given {@link DRepresentationDescriptor} into an + * {@link AbstractSiriusServerRepresentationDto}. + * + * @param descriptor + * The descriptor + * @return The {@link AbstractSiriusServerRepresentationDto} + */ + private AbstractSiriusServerRepresentationDto convertToRepresentation(DRepresentationDescriptor descriptor) { + String name = descriptor.getName(); + + RepresentationDescription description = descriptor.getDescription(); + String descriptionName = description.getName(); + + // @formatter:off + String viewpointName = Optional.of(description.eContainer()) + .filter(Viewpoint.class::isInstance) + .map(Viewpoint.class::cast) + .map(Viewpoint::getName) + .orElse(""); //$NON-NLS-1$ + // @formatter:on + + AbstractSiriusServerRepresentationDto representation = null; + if (description instanceof DiagramDescription) { + representation = new SiriusServerDiagramDto(viewpointName, descriptionName, name); + } else if (description instanceof TableDescription) { + representation = new SiriusServerTableDto(viewpointName, descriptionName, name); + } else if (description instanceof TreeDescription) { + representation = new SiriusServerTreeDto(viewpointName, descriptionName, name); + } + + return representation; + } + + /** + * Returns the list of semantic resources from the given session. + * + * @param session + * The Sirius session + * @return The list of semantic resources from the given session + */ + private List<SiriusServerSemanticResourceDto> getSemanticResources(IProject project, Session session) { + Collection<Resource> semanticResources = session.getSemanticResources(); + // @formatter:off + return semanticResources.stream() + .map(Resource::getURI) + .filter(URI::isPlatformResource) + .map(uri -> { + String platformString = uri.toPlatformString(true); + return ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(platformString)); + }) + .filter(iFile -> iFile.getProject().equals(project)) + .map(this::convertToSemanticResource) + .collect(Collectors.toList()); + // @formatter:on + } + + /** + * Converts the given IFile into a {@link SiriusServerSemanticResourceDto}. + * + * @param iFile + * The semantic resource + * @return A {@link SiriusServerSemanticResourceDto}. + */ + private SiriusServerSemanticResourceDto convertToSemanticResource(IFile iFile) { + String name = iFile.getName(); + String path = iFile.getProjectRelativePath().toString(); + + long size = 0; + + File file = iFile.getLocation().toFile(); + try { + size = Files.size(file.toPath()); + } catch (IOException exception) { + IStatus status = new Status(IStatus.ERROR, SiriusServerBackendPlugin.PLUGIN_ID, exception.getMessage(), exception); + SiriusServerBackendPlugin.getPlugin().log(status); + } + + String sizeLabel = this.getSizeLabel(size); + + return new SiriusServerSemanticResourceDto(path, name, sizeLabel); + } + + /** + * Returns a label displaying the given size in KB or MB. + * + * @param size + * The size + * @return The label + */ + private String getSizeLabel(long size) { + DecimalFormat decimalFormat = new DecimalFormat("0.00"); //$NON-NLS-1$ + + double kb = 1024d; + double mb = kb * 1024d; + + if (size > mb) { + return decimalFormat.format(size / mb) + "MB"; //$NON-NLS-1$ + } + return decimalFormat.format(size / kb) + "KB"; //$NON-NLS-1$ + } +} diff --git a/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/services/project/SiriusServerSemanticResourceDto.java b/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/services/project/SiriusServerSemanticResourceDto.java new file mode 100644 index 0000000000..029f09cf21 --- /dev/null +++ b/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/services/project/SiriusServerSemanticResourceDto.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * Copyright (c) 2018 Obeo. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.server.backend.internal.services.project; + +/** + * The DTO used to represent a semantic resource. + * + * @author sbegaudeau + */ +@SuppressWarnings({ "checkstyle::javadocmethod", "checkstyle::javadocfield" }) +public class SiriusServerSemanticResourceDto { + private String path; + + private String name; + + private String size; + + /** + * The constructor. + * + * @param path + * The path + * @param name + * The name + * @param size + * The size + */ + public SiriusServerSemanticResourceDto(String path, String name, String size) { + this.path = path; + this.name = name; + this.size = size; + } + + public String getPath() { + return this.path; + } + + public String getName() { + return this.name; + } + + public String getSize() { + return this.size; + } +} diff --git a/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/services/project/SiriusServerTableDto.java b/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/services/project/SiriusServerTableDto.java new file mode 100644 index 0000000000..35e1a1ae80 --- /dev/null +++ b/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/services/project/SiriusServerTableDto.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright (c) 2018 Obeo. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.server.backend.internal.services.project; + +/** + * The DTO used to represent a table. + * + * @author sbegaudeau + */ +@SuppressWarnings({ "checkstyle::javadocmethod", "checkstyle::javadocfield" }) +public class SiriusServerTableDto extends AbstractSiriusServerRepresentationDto { + + private static final String KIND = "table"; //$NON-NLS-1$ + + /** + * The constructor. + * + * @param viewpointName + * The name of the viewpoint + * @param descriptionName + * The name of the description + * @param name + * The name + */ + public SiriusServerTableDto(String viewpointName, String descriptionName, String name) { + super(KIND, viewpointName, descriptionName, name); + } + +} diff --git a/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/services/project/SiriusServerTreeDto.java b/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/services/project/SiriusServerTreeDto.java new file mode 100644 index 0000000000..f05e28e62d --- /dev/null +++ b/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/services/project/SiriusServerTreeDto.java @@ -0,0 +1,38 @@ +/******************************************************************************* + * Copyright (c) 2018 Obeo. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.server.backend.internal.services.project; + +/** + * The DTO used to represent a tree. + * + * @author sbegaudeau + */ +@SuppressWarnings({ "checkstyle::javadocmethod", "checkstyle::javadocfield" }) +public class SiriusServerTreeDto extends AbstractSiriusServerRepresentationDto { + + private static final String KIND = "tree"; //$NON-NLS-1$ + + /** + * The constructor. + * + * @param viewpointName + * The name of the viewpoint + * + * @param descriptionName + * The name of the description + * @param name + * The name + */ + public SiriusServerTreeDto(String viewpointName, String descriptionName, String name) { + super(KIND, viewpointName, descriptionName, name); + } + +} diff --git a/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/services/projects/SiriusServerNewProjectDto.java b/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/services/projects/SiriusServerNewProjectDto.java new file mode 100644 index 0000000000..436ded6f2d --- /dev/null +++ b/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/services/projects/SiriusServerNewProjectDto.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright (c) 2018 Obeo. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.server.backend.internal.services.projects; + +/** + * The DTO sent by clients to create new projects. + * + * @author sbegaudeau + */ +@SuppressWarnings({ "checkstyle::javadocmethod", "checkstyle::javadocfield" }) +public class SiriusServerNewProjectDto { + private String name; + + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/services/projects/SiriusServerProjectDto.java b/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/services/projects/SiriusServerProjectDto.java new file mode 100644 index 0000000000..f9608b1ceb --- /dev/null +++ b/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/services/projects/SiriusServerProjectDto.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright (c) 2018 Obeo. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.server.backend.internal.services.projects; + +/** + * The DTO used to return a project. + * + * @author sbegaudeau + */ +@SuppressWarnings({ "checkstyle::javadocmethod", "checkstyle::javadocfield" }) +public class SiriusServerProjectDto { + private String name; + + /** + * The constructor. + * + * @param name + * The name of the project + */ + public SiriusServerProjectDto(String name) { + this.name = name; + } + + public String getName() { + return this.name; + } +} diff --git a/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/services/projects/SiriusServerProjectsDto.java b/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/services/projects/SiriusServerProjectsDto.java new file mode 100644 index 0000000000..a647ad9536 --- /dev/null +++ b/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/services/projects/SiriusServerProjectsDto.java @@ -0,0 +1,38 @@ +/******************************************************************************* + * Copyright (c) 2018 Obeo. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.server.backend.internal.services.projects; + +import java.util.ArrayList; +import java.util.List; + +/** + * The DTO used to return the list of projects. + * + * @author sbegaudeau + */ +@SuppressWarnings({ "checkstyle::javadocmethod", "checkstyle::javadocfield" }) +public class SiriusServerProjectsDto { + private List<SiriusServerProjectDto> projects = new ArrayList<>(); + + /** + * The constructor. + * + * @param projects + * The projects + */ + public SiriusServerProjectsDto(List<SiriusServerProjectDto> projects) { + this.projects = projects; + } + + public List<SiriusServerProjectDto> getProjects() { + return this.projects; + } +} diff --git a/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/services/projects/SiriusServerProjectsService.java b/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/services/projects/SiriusServerProjectsService.java new file mode 100644 index 0000000000..fa9ce4c484 --- /dev/null +++ b/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/services/projects/SiriusServerProjectsService.java @@ -0,0 +1,123 @@ +/******************************************************************************* + * Copyright (c) 2018 Obeo. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.server.backend.internal.services.projects; + +import static org.eclipse.sirius.server.backend.internal.SiriusServerResponse.STATUS_BAD_REQUEST; +import static org.eclipse.sirius.server.backend.internal.SiriusServerResponse.STATUS_CREATED; +import static org.eclipse.sirius.server.backend.internal.SiriusServerResponse.STATUS_INTERNAL_SERVER_ERROR; +import static org.eclipse.sirius.server.backend.internal.SiriusServerResponse.STATUS_OK; + +import com.google.gson.Gson; + +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.Reader; +import java.text.MessageFormat; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import javax.servlet.http.HttpServletRequest; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.emf.common.util.URI; +import org.eclipse.sirius.business.api.modelingproject.ModelingProject; +import org.eclipse.sirius.business.api.session.DefaultLocalSessionCreationOperation; +import org.eclipse.sirius.business.api.session.SessionCreationOperation; +import org.eclipse.sirius.server.backend.internal.ISiriusServerService; +import org.eclipse.sirius.server.backend.internal.SiriusServerMessages; +import org.eclipse.sirius.server.backend.internal.SiriusServerPath; +import org.eclipse.sirius.server.backend.internal.SiriusServerResponse; +import org.eclipse.sirius.server.backend.internal.utils.SiriusServerErrorDto; +import org.eclipse.sirius.server.backend.internal.utils.SiriusServerUtils; + +/** + * Service used to manipulate the list of projects. + * + * @author sbegaudeau + */ +@SiriusServerPath("/projects") +public class SiriusServerProjectsService implements ISiriusServerService { + + @Override + public SiriusServerResponse doGet(HttpServletRequest request, Map<String, String> variables, String remainingPart) { + return new SiriusServerResponse(STATUS_OK, this.getModelingProjects()); + } + + /** + * Returns all the modeling projects of the workspace. + * + * @return All the modeling projects of the workspace + */ + private SiriusServerProjectsDto getModelingProjects() { + IProject[] allProjects = ResourcesPlugin.getWorkspace().getRoot().getProjects(); + // @formatter:off + List<SiriusServerProjectDto> modelingProjects = Arrays.stream(allProjects) + .filter(ModelingProject::hasModelingProjectNature) + .filter(IProject::isOpen) + .map(project -> ModelingProject.asModelingProject(project).get()) + .map(this::convertToProject) + .collect(Collectors.toList()); + // @formatter:on + return new SiriusServerProjectsDto(modelingProjects); + } + + /** + * Converts the given modeling project into a + * {@link SiriusServerProjectDto}. + * + * @param modelingProject + * The modeling project + * @return The {@link SiriusServerProjectDto} created + */ + private SiriusServerProjectDto convertToProject(ModelingProject modelingProject) { + String name = modelingProject.getProject().getName(); + return new SiriusServerProjectDto(name); + } + + @Override + public SiriusServerResponse doPost(HttpServletRequest request, Map<String, String> variables, String remainingPart) { + SiriusServerResponse response = null; + try { + Reader reader = new InputStreamReader(request.getInputStream(), SiriusServerUtils.UTF_8); + SiriusServerNewProjectDto newProject = new Gson().fromJson(reader, SiriusServerNewProjectDto.class); + + String name = newProject.getName(); + IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name); + if (project.exists()) { + String message = MessageFormat.format(SiriusServerMessages.SiriusServerProjectsService_projectAlreadyExists, name); + response = new SiriusServerResponse(STATUS_BAD_REQUEST, new SiriusServerErrorDto(message)); + } else { + // TODO Improve this code once this issue is fixed: https://bugs.eclipse.org/bugs/show_bug.cgi?id=533931 + IProjectDescription projectDescription = ResourcesPlugin.getWorkspace().newProjectDescription(name); + projectDescription.setNatureIds(new String[] { ModelingProject.NATURE_ID }); + project.create(projectDescription, new NullProgressMonitor()); + project.open(new NullProgressMonitor()); + + URI representationsURI = URI.createPlatformResourceURI(project.getFullPath().append(ModelingProject.DEFAULT_REPRESENTATIONS_FILE_NAME).toString(), true); + SessionCreationOperation sessionCreationOperation = new DefaultLocalSessionCreationOperation(representationsURI, new NullProgressMonitor()); + sessionCreationOperation.execute(); + + response = new SiriusServerResponse(STATUS_CREATED, new SiriusServerProjectDto(name)); + } + } catch (@SuppressWarnings("unused") IOException | CoreException exception) { + // We don't want to send back the message of the exception + response = new SiriusServerResponse(STATUS_INTERNAL_SERVER_ERROR); + } + + return response; + } +} diff --git a/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/servlets/APIServlet.java b/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/servlets/APIServlet.java deleted file mode 100644 index 64603cfa73..0000000000 --- a/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/servlets/APIServlet.java +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2018 Obeo. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Obeo - initial API and implementation - *******************************************************************************/ -package org.eclipse.sirius.server.backend.internal.servlets; - -import java.io.IOException; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -/** - * The servlet used to retrieve some information regarding the state of the Sirius API. - * - * @author sbegaudeau - */ -public class APIServlet extends HttpServlet { - - /** - * The path of the servlet in the context. - */ - public static final String PATH = "/"; //$NON-NLS-1$ - - /** - * The generated serial version UID. - */ - private static final long serialVersionUID = 6210938150537358944L; - - /** - * {@inheritDoc} - * - * @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, - * javax.servlet.http.HttpServletResponse) - */ - @Override - protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - response.getWriter().write("Hello World"); //$NON-NLS-1$ - } - -} diff --git a/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/utils/SiriusServerErrorDto.java b/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/utils/SiriusServerErrorDto.java new file mode 100644 index 0000000000..7e59babce4 --- /dev/null +++ b/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/utils/SiriusServerErrorDto.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright (c) 2018 Obeo. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.server.backend.internal.utils; + +/** + * The DTO used to return an error. + * + * @author sbegaudeau + */ +@SuppressWarnings({ "checkstyle::javadocmethod", "checkstyle::javadocfield" }) +public class SiriusServerErrorDto { + private String message; + + /** + * The constructor. + * + * @param message + * The message + */ + public SiriusServerErrorDto(String message) { + this.message = message; + } + + public String getMessage() { + return this.message; + } +} diff --git a/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/utils/SiriusServerUtils.java b/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/utils/SiriusServerUtils.java new file mode 100644 index 0000000000..7a97954012 --- /dev/null +++ b/plugins/org.eclipse.sirius.server.backend/src/org/eclipse/sirius/server/backend/internal/utils/SiriusServerUtils.java @@ -0,0 +1,60 @@ +/******************************************************************************* + * Copyright (c) 2018 Obeo. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.server.backend.internal.utils; + +import java.util.Optional; + +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.emf.common.util.URI; +import org.eclipse.sirius.business.api.modelingproject.ModelingProject; +import org.eclipse.sirius.business.api.session.Session; +import org.eclipse.sirius.business.api.session.SessionManager; +import org.eclipse.sirius.viewpoint.SiriusPlugin; + +/** + * Utility class. + * + * @author sbegaudeau + */ +public final class SiriusServerUtils { + + /** + * The UTF-8 encoding. + */ + public static final String UTF_8 = "UTF-8"; //$NON-NLS-1$ + + /** + * The constructor. + */ + private SiriusServerUtils() { + // prevent instantiation + } + + /** + * Returns the session of the given modeling project or open a new one and + * return it. + * + * @param modelingProject + * The modeling project + * @return The session + */ + public static Session getSession(ModelingProject modelingProject) { + Optional<Session> optionalSession = Optional.ofNullable(modelingProject.getSession()); + Session session = optionalSession.orElseGet(() -> { + // FIXME SBE: proper management of optionals once Sirius has + // switched to Java optional + URI sessionResourceURI = modelingProject.getMainRepresentationsFileURI(new NullProgressMonitor()).get(); + return SessionManager.INSTANCE.openSession(sessionResourceURI, new NullProgressMonitor(), SiriusPlugin.getDefault().getUiCallback()); + }); + return session; + } + +} diff --git a/plugins/org.eclipse.sirius.server.frontend/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.sirius.server.frontend/.settings/org.eclipse.jdt.core.prefs index 523c3d606b..e9b804fc3a 100644 --- a/plugins/org.eclipse.sirius.server.frontend/.settings/org.eclipse.jdt.core.prefs +++ b/plugins/org.eclipse.sirius.server.frontend/.settings/org.eclipse.jdt.core.prefs @@ -109,9 +109,10 @@ org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning org.eclipse.jdt.core.compiler.source=1.8 +org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 @@ -122,8 +123,11 @@ org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header=0 org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 +org.eclipse.jdt.core.formatter.alignment_for_module_statements=16 org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 +org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references=0 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 @@ -133,10 +137,12 @@ org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_type_arguments=0 +org.eclipse.jdt.core.formatter.alignment_for_type_parameters=0 org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16 org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 org.eclipse.jdt.core.formatter.blank_lines_after_package=1 -org.eclipse.jdt.core.formatter.blank_lines_before_field=0 +org.eclipse.jdt.core.formatter.blank_lines_before_field=1 org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 @@ -157,8 +163,9 @@ org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line -org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=true org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false +org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position=false org.eclipse.jdt.core.formatter.comment.format_block_comments=true org.eclipse.jdt.core.formatter.comment.format_header=false org.eclipse.jdt.core.formatter.comment.format_html=true @@ -169,7 +176,7 @@ org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true org.eclipse.jdt.core.formatter.comment.indent_root_tags=true org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert -org.eclipse.jdt.core.formatter.comment.line_length=120 +org.eclipse.jdt.core.formatter.comment.line_length=80 org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false @@ -191,6 +198,7 @@ org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false org.eclipse.jdt.core.formatter.indentation.size=4 +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enum_constant=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert @@ -200,17 +208,17 @@ org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=insert org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=do not insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=do not insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert @@ -380,17 +388,29 @@ org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false -org.eclipse.jdt.core.formatter.lineSplit=150 +org.eclipse.jdt.core.formatter.lineSplit=200 org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 -org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true -org.eclipse.jdt.core.formatter.tabulation.char=tab +org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_enum_constant_declaration=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_lambda_declaration=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_switch_statement=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause=common_lines +org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=false +org.eclipse.jdt.core.formatter.tabulation.char=space org.eclipse.jdt.core.formatter.tabulation.size=4 org.eclipse.jdt.core.formatter.use_on_off_tags=true org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false +org.eclipse.jdt.core.formatter.wrap_before_assignment_operator=false org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true +org.eclipse.jdt.core.formatter.wrap_before_conditional_operator=true org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true org.eclipse.jdt.core.incompatibleJDKLevel=ignore diff --git a/plugins/org.eclipse.sirius.server.frontend/.settings/org.eclipse.jdt.ui.prefs b/plugins/org.eclipse.sirius.server.frontend/.settings/org.eclipse.jdt.ui.prefs index 3e1d90bc04..31ae3f46ff 100644 --- a/plugins/org.eclipse.sirius.server.frontend/.settings/org.eclipse.jdt.ui.prefs +++ b/plugins/org.eclipse.sirius.server.frontend/.settings/org.eclipse.jdt.ui.prefs @@ -1,6 +1,7 @@ eclipse.preferences.version=1 editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true -formatter_settings_version=12 +formatter_profile=_Sirius +formatter_settings_version=13 org.eclipse.jdt.ui.ignorelowercasenames=true org.eclipse.jdt.ui.importorder=com;java;javax;org; org.eclipse.jdt.ui.javadoc=true diff --git a/plugins/org.eclipse.sirius.server.frontend/src/org/eclipse/sirius/server/frontend/internal/SiriusServerFrontendConfigurator.java b/plugins/org.eclipse.sirius.server.frontend/src/org/eclipse/sirius/server/frontend/internal/SiriusServerFrontendConfigurator.java index 8c3ee82e4c..9bbfd138f3 100644 --- a/plugins/org.eclipse.sirius.server.frontend/src/org/eclipse/sirius/server/frontend/internal/SiriusServerFrontendConfigurator.java +++ b/plugins/org.eclipse.sirius.server.frontend/src/org/eclipse/sirius/server/frontend/internal/SiriusServerFrontendConfigurator.java @@ -35,55 +35,55 @@ import org.osgi.framework.Bundle; */ public class SiriusServerFrontendConfigurator implements ISiriusServerConfigurator { - /** - * The context path of the Sirius front-end. - */ - private static final String CONTEXT_PATH = "/"; //$NON-NLS-1$ + /** + * The context path of the Sirius front-end. + */ + private static final String CONTEXT_PATH = "/"; //$NON-NLS-1$ - /** - * The default servlet holder name. - */ - private static final String SERVLET_HOLDER_NAME = "SiriusFrontendServletHolder"; //$NON-NLS-1$ + /** + * The default servlet holder name. + */ + private static final String SERVLET_HOLDER_NAME = "SiriusFrontendServletHolder"; //$NON-NLS-1$ - /** - * The path of the front end resources. - */ - private static final String FRONTEND_RESOURCES_PATH = "./sirius-frontend"; //$NON-NLS-1$ + /** + * The path of the front end resources. + */ + private static final String FRONTEND_RESOURCES_PATH = "./sirius-frontend"; //$NON-NLS-1$ - /** - * The path of the default servlet used to expose the static resources. - */ - private static final String SERVLET_PATH = "/"; //$NON-NLS-1$ + /** + * The path of the default servlet used to expose the static resources. + */ + private static final String SERVLET_PATH = "/"; //$NON-NLS-1$ - /** - * {@inheritDoc} - * - * @see org.eclipse.sirius.server.api.ISiriusServerConfigurator#configure(org.eclipse.jetty.server.Server) - */ - @Override - public void configure(Server server) { - ServletContextHandler servletContextHandler = new ServletContextHandler(ServletContextHandler.SESSIONS | ServletContextHandler.GZIP); - servletContextHandler.setContextPath(CONTEXT_PATH); + /** + * {@inheritDoc} + * + * @see org.eclipse.sirius.server.api.ISiriusServerConfigurator#configure(org.eclipse.jetty.server.Server) + */ + @Override + public void configure(Server server) { + ServletContextHandler servletContextHandler = new ServletContextHandler(ServletContextHandler.SESSIONS | ServletContextHandler.GZIP); + servletContextHandler.setContextPath(CONTEXT_PATH); - try { - Bundle bundle = SiriusServerFrontendPlugin.getPlugin().getBundle(); - URL frontendResourcesURL = bundle.getResource(FRONTEND_RESOURCES_PATH); - URI frontendResourcesURI = FileLocator.resolve(frontendResourcesURL).toURI(); - String frontendResourcesPath = new File(frontendResourcesURI).getAbsolutePath(); + try { + Bundle bundle = SiriusServerFrontendPlugin.getPlugin().getBundle(); + URL frontendResourcesURL = bundle.getResource(FRONTEND_RESOURCES_PATH); + URI frontendResourcesURI = FileLocator.resolve(frontendResourcesURL).toURI(); + String frontendResourcesPath = new File(frontendResourcesURI).getAbsolutePath(); - ServletHolder servletHolder = new ServletHolder(SERVLET_HOLDER_NAME, new DefaultServlet()); - servletHolder.setInitParameter("resourceBase", frontendResourcesPath); //$NON-NLS-1$ - servletHolder.setInitParameter("dirAllowed", "false"); //$NON-NLS-1$ //$NON-NLS-2$ - servletContextHandler.addServlet(servletHolder, SERVLET_PATH); + ServletHolder servletHolder = new ServletHolder(SERVLET_HOLDER_NAME, new DefaultServlet()); + servletHolder.setInitParameter("resourceBase", frontendResourcesPath); //$NON-NLS-1$ + servletHolder.setInitParameter("dirAllowed", "false"); //$NON-NLS-1$ //$NON-NLS-2$ + servletContextHandler.addServlet(servletHolder, SERVLET_PATH); - Handler handler = server.getHandler(); - if (handler instanceof HandlerCollection) { - HandlerCollection handlerCollection = (HandlerCollection) handler; - handlerCollection.addHandler(servletContextHandler); - } - } catch (URISyntaxException | IOException exception) { - IStatus status = new Status(IStatus.ERROR, SiriusServerFrontendPlugin.PLUGIN_ID, exception.getMessage(), exception); - SiriusServerFrontendPlugin.getPlugin().log(status); - } - } + Handler handler = server.getHandler(); + if (handler instanceof HandlerCollection) { + HandlerCollection handlerCollection = (HandlerCollection) handler; + handlerCollection.addHandler(servletContextHandler); + } + } catch (URISyntaxException | IOException exception) { + IStatus status = new Status(IStatus.ERROR, SiriusServerFrontendPlugin.PLUGIN_ID, exception.getMessage(), exception); + SiriusServerFrontendPlugin.getPlugin().log(status); + } + } } diff --git a/plugins/org.eclipse.sirius.server.frontend/src/org/eclipse/sirius/server/frontend/internal/SiriusServerFrontendPlugin.java b/plugins/org.eclipse.sirius.server.frontend/src/org/eclipse/sirius/server/frontend/internal/SiriusServerFrontendPlugin.java index 453c04348f..d0012c4167 100644 --- a/plugins/org.eclipse.sirius.server.frontend/src/org/eclipse/sirius/server/frontend/internal/SiriusServerFrontendPlugin.java +++ b/plugins/org.eclipse.sirius.server.frontend/src/org/eclipse/sirius/server/frontend/internal/SiriusServerFrontendPlugin.java @@ -20,75 +20,75 @@ import org.osgi.framework.BundleContext; * @author sbegaudeau */ public class SiriusServerFrontendPlugin extends EMFPlugin { - /** - * The identifier of the plugin. - */ - public static final String PLUGIN_ID = "org.eclipse.sirius.server.frontend"; //$NON-NLS-1$ + /** + * The identifier of the plugin. + */ + public static final String PLUGIN_ID = "org.eclipse.sirius.server.frontend"; //$NON-NLS-1$ - /** - * The sole instance of the plugin. - */ - public static final SiriusServerFrontendPlugin INSTANCE = new SiriusServerFrontendPlugin(); + /** + * The sole instance of the plugin. + */ + public static final SiriusServerFrontendPlugin INSTANCE = new SiriusServerFrontendPlugin(); - /** - * The sole instance of the bundle activator. - */ - private static Implementation plugin; + /** + * The sole instance of the bundle activator. + */ + private static Implementation plugin; - /** - * The constructor. - */ - public SiriusServerFrontendPlugin() { - super(new ResourceLocator[0]); - } + /** + * The constructor. + */ + public SiriusServerFrontendPlugin() { + super(new ResourceLocator[0]); + } - @Override - public ResourceLocator getPluginResourceLocator() { - return plugin; - } + @Override + public ResourceLocator getPluginResourceLocator() { + return plugin; + } - /** - * Returns the singleton instance of the Eclipse plugin. - * - * @return the singleton instance. - */ - public static Implementation getPlugin() { - return plugin; - } + /** + * Returns the singleton instance of the Eclipse plugin. + * + * @return the singleton instance. + */ + public static Implementation getPlugin() { + return plugin; + } - /** - * The bundle activator. - * - * @author sbegaudeau - */ - public static class Implementation extends EclipsePlugin { + /** + * The bundle activator. + * + * @author sbegaudeau + */ + public static class Implementation extends EclipsePlugin { - /** - * The constructor. - */ - public Implementation() { - super(); - SiriusServerFrontendPlugin.plugin = this; - } + /** + * The constructor. + */ + public Implementation() { + super(); + SiriusServerFrontendPlugin.plugin = this; + } - /** - * {@inheritDoc} - * - * @see org.eclipse.core.runtime.Plugin#start(org.osgi.framework.BundleContext) - */ - @Override - public void start(BundleContext context) throws Exception { - super.start(context); - } + /** + * {@inheritDoc} + * + * @see org.eclipse.core.runtime.Plugin#start(org.osgi.framework.BundleContext) + */ + @Override + public void start(BundleContext context) throws Exception { + super.start(context); + } - /** - * {@inheritDoc} - * - * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext) - */ - @Override - public void stop(BundleContext context) throws Exception { - super.stop(context); - } - } + /** + * {@inheritDoc} + * + * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext) + */ + @Override + public void stop(BundleContext context) throws Exception { + super.stop(context); + } + } } diff --git a/plugins/org.eclipse.sirius.server.ui.autostart/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.sirius.server.ui.autostart/.settings/org.eclipse.jdt.core.prefs index 523c3d606b..e9b804fc3a 100644 --- a/plugins/org.eclipse.sirius.server.ui.autostart/.settings/org.eclipse.jdt.core.prefs +++ b/plugins/org.eclipse.sirius.server.ui.autostart/.settings/org.eclipse.jdt.core.prefs @@ -109,9 +109,10 @@ org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning org.eclipse.jdt.core.compiler.source=1.8 +org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 @@ -122,8 +123,11 @@ org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header=0 org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 +org.eclipse.jdt.core.formatter.alignment_for_module_statements=16 org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 +org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references=0 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 @@ -133,10 +137,12 @@ org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_type_arguments=0 +org.eclipse.jdt.core.formatter.alignment_for_type_parameters=0 org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16 org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 org.eclipse.jdt.core.formatter.blank_lines_after_package=1 -org.eclipse.jdt.core.formatter.blank_lines_before_field=0 +org.eclipse.jdt.core.formatter.blank_lines_before_field=1 org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 @@ -157,8 +163,9 @@ org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line -org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=true org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false +org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position=false org.eclipse.jdt.core.formatter.comment.format_block_comments=true org.eclipse.jdt.core.formatter.comment.format_header=false org.eclipse.jdt.core.formatter.comment.format_html=true @@ -169,7 +176,7 @@ org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true org.eclipse.jdt.core.formatter.comment.indent_root_tags=true org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert -org.eclipse.jdt.core.formatter.comment.line_length=120 +org.eclipse.jdt.core.formatter.comment.line_length=80 org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false @@ -191,6 +198,7 @@ org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false org.eclipse.jdt.core.formatter.indentation.size=4 +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enum_constant=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert @@ -200,17 +208,17 @@ org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=insert org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=do not insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=do not insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert @@ -380,17 +388,29 @@ org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false -org.eclipse.jdt.core.formatter.lineSplit=150 +org.eclipse.jdt.core.formatter.lineSplit=200 org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 -org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true -org.eclipse.jdt.core.formatter.tabulation.char=tab +org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_enum_constant_declaration=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_lambda_declaration=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_switch_statement=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause=common_lines +org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=false +org.eclipse.jdt.core.formatter.tabulation.char=space org.eclipse.jdt.core.formatter.tabulation.size=4 org.eclipse.jdt.core.formatter.use_on_off_tags=true org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false +org.eclipse.jdt.core.formatter.wrap_before_assignment_operator=false org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true +org.eclipse.jdt.core.formatter.wrap_before_conditional_operator=true org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true org.eclipse.jdt.core.incompatibleJDKLevel=ignore diff --git a/plugins/org.eclipse.sirius.server.ui.autostart/.settings/org.eclipse.jdt.ui.prefs b/plugins/org.eclipse.sirius.server.ui.autostart/.settings/org.eclipse.jdt.ui.prefs index 3e1d90bc04..31ae3f46ff 100644 --- a/plugins/org.eclipse.sirius.server.ui.autostart/.settings/org.eclipse.jdt.ui.prefs +++ b/plugins/org.eclipse.sirius.server.ui.autostart/.settings/org.eclipse.jdt.ui.prefs @@ -1,6 +1,7 @@ eclipse.preferences.version=1 editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true -formatter_settings_version=12 +formatter_profile=_Sirius +formatter_settings_version=13 org.eclipse.jdt.ui.ignorelowercasenames=true org.eclipse.jdt.ui.importorder=com;java;javax;org; org.eclipse.jdt.ui.javadoc=true diff --git a/plugins/org.eclipse.sirius.server/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.sirius.server/.settings/org.eclipse.jdt.core.prefs index 523c3d606b..e9b804fc3a 100644 --- a/plugins/org.eclipse.sirius.server/.settings/org.eclipse.jdt.core.prefs +++ b/plugins/org.eclipse.sirius.server/.settings/org.eclipse.jdt.core.prefs @@ -109,9 +109,10 @@ org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning org.eclipse.jdt.core.compiler.source=1.8 +org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 -org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 @@ -122,8 +123,11 @@ org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header=0 org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 +org.eclipse.jdt.core.formatter.alignment_for_module_statements=16 org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 +org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references=0 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 @@ -133,10 +137,12 @@ org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_type_arguments=0 +org.eclipse.jdt.core.formatter.alignment_for_type_parameters=0 org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16 org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 org.eclipse.jdt.core.formatter.blank_lines_after_package=1 -org.eclipse.jdt.core.formatter.blank_lines_before_field=0 +org.eclipse.jdt.core.formatter.blank_lines_before_field=1 org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 @@ -157,8 +163,9 @@ org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line -org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=true org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false +org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position=false org.eclipse.jdt.core.formatter.comment.format_block_comments=true org.eclipse.jdt.core.formatter.comment.format_header=false org.eclipse.jdt.core.formatter.comment.format_html=true @@ -169,7 +176,7 @@ org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true org.eclipse.jdt.core.formatter.comment.indent_root_tags=true org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert -org.eclipse.jdt.core.formatter.comment.line_length=120 +org.eclipse.jdt.core.formatter.comment.line_length=80 org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false @@ -191,6 +198,7 @@ org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false org.eclipse.jdt.core.formatter.indentation.size=4 +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enum_constant=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert @@ -200,17 +208,17 @@ org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=insert org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=do not insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert -org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=do not insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert @@ -380,17 +388,29 @@ org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false -org.eclipse.jdt.core.formatter.lineSplit=150 +org.eclipse.jdt.core.formatter.lineSplit=200 org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 -org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true -org.eclipse.jdt.core.formatter.tabulation.char=tab +org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_enum_constant_declaration=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_lambda_declaration=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_switch_statement=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause=common_lines +org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=false +org.eclipse.jdt.core.formatter.tabulation.char=space org.eclipse.jdt.core.formatter.tabulation.size=4 org.eclipse.jdt.core.formatter.use_on_off_tags=true org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false +org.eclipse.jdt.core.formatter.wrap_before_assignment_operator=false org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true +org.eclipse.jdt.core.formatter.wrap_before_conditional_operator=true org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true org.eclipse.jdt.core.incompatibleJDKLevel=ignore diff --git a/plugins/org.eclipse.sirius.server/.settings/org.eclipse.jdt.ui.prefs b/plugins/org.eclipse.sirius.server/.settings/org.eclipse.jdt.ui.prefs index 3e1d90bc04..31ae3f46ff 100644 --- a/plugins/org.eclipse.sirius.server/.settings/org.eclipse.jdt.ui.prefs +++ b/plugins/org.eclipse.sirius.server/.settings/org.eclipse.jdt.ui.prefs @@ -1,6 +1,7 @@ eclipse.preferences.version=1 editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true -formatter_settings_version=12 +formatter_profile=_Sirius +formatter_settings_version=13 org.eclipse.jdt.ui.ignorelowercasenames=true org.eclipse.jdt.ui.importorder=com;java;javax;org; org.eclipse.jdt.ui.javadoc=true diff --git a/plugins/org.eclipse.sirius.server/META-INF/MANIFEST.MF b/plugins/org.eclipse.sirius.server/META-INF/MANIFEST.MF index 388c53201a..2833e59980 100644 --- a/plugins/org.eclipse.sirius.server/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.sirius.server/META-INF/MANIFEST.MF @@ -8,6 +8,7 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-Localization: plugin Require-Bundle: org.eclipse.core.runtime;bundle-version="3.8.0", org.eclipse.emf.common;bundle-version="2.8.0", + javax.servlet;bundle-version="3.1.0", org.eclipse.jetty.server;bundle-version="[9.0.0,10.0.0)", org.eclipse.jetty.util;bundle-version="[9.0.0,10.0.0)", org.eclipse.sirius.ext.base;bundle-version="6.0.0", diff --git a/plugins/org.eclipse.sirius.server/src/org/eclipse/sirius/server/api/ISiriusServerConfigurator.java b/plugins/org.eclipse.sirius.server/src/org/eclipse/sirius/server/api/ISiriusServerConfigurator.java index 4926070a86..548bbb1ae3 100644 --- a/plugins/org.eclipse.sirius.server/src/org/eclipse/sirius/server/api/ISiriusServerConfigurator.java +++ b/plugins/org.eclipse.sirius.server/src/org/eclipse/sirius/server/api/ISiriusServerConfigurator.java @@ -18,11 +18,11 @@ import org.eclipse.jetty.server.Server; * @author sbegaudeau */ public interface ISiriusServerConfigurator { - /** - * Configures the given server. - * - * @param server - * The server - */ - void configure(Server server); + /** + * Configures the given server. + * + * @param server + * The server + */ + void configure(Server server); } diff --git a/plugins/org.eclipse.sirius.server/src/org/eclipse/sirius/server/internal/Messages.java b/plugins/org.eclipse.sirius.server/src/org/eclipse/sirius/server/internal/Messages.java index 877c529464..092a5da19f 100644 --- a/plugins/org.eclipse.sirius.server/src/org/eclipse/sirius/server/internal/Messages.java +++ b/plugins/org.eclipse.sirius.server/src/org/eclipse/sirius/server/internal/Messages.java @@ -20,20 +20,20 @@ import org.eclipse.sirius.ext.base.I18N.TranslatableMessage; */ public final class Messages { - static { - I18N.initializeMessages(Messages.class, SiriusServerPlugin.INSTANCE); - } + static { + I18N.initializeMessages(Messages.class, SiriusServerPlugin.INSTANCE); + } - // CHECKSTYLE:OFF + // CHECKSTYLE:OFF - @TranslatableMessage - public static String SiriusServerManager_cannotStartServer; + @TranslatableMessage + public static String SiriusServerManager_cannotStartServer; - @TranslatableMessage - public static String SiriusServerManager_cannotStopServer; - // CHECKSTYLE:ON + @TranslatableMessage + public static String SiriusServerManager_cannotStopServer; + // CHECKSTYLE:ON - private Messages() { - // Prevents instantiation. - } + private Messages() { + // Prevents instantiation. + } } diff --git a/plugins/org.eclipse.sirius.server/src/org/eclipse/sirius/server/internal/SiriusServerManager.java b/plugins/org.eclipse.sirius.server/src/org/eclipse/sirius/server/internal/SiriusServerManager.java index 1d08601f23..655966dfa0 100644 --- a/plugins/org.eclipse.sirius.server/src/org/eclipse/sirius/server/internal/SiriusServerManager.java +++ b/plugins/org.eclipse.sirius.server/src/org/eclipse/sirius/server/internal/SiriusServerManager.java @@ -24,60 +24,60 @@ import org.eclipse.jetty.server.handler.HandlerCollection; * @author sbegaudeau */ public class SiriusServerManager { - /** - * The VM argument used to customize the jetty {@link Server} port. - */ - private static final String PORT_VMARG = "SIRIUS_SERVER_PORT"; //$NON-NLS-1$ + /** + * The VM argument used to customize the jetty {@link Server} port. + */ + private static final String PORT_VMARG = "SIRIUS_SERVER_PORT"; //$NON-NLS-1$ - /** - * The default hostname. - */ - private static final String HOSTNAME = "localhost"; //$NON-NLS-1$ + /** + * The default hostname. + */ + private static final String HOSTNAME = "localhost"; //$NON-NLS-1$ - /** - * The default port. - */ - private static final String PORT = "8080"; //$NON-NLS-1$ + /** + * The default port. + */ + private static final String PORT = "8080"; //$NON-NLS-1$ - /** - * The Jetty server. - */ - private Server server; + /** + * The Jetty server. + */ + private Server server; - /** - * Starts the HTTP server. - */ - @SuppressWarnings({ "checkstyle:illegalcatch" }) - public void start() { - if (this.server == null || !this.server.isRunning()) { - int port = Integer.valueOf(System.getProperty(PORT_VMARG, PORT)).intValue(); - InetSocketAddress address = new InetSocketAddress(HOSTNAME, port); - this.server = new Server(address); - this.server.setHandler(new HandlerCollection()); + /** + * Starts the HTTP server. + */ + @SuppressWarnings({ "checkstyle:illegalcatch" }) + public void start() { + if (this.server == null || !this.server.isRunning()) { + int port = Integer.valueOf(System.getProperty(PORT_VMARG, PORT)).intValue(); + InetSocketAddress address = new InetSocketAddress(HOSTNAME, port); + this.server = new Server(address); + this.server.setHandler(new HandlerCollection()); - SiriusServerPlugin.getPlugin().getSiriusServerConfigurators().forEach(configurator -> configurator.configure(server)); + SiriusServerPlugin.getPlugin().getSiriusServerConfigurators().forEach(configurator -> configurator.configure(server)); - try { - this.server.start(); - } catch (Exception exception) { - IStatus status = new Status(IStatus.ERROR, SiriusServerPlugin.PLUGIN_ID, Messages.SiriusServerManager_cannotStartServer, exception); - SiriusServerPlugin.getPlugin().log(status); - } - } - } + try { + this.server.start(); + } catch (Exception exception) { + IStatus status = new Status(IStatus.ERROR, SiriusServerPlugin.PLUGIN_ID, Messages.SiriusServerManager_cannotStartServer, exception); + SiriusServerPlugin.getPlugin().log(status); + } + } + } - /** - * Stops the HTTP server. - */ - @SuppressWarnings({ "checkstyle:illegalcatch" }) - public void stop() { - Optional.ofNullable(this.server).ifPresent(s -> { - try { - s.stop(); - } catch (Exception exception) { - IStatus status = new Status(IStatus.ERROR, SiriusServerPlugin.PLUGIN_ID, Messages.SiriusServerManager_cannotStopServer, exception); - SiriusServerPlugin.getPlugin().log(status); - } - }); - } + /** + * Stops the HTTP server. + */ + @SuppressWarnings({ "checkstyle:illegalcatch" }) + public void stop() { + Optional.ofNullable(this.server).ifPresent(s -> { + try { + s.stop(); + } catch (Exception exception) { + IStatus status = new Status(IStatus.ERROR, SiriusServerPlugin.PLUGIN_ID, Messages.SiriusServerManager_cannotStopServer, exception); + SiriusServerPlugin.getPlugin().log(status); + } + }); + } } diff --git a/plugins/org.eclipse.sirius.server/src/org/eclipse/sirius/server/internal/SiriusServerPlugin.java b/plugins/org.eclipse.sirius.server/src/org/eclipse/sirius/server/internal/SiriusServerPlugin.java index 988eb39cfa..bb16c84fcb 100644 --- a/plugins/org.eclipse.sirius.server/src/org/eclipse/sirius/server/internal/SiriusServerPlugin.java +++ b/plugins/org.eclipse.sirius.server/src/org/eclipse/sirius/server/internal/SiriusServerPlugin.java @@ -31,125 +31,124 @@ import org.osgi.framework.BundleContext; * @author sbegaudeau */ public class SiriusServerPlugin extends EMFPlugin { - /** - * The identifier of the plugin. - */ - public static final String PLUGIN_ID = "org.eclipse.sirius.server"; //$NON-NLS-1$ - - /** - * The sole instance of the plugin. - */ - public static final SiriusServerPlugin INSTANCE = new SiriusServerPlugin(); - - /** - * The sole instance of the bundle activator. - */ - private static Implementation plugin; - - /** - * The constructor. - */ - public SiriusServerPlugin() { - super(new ResourceLocator[0]); - } - - @Override - public ResourceLocator getPluginResourceLocator() { - return plugin; - } - - /** - * Returns the singleton instance of the Eclipse plugin. - * - * @return the singleton instance. - */ - public static Implementation getPlugin() { - return plugin; - } - - /** - * The bundle activator. - * - * @author sbegaudeau - */ - public static class Implementation extends EclipsePlugin { - - /** - * The name of the extention point. - */ - private static final String SIRIUS_SERVER_CONFIGURATOR = "siriusServerConfigurator"; //$NON-NLS-1$ - - /** - * The {@link IItemRegistry} used to retrieve the configurators. - */ - private IItemRegistry<ISiriusServerConfigurator> siriusServerConfiguratorRegistry; - - /** - * The extension registry listener for the configurator. - */ - private AbstractRegistryEventListener siriusServerConfiguratorListener; - - /** - * The server manager. - */ - private SiriusServerManager serverManager = new SiriusServerManager(); - - /** - * The constructor. - */ - public Implementation() { - super(); - SiriusServerPlugin.plugin = this; - } - - /** - * {@inheritDoc} - * - * @see org.eclipse.core.runtime.Plugin#start(org.osgi.framework.BundleContext) - */ - @Override - public void start(BundleContext context) throws Exception { - super.start(context); - - IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry(); - this.siriusServerConfiguratorRegistry = new ItemRegistry<>(); - this.siriusServerConfiguratorListener = new DescriptorRegistryEventListener<>(PLUGIN_ID, SIRIUS_SERVER_CONFIGURATOR, - this.siriusServerConfiguratorRegistry); - extensionRegistry.addListener(this.siriusServerConfiguratorListener, PLUGIN_ID + '.' + SIRIUS_SERVER_CONFIGURATOR); - this.siriusServerConfiguratorListener.readRegistry(extensionRegistry); - - this.serverManager.start(); - } - - /** - * {@inheritDoc} - * - * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext) - */ - @Override - public void stop(BundleContext context) throws Exception { - this.serverManager.stop(); - - IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry(); - extensionRegistry.removeListener(this.siriusServerConfiguratorListener); - - this.siriusServerConfiguratorListener = null; - this.siriusServerConfiguratorRegistry = null; - - super.stop(context); - } - - /** - * Returns the list of the {@link ISiriusServerConfigurator}. - * - * @return The list of the {@link ISiriusServerConfigurator} - */ - public List<ISiriusServerConfigurator> getSiriusServerConfigurators() { - // @formatter:off + /** + * The identifier of the plugin. + */ + public static final String PLUGIN_ID = "org.eclipse.sirius.server"; //$NON-NLS-1$ + + /** + * The sole instance of the plugin. + */ + public static final SiriusServerPlugin INSTANCE = new SiriusServerPlugin(); + + /** + * The sole instance of the bundle activator. + */ + private static Implementation plugin; + + /** + * The constructor. + */ + public SiriusServerPlugin() { + super(new ResourceLocator[0]); + } + + @Override + public ResourceLocator getPluginResourceLocator() { + return plugin; + } + + /** + * Returns the singleton instance of the Eclipse plugin. + * + * @return the singleton instance. + */ + public static Implementation getPlugin() { + return plugin; + } + + /** + * The bundle activator. + * + * @author sbegaudeau + */ + public static class Implementation extends EclipsePlugin { + + /** + * The name of the extention point. + */ + private static final String SIRIUS_SERVER_CONFIGURATOR = "siriusServerConfigurator"; //$NON-NLS-1$ + + /** + * The {@link IItemRegistry} used to retrieve the configurators. + */ + private IItemRegistry<ISiriusServerConfigurator> siriusServerConfiguratorRegistry; + + /** + * The extension registry listener for the configurator. + */ + private AbstractRegistryEventListener siriusServerConfiguratorListener; + + /** + * The server manager. + */ + private SiriusServerManager serverManager = new SiriusServerManager(); + + /** + * The constructor. + */ + public Implementation() { + super(); + SiriusServerPlugin.plugin = this; + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.core.runtime.Plugin#start(org.osgi.framework.BundleContext) + */ + @Override + public void start(BundleContext context) throws Exception { + super.start(context); + + IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry(); + this.siriusServerConfiguratorRegistry = new ItemRegistry<>(); + this.siriusServerConfiguratorListener = new DescriptorRegistryEventListener<>(PLUGIN_ID, SIRIUS_SERVER_CONFIGURATOR, this.siriusServerConfiguratorRegistry); + extensionRegistry.addListener(this.siriusServerConfiguratorListener, PLUGIN_ID + '.' + SIRIUS_SERVER_CONFIGURATOR); + this.siriusServerConfiguratorListener.readRegistry(extensionRegistry); + + this.serverManager.start(); + } + + /** + * {@inheritDoc} + * + * @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext) + */ + @Override + public void stop(BundleContext context) throws Exception { + this.serverManager.stop(); + + IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry(); + extensionRegistry.removeListener(this.siriusServerConfiguratorListener); + + this.siriusServerConfiguratorListener = null; + this.siriusServerConfiguratorRegistry = null; + + super.stop(context); + } + + /** + * Returns the list of the {@link ISiriusServerConfigurator}. + * + * @return The list of the {@link ISiriusServerConfigurator} + */ + public List<ISiriusServerConfigurator> getSiriusServerConfigurators() { + // @formatter:off return this.siriusServerConfiguratorRegistry.getItemDescriptors().stream() .map(IItemDescriptor::getItem) .collect(Collectors.toList()); // @formatter:on - } - } + } + } } diff --git a/plugins/org.eclipse.sirius.tests.server.backend/.checkstyle b/plugins/org.eclipse.sirius.tests.server.backend/.checkstyle new file mode 100644 index 0000000000..3c756ff819 --- /dev/null +++ b/plugins/org.eclipse.sirius.tests.server.backend/.checkstyle @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<fileset-config file-format-version="1.2.0" simple-config="true" sync-formatter="false"> + <local-check-config name="Sirius Checks" location="/org.eclipse.sirius.settings/CheckstyleConfiguration.xml" type="project" description=""> + <additional-data name="protect-config-file" value="false"/> + </local-check-config> + <fileset name="all" enabled="true" check-config-name="Sirius Checks" local="true"> + <file-match-pattern match-pattern="." include-pattern="true"/> + </fileset> + <filter name="FilesFromPackage" enabled="true"> + <filter-data value="src-gen"/> + </filter> +</fileset-config> diff --git a/plugins/org.eclipse.sirius.tests.server.backend/.classpath b/plugins/org.eclipse.sirius.tests.server.backend/.classpath new file mode 100644 index 0000000000..eca7bdba8f --- /dev/null +++ b/plugins/org.eclipse.sirius.tests.server.backend/.classpath @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="src" path="src"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/plugins/org.eclipse.sirius.tests.server.backend/.project b/plugins/org.eclipse.sirius.tests.server.backend/.project new file mode 100644 index 0000000000..9b30ff3d3c --- /dev/null +++ b/plugins/org.eclipse.sirius.tests.server.backend/.project @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.sirius.tests.server.backend</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>net.sf.eclipsecs.core.CheckstyleBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + <nature>net.sf.eclipsecs.core.CheckstyleNature</nature> + </natures> +</projectDescription> diff --git a/plugins/org.eclipse.sirius.tests.server.backend/.settings/org.eclipse.core.resources.prefs b/plugins/org.eclipse.sirius.tests.server.backend/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000000..9093a2c880 --- /dev/null +++ b/plugins/org.eclipse.sirius.tests.server.backend/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,4 @@ +#Thu Jan 26 14:35:58 CET 2012 +eclipse.preferences.version=1 +encoding/<project>=US-ASCII +encoding/analysis_templates=ISO-8859-1 diff --git a/plugins/org.eclipse.sirius.tests.server.backend/.settings/org.eclipse.core.runtime.prefs b/plugins/org.eclipse.sirius.tests.server.backend/.settings/org.eclipse.core.runtime.prefs new file mode 100644 index 0000000000..a287fefdba --- /dev/null +++ b/plugins/org.eclipse.sirius.tests.server.backend/.settings/org.eclipse.core.runtime.prefs @@ -0,0 +1,3 @@ +#Mon Sep 24 15:04:19 CEST 2007 +eclipse.preferences.version=1 +line.separator=\n diff --git a/plugins/org.eclipse.sirius.tests.server.backend/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.sirius.tests.server.backend/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..e9b804fc3a --- /dev/null +++ b/plugins/org.eclipse.sirius.tests.server.backend/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,418 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.builder.cleanOutputFolder=clean +org.eclipse.jdt.core.builder.duplicateResourceTask=warning +org.eclipse.jdt.core.builder.invalidClasspath=abort +org.eclipse.jdt.core.builder.recreateModifiedClassFileInOutputFolder=ignore +org.eclipse.jdt.core.builder.resourceCopyExclusionFilter= +org.eclipse.jdt.core.circularClasspath=error +org.eclipse.jdt.core.classpath.exclusionPatterns=enabled +org.eclipse.jdt.core.classpath.multipleOutputLocations=enabled +org.eclipse.jdt.core.classpath.outputOverlappingAnotherSource=error +org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled +org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore +org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.maxProblemPerUnit=100 +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.autoboxing=warning +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=warning +org.eclipse.jdt.core.compiler.problem.emptyStatement=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore +org.eclipse.jdt.core.compiler.problem.fallthroughCase=error +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=warning +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=error +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=error +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDefaultCase=error +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=error +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=error +org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning +org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=error +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning +org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning +org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=warning +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=warning +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=warning +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=warning +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning +org.eclipse.jdt.core.compiler.source=1.8 +org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647 +org.eclipse.jdt.core.formatter.align_type_members_on_columns=false +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_assignment=0 +org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 +org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 +org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header=0 +org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 +org.eclipse.jdt.core.formatter.alignment_for_module_statements=16 +org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 +org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references=0 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 +org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_type_arguments=0 +org.eclipse.jdt.core.formatter.alignment_for_type_parameters=0 +org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16 +org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_after_package=1 +org.eclipse.jdt.core.formatter.blank_lines_before_field=1 +org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 +org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 +org.eclipse.jdt.core.formatter.blank_lines_before_method=1 +org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 +org.eclipse.jdt.core.formatter.blank_lines_before_package=0 +org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 +org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 +org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=true +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false +org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position=false +org.eclipse.jdt.core.formatter.comment.format_block_comments=true +org.eclipse.jdt.core.formatter.comment.format_header=false +org.eclipse.jdt.core.formatter.comment.format_html=true +org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true +org.eclipse.jdt.core.formatter.comment.format_line_comments=true +org.eclipse.jdt.core.formatter.comment.format_source_code=true +org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true +org.eclipse.jdt.core.formatter.comment.indent_root_tags=true +org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert +org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert +org.eclipse.jdt.core.formatter.comment.line_length=80 +org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true +org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true +org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false +org.eclipse.jdt.core.formatter.compact_else_if=true +org.eclipse.jdt.core.formatter.continuation_indentation=2 +org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 +org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off +org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on +org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false +org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true +org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_empty_lines=false +org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true +org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false +org.eclipse.jdt.core.formatter.indentation.size=4 +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=insert +org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert +org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert +org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert +org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.join_lines_in_comments=true +org.eclipse.jdt.core.formatter.join_wrapped_lines=true +org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false +org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false +org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false +org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false +org.eclipse.jdt.core.formatter.lineSplit=200 +org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false +org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 +org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 +org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_enum_constant_declaration=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_lambda_declaration=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_switch_statement=common_lines +org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause=common_lines +org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=false +org.eclipse.jdt.core.formatter.tabulation.char=space +org.eclipse.jdt.core.formatter.tabulation.size=4 +org.eclipse.jdt.core.formatter.use_on_off_tags=true +org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false +org.eclipse.jdt.core.formatter.wrap_before_assignment_operator=false +org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true +org.eclipse.jdt.core.formatter.wrap_before_conditional_operator=true +org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true +org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true +org.eclipse.jdt.core.incompatibleJDKLevel=ignore +org.eclipse.jdt.core.incompleteClasspath=error +org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter diff --git a/plugins/org.eclipse.sirius.tests.server.backend/.settings/org.eclipse.jdt.launching.prefs b/plugins/org.eclipse.sirius.tests.server.backend/.settings/org.eclipse.jdt.launching.prefs new file mode 100644 index 0000000000..3bb235278e --- /dev/null +++ b/plugins/org.eclipse.sirius.tests.server.backend/.settings/org.eclipse.jdt.launching.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.launching.PREF_STRICTLY_COMPATIBLE_JRE_NOT_AVAILABLE=ignore diff --git a/plugins/org.eclipse.sirius.tests.server.backend/.settings/org.eclipse.jdt.ui.prefs b/plugins/org.eclipse.sirius.tests.server.backend/.settings/org.eclipse.jdt.ui.prefs new file mode 100644 index 0000000000..31ae3f46ff --- /dev/null +++ b/plugins/org.eclipse.sirius.tests.server.backend/.settings/org.eclipse.jdt.ui.prefs @@ -0,0 +1,68 @@ +eclipse.preferences.version=1 +editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true +formatter_profile=_Sirius +formatter_settings_version=13 +org.eclipse.jdt.ui.ignorelowercasenames=true +org.eclipse.jdt.ui.importorder=com;java;javax;org; +org.eclipse.jdt.ui.javadoc=true +org.eclipse.jdt.ui.ondemandthreshold=99 +org.eclipse.jdt.ui.staticondemandthreshold=99 +org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates><template autoinsert\="false" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\n * Return the ${bare_field_name}.\n *\n * @return the ${bare_field_name}\n */</template><template autoinsert\="false" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\n * Sets the ${bare_field_name}.\n *\n * @param ${param} the ${bare_field_name} to set\n */</template><template autoinsert\="true" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\n * ${tags}\n */</template><template autoinsert\="false" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/*******************************************************************************\n * Copyright (c) 2018 Obeo.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http\://www.eclipse.org/legal/epl-v10.html\n *\n * Contributors\:\n * Obeo - initial API and implementation\n *******************************************************************************/</template><template autoinsert\="true" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\n * @author ${user}\n *\n * ${tags}\n */</template><template autoinsert\="true" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\n * \n */</template><template autoinsert\="true" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\n * ${tags}\n */</template><template autoinsert\="false" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment">/**\n * {@inheritDoc}\n *\n * ${see_to_overridden}\n */</template><template autoinsert\="true" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment">/**\n * ${tags}\n * ${see_to_target}\n */</template><template autoinsert\="true" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\n${package_declaration}\n\n${typecomment}\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\n</template><template autoinsert\="false" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">e.printStackTrace();</template><template autoinsert\="false" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">${body_statement}</template><template autoinsert\="false" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}</template><template autoinsert\="false" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return this.${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates> +sp_cleanup.add_default_serial_version_id=false +sp_cleanup.add_generated_serial_version_id=false +sp_cleanup.add_missing_annotations=true +sp_cleanup.add_missing_deprecated_annotations=true +sp_cleanup.add_missing_methods=false +sp_cleanup.add_missing_nls_tags=false +sp_cleanup.add_missing_override_annotations=true +sp_cleanup.add_missing_override_annotations_interface_methods=true +sp_cleanup.add_serial_version_id=false +sp_cleanup.always_use_blocks=false +sp_cleanup.always_use_parentheses_in_expressions=false +sp_cleanup.always_use_this_for_non_static_field_access=false +sp_cleanup.always_use_this_for_non_static_method_access=false +sp_cleanup.convert_functional_interfaces=false +sp_cleanup.convert_to_enhanced_for_loop=false +sp_cleanup.correct_indentation=true +sp_cleanup.format_source_code=true +sp_cleanup.format_source_code_changes_only=false +sp_cleanup.insert_inferred_type_arguments=false +sp_cleanup.make_local_variable_final=false +sp_cleanup.make_parameters_final=false +sp_cleanup.make_private_fields_final=false +sp_cleanup.make_type_abstract_if_missing_method=false +sp_cleanup.make_variable_declarations_final=false +sp_cleanup.never_use_blocks=false +sp_cleanup.never_use_parentheses_in_expressions=false +sp_cleanup.on_save_use_additional_actions=true +sp_cleanup.organize_imports=true +sp_cleanup.qualify_static_field_accesses_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=false +sp_cleanup.qualify_static_member_accesses_with_declaring_class=false +sp_cleanup.qualify_static_method_accesses_with_declaring_class=false +sp_cleanup.remove_private_constructors=false +sp_cleanup.remove_redundant_type_arguments=false +sp_cleanup.remove_trailing_whitespaces=true +sp_cleanup.remove_trailing_whitespaces_all=true +sp_cleanup.remove_trailing_whitespaces_ignore_empty=false +sp_cleanup.remove_unnecessary_casts=true +sp_cleanup.remove_unnecessary_nls_tags=true +sp_cleanup.remove_unused_imports=true +sp_cleanup.remove_unused_local_variables=false +sp_cleanup.remove_unused_private_fields=false +sp_cleanup.remove_unused_private_members=false +sp_cleanup.remove_unused_private_methods=false +sp_cleanup.remove_unused_private_types=false +sp_cleanup.sort_members=false +sp_cleanup.sort_members_all=false +sp_cleanup.use_anonymous_class_creation=false +sp_cleanup.use_blocks=false +sp_cleanup.use_blocks_only_for_return_and_throw=false +sp_cleanup.use_lambda=false +sp_cleanup.use_parentheses_in_expressions=false +sp_cleanup.use_this_for_non_static_field_access=false +sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=false +sp_cleanup.use_this_for_non_static_method_access=false +sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=false +sp_cleanup.use_type_arguments=false diff --git a/plugins/org.eclipse.sirius.tests.server.backend/.settings/org.eclipse.ltk.core.refactoring.prefs b/plugins/org.eclipse.sirius.tests.server.backend/.settings/org.eclipse.ltk.core.refactoring.prefs new file mode 100644 index 0000000000..b196c64a34 --- /dev/null +++ b/plugins/org.eclipse.sirius.tests.server.backend/.settings/org.eclipse.ltk.core.refactoring.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false diff --git a/plugins/org.eclipse.sirius.tests.server.backend/.settings/org.eclipse.pde.core.prefs b/plugins/org.eclipse.sirius.tests.server.backend/.settings/org.eclipse.pde.core.prefs new file mode 100644 index 0000000000..923c37fb8d --- /dev/null +++ b/plugins/org.eclipse.sirius.tests.server.backend/.settings/org.eclipse.pde.core.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +resolve.requirebundle=false diff --git a/plugins/org.eclipse.sirius.tests.server.backend/.settings/org.eclipse.pde.prefs b/plugins/org.eclipse.sirius.tests.server.backend/.settings/org.eclipse.pde.prefs new file mode 100644 index 0000000000..12b4bcc1a4 --- /dev/null +++ b/plugins/org.eclipse.sirius.tests.server.backend/.settings/org.eclipse.pde.prefs @@ -0,0 +1,32 @@ +compilers.f.unresolved-features=1 +compilers.f.unresolved-plugins=1 +compilers.incompatible-environment=1 +compilers.p.build=1 +compilers.p.build.bin.includes=1 +compilers.p.build.encodings=1 +compilers.p.build.java.compiler=1 +compilers.p.build.java.compliance=1 +compilers.p.build.missing.output=2 +compilers.p.build.output.library=1 +compilers.p.build.source.library=1 +compilers.p.build.src.includes=1 +compilers.p.deprecated=1 +compilers.p.discouraged-class=1 +compilers.p.internal=1 +compilers.p.missing-packages=1 +compilers.p.missing-version-export-package=2 +compilers.p.missing-version-import-package=0 +compilers.p.missing-version-require-bundle=0 +compilers.p.no-required-att=0 +compilers.p.not-externalized-att=0 +compilers.p.unknown-attribute=1 +compilers.p.unknown-class=1 +compilers.p.unknown-element=1 +compilers.p.unknown-identifier=1 +compilers.p.unknown-resource=1 +compilers.p.unresolved-ex-points=0 +compilers.p.unresolved-import=0 +compilers.s.create-docs=false +compilers.s.doc-folder=doc +compilers.s.open-tags=1 +eclipse.preferences.version=1 diff --git a/plugins/org.eclipse.sirius.tests.server.backend/META-INF/MANIFEST.MF b/plugins/org.eclipse.sirius.tests.server.backend/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..5f3c61044d --- /dev/null +++ b/plugins/org.eclipse.sirius.tests.server.backend/META-INF/MANIFEST.MF @@ -0,0 +1,11 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: %pluginName +Bundle-SymbolicName: org.eclipse.sirius.tests.server.backend +Bundle-Version: 6.0.0.qualifier +Bundle-Vendor: %providerName +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Bundle-Localization: plugin +Require-Bundle: org.junit;bundle-version="4.12.0", + org.eclipse.sirius.server.backend;bundle-version="6.0.0" +Export-Package: org.eclipse.sirius.tests.server.backend.internal;version="6.0.0" diff --git a/plugins/org.eclipse.sirius.tests.server.backend/build.properties b/plugins/org.eclipse.sirius.tests.server.backend/build.properties new file mode 100644 index 0000000000..2ed1abe937 --- /dev/null +++ b/plugins/org.eclipse.sirius.tests.server.backend/build.properties @@ -0,0 +1,17 @@ +# ==================================================================== +# Copyright (c) 2018 Obeo +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# Obeo - initial API and implementation +# ==================================================================== +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + plugin.properties +javacProjectSettings = true +javacDefaultEncoding.. = US-ASCII diff --git a/plugins/org.eclipse.sirius.tests.server.backend/plugin.properties b/plugins/org.eclipse.sirius.tests.server.backend/plugin.properties new file mode 100644 index 0000000000..95a691fe70 --- /dev/null +++ b/plugins/org.eclipse.sirius.tests.server.backend/plugin.properties @@ -0,0 +1,12 @@ +# ==================================================================== +# Copyright (c) 2018 Obeo +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# Obeo - initial API and implementation +# ==================================================================== +pluginName = Sirius Server Backend Tests +providerName = Eclipse Modeling Project
\ No newline at end of file diff --git a/plugins/org.eclipse.sirius.tests.server.backend/pom.xml b/plugins/org.eclipse.sirius.tests.server.backend/pom.xml new file mode 100644 index 0000000000..2abac2bda2 --- /dev/null +++ b/plugins/org.eclipse.sirius.tests.server.backend/pom.xml @@ -0,0 +1,50 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Copyright (c) 2018 Obeo + All rights reserved. This program and the accompanying materials + are made available under the terms of the Eclipse Public License v1.0 + which accompanies this distribution, and is available at + http://www.eclipse.org/legal/epl-v10.html + + Contributors: + Obeo - Initial API and implementation +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.eclipse.sirius</groupId> + <artifactId>sirius-parent</artifactId> + <version>6.0.0-SNAPSHOT</version> + <relativePath>../../packaging/org.eclipse.sirius.parent</relativePath> + </parent> + + <properties> + <sonar.coverage.exclusions>src/**/*</sonar.coverage.exclusions> + </properties> + + <artifactId>org.eclipse.sirius.tests.server.backend</artifactId> + <packaging>eclipse-test-plugin</packaging> + + <build> + <plugins> + <plugin> + <groupId>org.eclipse.tycho</groupId> + <artifactId>tycho-surefire-plugin</artifactId> + <version>${tycho-version}</version> + <configuration> + <skipTests>${tests.junit.skip}</skipTests> + <includes> + <include>${tests.junit.include}</include> + </includes> + <argLine>${tests.vmargs}</argLine> + <testFailureIgnore>${tests.ignoreFailures}</testFailureIgnore> + <testClass>org.eclipse.sirius.tests.server.backend.internal.SiriusServerBackendTests</testClass> + </configuration> + </plugin> + </plugins> + </build> + +</project> diff --git a/plugins/org.eclipse.sirius.tests.server.backend/src/org/eclipse/sirius/tests/server/backend/internal/SiriusServerBackendTests.java b/plugins/org.eclipse.sirius.tests.server.backend/src/org/eclipse/sirius/tests/server/backend/internal/SiriusServerBackendTests.java new file mode 100644 index 0000000000..23c961e46e --- /dev/null +++ b/plugins/org.eclipse.sirius.tests.server.backend/src/org/eclipse/sirius/tests/server/backend/internal/SiriusServerBackendTests.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2018 Obeo. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.tests.server.backend.internal; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; + +/** + * Test suite for the Sirius server backend. + * + * @author sbegaudeau + */ +@RunWith(Suite.class) +@SuiteClasses({ SiriusServerPathMatcherTests.class }) +public class SiriusServerBackendTests { + // Do nothing +} diff --git a/plugins/org.eclipse.sirius.tests.server.backend/src/org/eclipse/sirius/tests/server/backend/internal/SiriusServerPathMatcherTests.java b/plugins/org.eclipse.sirius.tests.server.backend/src/org/eclipse/sirius/tests/server/backend/internal/SiriusServerPathMatcherTests.java new file mode 100644 index 0000000000..e5a25a2959 --- /dev/null +++ b/plugins/org.eclipse.sirius.tests.server.backend/src/org/eclipse/sirius/tests/server/backend/internal/SiriusServerPathMatcherTests.java @@ -0,0 +1,125 @@ +/******************************************************************************* + * Copyright (c) 2018 Obeo. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.sirius.tests.server.backend.internal; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.util.Map; + +import org.eclipse.sirius.server.backend.internal.SiriusServerMatchResult; +import org.eclipse.sirius.server.backend.internal.SiriusServerPathMatcher; +import org.junit.Test; + +/** + * Unit tests for the {@link SiriusServerPathMatcher}. + * + * @author sbegaudeau + */ +@SuppressWarnings({ "checkstyle:javadocmethod" }) +public class SiriusServerPathMatcherTests { + + /** The path of the API. */ + private static final String API_PATH = "/api"; //$NON-NLS-1$ + + /** The path of the projects API. */ + private static final String PROJECTS_PATH = "/api/projects"; //$NON-NLS-1$ + + /** The path of the project API. */ + private static final String PROJECT_PATH = "/api/projects/{projectName}"; //$NON-NLS-1$ + + /** The path of the representations API. */ + private static final String REPRESENTATIONS_PATH = "/api/projects/{projectName}/representations"; //$NON-NLS-1$ + + /** The path of the representation API. */ + private static final String REPRESENTATION_PATH = "/api/projects/{projectName}/representations/{representationName}"; //$NON-NLS-1$ + + /** The name of the variable used to capture the project name. */ + private static final String PROJECT_NAME_VARIABLE = "projectName"; //$NON-NLS-1$ + + /** The name of the variable used to capture the representation name. */ + private static final String REPRESENTATION_NAME_VARIABLE = "representationName"; //$NON-NLS-1$ + + /** The name of the test project. */ + private static final String SAMPLE = "sample"; //$NON-NLS-1$ + + /** The name of the test representation. */ + private static final String CLASS_DIAGRAM = "classDiagram"; //$NON-NLS-1$ + + @Test + public void testAPIPathValidRequest() { + SiriusServerPathMatcher pathMatcher = new SiriusServerPathMatcher(API_PATH); + SiriusServerMatchResult matchResult = pathMatcher.match("/api"); //$NON-NLS-1$ + assertTrue(matchResult.hasMatched()); + } + + @Test + public void testAPIPathInvalidRequest() { + SiriusServerPathMatcher pathMatcher = new SiriusServerPathMatcher(API_PATH); + SiriusServerMatchResult matchResult = pathMatcher.match("/invalid"); //$NON-NLS-1$ + assertFalse(matchResult.hasMatched()); + } + + @Test + public void testProjectsPathValidRequest() { + SiriusServerPathMatcher pathMatcher = new SiriusServerPathMatcher(PROJECTS_PATH); + SiriusServerMatchResult matchResult = pathMatcher.match("/api/projects"); //$NON-NLS-1$ + assertTrue(matchResult.hasMatched()); + } + + @Test + public void testProjectPathValidRequest() { + SiriusServerPathMatcher pathMatcher = new SiriusServerPathMatcher(PROJECT_PATH); + SiriusServerMatchResult matchResult = pathMatcher.match("/api/projects/sample"); //$NON-NLS-1$ + assertTrue(matchResult.hasMatched()); + + Map<String, String> variables = matchResult.getVariables(); + assertEquals(variables.size(), 1); + assertEquals(variables.get(PROJECT_NAME_VARIABLE), SAMPLE); + } + + @Test + public void testProjectPathValidRequestWithRemainingPart() { + SiriusServerPathMatcher pathMatcher = new SiriusServerPathMatcher(PROJECT_PATH); + SiriusServerMatchResult matchResult = pathMatcher.match("/api/projects/sample/documentation"); //$NON-NLS-1$ + assertTrue(matchResult.hasMatched()); + + Map<String, String> variables = matchResult.getVariables(); + assertEquals(variables.size(), 1); + assertEquals(variables.get(PROJECT_NAME_VARIABLE), SAMPLE); + + assertEquals("documentation", matchResult.getRemainingPart()); //$NON-NLS-1$ + } + + @Test + public void testRepresentationsPathValidRequest() { + SiriusServerPathMatcher pathMatcher = new SiriusServerPathMatcher(REPRESENTATIONS_PATH); + SiriusServerMatchResult matchResult = pathMatcher.match("/api/projects/sample/representations"); //$NON-NLS-1$ + assertTrue(matchResult.hasMatched()); + + Map<String, String> variables = matchResult.getVariables(); + assertEquals(variables.size(), 1); + assertEquals(variables.get(PROJECT_NAME_VARIABLE), SAMPLE); + } + + @Test + public void testRepresentationPathValidRequest() { + SiriusServerPathMatcher pathMatcher = new SiriusServerPathMatcher(REPRESENTATION_PATH); + SiriusServerMatchResult matchResult = pathMatcher.match("/api/projects/sample/representations/classDiagram"); //$NON-NLS-1$ + assertTrue(matchResult.hasMatched()); + + Map<String, String> variables = matchResult.getVariables(); + assertEquals(variables.size(), 2); + assertEquals(variables.get(PROJECT_NAME_VARIABLE), SAMPLE); + assertEquals(variables.get(REPRESENTATION_NAME_VARIABLE), CLASS_DIAGRAM); + } +} |
