Search in sources :

Example 91 with PerunError

use of cz.metacentrum.perun.webgui.model.PerunError in project perun by CESNET.

the class DeleteGroups method deleteGroups.

/**
	 * Delete (sub)groups of any group or VO.
	 *
	 * @param groups groups to be deleted
	 * @param force TRUE = forced delete (remove all members, remove from resources) / FALSE = not delete if group has members
	 */
public void deleteGroups(final ArrayList<? extends Group> groups, boolean force) {
    // whole JSON query
    JSONObject jsonQuery = new JSONObject();
    JSONArray grps = new JSONArray();
    for (int i = 0; i < groups.size(); i++) {
        grps.set(i, new JSONNumber(groups.get(i).getId()));
    }
    jsonQuery.put("groups", grps);
    jsonQuery.put("forceDelete", new JSONNumber((force) ? 1 : 0));
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Deleting groups failed.");
            events.onError(error);
        }

        ;

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("Groups successfully deleted!");
            events.onFinished(jso);
        }

        ;

        public void onLoadingStart() {
            events.onLoadingStart();
        }

        ;
    };
    // sending data
    JsonPostClient jspc = new JsonPostClient(newEvents);
    jspc.sendData(JSON_URL, jsonQuery);
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) JSONObject(com.google.gwt.json.client.JSONObject) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) JsonPostClient(cz.metacentrum.perun.webgui.json.JsonPostClient) JSONArray(com.google.gwt.json.client.JSONArray) JSONNumber(com.google.gwt.json.client.JSONNumber) PerunError(cz.metacentrum.perun.webgui.model.PerunError)

Example 92 with PerunError

use of cz.metacentrum.perun.webgui.model.PerunError in project perun by CESNET.

the class ForceServicePropagation method forcePropagation.

/**
	 * Starts Force service propagation for specified service and facility
	 *
	 * @param facilityId ID of facility to propagate service to
	 * @param serviceId ID of service to be propagated
	 */
public void forcePropagation(final int facilityId, final int serviceId) {
    this.facilityId = facilityId;
    this.serviceId = serviceId;
    // test arguments
    if (!this.testArguments()) {
        return;
    }
    // whole JSON query
    JSONObject jsonQuery = new JSONObject();
    jsonQuery.put("facility", new JSONNumber(facilityId));
    jsonQuery.put("service", new JSONNumber(serviceId));
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Propagation initialization of service: " + serviceId + " failed.");
            events.onError(error);
        }

        ;

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("Propagation of service: " + serviceId + " initiated.");
            events.onFinished(jso);
        }

        ;

        public void onLoadingStart() {
            events.onLoadingStart();
        }

        ;
    };
    // sending data
    JsonPostClient jspc = new JsonPostClient(newEvents);
    jspc.sendData(JSON_URL, jsonQuery);
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) JSONObject(com.google.gwt.json.client.JSONObject) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) JsonPostClient(cz.metacentrum.perun.webgui.json.JsonPostClient) JSONNumber(com.google.gwt.json.client.JSONNumber) PerunError(cz.metacentrum.perun.webgui.model.PerunError)

Example 93 with PerunError

use of cz.metacentrum.perun.webgui.model.PerunError in project perun by CESNET.

the class InsertExecService method addExecService.

/**
	 * Creates exec service in DB and associate it with service
	 *
	 * @param service service to associate with
	 * @param type type of exec service (SEND, GENERATE)
	 * @param enabled true if exec service is enabled
	 * @param delayNum default delay
	 * @param scriptPath path to propagation scripts
	 */
public void addExecService(Service service, String type, Boolean enabled, int delayNum, String scriptPath) {
    // TODO - test input
    // test arguments
    // if(!this.testArguments()){
    //	return;
    //}
    // reconstruct service
    JSONObject serv = new JSONObject();
    serv.put("id", new JSONNumber(service.getId()));
    serv.put("name", new JSONString(service.getName()));
    // reconstruct exec service
    JSONObject exec = new JSONObject();
    exec.put("execServiceType", new JSONString(type));
    exec.put("enabled", JSONBoolean.getInstance(enabled));
    exec.put("defaultDelay", new JSONNumber(delayNum));
    // insert service into exec service
    exec.put("service", serv);
    exec.put("script", new JSONString(scriptPath));
    // whole JSON query
    JSONObject jsonQuery = new JSONObject();
    jsonQuery.put("execService", exec);
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Adding of exec service failed.");
            events.onError(error);
        }

        ;

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("Exec service successfully added!");
            events.onFinished(jso);
        }

        ;

        public void onLoadingStart() {
            events.onLoadingStart();
        }

        ;
    };
    // sending data
    JsonPostClient jspc = new JsonPostClient(newEvents);
    jspc.sendData(JSON_URL, jsonQuery);
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) JSONObject(com.google.gwt.json.client.JSONObject) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) JsonPostClient(cz.metacentrum.perun.webgui.json.JsonPostClient) JSONNumber(com.google.gwt.json.client.JSONNumber) PerunError(cz.metacentrum.perun.webgui.model.PerunError) JSONString(com.google.gwt.json.client.JSONString)

Example 94 with PerunError

use of cz.metacentrum.perun.webgui.model.PerunError in project perun by CESNET.

the class RemoveHosts method removeHost.

/**
	 * Removes host from cluster in DB - make RPC call
	 *
	 * @param hostId ID of host to be removed
	 */
public void removeHost(final int hostId) {
    this.hostId = hostId;
    // test arguments
    if (!this.testDeleting()) {
        return;
    }
    // json object
    JSONObject jsonQuery = prepareJSONObject();
    // local events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Removing host: " + hostId + " failed.");
            events.onError(error);
        }

        ;

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("Host: " + hostId + " removed!");
            events.onFinished(jso);
        }

        ;

        public void onLoadingStart() {
            events.onLoadingStart();
        }

        ;
    };
    // create request
    JsonPostClient request = new JsonPostClient(newEvents);
    request.sendData(JSON_URL, jsonQuery);
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) JSONObject(com.google.gwt.json.client.JSONObject) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) JsonPostClient(cz.metacentrum.perun.webgui.json.JsonPostClient) PerunError(cz.metacentrum.perun.webgui.model.PerunError)

Example 95 with PerunError

use of cz.metacentrum.perun.webgui.model.PerunError in project perun by CESNET.

the class RemoveOwner method removeFacilityOwner.

/**
	 * Attempts to remove admin from facility
	 *
	 * @param facilityId id of facility
	 * @param ownerId ID of user which should be removed as admin
	 */
public void removeFacilityOwner(final int facilityId, final int ownerId) {
    this.ownerId = ownerId;
    this.facilityId = facilityId;
    // test arguments
    if (!this.testRemoving()) {
        return;
    }
    // prepare json object
    JSONObject jsonQuery = prepareJSONObject();
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Removing owner (" + ownerId + ") from facility: " + facilityId + " failed.");
            events.onError(error);
        }

        ;

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("Owner (" + ownerId + ") removed from facility: " + facilityId);
            events.onFinished(jso);
        }

        ;

        public void onLoadingStart() {
            events.onLoadingStart();
        }

        ;
    };
    // sending data
    JsonPostClient jspc = new JsonPostClient(newEvents);
    jspc.sendData(JSON_URL, jsonQuery);
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) JSONObject(com.google.gwt.json.client.JSONObject) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) JsonPostClient(cz.metacentrum.perun.webgui.json.JsonPostClient) PerunError(cz.metacentrum.perun.webgui.model.PerunError)

Aggregations

PerunError (cz.metacentrum.perun.webgui.model.PerunError)177 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)173 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)167 JsonPostClient (cz.metacentrum.perun.webgui.json.JsonPostClient)126 JSONObject (com.google.gwt.json.client.JSONObject)55 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)36 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)36 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)30 ArrayList (java.util.ArrayList)30 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)27 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)21 JSONNumber (com.google.gwt.json.client.JSONNumber)17 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)16 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)16 ListBoxWithObjects (cz.metacentrum.perun.webgui.widgets.ListBoxWithObjects)15 AjaxLoaderImage (cz.metacentrum.perun.webgui.widgets.AjaxLoaderImage)11 Attribute (cz.metacentrum.perun.webgui.model.Attribute)10 HashMap (java.util.HashMap)10 JSONString (com.google.gwt.json.client.JSONString)8 ExtendedTextBox (cz.metacentrum.perun.webgui.widgets.ExtendedTextBox)8