diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3b7c1a4e..22b5e470 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -45,15 +45,6 @@ jobs: asset_path: perun-wui-admin/target/perun-wui-admin.war asset_name: perun-wui-admin.war asset_content_type: application/x-webarchive - - name: "Upload asset perun-wui-cabinet.war" - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: perun-wui-cabinet/target/perun-wui-cabinet.war - asset_name: perun-wui-cabinet.war - asset_content_type: application/x-webarchive - name: "Upload asset perun-wui-registrar.war" uses: actions/upload-release-asset@v1 env: @@ -90,13 +81,4 @@ jobs: asset_path: perun-wui-profile/target/perun-wui-profile.war asset_name: perun-wui-profile.war asset_content_type: application/x-webarchive - - name: "Upload asset perun-wui-setAffiliation.war" - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ steps.create_release.outputs.upload_url }} - asset_path: perun-wui-setAffiliation/target/perun-wui-setAffiliation.war - asset_name: perun-wui-setAffiliation.war - asset_content_type: application/x-webarchive diff --git a/perun-wui-setAffiliation/pom.xml b/perun-wui-setAffiliation/pom.xml deleted file mode 100644 index 5aec1925..00000000 --- a/perun-wui-setAffiliation/pom.xml +++ /dev/null @@ -1,189 +0,0 @@ - - - 4.0.0 - - - wui - cz.metacentrum.perun - 3.2.1 - - - cz.metacentrum.perun.wui - perun-wui-setAffiliation - 3.2.1 - war - - perun-wui-setAffiliation - Web interface for setting eduPersonScopedAffiliationManuallyAssigned in Perun. - - - scm:git:https://github.com/CESNET/perun.git - scm:git:https://github.com/CESNET/perun.git - HEAD - - - - - ${project.build.directory}/${project.name} - - - - - - - org.apache.maven.plugins - maven-clean-plugin - - - - org.apache.maven.plugins - maven-compiler-plugin - - - - org.apache.maven.plugins - maven-install-plugin - - - - org.apache.maven.plugins - maven-javadoc-plugin - - - - org.apache.maven.plugins - maven-source-plugin - - - - org.apache.maven.plugins - maven-surefire-plugin - - - - - org.codehaus.mojo - buildnumber-maven-plugin - 1.2 - - - validate - - create - - - - - 5 - 0000 - false - false - - - - - - org.apache.maven.plugins - maven-war-plugin - - - compile - - exploded - - - - - ${webappDirectory} - perun-wui-setAffiliation - - - - - - org.codehaus.mojo - gwt-maven-plugin - ${gwtPluginVersion} - - - - compile - - - - - - cz.metacentrum.perun.wui.setAffiliation.perun-wui-setAffiliation - PerunSetAffiliation.html - ${webappDirectory} - ${webappDirectory} - - - - - - - - - src/main/resources/ - true - - - - - - - - - - cz.metacentrum.perun.wui - perun-wui-core - ${project.version} - - - - cz.metacentrum.perun.wui - perun-wui-core - ${project.version} - sources - compile - - - - - - com.google.gwt - gwt-user - - - - - - org.gwtbootstrap3 - gwtbootstrap3 - - - - org.gwtbootstrap3 - gwtbootstrap3-extras - - - - com.google.gwt.inject - gin - - - - com.gwtplatform - gwtp-mvp-client - provided - - - - - diff --git a/perun-wui-setAffiliation/src/main/java/cz/metacentrum/perun/wui/setAffiliation/client/PerunSetAffiliation.java b/perun-wui-setAffiliation/src/main/java/cz/metacentrum/perun/wui/setAffiliation/client/PerunSetAffiliation.java deleted file mode 100644 index 966be38e..00000000 --- a/perun-wui-setAffiliation/src/main/java/cz/metacentrum/perun/wui/setAffiliation/client/PerunSetAffiliation.java +++ /dev/null @@ -1,80 +0,0 @@ -package cz.metacentrum.perun.wui.setAffiliation.client; - -import com.google.gwt.core.client.EntryPoint; -import com.google.gwt.core.client.GWT; -import com.gwtplatform.mvp.client.RootPresenter; -import com.gwtplatform.mvp.client.annotations.DefaultPlace; -import com.gwtplatform.mvp.client.annotations.ErrorPlace; -import com.gwtplatform.mvp.client.annotations.UnauthorizedPlace; -import com.gwtplatform.mvp.client.gin.AbstractPresenterModule; -import com.gwtplatform.mvp.client.gin.DefaultModule; -import cz.metacentrum.perun.wui.client.PerunPlaceManager; -import cz.metacentrum.perun.wui.client.PerunRootPresenter; -import cz.metacentrum.perun.wui.client.resources.ExceptionLogger; -import cz.metacentrum.perun.wui.client.resources.PerunResources; -import cz.metacentrum.perun.wui.client.utils.Utils; -import cz.metacentrum.perun.wui.pages.*; -import cz.metacentrum.perun.wui.setAffiliation.client.resources.PerunSetAffiliationPlaceTokens; -import cz.metacentrum.perun.wui.setAffiliation.client.resources.PerunSetAffiliationResources; -import cz.metacentrum.perun.wui.setAffiliation.pages.affiliation.AffiliationPresenter; -import cz.metacentrum.perun.wui.setAffiliation.pages.affiliation.AffiliationView; - - -/** - * Entry point class and GWTP module for Perun WUI Set Affiliation. - * - * @author Pavel Zlámal - * @author Dominik Frantisek Bucik - */ -public class PerunSetAffiliation extends AbstractPresenterModule implements EntryPoint { - - @Override - protected void configure() { - - install(new DefaultModule.Builder().placeManager(PerunPlaceManager.class).build()); - - // make sure app is embedded in a correct DIV - bind(RootPresenter.class).to(PerunRootPresenter.class).asEagerSingleton(); - - // Main Application must bind generic Presenter and custom View !! - bindPresenter(PerunSetAffiliationPresenter.class, PerunSetAffiliationPresenter.MyView.class, PerunSetAffiliationView.class, PerunSetAffiliationPresenter.MyProxy.class); - - // bind app-specific pages - bindPresenter(AffiliationPresenter.class, AffiliationPresenter.MyView.class, AffiliationView.class, AffiliationPresenter.MyProxy.class); - - // pre-defined places - bindConstant().annotatedWith(DefaultPlace.class).to(PerunSetAffiliationPlaceTokens.AFFILIATION); - bindConstant().annotatedWith(ErrorPlace.class).to(PerunSetAffiliationPlaceTokens.NOT_FOUND); - bindConstant().annotatedWith(UnauthorizedPlace.class).to(PerunSetAffiliationPlaceTokens.UNAUTHORIZED); - - // generic pages - bindPresenter(NotAuthorizedPresenter.class, NotAuthorizedPresenter.MyView.class, NotAuthorizedView.class, NotAuthorizedPresenter.MyProxy.class); - bindPresenter(NotFoundPresenter.class, NotFoundPresenter.MyView.class, NotFoundView.class, NotFoundPresenter.MyProxy.class); - bindPresenter(LogoutPresenter.class, LogoutPresenter.MyView.class, LogoutView.class, LogoutPresenter.MyProxy.class); - bindPresenter(NotUserPresenter.class, NotUserPresenter.MyView.class, NotUserView.class, NotUserPresenter.MyProxy.class); - - } - - @Override - public void onModuleLoad() { - - ExceptionLogger exceptionHandler = new ExceptionLogger(); - GWT.setUncaughtExceptionHandler(exceptionHandler); - - try { - - // set default for Growl plugin - Utils.getDefaultNotifyOptions().makeDefault(); - - // ensure injecting custom CSS styles of PerunWui - PerunResources.INSTANCE.gss().ensureInjected(); - - PerunSetAffiliationResources.INSTANCE.gss().ensureInjected(); - - } catch (Exception ex) { - exceptionHandler.onUncaughtException(ex); - } - - } - -} \ No newline at end of file diff --git a/perun-wui-setAffiliation/src/main/java/cz/metacentrum/perun/wui/setAffiliation/client/PerunSetAffiliationPresenter.java b/perun-wui-setAffiliation/src/main/java/cz/metacentrum/perun/wui/setAffiliation/client/PerunSetAffiliationPresenter.java deleted file mode 100644 index 8e7fab0b..00000000 --- a/perun-wui-setAffiliation/src/main/java/cz/metacentrum/perun/wui/setAffiliation/client/PerunSetAffiliationPresenter.java +++ /dev/null @@ -1,32 +0,0 @@ -package cz.metacentrum.perun.wui.setAffiliation.client; - -import com.google.inject.Inject; -import com.google.web.bindery.event.shared.EventBus; -import com.gwtplatform.mvp.client.View; -import com.gwtplatform.mvp.client.annotations.ProxyStandard; -import com.gwtplatform.mvp.client.proxy.Proxy; -import cz.metacentrum.perun.wui.client.PerunPresenter; - -/** - * Main presenter for Set Affiliation app. - * - * @author Ondrej Velisek - * @author Pavel Zlámal - * @author Dominik Frantisek Bucik - */ -public class PerunSetAffiliationPresenter extends PerunPresenter { - - @ProxyStandard - public interface MyProxy extends Proxy { - } - - public interface MyView extends View { - } - - @Inject - PerunSetAffiliationPresenter(EventBus eventBus, MyView view, MyProxy proxy) { - super(eventBus, view, proxy); - } - - -} diff --git a/perun-wui-setAffiliation/src/main/java/cz/metacentrum/perun/wui/setAffiliation/client/PerunSetAffiliationUtils.java b/perun-wui-setAffiliation/src/main/java/cz/metacentrum/perun/wui/setAffiliation/client/PerunSetAffiliationUtils.java deleted file mode 100644 index f3a7077c..00000000 --- a/perun-wui-setAffiliation/src/main/java/cz/metacentrum/perun/wui/setAffiliation/client/PerunSetAffiliationUtils.java +++ /dev/null @@ -1,70 +0,0 @@ -package cz.metacentrum.perun.wui.setAffiliation.client; - -import com.google.gwt.core.client.JavaScriptObject; -import com.google.gwt.i18n.client.DateTimeFormat; -import cz.metacentrum.perun.wui.model.beans.Attribute; - -import java.sql.Date; -import java.util.concurrent.TimeUnit; - -/** - * Class with utility methods - * - * @author Dominik Frantisek Bucik - */ -public class PerunSetAffiliationUtils { - - public static final String EDU_PERSON_SCOPED_AFFILIATIONS_MANUALLY_ASSIGNED_ATTR = "urn:perun:user:attribute-def:def:eduPersonScopedAffiliationsManuallyAssigned"; - public static final String AUTHORIZED_AFFILIATION_SCOPES_ATTR = "urn:perun:user:attribute-def:def:authorizedAffiliationScopes"; - - /** - * Create EDU_PERSON_SCOPED_AFFILIATIONS_MANUALLY_ASSIGNED_ATTR - * @param attr attribute - * @param member member affiliation - * @param faculty faculty affiliation - * @param affiliate affiliate affiliation - * @param organization organization to be affiliated with - * @return created attribute - */ - public static Attribute createAssignedAffiliationsAttribute(Attribute attr, boolean member, boolean faculty, - boolean affiliate, String organization ) { - JavaScriptObject value = attr.getValueAsJso(); - // format has to match the format in Perun attribute module for - // urn:perun:user:attribute-def:def:eduPersonScopedAffiliationsManuallyAssigned - DateTimeFormat dateFormat = DateTimeFormat.getFormat("yyyy-MM-dd"); - long expiration = System.currentTimeMillis() + TimeUnit.DAYS.toMillis(365L); - Date date = new Date(expiration); - - attr.setValueAsJso(updateAffiliations(value, organization, member, faculty, affiliate, dateFormat.format(date))); - - return attr; - } - - /** - * Update affiliations attribute - */ - public static native JavaScriptObject updateAffiliations(JavaScriptObject jso, String organization, boolean member, - boolean faculty, boolean affiliate, String date) - /*-{ - if (jso === undefined || jso === null) { - jso = {}; - } - - delete jso["member@" + organization]; - delete jso["faculty@" + organization]; - delete jso["affiliate@" + organization]; - - if (member) { - jso["member@" + organization] = date; - } - if (faculty) { - jso["faculty@" + organization] = date; - } - if (affiliate) { - jso["affiliate@" + organization] = date; - } - - return jso; - }-*/; - -} diff --git a/perun-wui-setAffiliation/src/main/java/cz/metacentrum/perun/wui/setAffiliation/client/PerunSetAffiliationView.java b/perun-wui-setAffiliation/src/main/java/cz/metacentrum/perun/wui/setAffiliation/client/PerunSetAffiliationView.java deleted file mode 100644 index 9bf6bc97..00000000 --- a/perun-wui-setAffiliation/src/main/java/cz/metacentrum/perun/wui/setAffiliation/client/PerunSetAffiliationView.java +++ /dev/null @@ -1,113 +0,0 @@ -package cz.metacentrum.perun.wui.setAffiliation.client; - -import com.google.gwt.core.client.GWT; -import com.google.gwt.event.dom.client.ClickEvent; -import com.google.gwt.safehtml.shared.SafeHtmlUtils; -import com.google.gwt.uibinder.client.UiBinder; -import com.google.gwt.uibinder.client.UiField; -import com.google.gwt.uibinder.client.UiHandler; -import com.google.gwt.user.client.DOM; -import com.google.gwt.user.client.Element; -import com.google.gwt.user.client.History; -import com.google.gwt.user.client.ui.IsWidget; -import com.google.gwt.user.client.ui.Widget; -import com.google.inject.Inject; -import com.gwtplatform.mvp.client.ViewImpl; -import cz.metacentrum.perun.wui.client.PerunPresenter; -import cz.metacentrum.perun.wui.client.resources.PerunConfiguration; -import cz.metacentrum.perun.wui.client.utils.JsUtils; -import cz.metacentrum.perun.wui.client.utils.UiUtils; -import cz.metacentrum.perun.wui.setAffiliation.client.resources.PerunSetAffiliationTranslation; -import org.gwtbootstrap3.client.ui.Anchor; -import org.gwtbootstrap3.client.ui.AnchorListItem; -import org.gwtbootstrap3.client.ui.Image; -import org.gwtbootstrap3.client.ui.Navbar; -import org.gwtbootstrap3.client.ui.NavbarHeader; -import org.gwtbootstrap3.client.ui.NavbarNav; -import org.gwtbootstrap3.client.ui.html.Div; -import org.gwtbootstrap3.client.ui.html.Span; - -/** - * Main View for Perun WUI Set Affiliation. - * - * @author Pavel Zlámal - * @author Dominik Frantisek Bucik - */ -public class PerunSetAffiliationView extends ViewImpl implements PerunSetAffiliationPresenter.MyView{ - - interface PerunSetAffiliationViewUiBinder extends UiBinder {} - - @UiField Div pageContent; - - private PerunSetAffiliationTranslation translation = GWT.create(PerunSetAffiliationTranslation.class); - - @UiField Navbar menuWrapper; - @UiField Span brand; - @UiField Div logoWrapper; - @UiField static NavbarHeader navbarHeader; - - @UiField NavbarNav topMenu; - - @UiField AnchorListItem logout; - - @UiHandler(value="logout") - public void logoutClick(ClickEvent event) { - History.newItem("logout"); - } - - @Inject - PerunSetAffiliationView(final PerunSetAffiliationViewUiBinder binder) { - - initWidget(binder.createAndBindUi(this)); - - if (PerunConfiguration.isHeaderDisabled()) { - menuWrapper.setVisible(false); - } - - // set Title from property if any - if (PerunConfiguration.getBrandProfileTitle() != null) { - brand.setText(PerunConfiguration.getBrandProfileTitle()); - } - - // put logo - Image logo = PerunConfiguration.getBrandLogo(); - logo.setWidth("auto"); - logo.setHeight("50px"); - //logo.setPull(Pull.LEFT); - String logoUrl = PerunConfiguration.getBrandLogoUrl(); - if (logoUrl == null) { - logoWrapper.add(logo); - } else { - Anchor a = new Anchor(logoUrl); - a.add(logo); - logoWrapper.add(a); - } - - if (!PerunConfiguration.isLangSwitchingDisabled()) { - UiUtils.addLanguageSwitcher(topMenu); - } - - - Element elem = DOM.getElementById("perun-help"); - if (elem != null) { - elem.setInnerHTML(translation.supportAt(SafeHtmlUtils.fromString(PerunConfiguration.getBrandSupportMail()).asString())); - } - Element elem2 = DOM.getElementById("perun-credits"); - if (elem2 != null) { - elem2.setInnerHTML(translation.credits(JsUtils.getCurrentYear())); - } - } - - @Override - public void setInSlot(final Object slot, final IsWidget content) { - if (slot == PerunPresenter.SLOT_MAIN_CONTENT) { - pageContent.clear(); - if (content != null) { - pageContent.add(content); - } - } else { - super.setInSlot(slot, content); - } - } - -} diff --git a/perun-wui-setAffiliation/src/main/java/cz/metacentrum/perun/wui/setAffiliation/client/PerunSetAffiliationView.ui.xml b/perun-wui-setAffiliation/src/main/java/cz/metacentrum/perun/wui/setAffiliation/client/PerunSetAffiliationView.ui.xml deleted file mode 100644 index cff3483a..00000000 --- a/perun-wui-setAffiliation/src/main/java/cz/metacentrum/perun/wui/setAffiliation/client/PerunSetAffiliationView.ui.xml +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/perun-wui-setAffiliation/src/main/java/cz/metacentrum/perun/wui/setAffiliation/client/resources/PerunSetAffiliationPlaceTokens.java b/perun-wui-setAffiliation/src/main/java/cz/metacentrum/perun/wui/setAffiliation/client/resources/PerunSetAffiliationPlaceTokens.java deleted file mode 100644 index 0340cdef..00000000 --- a/perun-wui-setAffiliation/src/main/java/cz/metacentrum/perun/wui/setAffiliation/client/resources/PerunSetAffiliationPlaceTokens.java +++ /dev/null @@ -1,18 +0,0 @@ -package cz.metacentrum.perun.wui.setAffiliation.client.resources; - -import cz.metacentrum.perun.wui.client.resources.PlaceTokens; - -/** - * Place tokens used in Perun WUI Set Affiliation app. - * - * @author Dominik Frantisek Bucik - */ -public class PerunSetAffiliationPlaceTokens extends PlaceTokens { - - // General Pages - public static final String AFFILIATION = "affiliation"; - - public static String getAffiliation() { - return AFFILIATION; - } -} diff --git a/perun-wui-setAffiliation/src/main/java/cz/metacentrum/perun/wui/setAffiliation/client/resources/PerunSetAffiliationResources.java b/perun-wui-setAffiliation/src/main/java/cz/metacentrum/perun/wui/setAffiliation/client/resources/PerunSetAffiliationResources.java deleted file mode 100644 index cffdf134..00000000 --- a/perun-wui-setAffiliation/src/main/java/cz/metacentrum/perun/wui/setAffiliation/client/resources/PerunSetAffiliationResources.java +++ /dev/null @@ -1,38 +0,0 @@ -package cz.metacentrum.perun.wui.setAffiliation.client.resources; - -import com.google.gwt.core.client.GWT; -import com.google.gwt.resources.client.ClientBundle; -import com.google.gwt.resources.client.CssResource; - -/** - * Perun Set Affiliation app resources - * - * @author Dominik Frantisek Bucik - */ -public interface PerunSetAffiliationResources extends ClientBundle { - - PerunSetAffiliationResources INSTANCE = GWT.create(PerunSetAffiliationResources.class); - - interface PerunSetAffiliationCss extends CssResource { - - String webContent(); - - String pageWrapper(); - - String page(); - - String logoWrapper(); - - String mobileContainer(); - - String mb1(); - - String pl0(); - - String mt0(); - } - - @Source("css/PerunSetAffiliation.gss") - PerunSetAffiliationCss gss(); - -} diff --git a/perun-wui-setAffiliation/src/main/java/cz/metacentrum/perun/wui/setAffiliation/client/resources/PerunSetAffiliationTranslation.java b/perun-wui-setAffiliation/src/main/java/cz/metacentrum/perun/wui/setAffiliation/client/resources/PerunSetAffiliationTranslation.java deleted file mode 100644 index 82bc39c1..00000000 --- a/perun-wui-setAffiliation/src/main/java/cz/metacentrum/perun/wui/setAffiliation/client/resources/PerunSetAffiliationTranslation.java +++ /dev/null @@ -1,62 +0,0 @@ -package cz.metacentrum.perun.wui.setAffiliation.client.resources; - -import cz.metacentrum.perun.wui.client.resources.PerunTranslation; - -/** - * Perun Set Affiliation translations - * - * @author Dominik Frantisek Bucik - */ -public interface PerunSetAffiliationTranslation extends PerunTranslation { - - @DefaultMessage("Set affiliations for user") - String setAffiliationTitle(); - - @DefaultMessage("Find users") - String userSearchbarLabel(); - - @DefaultMessage("Enter the name or email address of user...") - String userSearchbarPlaceholder(); - - @DefaultMessage("Search") - String searchUserBtn(); - - @DefaultMessage("Assign user affiliations") - String affiliationTitleLabel(); - - @DefaultMessage("User has a formal affiliation with organisation") - String affiliationMember(); - - @DefaultMessage("User is a researcher or teacher") - String affiliationFaculty(); - - @DefaultMessage("User has an informal affiliation with organisation") - String affiliationAffiliate(); - - @DefaultMessage("Organization") - String organizationLabel(); - - @DefaultMessage("Confirm") - String submit(); - - @DefaultMessage("Select user") - String userSelectLabel(); - - @DefaultMessage("Changes were successfully saved") - String success(); - - @DefaultMessage("Request is being processed, please wait") - String loadingData(); - - @DefaultMessage("Select user from list") - String userSelectPlaceholder(); - - @DefaultMessage("You are not authorized to assign affiliations") - String unauthorizedMessage(); - - @DefaultMessage("No user has been found") - String noUsersFound(); - - @DefaultMessage("Select VO or group to search in") - String voGroupSelectLabel(); -} diff --git a/perun-wui-setAffiliation/src/main/java/cz/metacentrum/perun/wui/setAffiliation/pages/affiliation/AffiliationPresenter.java b/perun-wui-setAffiliation/src/main/java/cz/metacentrum/perun/wui/setAffiliation/pages/affiliation/AffiliationPresenter.java deleted file mode 100644 index 7f8cc8be..00000000 --- a/perun-wui-setAffiliation/src/main/java/cz/metacentrum/perun/wui/setAffiliation/pages/affiliation/AffiliationPresenter.java +++ /dev/null @@ -1,390 +0,0 @@ -package cz.metacentrum.perun.wui.setAffiliation.pages.affiliation; - -import com.google.gwt.core.client.JavaScriptObject; -import com.google.inject.Inject; -import com.google.web.bindery.event.shared.EventBus; -import com.gwtplatform.mvp.client.HasUiHandlers; -import com.gwtplatform.mvp.client.Presenter; -import com.gwtplatform.mvp.client.View; -import com.gwtplatform.mvp.client.annotations.NameToken; -import com.gwtplatform.mvp.client.annotations.ProxyStandard; -import com.gwtplatform.mvp.client.proxy.PlaceManager; -import com.gwtplatform.mvp.client.proxy.ProxyPlace; -import com.gwtplatform.mvp.shared.proxy.PlaceRequest; -import cz.metacentrum.perun.wui.client.PerunPresenter; -import cz.metacentrum.perun.wui.client.resources.PerunSession; -import cz.metacentrum.perun.wui.client.utils.JsUtils; -import cz.metacentrum.perun.wui.json.JsonEvents; -import cz.metacentrum.perun.wui.json.managers.*; -import cz.metacentrum.perun.wui.model.PerunException; -import cz.metacentrum.perun.wui.model.beans.*; -import cz.metacentrum.perun.wui.model.common.Roles; -import cz.metacentrum.perun.wui.setAffiliation.client.PerunSetAffiliationUtils; -import cz.metacentrum.perun.wui.setAffiliation.client.resources.PerunSetAffiliationPlaceTokens; - -import java.util.ArrayList; -import java.util.List; - -/** - * Presenter for setting affiliations - * - * @author Dominik Frantisek Bucik - */ -public class AffiliationPresenter extends Presenter - implements AffiliationUiHandlers { - - private PlaceManager placeManager = PerunSession.getPlaceManager(); - - private static final String PREFERRED_MAIL_ATTR = "urn:perun:user:attribute-def:def:preferredMail"; - - public interface MyView extends View, HasUiHandlers { - - void onLoadingStart(); - - void onError(PerunException e); - - void loadUsersUiCallback(List users); - - void loadUsersAsMembersUiCallback(List users); - - void loadAuthorizedAffiliationsUiCallback(Attribute allowedAffiliations); - - void loadAssignedAffiliationsUiCallback(Attribute assignedAffiliations); - - void storeAssignedAffiliationsUiCallback(); - - void loadAdminPerun(); - - void unauthorizedUiCallback(); - - void loadVoGroupsAdmin(List vos, List groups); - } - - @NameToken(PerunSetAffiliationPlaceTokens.AFFILIATION) - @ProxyStandard - public interface MyProxy extends ProxyPlace { - - } - - @Inject - public AffiliationPresenter(final EventBus eventBus, final MyView myView, final MyProxy myProxy) { - super(eventBus, myView, myProxy, PerunPresenter.SLOT_MAIN_CONTENT); - getView().setUiHandlers(this); - } - - @Override - protected void onReveal() { - PerunSession session = PerunSession.getInstance(); - int uid = session.getUserId(); - Roles roles = session.getPerunPrincipal().getRoles(); - if (roles == null) { - return; - } - - if (roles.hasRole(PerunSession.PERUN_ADMIN_PRINCIPAL_ROLE)) { - perunAdminSetup(); - } else if (roles.hasRole(PerunSession.VO_ADMIN_PRINCIPAL_ROLE) - && roles.hasRole(PerunSession.GROUP_ADMIN_PRINCIPAL_ROLE)) { - voAndGroupAdminSetup(uid); - } else if (roles.hasRole(PerunSession.VO_ADMIN_PRINCIPAL_ROLE)){ - voAdminSetup(uid); - } else if (roles.hasRole(PerunSession.GROUP_ADMIN_PRINCIPAL_ROLE)) { - groupAdminSetup(uid); - } else { - getView().unauthorizedUiCallback(); - return; - } - - AttributesManager.getUserAttribute(uid, PerunSetAffiliationUtils.AUTHORIZED_AFFILIATION_SCOPES_ATTR, - new JsonEvents() { - @Override - public void onFinished(JavaScriptObject result) { - Attribute allowedAffiliations = (Attribute) result; - getView().loadAuthorizedAffiliationsUiCallback(allowedAffiliations); - } - - @Override - public void onError(PerunException error) { - getView().onError(error); - } - - @Override - public void onLoadingStart() { - getView().onLoadingStart(); - } - }); - } - - @Override - public void loadUsers(String searchString) { - ArrayList attrs = new ArrayList<>(); - attrs.add(PREFERRED_MAIL_ATTR); - - if (searchString == null || searchString.isEmpty()) { - UsersManager.getRichUsersWithAttributes(attrs, false, new JsonEvents() { - @Override - public void onFinished(JavaScriptObject result) { - getView().loadUsersUiCallback(JsUtils.jsoAsList(result)); - } - - @Override - public void onError(PerunException error) { - getView().onError(error); - } - - @Override - public void onLoadingStart() { - getView().onLoadingStart(); - } - }); - } else { - UsersManager.findRichUsersWithAttributes(searchString, attrs, new JsonEvents() { - @Override - public void onFinished(JavaScriptObject result) { - getView().loadUsersUiCallback(JsUtils.jsoAsList(result)); - } - - @Override - public void onError(PerunException error) { - getView().onError(error); - } - - @Override - public void onLoadingStart() { - getView().onLoadingStart(); - } - }); - } - } - - @Override - public void loadUsersFromGroup(String searchString, int groupId) { - final PlaceRequest request = placeManager.getCurrentPlaceRequest(); - - if (searchString == null) { - placeManager.revealErrorPlace(request.getNameToken()); - } - - List attrs = new ArrayList<>(); - attrs.add(PREFERRED_MAIL_ATTR); - MembersManager.getCompleteRichMembers(groupId, attrs, false, new JsonEvents(){ - @Override - public void onFinished(JavaScriptObject result) { - processMembersResult(searchString, result); - } - - @Override - public void onError(PerunException error) { - getView().onError(error); - } - - @Override - public void onLoadingStart() { - getView().onLoadingStart(); - } - }); - } - - @Override - public void loadUsersFromVo(String searchString, int voId) { - final PlaceRequest request = placeManager.getCurrentPlaceRequest(); - - if (searchString == null) { - placeManager.revealErrorPlace(request.getNameToken()); - } - - List attrs = new ArrayList<>(); - attrs.add(PREFERRED_MAIL_ATTR); - MembersManager.getCompleteRichMembers(voId, attrs, new JsonEvents(){ - @Override - public void onFinished(JavaScriptObject result) { - processMembersResult(searchString, result); - } - - @Override - public void onError(PerunException error) { - getView().onError(error); - } - - @Override - public void onLoadingStart() { - getView().onLoadingStart(); - } - }); - } - - @Override - public void loadAssignedAffiliations(Long uid) { - final PlaceRequest request = placeManager.getCurrentPlaceRequest(); - - if (uid <= 0L ) { - placeManager.revealErrorPlace(request.getNameToken()); - } - - AttributesManager.getUserAttribute(uid.intValue(), - PerunSetAffiliationUtils.EDU_PERSON_SCOPED_AFFILIATIONS_MANUALLY_ASSIGNED_ATTR , new JsonEvents() { - @Override - public void onFinished(JavaScriptObject result) { - Attribute assignedAffiliations = (Attribute) result; - getView().loadAssignedAffiliationsUiCallback(assignedAffiliations); - } - - @Override - public void onError(PerunException error) { - getView().onError(error); - } - - @Override - public void onLoadingStart() { - getView().onLoadingStart(); - } - }); - } - - @Override - public void storeAssignedAffiliations(Long uid, String organization, boolean member, boolean faculty, - boolean affiliate) { - - final PlaceRequest request = placeManager.getCurrentPlaceRequest(); - - if (uid <= 0L ) { - placeManager.revealErrorPlace(request.getNameToken()); - } - - AttributesManager.getUserAttribute(uid.intValue(), - PerunSetAffiliationUtils.EDU_PERSON_SCOPED_AFFILIATIONS_MANUALLY_ASSIGNED_ATTR, new JsonEvents() { - @Override - public void onFinished(JavaScriptObject result) { - storeAttribute(uid, result, member, faculty, affiliate, organization); - } - - @Override - public void onError(PerunException error) { - getView().onError(error); - } - - @Override - public void onLoadingStart() { - getView().onLoadingStart(); - } - }); - } - - private void perunAdminSetup() { - getView().loadAdminPerun(); - } - - private void voAdminSetup(int uid) { - UsersManager.getVosWhereUserIsAdmin(uid, new JsonEvents() { - @Override - public void onFinished(JavaScriptObject result) { - getView().loadVoGroupsAdmin(JsUtils.jsoAsList(result), null); - } - - @Override - public void onError(PerunException error) { - getView().onError(error); - } - - @Override - public void onLoadingStart() { - getView().onLoadingStart(); - } - }); - } - - - private void voAndGroupAdminSetup(int uid) { - UsersManager.getVosWhereUserIsAdmin(uid, new JsonEvents() { - @Override - public void onFinished(JavaScriptObject vos) { - UsersManager.getGroupsWhereUserIsAdmin(uid, new JsonEvents() { - @Override - public void onFinished(JavaScriptObject groups) { - getView().loadVoGroupsAdmin(JsUtils.jsoAsList(vos), JsUtils.jsoAsList(groups)); - } - - @Override - public void onError(PerunException error) { - getView().onError(error); - } - - @Override - public void onLoadingStart() { - getView().onLoadingStart(); - } - }); - } - - @Override - public void onError(PerunException error) { - getView().onError(error); - } - - @Override - public void onLoadingStart() { - getView().onLoadingStart(); - } - }); - } - - private void groupAdminSetup(int uid) { - UsersManager.getGroupsWhereUserIsAdmin(uid, new JsonEvents() { - @Override - public void onFinished(JavaScriptObject result) { - getView().loadVoGroupsAdmin(null, JsUtils.jsoAsList(result)); - } - - @Override - public void onError(PerunException error) { - getView().onError(error); - } - - @Override - public void onLoadingStart() { - getView().onLoadingStart(); - } - }); - } - - private void storeAttribute(Long uid, JavaScriptObject result, boolean member, boolean faculty, boolean affiliate, - String organization) { - Attribute old = (Attribute) result; - Attribute attr = PerunSetAffiliationUtils.createAssignedAffiliationsAttribute( - old, member, faculty, affiliate, organization); - AttributesManager.setUserAttribute(uid.intValue(), attr, new JsonEvents() { - @Override - public void onFinished(JavaScriptObject result) { - getView().storeAssignedAffiliationsUiCallback(); - } - - @Override - public void onError(PerunException error) { - getView().onError(error); - } - - @Override - public void onLoadingStart() { - getView().onLoadingStart(); - } - }); - } - - private void processMembersResult(String searchString, JavaScriptObject result) { - List members = JsUtils.jsoAsList(result); - if (searchString == null ) { - getView().loadUsersAsMembersUiCallback(JsUtils.jsoAsList(result)); - return; - } - - List res = new ArrayList<>(); - for (RichMember m : members) { - if (m.getUser().getFullName().contains(searchString) || - m.getUserAttributes().get(0).getValue().contains(searchString)) { - res.add(m); - } - } - - getView().loadUsersAsMembersUiCallback(res); - } -} diff --git a/perun-wui-setAffiliation/src/main/java/cz/metacentrum/perun/wui/setAffiliation/pages/affiliation/AffiliationUiHandlers.java b/perun-wui-setAffiliation/src/main/java/cz/metacentrum/perun/wui/setAffiliation/pages/affiliation/AffiliationUiHandlers.java deleted file mode 100644 index 7dc00e34..00000000 --- a/perun-wui-setAffiliation/src/main/java/cz/metacentrum/perun/wui/setAffiliation/pages/affiliation/AffiliationUiHandlers.java +++ /dev/null @@ -1,21 +0,0 @@ -package cz.metacentrum.perun.wui.setAffiliation.pages.affiliation; - -import com.gwtplatform.mvp.client.UiHandlers; - -/** - * UI Handlers interface for setting affiliations - * - * @author Dominik Frantisek Bucik - */ -public interface AffiliationUiHandlers extends UiHandlers { - - void loadUsers(String searchString); - - void loadUsersFromGroup(String searchString, int groupId); - - void loadUsersFromVo(String searchString, int voId); - - void loadAssignedAffiliations(Long uid); - - void storeAssignedAffiliations(Long uid, String organization, boolean member, boolean faculty, boolean affiliate); -} diff --git a/perun-wui-setAffiliation/src/main/java/cz/metacentrum/perun/wui/setAffiliation/pages/affiliation/AffiliationView.java b/perun-wui-setAffiliation/src/main/java/cz/metacentrum/perun/wui/setAffiliation/pages/affiliation/AffiliationView.java deleted file mode 100644 index eeff3dad..00000000 --- a/perun-wui-setAffiliation/src/main/java/cz/metacentrum/perun/wui/setAffiliation/pages/affiliation/AffiliationView.java +++ /dev/null @@ -1,371 +0,0 @@ -package cz.metacentrum.perun.wui.setAffiliation.pages.affiliation; - -import com.google.gwt.core.client.GWT; -import com.google.gwt.event.dom.client.KeyUpEvent; -import com.google.gwt.i18n.client.DateTimeFormat; -import com.google.gwt.json.client.JSONValue; -import com.google.gwt.uibinder.client.UiBinder; -import com.google.gwt.uibinder.client.UiField; -import com.google.gwt.user.client.Window; -import com.google.gwt.user.client.ui.Widget; -import com.google.inject.Inject; -import com.gwtplatform.mvp.client.ViewWithUiHandlers; -import cz.metacentrum.perun.wui.model.PerunException; -import cz.metacentrum.perun.wui.model.beans.Attribute; -import cz.metacentrum.perun.wui.model.beans.Group; -import cz.metacentrum.perun.wui.model.beans.RichMember; -import cz.metacentrum.perun.wui.model.beans.RichUser; -import cz.metacentrum.perun.wui.model.beans.Vo; -import cz.metacentrum.perun.wui.setAffiliation.client.resources.PerunSetAffiliationTranslation; -import cz.metacentrum.perun.wui.widgets.PerunButton; -import cz.metacentrum.perun.wui.widgets.PerunLoader; -import org.gwtbootstrap3.client.ui.CheckBox; -import org.gwtbootstrap3.client.ui.Column; -import org.gwtbootstrap3.client.ui.Heading; -import org.gwtbootstrap3.client.ui.Row; -import org.gwtbootstrap3.client.ui.TextBox; -import org.gwtbootstrap3.client.ui.html.Paragraph; -import org.gwtbootstrap3.client.ui.html.Text; -import org.gwtbootstrap3.extras.select.client.ui.Option; -import org.gwtbootstrap3.extras.select.client.ui.Select; - -import java.util.Date; -import java.util.List; -import java.util.Map; - -/** - * View for setting affiliations - * - * @author Dominik Frantisek Bucik - */ -public class AffiliationView extends ViewWithUiHandlers implements AffiliationPresenter.MyView { - - interface AffiliationViewUiBinder extends UiBinder {} - - private PerunSetAffiliationTranslation translation = GWT.create(PerunSetAffiliationTranslation.class); - private static final String PREFIX_DELIMITER = ":"; - private static final String GROUP_PREFIX = "G"; - private static final String VO_PREFIX = "VO"; - - @UiField Text title; - @UiField PerunLoader loader; - @UiField Row unauthorized; - @UiField Row form; - @UiField Heading unauthorizedText; - @UiField Column voGroupSel; - @UiField Paragraph voGroupSelectLabel; - @UiField Select voGroupSelect; - @UiField Paragraph userSearchbarLabel; - @UiField TextBox userSearchbar; - @UiField PerunButton searchUserBtn; - @UiField Paragraph userSelectLabel; - @UiField Select userSelect; - @UiField Paragraph affiliationTitleLabel; - @UiField CheckBox memberCheckbox; - @UiField CheckBox facultyCheckbox; - @UiField CheckBox affiliateCheckbox; - @UiField Paragraph organizationLabel; - @UiField Select organizationSelect; - @UiField PerunButton submitBtn; - - @Inject - public AffiliationView(AffiliationViewUiBinder binder) { - - initWidget(binder.createAndBindUi(this)); - - //texts - title.setText(translation.setAffiliationTitle()); - voGroupSelectLabel.setText(translation.voGroupSelectLabel()); - userSearchbarLabel.setText(translation.userSearchbarLabel()); - userSearchbar.setPlaceholder(translation.userSearchbarPlaceholder()); - userSelectLabel.setText(translation.userSelectLabel()); - searchUserBtn.setText(translation.searchUserBtn()); - userSelect.setPlaceholder(translation.userSelectPlaceholder()); - affiliationTitleLabel.setText(translation.affiliationTitleLabel()); - memberCheckbox.setText(translation.affiliationMember()); - facultyCheckbox.setText(translation.affiliationFaculty()); - affiliateCheckbox.setText(translation.affiliationAffiliate()); - organizationLabel.setText(translation.organizationLabel()); - submitBtn.setText(translation.submit()); - unauthorizedText.setText(translation.unauthorizedMessage()); - - //handlers - searchUserBtn.addClickHandler(clickEvent -> searchUserCallback()); - submitBtn.addClickHandler(clickEvent -> submitBtnCallback()); - userSearchbar.addKeyUpHandler(keyUpEvent -> userSearchbarKeyUpCallback(keyUpEvent)); - userSelect.addValueChangeHandler(valueChangeEvent -> organizationAndUserSelectCallback()); - organizationSelect.addValueChangeHandler(valueChangeEvent -> organizationAndUserSelectCallback()); - } - - /* EVENT HANDLERS */ - private void userSearchbarKeyUpCallback(KeyUpEvent keyUpEvent) { - String val = userSearchbar.getValue(); - if (keyUpEvent.getNativeKeyCode() == 13) { - searchUserCallback(); - } else { - reset(); - userSearchbar.setValue(val); - } - } - - private void submitBtnCallback() { - Long uid = Long.parseLong(userSelect.getValue()); - - getUiHandlers().storeAssignedAffiliations(uid, organizationSelect.getValue(), memberCheckbox.getValue(), - facultyCheckbox.getValue(), affiliateCheckbox.getValue()); - } - - private void searchUserCallback() { - if (voGroupSel.isVisible()) { - String selection = voGroupSelect.getValue(); - String[] parts = selection.split(PREFIX_DELIMITER, 2); - if (parts[0].equals(VO_PREFIX)) { - getUiHandlers().loadUsersFromVo(userSearchbar.getText(), Integer.parseInt(parts[1])); - } else if (parts[0].equals(GROUP_PREFIX)) { - getUiHandlers().loadUsersFromGroup(userSearchbar.getText(), Integer.parseInt(parts[1])); - } - } else { - getUiHandlers().loadUsers(userSearchbar.getText()); - } - } - - private void organizationAndUserSelectCallback() { - boolean userCheckPassed = !(userSelect.getValue() == null || userSelect.getValue().isEmpty()); - boolean orgCheckPassed = !(organizationSelect.getValue() == null || organizationSelect.getValue().isEmpty()); - - reloadCheckboxes(userCheckPassed, orgCheckPassed); - } - - private void reloadCheckboxes(boolean userCheckPassed, boolean orgCheckPassed) { - if (!(userCheckPassed && orgCheckPassed)) { - return; - } - //both checks have passed - Option user = userSelect.getSelectedItem(); - Option org = organizationSelect.getSelectedItem(); - if (user == null || user.getValue() == null || user.getValue().isEmpty() - || org == null || org.getValue() == null || org.getValue().isEmpty()) { - return; - } - - Long uid = Long.parseLong(userSelect.getValue()); - getUiHandlers().loadAssignedAffiliations(uid); - } - - /* OVERRIDES */ - - @Override - public void onError(PerunException e) { - loader.onError(e, clickEvent -> loader.setVisible(false)); - } - - @Override - public void onLoadingStart() { - loader.setVisible(true); - loader.onLoading(translation.loadingData()); - setInputsEnabled(false, false); - } - - @Override - public void loadUsersUiCallback(List users) { - onLoadingFinished(false); - if (users.size() < 1) { - Window.alert(translation.noUsersFound()); - return; - } - - for (int i = 0; i < userSelect.getItems().size(); i++) { - userSelect.remove(i); - } - - for (RichUser u: users) { - Option option = new Option(); - option.setText(u.getFullName() + " < " + u.getPreferredEmail() + ">"); - option.setValue(String.valueOf(u.getId())); - userSelect.add(option); - } - - userSelect.refresh(); - userSelect.setEnabled(true); - userSelect.setFocus(true); - userSelect.setValue(""); - } - - @Override - public void loadUsersAsMembersUiCallback(List members) { - onLoadingFinished(false); - if (members.size() < 1) { - Window.alert(translation.noUsersFound()); - return; - } - - List