Skip to content

Commit cdea0fd

Browse files
[ADD] XQuery: session:client-id. Closes BaseXdb#2132
1 parent bbde9b4 commit cdea0fd

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

basex-api/src/main/java/org/basex/query/func/ApiFunction.java

+3
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ public enum ApiFunction implements AFunction {
112112
_SESSION_ACCESSED(SessionAccessed::new, "accessed()",
113113
params(), DATE_TIME_O, SESSION_URI),
114114
/** XQuery function. */
115+
_SESSION_CLIENT_ID(SessionClientId::new, "client-id()",
116+
params(), STRING_ZO, SESSION_URI),
117+
/** XQuery function. */
115118
_SESSION_CLOSE(SessionClose::new, "close()",
116119
params(), EMPTY_SEQUENCE_Z, SESSION_URI),
117120
/** XQuery function. */
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package org.basex.query.func.session;
2+
3+
import org.basex.query.*;
4+
import org.basex.query.value.item.*;
5+
import org.basex.query.value.seq.*;
6+
import org.basex.util.*;
7+
8+
/**
9+
* Function implementation.
10+
*
11+
* @author BaseX Team 2005-22, BSD License
12+
* @author Christian Gruen
13+
*/
14+
public final class SessionClientId extends SessionFn {
15+
@Override
16+
public Item item(final QueryContext qc, final InputInfo ii) throws QueryException {
17+
final String id = request(qc).getRequestedSessionId();
18+
return id != null ? Str.get(id) : Empty.VALUE;
19+
}
20+
}

0 commit comments

Comments
 (0)