/** * The contents of this file are subject to the license and copyright * detailed in the LICENSE file at the root of the source * tree and available online at * * https://github.com/keeps/roda */ /** * */ package org.roda.wui.client.ingest.preingest; import java.util.List; import org.roda.wui.client.common.UserLogin; import org.roda.wui.client.ingest.Ingest; import org.roda.wui.common.client.HistoryResolver; import org.roda.wui.common.client.tools.HistoryUtils; import org.roda.wui.common.client.tools.ListUtils; import org.roda.wui.common.client.widgets.HTMLWidgetWrapper; import org.roda.wui.common.client.widgets.wcag.WCAGUtilities; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.VerticalPanel; import com.google.gwt.user.client.ui.Widget; /** * @author Luis Faria * */ public class PreIngest { public static final HistoryResolver RESOLVER = new HistoryResolver() { @Override public void resolve(List<String> historyTokens, AsyncCallback<Widget> callback) { getInstance().resolve(historyTokens, callback); } @Override public void isCurrentUserPermitted(AsyncCallback<Boolean> callback) { UserLogin.getInstance().checkRole(this, callback); } @Override public String getHistoryToken() { return "pre"; } @Override public List<String> getHistoryPath() { return ListUtils.concat(Ingest.RESOLVER.getHistoryPath(), getHistoryToken()); } }; private static PreIngest instance = null; /** * Get instance * * @return {@link PreIngest} singleton */ public static PreIngest getInstance() { if (instance == null) { instance = new PreIngest(); } return instance; } private VerticalPanel layout; private HTMLWidgetWrapper html; private PreIngest() { layout = new VerticalPanel(); html = new HTMLWidgetWrapper("PreIngest.html"); layout.add(html); layout.addStyleName("wui-ingest-pre"); WCAGUtilities.getInstance().makeAccessible(layout.getElement()); } public void resolve(List<String> historyTokens, AsyncCallback<Widget> callback) { if (historyTokens.isEmpty()) { callback.onSuccess(layout); } else { HistoryUtils.newHistory(RESOLVER); callback.onSuccess(null); } } }