Add stream base file download support

file-downloader-service
Rajitha Kumara 4 weeks ago
parent a45820e845
commit f9bd9e1156

@ -50,4 +50,16 @@ public interface AppmDataHandler {
* @throws ApplicationManagementException throws if an error occurs when accessing the file. * @throws ApplicationManagementException throws if an error occurs when accessing the file.
*/ */
InputStream getAgentStream(String tenantDomain, String deviceType) throws ApplicationManagementException; InputStream getAgentStream(String tenantDomain, String deviceType) throws ApplicationManagementException;
/**
* Check if the artifact is existing in the file system
*
* @param hashVal Hash Value of the application
* @param folderName Folder name
* @param fileName Artifact file name
* @param tenantId Tenant id
* @return true if the artifact exists, otherwise false
* @throws ApplicationManagementException if error occurred while checking the existence of the artifact
*/
boolean isArtifactExists(String hashVal, String folderName, String fileName, int tenantId) throws ApplicationManagementException;
} }

@ -35,6 +35,7 @@ import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import java.io.File;
import java.io.InputStream; import java.io.InputStream;
import java.util.Map; import java.util.Map;
@ -136,4 +137,11 @@ public class AppmDataHandlerImpl implements AppmDataHandler {
throw new ApplicationManagementException(msg, e); throw new ApplicationManagementException(msg, e);
} }
} }
@Override
public boolean isArtifactExists(String hashVal, String folderName, String fileName, int tenantId) throws BadRequestException {
validateArtifactDownloadRequest(tenantId, hashVal, folderName, fileName);
return new File(APIUtil.
getApplicationStorageManager().getAbsolutePathOfFile(hashVal, folderName, fileName, tenantId)).exists();
}
} }

Loading…
Cancel
Save