org.kie.workbench.common.kogito.webapp.base.client.workarounds.KogitoResourceContentService Maven / Gradle / Ivy
/* * Copyright 2020 Red Hat, Inc. and/or its affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.kie.workbench.common.kogito.webapp.base.client.workarounds; import java.util.Arrays; import java.util.List; import javax.enterprise.context.ApplicationScoped; import javax.inject.Inject; import elemental2.promise.IThenable; import elemental2.promise.Promise; import org.appformer.kogito.bridge.client.resource.ResourceContentService; import org.appformer.kogito.bridge.client.resource.interop.ResourceListOptions; import org.jboss.errai.common.client.api.ErrorCallback; import org.jboss.errai.common.client.api.RemoteCallback; import org.uberfire.client.promise.Promises; /** * Class used to provide resources access to kogito editors. * It is a simple wrapper around {@link ResourceContentService} */ @ApplicationScoped public class KogitoResourceContentService { private ResourceContentService resourceContentService; private Promises promises; private KogitoResourceContentService() { //CDI proxy } @Inject public KogitoResourceContentService(final ResourceContentService resourceContentService, final Promises promises) { this.resourceContentService = resourceContentService; this.promises = promises; } /** * Load the file at given uri
and returns its content inside the given callback * * @param fileUri the resource uri relative to the workspace/project * @param callback TheRemoteCallback
to be invoked on success * @param errorCallback TheErrorCallback
to be invoked on failure * @see ResourceContentService#get(String) */ public void loadFile(final String fileUri, final RemoteCallbackcallback, final ErrorCallback