Example usage for com.google.gwt.safehtml.shared UriUtils fromTrustedString

List of usage examples for com.google.gwt.safehtml.shared UriUtils fromTrustedString

Introduction

In this page you can find the example usage for com.google.gwt.safehtml.shared UriUtils fromTrustedString.

Prototype

public static SafeUri fromTrustedString(String s) 

Source Link

Document

Returns a SafeUri constructed from a trusted string, i.e., without sanitizing the string.

Usage

From source file:nl.mpi.tg.eg.experiment.client.presenter.AbstractStimulusPresenter.java

License:Open Source License

protected void stimulusAudio(final Stimulus currentStimulus, final boolean autoPlay, final String mediaId,
        boolean showPlaybackIndicator, final int dataChannel,
        final CancelableStimulusListener loadedStimulusListener,
        final CancelableStimulusListener failedStimulusListener,
        final CancelableStimulusListener playbackStartedStimulusListener,
        final CancelableStimulusListener playedStimulusListener) {
    final String audio = currentStimulus.getAudio();
    final String uniqueId = currentStimulus.getUniqueId();
    final String formattedMediaId = new HtmlTokenFormatter(currentStimulus, localStorage,
            groupParticipantService, userResults.getUserData(), timerService,
            metadataFieldProvider.metadataFieldArray).formatString(mediaId);
    String ogg = audio + ".ogg";
    String mp3 = audio + ".mp3";
    //        submissionService.submitTagValue(userResults.getUserData().getUserId(), "StimulusAudio", ogg, duration.elapsedMillis());
    final CancelableStimulusListener shownStimulusListener = new CancelableStimulusListener() {
        @Override//from ww w. j a v  a2  s  .c o m
        protected void trigggerCancelableEvent() {
            submissionService.submitTagPairValue(userResults.getUserData().getUserId(), getSelfTag(),
                    dataChannel, "StimulusAudioShown", uniqueId, audio, duration.elapsedMillis());
            loadedStimulusListener.postLoadTimerFired();
        }
    };
    timedStimulusView.addTimedAudio(timedEventMonitor, UriUtils.fromTrustedString(ogg),
            UriUtils.fromTrustedString(mp3), showPlaybackIndicator, shownStimulusListener,
            failedStimulusListener, playbackStartedStimulusListener, playedStimulusListener, autoPlay,
            formattedMediaId);
    //        timedStimulusView.addText("playStimulusAudio: " + duration.elapsedMillis() + "ms");
}

From source file:nl.mpi.tg.eg.experiment.client.presenter.AbstractStimulusPresenter.java

License:Open Source License

protected void startAudioRecorder(final String recordingFormat, final int downloadPermittedWindowMs,
        final String mediaId, final String deviceRegex, boolean filePerStimulus, String directoryName,
        final Stimulus currentStimulus, final TimedStimulusListener onError,
        final TimedStimulusListener onSuccess, final CancelableStimulusListener loadedStimulusListener,
        final CancelableStimulusListener failedStimulusListener,
        final CancelableStimulusListener playbackStartedStimulusListener,
        final CancelableStimulusListener playedStimulusListener) {
    //        final String subdirectoryName = userResults.getUserData().getUserId().toString();
    final String subdirectoryName = userResults.getUserData()
            .getMetadataValue(new MetadataFieldProvider().workerIdMetadataField);
    final String formattedMediaId = new HtmlTokenFormatter(currentStimulus, localStorage,
            groupParticipantService, userResults.getUserData(), timerService,
            metadataFieldProvider.metadataFieldArray).formatString(mediaId);
    final MediaSubmissionListener mediaSubmissionListener = new MediaSubmissionListener() {
        @Override/*from  w  w  w  . j ava  2 s .  co  m*/
        public void recorderStarted() {
            onSuccess.postLoadTimerFired();
        }

        @Override
        public void submissionFailed(final String message, final String userIdString, final String screenName,
                final String stimulusIdString, final Uint8Array dataArray) {
            // todo: consider storing unsent data for retries, but keep in mind that the local storage will overfill very quickly
            //                timedStimulusView.addText("(debug) Media Submission Failed (retry not implemented): " + message);
            onError.postLoadTimerFired();
            final MediaSubmissionListener mediaSubmissionListener = this;
            actionButton(new PresenterEventListner() {
                @Override
                public String getLabel() {
                    return "Media Submission Failed"; // todo: this needs to be parameterised but with internationalisation
                }

                @Override
                public void eventFired(ButtonBase button, SingleShotEventListner shotEventListner) {
                    submissionService.submitAudioData(userIdString, screenName, stimulusIdString, dataArray,
                            mediaSubmissionListener, downloadPermittedWindowMs);
                }

                @Override
                public String getStyleName() {
                    return null;
                }

                @Override
                public int getHotKey() {
                    return -1;
                }
            }, "startAudioRecorderRetry");
        }

        @Override
        public void recorderFailed(final String message) {
            onError.postLoadTimerFired();
            submissionService.submitTagValue(userResults.getUserData().getUserId(), getSelfTag(),
                    "AudioRecorder", message, duration.elapsedMillis());
        }

        @Override
        public void submissionComplete(String message, String urlAudioData) {
            String replayAudioUrl = serviceLocations.dataSubmitUrl() + "replayAudio/"
                    + message.replaceAll("[^a-zA-Z0-9\\-]", "") + "/" + userResults.getUserData().getUserId();
            //                timedStimulusView.addText("(debug) Media Submission OK: " + message);
            timedStimulusView.addTimedAudio(timedEventMonitor,
                    (downloadPermittedWindowMs <= 0) ? UriUtils.fromTrustedString(urlAudioData)
                            : UriUtils.fromString(replayAudioUrl),
                    null, false, loadedStimulusListener, failedStimulusListener,
                    playbackStartedStimulusListener, playedStimulusListener, false, formattedMediaId);
        }
    };
    super.startAudioRecorder(submissionService, "wav".equals(recordingFormat), deviceRegex, subdirectoryName,
            directoryName, filePerStimulus, currentStimulus.getUniqueId(),
            userResults.getUserData().getUserId().toString(), getSelfTag(), mediaSubmissionListener,
            downloadPermittedWindowMs);
}

From source file:org.activityinfo.legacy.shared.reports.model.MapIcon.java

License:Open Source License

@Override
public SafeUri getSafeUri() {
    return UriUtils.fromTrustedString(getURL());
}

From source file:org.wisepersist.gwtmockito.ng.fakes.FakeClientBundleProvider.java

License:Apache License

/**
 * Fake invoking on a specified method with arguments.
 *
 * @param method The method specified.//from ww w  . java  2s  .  c  o  m
 * @param args The arguments specified.
 * @param name The name specified.
 * @return The result object.
 */
private Object doInvoke(final Method method, final Object[] args, final String name) {
    final Object result;
    final Class<?> returnType = method.getReturnType();
    if (returnType == String.class) {
        result = name;
    } else if (returnType == SafeHtml.class) {
        result = SafeHtmlUtils.fromTrustedString(name);
    } else if (returnType == SafeUri.class) {
        result = UriUtils.fromTrustedString(name);
    } else if (returnType == boolean.class) {
        result = false;
    } else if (returnType == int.class) {
        result = 0;
    } else if (method.getParameterTypes()[0] == ResourceCallback.class) {
        result = createFakeForResourceCallback(args[0], name);
    } else {
        throw new IllegalArgumentException("Unexpected return type for method " + method.getName());
    }
    return result;
}