xref: /aosp_15_r20/external/aws-sdk-java-v2/scripts/doc_crosslinks/crosslink_redirect.html (revision 8a52c7834d808308836a99fc2a6e0ed8db339086)
1<DOCTYPE HTML>
2    <html lang="en-US">
3    <head>
4        <meta charset="UTF-8">
5        <script type="text/javascript">
6
7            var uidServiceData = '${UID_SERVICE_MAPPING}';
8            var uidToServiceName = JSON.parse(uidServiceData);
9            var uidClientNameData = '${UID_CLIENT_CLASS_MAPPING}';
10            var uidToClientPrefix = JSON.parse(uidClientNameData);
11            // A mapping from uid to the list of operations that are only available on the async client
12            var uidToAsyncOnlyOperationData = '${SERVICE_NAME_TO_ASYNC_ONLY_OPERATION_MAPPING}';
13            var uidToAsyncOnlyOperations = JSON.parse(uidToAsyncOnlyOperationData)
14            var baseUri = window.location.href;
15            var serviceFolderPath = "software/amazon/awssdk/services/";
16
17            function getQueryStringParameter(name, url) {
18
19                var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)");
20                name = name.replace(/[\[\]]/g, "\\$&");
21                results = regex.exec(url);
22                if (!results) return null;
23                if (!results[2]) return '';
24                return decodeURIComponent(results[2].replace(/\+/g, " "));
25            }
26
27            function camelize(str) {
28                return str.replace(/(?:^\w|[A-Z]|\b\w)/g, function(word, index) {
29                    return index === 0 ? word.toLowerCase() : word.toUpperCase();
30                }).replace(/\s+/g, '');
31            }
32
33            function checkResourceExists(url) {
34                try {
35                    var xmlHttp = new XMLHttpRequest();
36                    xmlHttp.open( "GET", url, false );
37                    xmlHttp.send( null );
38                    return xmlHttp.status == 200;
39                }
40                catch(err) {
41                    return false;
42                }
43            }
44
45            function requestSignature(uid, serviceName, typeName) {
46                var pkgBase = "software.amazon.awssdk.services." + serviceName + ".model.";
47                var requestObjectName = typeName + "Request";
48
49                var params = pkgBase + requestObjectName;
50
51                if (isAsyncOnlyMethod(uid, typeName)) {
52                    eventStreamInfo = uidToAsyncOnlyOperations[uid][typeName];
53                    if (eventStreamInfo['input'] === true) {
54                        params = params + ",org.reactivestreams.Publisher";
55                    }
56
57                    if (eventStreamInfo['output'] === true) {
58                        params = params + "," + pkgBase + typeName + "ResponseHandler";
59                    }
60                }
61
62                return "(" + params + ")"
63            }
64
65            function isAsyncOnlyMethod(uid, typeName) {
66                return uidToAsyncOnlyOperations[uid] != null && uidToAsyncOnlyOperations[uid][typeName] != null;
67            }
68
69            function asyncClientName(uid) {
70                return uidToClientPrefix[uid] + "AsyncClient";
71            }
72
73            function syncClientName(uid) {
74                return uidToClientPrefix[uid] + "Client";
75            }
76
77            var typeName = getQueryStringParameter("type", window.location.href);
78            var operation = getQueryStringParameter("operation", window.location.href);
79            var uid = getQueryStringParameter("uid", window.location.href);
80            var clientObjectName =  syncClientName(uid);
81            var serviceName =  uidToServiceName[uid];
82            var redirectSuffixLink = "index.html"
83
84            if(clientObjectName != null && serviceName != null) {
85                redirectServiceSuffixLink = serviceFolderPath + serviceName + "/model/" + typeName + ".html" ;
86                if(checkResourceExists( baseUri.replace(/crosslink_redirect.*/gi, redirectServiceSuffixLink) )) {
87                    redirectSuffixLink =  redirectServiceSuffixLink;
88                } else {
89                    redirectServiceSuffixLink =  serviceFolderPath + serviceName + "/";
90                    if(typeName != null) {
91                        if (isAsyncOnlyMethod(uid, typeName)) {
92                            clientObjectName = asyncClientName(uid);
93                        }
94                        redirectServiceSuffixLink = redirectServiceSuffixLink + clientObjectName + ".html" ;
95                        methodName = camelize(typeName);
96                        redirectServiceSuffixLink =
97                            redirectServiceSuffixLink +
98                            "#" +
99                            methodName + requestSignature(uid, serviceName, typeName);
100                    } else {
101                        redirectServiceSuffixLink = redirectServiceSuffixLink + clientObjectName + ".html" ;
102                    }
103
104                    if(checkResourceExists( baseUri.replace(/crosslink_redirect.*/gi, redirectServiceSuffixLink) )) {
105                        redirectSuffixLink =  redirectServiceSuffixLink;
106                    }
107                }
108            }
109            window.location.href = redirectSuffixLink ;
110        </script>
111    </head>
112    <body>
113    </body>
114</html>