Class BackendConnector
- java.lang.Object
-
- org.eclipse.steady.backend.BackendConnector
-
public class BackendConnector extends Object
To be used for interacting with the RESTful backend API.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedBackendConnector()Constructor for BackendConnector.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbatchUpload(GoalContext _ctx)Loads all upload requests form the upload folder and sends them to the backend (as long as they do not have a payload, or the payload does not exceed the maximum lengthCoreConfiguration.UPLOAD_MAX_SIZE).voidcleanApp(GoalContext _goal_context, Application _app, boolean _clean_history)cleanApp.voidcleanCache()cleanCache.voidcleanSpace(GoalContext _goal_context, Space _space)cleanSpace.intcountLibraryConstructs(String _ja)countLibraryConstructs.SpacecreateSpace(GoalContext _goal_context, Space _space)createSpace.voiddeletePatchEvalResults(String _bugId, AffectedVersionSource _source)deletePatchEvalResults.voiddeleteSpace(GoalContext _goal_context, Space _space)deleteSpace.booleandoesArtifactExist(String _g, String _a, String _v, Boolean _sources, String packaging)doesArtifactExist.Artifact[]getAllArtifactsGroupArtifact(String _g, String _a)getAllArtifactsGroupArtifact.Map<String,Set<ConstructId>>getAppBugs(GoalContext _ctx, Application _app)Retrieves the change lists of all bugs relevant for the given application from the backend.Map<String,Set<ConstructId>>getAppBugs(GoalContext _ctx, Application _app, String _filter)Retrieves the change lists of the given bug(s) from the backend.Set<ConstructId>getAppConstructIds(GoalContext _ctx, Application _app)getAppConstructIds.Set<Dependency>getAppDependencies(GoalContext _ctx, Application _app)Set<Dependency>getAppDeps(GoalContext _ctx, Application _app)getAppDeps.Set<ConstructId>getAppTraces(GoalContext _ctx, Application _app)Returns allConstructIds that have been previously traced for the givenApplication.Set<VulnerableDependency>getAppVulnDeps(GoalContext _ctx, Application _app, boolean _include_historical, boolean _include_affected, boolean _include_affected_unconfirmed)getAppVulnDeps.ArtifactgetArtifact(String _g, String _a, String _v)getArtifact.ConstructId[]getArtifactBugConstructsIntersection(String _qString, List<ConstructId> c, String packaging, ProgrammingLanguage lang)getArtifactBugConstructsIntersection.ConstructId[]getArtifactConstructs(String _g, String _a, String _v)getArtifactConstructs.StringgetAstDiff(GoalContext _g, String _json)getAstDiff.StringgetAstForQnameInLib(GoalContext _gc, String _qname, Boolean _sources, ProgrammingLanguage _lang)getAstForQnameInLib.BuggetBug(GoalContext _g, String _bugId)getBug.AffectedLibrary[]getBugAffectedLibraries(String _bugId, String _group, String _artifact, String _version, AffectedVersionSource _source)getBugAffectedLibrary for a GAV.AffectedLibrary[]getBugAffectedLibraries(GoalContext _g, String _bugId, String _source, Boolean _onlyWellKnown)getBugAffectedLibraries.Library[]getBugLibraries(String _bugId)getBugLibraries.StringgetBugsForLib(String _digest)getBugsForLib.StringgetBugsList(ProgrammingLanguage _l)getBugsList.StringgetClassLibraryIds(String _className)getClassLibraryIds.StringgetCVE(String _bugId)get CVE descriptionstatic BackendConnectorgetInstance()Getter for the fieldinstance.StringgetJarConstructs(String qString)getJarConstructs.HttpResponsegetJarForLib(String _g, String _a, String _v, Boolean _s, String _d)getJarForLib.StringgetLibrary(String _sha1)getLibrary.StringgetSourcesForQnameInLib(String qString)getSourcesForQnameInLib.VulnerableDependency[]getVulnDeps(Boolean unconfirmedOnly)getVulnDeps.booleanisAppExisting(GoalContext _goal_context, Application _app)isAppExisting.booleanisBugExisting(String _bug)isBugExisting.booleanisSpaceExisting(GoalContext _goal_context, Space _space)Returns true if the givenSpaceexists in the backend, false otherwise.voidmodifySpace(GoalContext _goal_context, Space _space)modifySpace.voidpurgeAppVersions(GoalContext _goal_context, Application _app, int _keep)purgeAppVersions.voiduploadApp(GoalContext _goal_context, Application _app)uploadApp.voiduploadBugAffectedLibraries(GoalContext _g, String _bugId, String _json, AffectedVersionSource _source)uploadPatchEvalResults.voiduploadChangeList(String _bug, String _json)uploadChangeList.voiduploadCheckVersionResults(String _bugId, String _json)uploadCheckVersionResults.booleanuploadGoalExecution(GoalContext _ctx, AbstractGoal _gexe, boolean _before)Returns true if the upload succeeded or the upload cannot be performed (because the application does not exist), false otherwise.voiduploadLibrary(GoalContext _ctx, Library _lib)uploadLibrary.voiduploadLibraryFile(String _sha1, Path _file)uploadLibraryFile.voiduploadPaths(GoalContext _ctx, Application _app, String _json)uploadPaths.booleanuploadReachableConstructs(GoalContext _goal_context, Application _app, String _lib_digest, String _json)uploadReachableConstructs.booleanuploadTouchPoints(GoalContext _goal_context, Application _app, String _lib_digest, String _json)uploadTouchPoints.voiduploadTraces(GoalContext _ctx, Application _app, String _json)uploadTraces.
-
-
-
Method Detail
-
getInstance
public static BackendConnector getInstance()
Getter for the field
instance.- Returns:
- a
BackendConnectorobject.
-
cleanCache
public void cleanCache()
cleanCache.
-
isSpaceExisting
public boolean isSpaceExisting(GoalContext _goal_context, Space _space) throws BackendConnectionException
Returns true if the givenSpaceexists in the backend, false otherwise. If the client isCoreConfiguration.ConnectType.OFFLINE, the check is skipped and true is returned.- Parameters:
_goal_context- aGoalContextobject._space- aSpaceobject.- Returns:
- a boolean.
- Throws:
BackendConnectionException
-
createSpace
public Space createSpace(GoalContext _goal_context, Space _space) throws BackendConnectionException
createSpace.
- Parameters:
_goal_context- aGoalContextobject._space- aSpaceobject.- Returns:
- a
Spaceobject. - Throws:
BackendConnectionException- if any.
-
modifySpace
public void modifySpace(GoalContext _goal_context, Space _space) throws BackendConnectionException
modifySpace.
- Parameters:
_goal_context- aGoalContextobject._space- aSpaceobject.- Throws:
BackendConnectionException- if any.
-
cleanSpace
public void cleanSpace(GoalContext _goal_context, Space _space) throws BackendConnectionException
cleanSpace.
- Parameters:
_goal_context- aGoalContextobject._space- aSpaceobject.- Throws:
BackendConnectionException- if any.
-
deleteSpace
public void deleteSpace(GoalContext _goal_context, Space _space) throws BackendConnectionException
deleteSpace.
- Parameters:
_goal_context- aGoalContextobject._space- aSpaceobject.- Throws:
BackendConnectionException- if any.
-
isAppExisting
public boolean isAppExisting(GoalContext _goal_context, Application _app) throws BackendConnectionException
isAppExisting.
- Parameters:
_goal_context- aGoalContextobject._app- aApplicationobject.- Returns:
- a boolean.
- Throws:
BackendConnectionException- if any.
-
cleanApp
public void cleanApp(GoalContext _goal_context, Application _app, boolean _clean_history) throws BackendConnectionException
cleanApp.
- Parameters:
_goal_context- TODO_app- aApplicationobject._clean_history- a boolean.- Throws:
BackendConnectionException
-
purgeAppVersions
public void purgeAppVersions(GoalContext _goal_context, Application _app, int _keep) throws BackendConnectionException
purgeAppVersions.
- Parameters:
_goal_context- TODO_app- aApplicationobject._keep- a int.- Throws:
BackendConnectionException- if any.
-
uploadApp
public void uploadApp(GoalContext _goal_context, Application _app) throws BackendConnectionException
uploadApp.
- Parameters:
_goal_context- aGoalContextobject._app- aApplicationobject.- Throws:
BackendConnectionException- if any.
-
uploadReachableConstructs
public boolean uploadReachableConstructs(GoalContext _goal_context, Application _app, String _lib_digest, String _json) throws BackendConnectionException
uploadReachableConstructs.
- Parameters:
_goal_context- aGoalContextobject._app- aApplicationobject._lib_digest- aStringobject._json- aStringobject.- Returns:
- a boolean.
- Throws:
BackendConnectionException- if any.
-
uploadTouchPoints
public boolean uploadTouchPoints(GoalContext _goal_context, Application _app, String _lib_digest, String _json) throws BackendConnectionException
uploadTouchPoints.
- Parameters:
_goal_context- aGoalContextobject._app- aApplicationobject._lib_digest- aStringobject._json- aStringobject.- Returns:
- a boolean.
- Throws:
BackendConnectionException- if any.
-
getAppConstructIds
public Set<ConstructId> getAppConstructIds(GoalContext _ctx, Application _app) throws BackendConnectionException
getAppConstructIds.
- Parameters:
_ctx- aGoalContextobject._app- aApplicationobject.- Returns:
- a
Setobject. - Throws:
BackendConnectionException- if any.
-
getAppBugs
public Map<String,Set<ConstructId>> getAppBugs(GoalContext _ctx, Application _app) throws BackendConnectionException
Retrieves the change lists of all bugs relevant for the given application from the backend.- Parameters:
_app- aApplicationobject._ctx- aGoalContextobject.- Returns:
- a
Mapobject. - Throws:
BackendConnectionException
-
getAppBugs
public Map<String,Set<ConstructId>> getAppBugs(GoalContext _ctx, Application _app, String _filter) throws BackendConnectionException
Retrieves the change lists of the given bug(s) from the backend. Note that only bugs relevant for the given application are included.- Parameters:
_app- aApplicationobject._filter- Comma-separated list of bug identifiers_ctx- aGoalContextobject.- Returns:
- a
Mapobject. - Throws:
BackendConnectionException
-
getAppDeps
public Set<Dependency> getAppDeps(GoalContext _ctx, Application _app) throws BackendConnectionException
getAppDeps.
- Parameters:
_ctx- aGoalContextobject._app- aApplicationobject.- Returns:
- a
Setobject. - Throws:
BackendConnectionException- if any.
-
getAppVulnDeps
public Set<VulnerableDependency> getAppVulnDeps(GoalContext _ctx, Application _app, boolean _include_historical, boolean _include_affected, boolean _include_affected_unconfirmed) throws BackendConnectionException
getAppVulnDeps.
- Parameters:
_ctx- aGoalContextobject._app- aApplicationobject._include_historical- a boolean._include_affected- a boolean._include_affected_unconfirmed- a boolean.- Returns:
- a
Setobject. - Throws:
BackendConnectionException- if any.
-
getVulnDeps
public VulnerableDependency[] getVulnDeps(Boolean unconfirmedOnly) throws BackendConnectionException
getVulnDeps.
- Parameters:
unconfirmedOnly- aBooleanobject.- Returns:
- an array of
VulnerableDependencyobjects. - Throws:
BackendConnectionException- if any.
-
getAppTraces
public Set<ConstructId> getAppTraces(GoalContext _ctx, @NotNull Application _app) throws BackendConnectionException
Returns allConstructIds that have been previously traced for the givenApplication.- Parameters:
_ctx- aGoalContextobject._app- aApplicationobject.- Returns:
- a
Setobject. - Throws:
BackendConnectionException- if any.
-
getAppDependencies
public Set<Dependency> getAppDependencies(GoalContext _ctx, @NotNull Application _app) throws BackendConnectionException
- Parameters:
_ctx- aGoalContextobject._app- aApplicationobject.- Returns:
- a
Setobject. - Throws:
BackendConnectionException- if any.
-
getLibrary
public String getLibrary(String _sha1) throws EntityNotFoundInBackendException
getLibrary.
- Parameters:
_sha1- aStringobject.- Returns:
- a
Stringobject. - Throws:
EntityNotFoundInBackendException- if any.
-
countLibraryConstructs
public int countLibraryConstructs(String _ja) throws BackendConnectionException
countLibraryConstructs.
- Parameters:
_ja- aStringobject.- Returns:
- a int.
- Throws:
BackendConnectionException- if any.
-
uploadLibrary
public void uploadLibrary(GoalContext _ctx, Library _lib) throws BackendConnectionException
uploadLibrary.
- Parameters:
_ctx- aGoalContextobject._lib- aLibraryobject.- Throws:
BackendConnectionException- if any.
-
uploadLibraryFile
public void uploadLibraryFile(String _sha1, Path _file) throws BackendConnectionException
uploadLibraryFile.
- Parameters:
_sha1- aStringobject._file- aPathobject.- Throws:
BackendConnectionException- if any.
-
uploadGoalExecution
public boolean uploadGoalExecution(GoalContext _ctx, AbstractGoal _gexe, boolean _before) throws BackendConnectionException
Returns true if the upload succeeded or the upload cannot be performed (because the application does not exist), false otherwise.- Parameters:
_ctx- aGoalContextobject._gexe- aAbstractGoalobject._before- a boolean.- Returns:
- a boolean.
- Throws:
BackendConnectionException
-
uploadTraces
public void uploadTraces(GoalContext _ctx, Application _app, String _json) throws BackendConnectionException
uploadTraces.
- Parameters:
_ctx- aGoalContextobject._app- aApplicationobject._json- aStringobject.- Throws:
BackendConnectionException- if any.
-
uploadPaths
public void uploadPaths(GoalContext _ctx, Application _app, String _json) throws BackendConnectionException
uploadPaths.
- Parameters:
_ctx- aGoalContextobject._app- aApplicationobject._json- aStringobject.- Throws:
BackendConnectionException- if any.
-
isBugExisting
public boolean isBugExisting(String _bug) throws BackendConnectionException
isBugExisting.
- Parameters:
_bug- aStringobject.- Returns:
- a boolean.
- Throws:
BackendConnectionException- if any.
-
uploadChangeList
public void uploadChangeList(String _bug, String _json) throws BackendConnectionException
uploadChangeList.
- Parameters:
_bug- aStringobject._json- aStringobject.- Throws:
BackendConnectionException- if any.
-
uploadCheckVersionResults
public void uploadCheckVersionResults(String _bugId, String _json) throws BackendConnectionException
uploadCheckVersionResults.
- Parameters:
_bugId- aStringobject._json- aStringobject.- Throws:
BackendConnectionException- if any.
-
getBugAffectedLibraries
public AffectedLibrary[] getBugAffectedLibraries(GoalContext _g, String _bugId, String _source, Boolean _onlyWellKnown) throws BackendConnectionException
getBugAffectedLibraries.
- Parameters:
_bugId- aStringobject._source- aStringobject._g- aGoalContextobject_onlyWellKnown- aBooleanobject- Returns:
- an array of
AffectedLibraryobjects. - Throws:
BackendConnectionException- if any.
-
deletePatchEvalResults
public void deletePatchEvalResults(String _bugId, AffectedVersionSource _source) throws BackendConnectionException
deletePatchEvalResults.
- Parameters:
_bugId- aStringobject._source- aStringobject.- Throws:
BackendConnectionException- if any.
-
uploadBugAffectedLibraries
public void uploadBugAffectedLibraries(GoalContext _g, String _bugId, String _json, AffectedVersionSource _source) throws BackendConnectionException
uploadPatchEvalResults.
- Parameters:
_bugId- aStringobject._json- aStringobject._source- aAffectedVersionSourceobject._g- aGoalContextobject- Throws:
BackendConnectionException- if any.
-
batchUpload
public void batchUpload(GoalContext _ctx)
Loads all upload requests form the upload folder and sends them to the backend (as long as they do not have a payload, or the payload does not exceed the maximum lengthCoreConfiguration.UPLOAD_MAX_SIZE).- Parameters:
_ctx- aGoalContextobject.
-
getBug
public Bug getBug(GoalContext _g, String _bugId) throws BackendConnectionException
getBug.
- Parameters:
_bugId- aStringobject._g- aGoalContextobject- Returns:
- a
Bugobject. - Throws:
BackendConnectionException
-
getAstForQnameInLib
public String getAstForQnameInLib(GoalContext _gc, String _qname, Boolean _sources, ProgrammingLanguage _lang)
getAstForQnameInLib.
- Parameters:
_gc- TODO_qname- aStringobject._sources- aBooleanobject._lang- aProgrammingLanguageobject.- Returns:
- a
Stringobject.
-
getSourcesForQnameInLib
public String getSourcesForQnameInLib(String qString)
getSourcesForQnameInLib.
-
getArtifactBugConstructsIntersection
public ConstructId[] getArtifactBugConstructsIntersection(String _qString, List<ConstructId> c, String packaging, ProgrammingLanguage lang) throws BackendConnectionException
getArtifactBugConstructsIntersection.
- Parameters:
_qString- aStringobject.c- aListobject.packaging- aStringobject.lang- aProgrammingLanguageobject.- Returns:
- an array of
ConstructIdobjects. - Throws:
BackendConnectionException- if any.
-
getAstDiff
public String getAstDiff(GoalContext _g, String _json)
getAstDiff.
- Parameters:
_json- aStringobject._g- aGoalContextobject- Returns:
- a
Stringobject.
-
getBugLibraries
public Library[] getBugLibraries(String _bugId) throws BackendConnectionException
getBugLibraries.
- Parameters:
_bugId- aStringobject.- Returns:
- an array of
Libraryobjects. - Throws:
BackendConnectionException- if any.
-
getAllArtifactsGroupArtifact
public Artifact[] getAllArtifactsGroupArtifact(String _g, String _a) throws BackendConnectionException
getAllArtifactsGroupArtifact.
- Parameters:
_g- aStringobject._a- aStringobject.- Returns:
- an array of
Artifactobjects. - Throws:
BackendConnectionException- if any.
-
getArtifact
public Artifact getArtifact(String _g, String _a, String _v) throws BackendConnectionException
getArtifact.
- Parameters:
_g- aStringobject._a- aStringobject._v- aStringobject.- Returns:
- a
Artifactobject. - Throws:
BackendConnectionException- if any.
-
getArtifactConstructs
public ConstructId[] getArtifactConstructs(String _g, String _a, String _v) throws BackendConnectionException
getArtifactConstructs.
- Parameters:
_g- aStringobject._a- aStringobject._v- aStringobject.- Returns:
- an array of
ConstructIdobjects. - Throws:
BackendConnectionException- if any.
-
doesArtifactExist
public boolean doesArtifactExist(String _g, String _a, String _v, Boolean _sources, String packaging) throws InterruptedException, BackendConnectionException
doesArtifactExist.
- Parameters:
_g- aStringobject._a- aStringobject._v- aStringobject._sources- aBooleanobject.packaging- aStringobject.- Returns:
- a boolean.
- Throws:
InterruptedException- if any.BackendConnectionException- if any.
-
getBugsList
public String getBugsList(ProgrammingLanguage _l) throws BackendConnectionException
getBugsList.
- Parameters:
_l- aProgrammingLanguageobject.- Returns:
- a
Stringobject. - Throws:
BackendConnectionException- if any.
-
getJarForLib
public HttpResponse getJarForLib(String _g, String _a, String _v, Boolean _s, String _d) throws BackendConnectionException
getJarForLib.
- Parameters:
_g- aStringobject._a- aStringobject._v- aStringobject._s- aBooleanobject._d- aStringobject.- Returns:
- a
HttpResponseobject. - Throws:
BackendConnectionException- if any.
-
getBugsForLib
public String getBugsForLib(String _digest) throws BackendConnectionException
getBugsForLib.
- Parameters:
_digest- aStringobject.- Returns:
- a
Stringobject. - Throws:
BackendConnectionException- if any.
-
getBugAffectedLibraries
public AffectedLibrary[] getBugAffectedLibraries(String _bugId, String _group, String _artifact, String _version, AffectedVersionSource _source) throws BackendConnectionException
getBugAffectedLibrary for a GAV. and source
- Parameters:
_bugId- aStringobject._group- aStringobject._artifact- aStringobject._version- aStringobject._source- aStringobject.- Returns:
AffectedLibraryobject.- Throws:
BackendConnectionException- if any.
-
getCVE
public String getCVE(String _bugId) throws BackendConnectionException
get CVE description
- Parameters:
_bugId- aStringobject- Returns:
- String
- Throws:
BackendConnectionException
-
-