From c25db47afa3bc89f912ef02132dd9427bd2b5cd0 Mon Sep 17 00:00:00 2001 From: Google Team Member Date: Fri, 27 Mar 2026 06:12:56 -0700 Subject: [PATCH] refactor: Deprecate methods in BaseArtifactService that use individual session parameters PiperOrigin-RevId: 890411230 --- .../adk/artifacts/BaseArtifactService.java | 101 +++++++++++++++++- 1 file changed, 96 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/com/google/adk/artifacts/BaseArtifactService.java b/core/src/main/java/com/google/adk/artifacts/BaseArtifactService.java index acf5979c2..e9bc4f968 100644 --- a/core/src/main/java/com/google/adk/artifacts/BaseArtifactService.java +++ b/core/src/main/java/com/google/adk/artifacts/BaseArtifactService.java @@ -23,10 +23,14 @@ import io.reactivex.rxjava3.core.Maybe; import io.reactivex.rxjava3.core.Single; import org.jspecify.annotations.Nullable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** Base interface for artifact services. */ public interface BaseArtifactService { + Logger logger = LoggerFactory.getLogger(BaseArtifactService.class); + /** * Saves an artifact. * @@ -36,12 +40,21 @@ public interface BaseArtifactService { * @param filename the filename * @param artifact the artifact * @return the revision ID (version) of the saved artifact. + * @deprecated Use {@link #saveArtifact(SessionKey, String, Part)} instead. */ + @Deprecated Single saveArtifact( String appName, String userId, String sessionId, String filename, Part artifact); - /** Saves an artifact. */ + /** + * Saves an artifact. + * + *

Deprecation warning: The default implementation will be removed and all implementing + * classes must provide their own implementation. + */ default Single saveArtifact(SessionKey sessionKey, String filename, Part artifact) { + logger.warn( + "This method relies on the default implementation, which will be removed in the future."); return saveArtifact( sessionKey.appName(), sessionKey.userId(), sessionKey.id(), filename, artifact); } @@ -58,45 +71,99 @@ default Single saveArtifact(SessionKey sessionKey, String filename, Par * @param filename the filename * @param artifact the artifact to save * @return the saved artifact with fileData if available. + * @deprecated Use {@link #saveAndReloadArtifact(SessionKey, String, Part)} instead. */ + @Deprecated default Single saveAndReloadArtifact( String appName, String userId, String sessionId, String filename, Part artifact) { + logger.warn( + "This method relies on the default implementation, which will be removed in the future."); return saveArtifact(appName, userId, sessionId, filename, artifact) .flatMap(version -> loadArtifact(appName, userId, sessionId, filename, version).toSingle()); } - /** Saves an artifact and returns it with fileData if available. */ + /** + * Saves an artifact and returns it with fileData if available. + * + *

Deprecation warning: The default implementation will be removed and all implementing + * classes must provide their own implementation. + */ default Single saveAndReloadArtifact( SessionKey sessionKey, String filename, Part artifact) { + logger.warn( + "This method relies on the default implementation, which will be removed in the future."); return saveAndReloadArtifact( sessionKey.appName(), sessionKey.userId(), sessionKey.id(), filename, artifact); } - /** Loads the latest version of an artifact from the service. */ + /** + * Loads the latest version of an artifact from the service. + * + * @deprecated Use {@link #loadArtifact(SessionKey, String)} instead. + */ + @Deprecated default Maybe loadArtifact( String appName, String userId, String sessionId, String filename) { + logger.warn( + "This method relies on the default implementation, which will be removed in the future."); return loadArtifact(appName, userId, sessionId, filename, /* version= */ (Integer) null); } - /** Loads the latest version of an artifact from the service. */ + /** + * Loads the latest version of an artifact from the service. + * + *

Deprecation warning: The default implementation will be removed and all implementing + * classes must provide their own implementation. + */ default Maybe loadArtifact(SessionKey sessionKey, String filename) { + logger.warn( + "This method relies on the default implementation, which will be removed in the future."); return loadArtifact(sessionKey.appName(), sessionKey.userId(), sessionKey.id(), filename); } - /** Loads a specific version of an artifact from the service. */ + /** + * Loads a specific version of an artifact from the service. + * + * @deprecated Use {@link #loadArtifact(SessionKey, String, int)} instead. + */ + @Deprecated default Maybe loadArtifact( String appName, String userId, String sessionId, String filename, int version) { + logger.warn( + "This method relies on the default implementation, which will be removed in the future."); return loadArtifact(appName, userId, sessionId, filename, Integer.valueOf(version)); } + /** + * Deprecation warning: The default implementation will be removed and all implementing + * classes must provide their own implementation. + */ default Maybe loadArtifact(SessionKey sessionKey, String filename, int version) { + logger.warn( + "This method relies on the default implementation, which will be removed in the future."); return loadArtifact( sessionKey.appName(), sessionKey.userId(), sessionKey.id(), filename, version); } + /** + * @deprecated Use {@link #loadArtifact(SessionKey, String, Integer)} instead. + */ + @Deprecated Maybe loadArtifact( String appName, String userId, String sessionId, String filename, @Nullable Integer version); + /** + * Deprecation warning: The default implementation will be removed and all implementing + * classes must provide their own implementation. + */ + default Maybe loadArtifact( + SessionKey sessionKey, String filename, @Nullable Integer version) { + logger.warn( + "This method relies on the default implementation, which will be removed in the future."); + return loadArtifact( + sessionKey.appName(), sessionKey.userId(), sessionKey.id(), filename, version); + } + /** * Lists all the artifact filenames within a session. * @@ -104,10 +171,18 @@ Maybe loadArtifact( * @param userId the user ID * @param sessionId the session ID * @return the list artifact response containing filenames + * @deprecated Use {@link #listArtifactKeys(SessionKey)} instead. */ + @Deprecated Single listArtifactKeys(String appName, String userId, String sessionId); + /** + * Deprecation warning: The default implementation will be removed and all implementing + * classes must provide their own implementation. + */ default Single listArtifactKeys(SessionKey sessionKey) { + logger.warn( + "This method relies on the default implementation, which will be removed in the future."); return listArtifactKeys(sessionKey.appName(), sessionKey.userId(), sessionKey.id()); } @@ -118,10 +193,18 @@ default Single listArtifactKeys(SessionKey sessionKey) { * @param userId the user ID * @param sessionId the session ID * @param filename the filename + * @deprecated Use {@link #deleteArtifact(SessionKey, String)} instead. */ + @Deprecated Completable deleteArtifact(String appName, String userId, String sessionId, String filename); + /** + * Deprecation warning: The default implementation will be removed and all implementing + * classes must provide their own implementation. + */ default Completable deleteArtifact(SessionKey sessionKey, String filename) { + logger.warn( + "This method relies on the default implementation, which will be removed in the future."); return deleteArtifact(sessionKey.appName(), sessionKey.userId(), sessionKey.id(), filename); } @@ -133,11 +216,19 @@ default Completable deleteArtifact(SessionKey sessionKey, String filename) { * @param sessionId the session ID * @param filename the artifact filename * @return A list of integer version numbers. + * @deprecated Use {@link #listVersions(SessionKey, String)} instead. */ + @Deprecated Single> listVersions( String appName, String userId, String sessionId, String filename); + /** + * Deprecation warning: The default implementation will be removed and all implementing + * classes must provide their own implementation. + */ default Single> listVersions(SessionKey sessionKey, String filename) { + logger.warn( + "This method relies on the default implementation, which will be removed in the future."); return listVersions(sessionKey.appName(), sessionKey.userId(), sessionKey.id(), filename); } }