-
Notifications
You must be signed in to change notification settings - Fork 57
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
Showing
13 changed files
with
273 additions
and
4 deletions.
There are no files selected for viewing
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,75 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
import sys | ||
if (sys.version_info > (3,)): | ||
import http.client | ||
from http.client import BAD_REQUEST, CONFLICT, NOT_FOUND, OK | ||
else: | ||
import httplib | ||
from httplib import BAD_REQUEST, CONFLICT, NOT_FOUND, OK | ||
from flask import make_response, request, session, send_file | ||
from flask_restful import Resource | ||
from flask_restful_swagger import swagger | ||
from cairis.core.ARM import DatabaseProxyException, ARMException | ||
from cairis.core.Borg import Borg | ||
from cairis.daemon.CairisHTTPError import MalformedJSONHTTPError, CairisHTTPError, ARMHTTPError, MissingParameterHTTPError | ||
from cairis.data.VersionDAO import VersionDAO | ||
from cairis.tools.JsonConverter import json_serialize | ||
from cairis.tools.MessageDefinitions import VersionMessage | ||
from cairis.tools.ModelDefinitions import VersionModel | ||
from cairis.tools.SessionValidator import get_session_id | ||
from io import StringIO | ||
|
||
__author__ = 'Shamal Faily' | ||
|
||
|
||
class VersionAPI(Resource): | ||
# region Swagger Doc | ||
@swagger.operation( | ||
notes='Get CAIRIS version', | ||
nickname='cairis-version', | ||
parameters=[ | ||
{ | ||
"name": "session_id", | ||
"description": "The ID of the user's session", | ||
"required": False, | ||
"allowMultiple": False, | ||
"dataType": str.__name__, | ||
"paramType": "query" | ||
} | ||
], | ||
responseMessages=[ | ||
{ | ||
'code': BAD_REQUEST, | ||
'message': 'The provided file is not a valid XML file' | ||
}, | ||
{ | ||
'code': BAD_REQUEST, | ||
'message': '''Some parameters are missing. Be sure 'file_contents' and 'type' are defined.''' | ||
} | ||
] | ||
) | ||
# endregion | ||
def get(self): | ||
session_id = get_session_id(session, request) | ||
dao = VersionDAO(session_id) | ||
objts = dao.cairis_version() | ||
dao.close() | ||
resp = make_response(json_serialize(objts, session_id=session_id)) | ||
resp.headers['Content-Type'] = "application/json" | ||
return resp |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
from cairis.core.ARM import * | ||
from cairis.daemon.CairisHTTPError import CairisHTTPError, ARMHTTPError | ||
from cairis.data.CairisDAO import CairisDAO | ||
__author__ = 'Shamal Faily' | ||
|
||
|
||
class VersionDAO(CairisDAO): | ||
|
||
def __init__(self, session_id): | ||
CairisDAO.__init__(self, session_id) | ||
|
||
def cairis_version(self): | ||
try: | ||
return self.db_proxy.cairisVersion() | ||
except ARMException as ex: | ||
self.close() | ||
raise ARMHTTPError(ex) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
import logging | ||
import sys | ||
if (sys.version_info > (3,)): | ||
from urllib.parse import quote | ||
else: | ||
from urllib import quote | ||
from io import StringIO | ||
import os | ||
import jsonpickle | ||
from cairis.test.CairisDaemonTestCase import CairisDaemonTestCase | ||
from cairis.mio.ModelImport import importModelFile | ||
import os | ||
|
||
__author__ = 'Shamal Faily' | ||
|
||
class VersionAPITests(CairisDaemonTestCase): | ||
|
||
@classmethod | ||
def setUpClass(cls): | ||
pass | ||
|
||
def setUp(self): | ||
self.logger = logging.getLogger(__name__) | ||
|
||
def test_version(self): | ||
method = 'test_version' | ||
url = '/api/version?session_id=test' | ||
self.logger.info('[%s] URL: %s', method, url) | ||
rv = self.app.get(url) | ||
self.assertIsNotNone(rv.data, 'No response') | ||
if (sys.version_info > (3,)): | ||
responseData = rv.data.decode('utf-8') | ||
else: | ||
responseData = rv.data | ||
objts = jsonpickle.decode(responseData) | ||
self.assertIsNotNone(objts, 'No results after deserialization') | ||
self.assertEqual(objts,'1.5.2') |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* Licensed to the Apache Software Foundation (ASF) under one | ||
or more contributor license agreements. See the NOTICE file | ||
distributed with this work for additional information | ||
regarding copyright ownership. The ASF licenses this file | ||
to you under the Apache License, Version 2.0 (the | ||
"License"); you may not use this file except in compliance | ||
with the License. You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, | ||
software distributed under the License is distributed on an | ||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, either express or implied. See the License for the | ||
specific language governing permissions and limitations | ||
under the License. | ||
Authors: Shamal Faily */ | ||
|
||
'use strict'; | ||
|
||
$("#aboutClick").click(function(e){ | ||
e.preventDefault(); | ||
$.ajax({ | ||
type: "GET", | ||
dataType: "json", | ||
accept: "application/json", | ||
data: { | ||
session_id: String($.session.get('sessionID')) | ||
}, | ||
crossDomain: true, | ||
url: serverIP + "/api/version", | ||
success: function (data) { | ||
$('#theVersion').text('Version ' + data); | ||
$('#cairisVersion').modal('show'); | ||
}, | ||
error: function (xhr, textStatus, errorThrown) { | ||
var error = JSON.parse(xhr.responseText); | ||
showPopup(false, String(error.message)); | ||
debugLogger(String(this.url)); | ||
debugLogger("error: " + xhr.responseText + ", textstatus: " + textStatus + ", thrown: " + errorThrown); | ||
} | ||
}); | ||
}); |
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 |
---|---|---|
|
@@ -37,6 +37,7 @@ CAIRIS documentation | |
configurable | ||
searching | ||
gendoc | ||
troubleshooting | ||
|
||
|
||
Indices and tables | ||
|
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,6 @@ | ||
Troubleshooting | ||
=============== | ||
|
||
If you experience any problems using CAIRIS then please raise an issue in GitHub. | ||
|
||
When raising an issue, please provide the version of CAIRIS you are using. You can find this by clicking on the System/About menu. |