private static void addToRegistry(String rootPath, File file, int tenantId) { try { Registry registry = getRegistry(tenantId); // This path is used to store the file resource under registry String fileRegistryPath = REGISTRY_GADGET_STORAGE_PATH + file.getAbsolutePath().substring(rootPath.length()).replaceAll("[/\\\\]+", "/"); // Adding the file to the Registry Resource fileResource = registry.newResource(); fileResource.setMediaType("application/vnd.wso2-gadget+xml"); fileResource.setContentStream(new FileInputStream(file)); registry.put(fileRegistryPath, fileResource); } catch (RegistryException e) { log.error(e.getMessage(), e); } catch (FileNotFoundException e) { log.error(e.getMessage(), e); } }