-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2ec6840
commit 79c1c29
Showing
43 changed files
with
3,035 additions
and
59 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Copyright DB InfraGO AG and contributors | ||
SPDX-License-Identifier: Apache-2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright DB InfraGO AG and contributors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package com.db.capella; | ||
|
||
import org.glassfish.jersey.server.ResourceConfig; | ||
|
||
import com.db.capella.api.JacksonJsonProvider; | ||
import com.db.capella.api.ProjectsApi; | ||
import com.db.capella.api.WorkspaceApi; | ||
|
||
public class Application extends ResourceConfig { | ||
public Application() { | ||
register(ProjectsApi.class); | ||
register(WorkspaceApi.class); | ||
register(JacksonJsonProvider.class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright DB InfraGO AG and contributors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package com.db.capella; | ||
|
||
import java.net.URI; | ||
|
||
import org.eclipse.core.runtime.ILog; | ||
import org.eclipse.core.runtime.IStatus; | ||
import org.eclipse.core.runtime.Platform; | ||
import org.eclipse.core.runtime.Status; | ||
import org.eclipse.ui.IStartup; | ||
import org.glassfish.grizzly.http.server.HttpServer; | ||
import org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory; | ||
import org.glassfish.jersey.server.ResourceConfig; | ||
import org.osgi.framework.Bundle; | ||
import org.osgi.framework.FrameworkUtil; | ||
|
||
public class Main implements IStartup { | ||
public static final String BASE_URI = "http://0.0.0.0:5007/api/v1"; | ||
|
||
public static void log(int severity, String message, Throwable exception) { | ||
Bundle bundle = FrameworkUtil.getBundle(Main.class); | ||
ILog log = Platform.getLog(bundle); | ||
IStatus status = new Status(severity, bundle.getSymbolicName(), | ||
message, exception); | ||
log.log(status); | ||
} | ||
|
||
@Override | ||
public void earlyStartup() { | ||
final ResourceConfig resourceConfig = new Application(); | ||
try { | ||
final HttpServer server = GrizzlyHttpServerFactory.createHttpServer( | ||
URI.create(BASE_URI), | ||
resourceConfig, true); | ||
log(IStatus.INFO, "Capella REST API server listens on " + BASE_URI + " ...", null); | ||
} catch (Exception e) { | ||
String msg = "There was an error while starting Capella REST API server."; | ||
log(IStatus.ERROR, msg, null); | ||
System.err.println(msg); | ||
e.printStackTrace(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright DB InfraGO AG and contributors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package com.db.capella.api; | ||
|
||
/** | ||
* The exception that can be used to store the HTTP status code returned by an API response. | ||
*/ | ||
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen", comments = "Generator version: 7.9.0") | ||
public class ApiException extends Exception { | ||
/** The HTTP status code. */ | ||
private int code; | ||
|
||
/** | ||
* Constructor. | ||
* | ||
* @param code The HTTP status code. | ||
* @param msg The error message. | ||
*/ | ||
public ApiException(int code, String msg) { | ||
super(msg); | ||
this.code = code; | ||
} | ||
|
||
/** | ||
* Get the HTTP status code. | ||
* | ||
* @return The HTTP status code. | ||
*/ | ||
public int getCode() { | ||
return code; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "ApiException{" + | ||
"code=" + code + | ||
'}'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright DB InfraGO AG and contributors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package com.db.capella.api; | ||
|
||
import java.io.IOException; | ||
|
||
import jakarta.servlet.*; | ||
import jakarta.servlet.http.HttpServletResponse; | ||
|
||
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen", comments = "Generator version: 7.9.0") | ||
public class ApiOriginFilter implements jakarta.servlet.Filter { | ||
public void doFilter(ServletRequest request, ServletResponse response, | ||
FilterChain chain) throws IOException, ServletException { | ||
HttpServletResponse res = (HttpServletResponse) response; | ||
res.addHeader("Access-Control-Allow-Origin", "*"); | ||
res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT"); | ||
res.addHeader("Access-Control-Allow-Headers", "Content-Type"); | ||
chain.doFilter(request, response); | ||
} | ||
|
||
public void destroy() {} | ||
|
||
public void init(FilterConfig filterConfig) throws ServletException {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// Copyright DB InfraGO AG and contributors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package com.db.capella.api; | ||
|
||
|
||
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaJerseyServerCodegen", comments = "Generator version: 7.9.0") | ||
public class ApiResponseMessage { | ||
public static final int ERROR = 1; | ||
public static final int WARNING = 2; | ||
public static final int INFO = 3; | ||
public static final int OK = 4; | ||
public static final int TOO_BUSY = 5; | ||
|
||
int code; | ||
String type; | ||
String message; | ||
|
||
public ApiResponseMessage(){} | ||
|
||
public ApiResponseMessage(int code, String message){ | ||
this.code = code; | ||
switch(code){ | ||
case ERROR: | ||
setType("error"); | ||
break; | ||
case WARNING: | ||
setType("warning"); | ||
break; | ||
case INFO: | ||
setType("info"); | ||
break; | ||
case OK: | ||
setType("ok"); | ||
break; | ||
case TOO_BUSY: | ||
setType("too busy"); | ||
break; | ||
default: | ||
setType("unknown"); | ||
break; | ||
} | ||
this.message = message; | ||
} | ||
|
||
public int getCode() { | ||
return code; | ||
} | ||
|
||
public void setCode(int code) { | ||
this.code = code; | ||
} | ||
|
||
public String getType() { | ||
return type; | ||
} | ||
|
||
public void setType(String type) { | ||
this.type = type; | ||
} | ||
|
||
public String getMessage() { | ||
return message; | ||
} | ||
|
||
public void setMessage(String message) { | ||
this.message = message; | ||
} | ||
} |
Oops, something went wrong.