001/*
002 * (C) Copyright 2017 Nuxeo (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     Guillaume Renard <grenard@nuxeo.com>
018 */
019package org.nuxeo.ecm.core.api.impl.blob;
020
021import org.apache.commons.text.StringEscapeUtils;
022
023/**
024 * An asynchronously build blob.
025 *
026 * @since 9.3
027 * @deprecated since 10.3, use the @async operation adapter instead.
028 */
029@Deprecated
030public class AsyncBlob extends JSONBlob {
031
032    private static final long serialVersionUID = 1L;
033
034    protected String key;
035
036    protected boolean completed;
037
038    protected int progress;
039
040    public AsyncBlob(String key) {
041        this(key, false, 0, "asyncBlob");
042    }
043
044    public AsyncBlob(String key, boolean completed, int progress) {
045        this(key, completed, progress, "asyncBlob");
046    }
047
048    public AsyncBlob(String key, boolean completed, int progress, String filename) {
049        super("{" + "\"key\":\"" + StringEscapeUtils.escapeJson(key) + "\"," + "\"completed\":" + completed + ","
050                + "\"progress\":" + progress + "}");
051        this.key = key;
052        this.completed = completed;
053        this.progress = progress;
054        setFilename(filename);
055    }
056
057    public String getKey() {
058        return key;
059    }
060
061    public int getProgress() {
062        return progress;
063    }
064
065    public boolean isCompleted() {
066        return completed;
067    }
068
069}