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 */ 028public class AsyncBlob extends JSONBlob { 029 030 private static final long serialVersionUID = 1L; 031 032 protected String key; 033 034 protected boolean completed; 035 036 protected int progress; 037 038 public AsyncBlob(String key) { 039 this(key, false, 0, "asyncBlob"); 040 } 041 042 public AsyncBlob(String key, boolean completed, int progress) { 043 this(key, completed, progress, "asyncBlob"); 044 } 045 046 public AsyncBlob(String key, boolean completed, int progress, String filename) { 047 super("{" + "\"key\":\"" + StringEscapeUtils.escapeJson(key) + "\"," + "\"completed\":" + completed + "," 048 + "\"progress\":" + progress + "}"); 049 this.key = key; 050 this.completed = completed; 051 this.progress = progress; 052 setFilename(filename); 053 } 054 055 public String getKey() { 056 return key; 057 } 058 059 public int getProgress() { 060 return progress; 061 } 062 063 public boolean isCompleted() { 064 return completed; 065 } 066 067}