This repository has been archived by the owner on Nov 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix sync behaviour for imported files (#494)
* Fix sync for imported files Signed-off-by: Julie Stalley <[email protected]>
- Loading branch information
Showing
2 changed files
with
140 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package project | ||
|
||
import ( | ||
"encoding/json" | ||
"errors" | ||
"io/ioutil" | ||
"net/http" | ||
|
||
"github.com/eclipse/codewind-installer/pkg/connections" | ||
"github.com/eclipse/codewind-installer/pkg/sechttp" | ||
"github.com/eclipse/codewind-installer/pkg/utils" | ||
) | ||
|
||
type FileList []string | ||
|
||
// GetProjectFromID : Get project details from Codewind | ||
func GetProjectFileList(httpClient utils.HTTPClient, connection *connections.Connection, url, projectID string) (FileList, *ProjectError) { | ||
req, requestErr := http.NewRequest("GET", url+"/api/v1/projects/"+projectID+"/fileList", nil) | ||
if requestErr != nil { | ||
return nil, &ProjectError{errOpRequest, requestErr, requestErr.Error()} | ||
} | ||
|
||
// send request | ||
resp, httpSecError := sechttp.DispatchHTTPRequest(httpClient, req, connection) | ||
if httpSecError != nil { | ||
return nil, &ProjectError{errOpRequest, httpSecError, httpSecError.Desc} | ||
} | ||
|
||
defer resp.Body.Close() | ||
if resp.StatusCode != http.StatusOK { | ||
respErr := errors.New(textAPINotFound) | ||
return nil, &ProjectError{errOpNotFound, respErr, textAPINotFound} | ||
} | ||
|
||
byteArray, readErr := ioutil.ReadAll(resp.Body) | ||
if readErr != nil { | ||
return nil, &ProjectError{errOpRequest, readErr, readErr.Error()} | ||
} | ||
|
||
var list FileList | ||
jsonErr := json.Unmarshal(byteArray, &list) | ||
if jsonErr != nil { | ||
return nil, &ProjectError{errOpRequest, jsonErr, jsonErr.Error()} | ||
} | ||
return list, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters