use of org.ballerinalang.net.http.session.Session in project ballerina by ballerina-lang.
the class SetMaxInactiveInterval method execute.
@Override
public void execute(Context context) throws IllegalFormatException {
try {
BStruct sessionStruct = ((BStruct) context.getRefArgument(0));
int timeInterval = (int) context.getIntArgument(0);
Session session = (Session) sessionStruct.getNativeData(HttpConstants.HTTP_SESSION);
if (timeInterval == 0) {
throw new IllegalStateException("Failed to set max time interval: Time interval: " + timeInterval);
}
if (session != null && session.isValid()) {
session.setMaxInactiveInterval(timeInterval);
} else {
throw new IllegalStateException("Failed to set max time interval: No such session in progress");
}
} catch (IllegalStateException e) {
throw new BallerinaException(e.getMessage(), e);
}
context.setReturnValues();
}
use of org.ballerinalang.net.http.session.Session in project ballerina by ballerina-lang.
the class GetAttributeNames method execute.
@Override
public void execute(Context context) {
try {
BStruct sessionStruct = ((BStruct) context.getRefArgument(0));
Session session = (Session) sessionStruct.getNativeData(HttpConstants.HTTP_SESSION);
if (session != null && session.isValid()) {
context.setReturnValues(new BStringArray(session.getAttributeNames()));
} else {
throw new IllegalStateException("Failed to get attribute names: No such session in progress");
}
} catch (IllegalStateException e) {
throw new BallerinaException(e.getMessage(), e);
}
}
use of org.ballerinalang.net.http.session.Session in project ballerina by ballerina-lang.
the class GetCreationTime method execute.
@Override
public void execute(Context context) {
try {
BStruct sessionStruct = ((BStruct) context.getRefArgument(0));
Session session = (Session) sessionStruct.getNativeData(HttpConstants.HTTP_SESSION);
if (session != null && session.isValid()) {
context.setReturnValues(new BInteger(session.getCreationTime()));
} else {
throw new IllegalStateException("Failed to get creation time: No such session in progress");
}
} catch (IllegalStateException e) {
throw new BallerinaException(e.getMessage(), e);
}
}
use of org.ballerinalang.net.http.session.Session in project ballerina by ballerina-lang.
the class Invalidate method execute.
@Override
public void execute(Context context) {
try {
BStruct sessionStruct = ((BStruct) context.getRefArgument(0));
Session session = (Session) sessionStruct.getNativeData(HttpConstants.HTTP_SESSION);
if (session != null && session.isValid()) {
session.invalidate();
} else {
throw new IllegalStateException("Failed to invalidate session: No such session in progress");
}
} catch (IllegalStateException e) {
throw new BallerinaException(e.getMessage(), e);
}
context.setReturnValues();
}
use of org.ballerinalang.net.http.session.Session in project ballerina by ballerina-lang.
the class IsNew method execute.
@Override
public void execute(Context context) {
try {
BStruct sessionStruct = ((BStruct) context.getRefArgument(0));
Session session = (Session) sessionStruct.getNativeData(HttpConstants.HTTP_SESSION);
if (session != null && session.isValid()) {
context.setReturnValues(new BBoolean(session.isNew()));
} else {
throw new IllegalStateException("Failed to get session status: No such session in progress");
}
} catch (IllegalStateException e) {
throw new BallerinaException(e.getMessage(), e);
}
}
Aggregations