use of cz.metacentrum.perun.webgui.model.BasicOverlayType in project perun by CESNET.
the class IsLoginAvailable method onFinished.
/**
* If last request OR NOT AVAILABLE, triggers the final events
*/
public void onFinished(JavaScriptObject jso) {
checkedNamespaces++;
BasicOverlayType ot = jso.cast();
int available = ot.getInt();
if (available == 0) {
isAvailable = false;
finalEvents.onFinished(generateFinalResponse());
return;
}
// is available, is the last
if (checkedNamespaces == namespacesToCheck.size()) {
finalEvents.onFinished(generateFinalResponse());
return;
}
}
use of cz.metacentrum.perun.webgui.model.BasicOverlayType in project perun by CESNET.
the class WebGui method checkIfMailVerification.
/**
* Check if URL parameters contains data for mail verification and display different GUI instead.
*
* @return TRUE if parameters are contained and valid in URL, FALSE otherwise.
*/
public boolean checkIfMailVerification() {
// Trigger validation if necessary
if (Location.getParameterMap().keySet().contains("token") && Location.getParameterMap().keySet().contains("u")) {
String verifyToken = Location.getParameter("token");
String verifyU = Location.getParameter("u");
if (verifyToken != null && !verifyToken.isEmpty() && verifyU != null && !verifyU.isEmpty() && JsonUtils.checkParseInt(verifyU)) {
ValidatePreferredEmailChange call = new ValidatePreferredEmailChange(verifyToken, Integer.parseInt(verifyU), new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
BasicOverlayType over = jso.cast();
RootLayoutPanel body = RootLayoutPanel.get();
body.clear();
FlexTable ft = new FlexTable();
ft.setSize("100%", "300px");
ft.setHTML(0, 0, new Image(LargeIcons.INSTANCE.acceptIcon()) + "<h2>" + "The email address: <i>" + (SafeHtmlUtils.fromString(over.getString())).asString() + "</i></h2><h2>was verified and set as your preferred email.</h2>");
ft.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
ft.getFlexCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE);
body.add(ft);
}
@Override
public void onLoadingStart() {
RootLayoutPanel body = RootLayoutPanel.get();
body.clear();
FlexTable ft = new FlexTable();
ft.setSize("100%", "300px");
ft.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
ft.getFlexCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE);
ft.setWidget(0, 0, new AjaxLoaderImage());
body.add(ft);
}
@Override
public void onError(PerunError error) {
RootLayoutPanel body = RootLayoutPanel.get();
body.clear();
FlexTable ft = new FlexTable();
ft.setSize("100%", "300px");
ft.setHTML(0, 0, new Image(LargeIcons.INSTANCE.deleteIcon()) + "<h2>Your new email address couldn't be verified !</h2>");
ft.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
ft.getFlexCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE);
if (error == null) {
ft.setHTML(1, 0, "Request timeout exceeded.");
ft.getFlexCellFormatter().setStyleName(1, 0, "serverResponseLabelError");
} else {
// display raw message
ft.setHTML(1, 0, "<strong>" + error.getErrorInfo() + "</strong>");
}
ft.getFlexCellFormatter().setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_CENTER);
ft.getFlexCellFormatter().setVerticalAlignment(1, 0, HasVerticalAlignment.ALIGN_MIDDLE);
body.add(ft);
}
});
call.retrieveData();
}
return true;
}
return false;
}
use of cz.metacentrum.perun.webgui.model.BasicOverlayType in project perun by CESNET.
the class RegistrarFormItemGenerator method generateUsernameBox.
/**
* Generates the username textbox
* @return
*/
private Widget generateUsernameBox() {
final TextBox tbox = new ExtendedTextBox();
tbox.setMaxLength(TEXT_BOX_MAX_LENGTH);
strValueBox = tbox;
tbox.setText(strValue);
tbox.getElement().setClassName("apptextbox" + counter++);
setCutCopyPasteHandler("apptextbox" + counter);
setVariableWidth(tbox);
// if username not empty - disable
if (!tbox.getValue().equalsIgnoreCase("")) {
tbox.setEnabled(false);
// do not check prefilled logins
inputChecker = getDefaultInputChecker();
} else {
// get namespace
if (item.getPerunDestinationAttribute() != null && !item.getPerunDestinationAttribute().isEmpty()) {
final String loginNamespace = item.getPerunDestinationAttribute().substring(PERUN_ATTRIBUTE_LOGIN_NAMESPACE_POSITION);
// check if login is new
inputChecker = new FormInputChecker() {
private boolean validating = false;
private boolean valid = true;
private Map<String, Boolean> validMap = new HashMap<String, Boolean>();
public boolean isValid(boolean forceNewValidation) {
// if not new, don't force
if (!forceNewValidation)
return valid;
final String str = tbox.getValue();
// missing?
valid = (!(item.isRequired() && str.equals("")));
if (!valid) {
statusCellWrapper.setWidget(new FormInputStatusWidget(ApplicationMessages.INSTANCE.missingValue(), Status.ERROR));
return false;
}
// length
valid = checkLength();
if (!valid) {
return false;
}
valid = checkValueRegex();
// regex check
if (!valid) {
return false;
}
// force check for base REGEX used in login attribute module
RegExp regExp = RegExp.compile(Utils.LOGIN_VALUE_MATCHER);
boolean match = regExp.test(str);
if (!match)
return false;
// has already checked it?
if (validMap.containsKey(str)) {
valid = validMap.get(str);
if (valid) {
statusCellWrapper.setWidget(new FormInputStatusWidget(ApplicationMessages.INSTANCE.usernameAvailable(), Status.OK));
} else {
statusCellWrapper.setWidget(new FormInputStatusWidget(ApplicationMessages.INSTANCE.usernameNotAvailable(), Status.ERROR));
}
return valid;
}
// check login
validating = true;
statusCellWrapper.setWidget(new FormInputStatusWidget(ApplicationMessages.INSTANCE.validating(), Status.LOADING));
// check login
new IsLoginAvailable(loginNamespace, str, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
// store result for the requested login
BasicOverlayType bo = jso.cast();
validMap.put(str, bo.getBoolean());
if (!str.equals(strValueBox.getValue())) {
// value changed before request finished, don't update the valid value
return;
}
valid = bo.getBoolean();
validating = false;
if (valid) {
statusCellWrapper.setWidget(new FormInputStatusWidget(ApplicationMessages.INSTANCE.usernameAvailable(), Status.OK));
} else {
statusCellWrapper.setWidget(new FormInputStatusWidget(ApplicationMessages.INSTANCE.usernameNotAvailable(), Status.ERROR));
}
validationTrigger.triggerValidation();
}
@Override
public void onError(PerunError error) {
if (!str.equals(strValueBox.getValue())) {
// value changed before request finished, don't update the valid value
return;
}
if ("InvalidLoginException".equalsIgnoreCase(error.getName())) {
validMap.put(str, false);
statusCellWrapper.setWidget(new FormInputStatusWidget("Login has invalid syntax." + error.getErrorInfo(), Status.ERROR));
} else {
// generic error
statusCellWrapper.setWidget(new FormInputStatusWidget("Unable to check if login is available!", Status.ERROR));
}
validating = false;
validationTrigger.triggerValidation();
}
}).retrieveData();
// check login end
valid = false;
return false;
}
public boolean isValidating() {
return validating;
}
public boolean useDefaultOkMessage() {
return false;
}
};
} else {
// Username has no "login-namespace"
// prevent such malformed applications from submission
tbox.setEnabled(false);
tbox.setValue("Wrong form item configuration !!");
inputChecker = new FormInputChecker() {
@Override
public boolean isValid(boolean forceNewValidation) {
return false;
}
@Override
public boolean isValidating() {
return false;
}
@Override
public boolean useDefaultOkMessage() {
return false;
}
};
}
}
return tbox;
}
use of cz.metacentrum.perun.webgui.model.BasicOverlayType in project perun by CESNET.
the class IsServiceBlockedOnFacility method onFinished.
/**
* Called when loading successfully finishes
*
* @param jso javascript object (array) returned from RPC
*/
public void onFinished(JavaScriptObject jso) {
BasicOverlayType bot = jso.cast();
this.update(bot);
session.getUiElements().setLogText("Loading denied info about service finished.");
events.onFinished(bot);
}
use of cz.metacentrum.perun.webgui.model.BasicOverlayType in project perun by CESNET.
the class GetGroupMembersCount method onFinished.
/**
* Called when loading successfully finishes.
*/
public void onFinished(JavaScriptObject jso) {
BasicOverlayType count = (BasicOverlayType) jso;
session.getUiElements().setLogText("Loading group members count finished: " + count.getInt());
this.events.onFinished(jso);
}
Aggregations