-
Notifications
You must be signed in to change notification settings - Fork 27
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
38eed91
commit c77d7da
Showing
26 changed files
with
350 additions
and
451 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 |
---|---|---|
@@ -1,2 +1,2 @@ | ||
group=cz.incad.kramerius | ||
version=7.0.37 | ||
version=7.0.38-dev |
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
78 changes: 78 additions & 0 deletions
78
rest/src/main/java/cz/incad/kramerius/rest/apiNew/client/v70/res/EmbeddedFilesResource.java
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,78 @@ | ||
/* | ||
* Copyright (C) Sep 28, 2024 Pavel Stastny | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package cz.incad.kramerius.rest.apiNew.client.v70.res; | ||
|
||
import java.io.File; | ||
import java.net.URL; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.PathParam; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.MediaType; | ||
import javax.ws.rs.core.Response; | ||
|
||
import org.apache.commons.io.IOUtils; | ||
|
||
@Path("/client/v7.0/embedded/files") | ||
public class EmbeddedFilesResource { | ||
|
||
public static final String OPENAPI_PREFIX = "openapi"; | ||
|
||
private static final Map<String, String> mimeTypeMap = new HashMap<>(); | ||
|
||
static { | ||
mimeTypeMap.put("js", "application/javascript"); | ||
mimeTypeMap.put("html", "text/html"); | ||
mimeTypeMap.put("map", "application/json"); | ||
mimeTypeMap.put("css", "text/css"); | ||
mimeTypeMap.put("png", "image/png"); | ||
mimeTypeMap.put("yaml", "application/x-yaml"); | ||
mimeTypeMap.put("yml", "application/x-yaml"); | ||
mimeTypeMap.put("openapi", "application/vnd.oai.openapi"); | ||
} | ||
|
||
@GET | ||
@Path("/{path: (.+)?}") | ||
@Produces(MediaType.APPLICATION_JSON) | ||
public Response getEmbbededFile(@PathParam("path") String path) { | ||
try { | ||
URL resource = this.getClass().getClassLoader().getResource("/"+OPENAPI_PREFIX + File.separator + path); | ||
if (resource != null) { | ||
String content = IOUtils.toString(resource.openStream(), "UTF-8"); | ||
String file = resource.getFile(); | ||
if (file.contains(".")) { | ||
String postfix = file.substring(file.lastIndexOf('.')+1); | ||
if (mimeTypeMap.containsKey(postfix)) { | ||
return Response.ok().entity(content).type(mimeTypeMap.get(postfix)+ "; charset=UTF-8").build(); | ||
} else { | ||
return Response.ok().entity(content).type("text/html; charset=UTF-8").build(); | ||
} | ||
} else { | ||
return Response.ok().entity(content).type("text/html; charset=UTF-8").build(); | ||
} | ||
} else { | ||
return Response.status(Response.Status.NOT_FOUND).build(); | ||
} | ||
} catch (Exception e) { | ||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); | ||
} | ||
} | ||
|
||
} |
354 changes: 0 additions & 354 deletions
354
rest/src/main/java/cz/incad/kramerius/rest/oai/MetadataExport.java.bak
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,16 @@ | ||
html { | ||
box-sizing: border-box; | ||
overflow: -moz-scrollbars-vertical; | ||
overflow-y: scroll; | ||
} | ||
|
||
*, | ||
*:before, | ||
*:after { | ||
box-sizing: inherit; | ||
} | ||
|
||
body { | ||
margin: 0; | ||
background: #fafafa; | ||
} |
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,110 @@ | ||
<!-- HTML for static distribution bundle build --> | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Swagger UI</title> | ||
<link rel="stylesheet" type="text/css" href="./swagger-ui.css" /> | ||
<link rel="stylesheet" type="text/css" href="index.css" /> | ||
<link rel="icon" type="image/png" href="./favicon-32x32.png" sizes="32x32" /> | ||
<link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16" /> | ||
<style> | ||
/* Styl pro vlastní tlačítka */ | ||
.custom-auth-buttons { | ||
position: absolute; | ||
top: 180px; | ||
left: 30px; | ||
} | ||
.custom-auth-buttons button { | ||
margin-left: 5px; | ||
padding: 5px 10px; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
|
||
<div class="custom-auth-buttons"> | ||
<button id="login-button" onclick="login()">Login</button> | ||
<button id="logout-button">Logout</button> | ||
</div> | ||
|
||
<div id="swagger-ui"></div> | ||
|
||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> | ||
|
||
<script src="./swagger-ui-bundle.js" charset="UTF-8"> </script> | ||
<script src="./swagger-ui-standalone-preset.js" charset="UTF-8"> </script> | ||
<script src="./swagger-initializer.js" charset="UTF-8"> </script> | ||
|
||
<script> | ||
|
||
var TOKEN = null; | ||
|
||
function login() { | ||
const redirectUri = window.location.origin + '/search/openapi/index.html'; | ||
const authorizationUrl = `../api/client/v7.0/user/auth/login?redirect_uri=${encodeURIComponent(redirectUri)}`; | ||
window.location.href = authorizationUrl; | ||
} | ||
|
||
function logout() { | ||
const redirectUri = window.location.origin + '/search/openapi/index.html'; | ||
const authorizationUrl = `../api/client/v7.0/user/auth/logout?redirect_uri=${encodeURIComponent(redirectUri)}`; | ||
window.location.href = authorizationUrl; | ||
} | ||
|
||
const currentUrl = window.location.origin; | ||
window.onload = function() { | ||
const ui = SwaggerUIBundle({ | ||
url: "../api/client/v7.0/embedded/files/openapi.yaml", | ||
dom_id: '#swagger-ui', | ||
deepLinking: true, | ||
defaultModelsExpandDepth: -1, | ||
validatorUrl : null, | ||
presets: [ | ||
SwaggerUIBundle.presets.apis, | ||
SwaggerUIStandalonePreset | ||
], | ||
plugins: [ | ||
SwaggerUIBundle.plugins.DownloadUrl | ||
], | ||
|
||
requestInterceptor: (request) => { | ||
if (TOKEN && TOKEN["access_token"]) { | ||
request.headers['Authorization'] = `Bearer ${TOKEN["access_token"]}`; | ||
} | ||
return request; | ||
}, | ||
|
||
layout: "StandaloneLayout" | ||
}); | ||
window.ui = ui; | ||
|
||
setTimeout(function() { | ||
const url = new URL(window.location.href); | ||
const code = url.searchParams.get('code'); | ||
const tokenSet = url.searchParams.get('tokenSet'); | ||
if (code && !tokenSet) { | ||
const redirectUri = window.location.origin + '/search/openapi/index.html'; | ||
const encodedRedirectUri = encodeURIComponent(redirectUri); | ||
const tokenUrl = window.location.origin + `/search/api/client/v7.0/user/auth/token?code=${encodeURIComponent(code)}&redirect_uri=${encodedRedirectUri}`; | ||
|
||
$.get(tokenUrl) | ||
.done(function(response) { | ||
|
||
if (response.error) { | ||
logout(); | ||
} else { | ||
TOKEN = response; | ||
} | ||
}).fail(function(jqXHR, textStatus, errorThrown) { | ||
logout(); | ||
console.error('Error fetching token:', textStatus, errorThrown); | ||
}); | ||
} | ||
},1000); | ||
|
||
}; | ||
</script> | ||
</body> | ||
</html> |
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 @@ | ||
<!DOCTYPE html> | ||
<html lang="cs"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>OAuth2 Redirect</title> | ||
</head> | ||
<body> | ||
<script> | ||
'use strict'; | ||
// Tento skript umožňuje Swagger UI správně zpracovat OAuth2 redirect | ||
function run() { | ||
const params = window.location.hash.substring(1); | ||
const query = {}; | ||
params.split('&').forEach(pair => { | ||
const [key, value] = pair.split('='); | ||
query[key] = decodeURIComponent(value); | ||
}); | ||
window.opener.swaggerUIRedirectOauth2 && window.opener.swaggerUIRedirectOauth2(query); | ||
window.close(); | ||
} | ||
|
||
run(); | ||
</script> | ||
</body> | ||
</html> |
Oops, something went wrong.