-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Patch notes for 99.0.2541 These patch notes summarize the changes from version 98.0.2363. Added 2 new APIs: * TaskField.QueryTaskFields (GET /api/data/projects/tasks/fields) * TaskField.QueryTaskFieldValues (GET /api/data/tasks/fields/values) Renamed 2 old APIs: * Renamed 'ProjectField.UpdateProjectField' to 'ProjectField.UpdateProjectFieldValue' * Renamed 'ProjectMembers.RetrieveUserProjectMemberShip' to 'ProjectMembers.RetrieveUserProjectMembership'
- Loading branch information
Showing
58 changed files
with
1,047 additions
and
605 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
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
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,207 @@ | ||
/** | ||
* ProjectManager API for Java | ||
* | ||
* (c) 2023-2023 ProjectManager.com | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @author ProjectManager.com <[email protected]> | ||
* @copyright 2023-2023 ProjectManager.com | ||
* @link https://github.com/projectmgr/projectmanager-sdk-java | ||
*/ | ||
|
||
package com.projectmanager; | ||
|
||
import java.lang.reflect.Type; | ||
import java.io.ByteArrayOutputStream; | ||
import java.net.InetAddress; | ||
import java.net.URI; | ||
import java.time.Duration; | ||
import java.time.Instant; | ||
import java.util.Hashtable; | ||
import java.util.Map.Entry; | ||
import org.apache.hc.client5.http.classic.methods.HttpDelete; | ||
import org.apache.hc.client5.http.classic.methods.HttpGet; | ||
import org.apache.hc.client5.http.classic.methods.HttpPatch; | ||
import org.apache.hc.client5.http.classic.methods.HttpPost; | ||
import org.apache.hc.client5.http.classic.methods.HttpPut; | ||
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; | ||
import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse; | ||
import org.apache.hc.client5.http.impl.classic.HttpClients; | ||
import org.apache.hc.core5.http.ClassicHttpRequest; | ||
import org.apache.hc.core5.http.io.entity.EntityUtils; | ||
import org.apache.hc.core5.http.io.entity.StringEntity; | ||
import org.apache.hc.core5.net.URIBuilder; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import com.google.gson.Gson; | ||
|
||
/** | ||
* Represents a request to a remote web server | ||
*/ | ||
public class BlobRequest { | ||
private Hashtable<String, String> queryParams; | ||
private Hashtable<String, String> pathReplacements; | ||
private String method; | ||
private String path; | ||
private Object body; | ||
private ProjectManagerClient client; | ||
|
||
/** | ||
* <p> | ||
* Constructor for BlobRequest. | ||
* </p> | ||
* | ||
* @param client a {@link com.projectmanager.ProjectManagerClient} object. | ||
* @param method a {@link java.lang.String} object. | ||
* @param path a {@link java.lang.String} object. | ||
*/ | ||
public BlobRequest(@NotNull ProjectManagerClient client, @NotNull String method, @NotNull String path) { | ||
this.client = client; | ||
this.method = method; | ||
this.path = path; | ||
queryParams = new Hashtable<String, String>(); | ||
pathReplacements = new Hashtable<String, String>(); | ||
} | ||
|
||
/** | ||
* <p> | ||
* AddQuery. | ||
* </p> | ||
* | ||
* @param name a {@link java.lang.String} object. | ||
* @param value a {@link java.lang.String} object. | ||
*/ | ||
public void AddQuery(@NotNull String name, @NotNull String value) { | ||
this.queryParams.put(name, value); | ||
} | ||
|
||
/** | ||
* <p> | ||
* AddPath. | ||
* </p> | ||
* | ||
* @param name a {@link java.lang.String} object. | ||
* @param value a {@link java.lang.String} object. | ||
*/ | ||
public void AddPath(@NotNull String name, @NotNull String value) { | ||
this.pathReplacements.put(name, value); | ||
} | ||
|
||
/** | ||
* <p> | ||
* AddBody. | ||
* </p> | ||
* | ||
* @param body a {@link java.lang.Object} object. | ||
*/ | ||
public void AddBody(Object body) { | ||
this.body = body; | ||
} | ||
|
||
/** | ||
* Adapted from Apache simple request client example | ||
* | ||
* @return a {@link com.projectmanager.AstroResult} object. | ||
*/ | ||
public @NotNull AstroResult<byte[]> Call(Type classReference) { | ||
Instant start = Instant.now(); | ||
AstroResult<byte[]> result = new AstroResult<byte[]>(); | ||
try { | ||
|
||
CloseableHttpClient httpclient = HttpClients.createDefault(); | ||
|
||
// Add query parameters | ||
URIBuilder builder = new URIBuilder(this.client.getServerUri()); | ||
for (Entry<String, String> entry : this.queryParams.entrySet()) { | ||
builder.addParameter(entry.getKey(), entry.getValue()); | ||
} | ||
|
||
// Set the path and execute replacements | ||
String filledPath = this.path; | ||
for (Entry<String, String> entry : this.pathReplacements.entrySet()) { | ||
filledPath = filledPath.replaceAll(entry.getKey(), entry.getValue()); | ||
} | ||
builder.setPath(filledPath); | ||
URI uri = builder.build(); | ||
|
||
// Create the appropriate request | ||
ClassicHttpRequest request; | ||
switch (this.method) { | ||
case "PATCH": | ||
request = new HttpPatch(uri); | ||
break; | ||
case "PUT": | ||
request = new HttpPut(uri); | ||
break; | ||
case "POST": | ||
request = new HttpPost(uri); | ||
break; | ||
case "DELETE": | ||
request = new HttpDelete(uri); | ||
break; | ||
case "GET": | ||
default: | ||
request = new HttpGet(uri); | ||
break; | ||
} | ||
|
||
request.addHeader("SdkName", "Java"); | ||
request.addHeader("SdkVersion", "99.0.2550.0"); | ||
|
||
String applicationName = this.client.getAppName(); | ||
|
||
if (applicationName != null) { | ||
request.addHeader("ApplicationName", applicationName); | ||
} | ||
|
||
String machineName = InetAddress.getLocalHost().getHostName(); | ||
|
||
if (machineName != null) { | ||
request.addHeader("MachineName", machineName); | ||
} | ||
|
||
String bearerToken = this.client.getBearerToken(); | ||
if (bearerToken != null) { | ||
request.addHeader("Authorization", "Bearer " + bearerToken); | ||
} | ||
|
||
// If we have a request body | ||
Gson gson = new Gson(); | ||
if (body != null) { | ||
StringEntity stringEntity = new StringEntity(gson.toJson(body)); | ||
request.setEntity(stringEntity); | ||
} | ||
// Execute and parse results | ||
final CloseableHttpResponse rawResponse = httpclient.execute(request); | ||
|
||
// get round trip time | ||
long roundTripTime = Duration.between(start, Instant.now()).toMillis(); | ||
|
||
// Did we succeed? | ||
int code = rawResponse.getCode(); | ||
long serverDuration = 0; | ||
|
||
if (rawResponse.getHeader("ServerDuration") != null) { | ||
serverDuration = Long.parseLong(rawResponse.getHeader("ServerDuration").getValue()); | ||
} | ||
|
||
// Detect success or failure | ||
result.Parse(getClass(), bearerToken, code, serverDuration, roundTripTime); | ||
|
||
if (code >= 200 && code < 300) { | ||
ByteArrayOutputStream baos = new ByteArrayOutputStream(); | ||
rawResponse.getEntity().writeTo(baos); | ||
result.ParseBlob(getClass(), baos.toByteArray(), code, serverDuration, roundTripTime); | ||
} else { | ||
String content = EntityUtils.toString(rawResponse.getEntity()); | ||
result.Parse(getClass(), content, code, serverDuration, roundTripTime); | ||
} | ||
return result; | ||
} catch (Exception e) { | ||
result.Parse(getClass(), e.toString(), -1, -1, -1); | ||
} | ||
return result; | ||
} | ||
} |
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 |
---|---|---|
|
@@ -9,7 +9,7 @@ | |
* @author ProjectManager.com <[email protected]> | ||
* | ||
* @copyright 2023-2023 ProjectManager.com, Inc. | ||
* @version 98.0.2363 | ||
* @version 99.0.2550 | ||
* @link https://github.com/projectmgr/projectmanager-sdk-java | ||
*/ | ||
|
||
|
@@ -47,6 +47,7 @@ | |
import com.projectmanager.clients.TaskFileClient; | ||
import com.projectmanager.clients.TaskStatusClient; | ||
import com.projectmanager.clients.TaskTagClient; | ||
import com.projectmanager.clients.TeamsClient; | ||
import com.projectmanager.clients.TimesheetClient; | ||
import com.projectmanager.clients.UserRoleClient; | ||
import com.projectmanager.clients.WorkSpaceClient; | ||
|
@@ -93,6 +94,7 @@ public class ProjectManagerClient { | |
private TaskFileClient taskFile; | ||
private TaskStatusClient taskStatus; | ||
private TaskTagClient taskTag; | ||
private TeamsClient teams; | ||
private TimesheetClient timesheet; | ||
private UserRoleClient userRole; | ||
private WorkSpaceClient workSpace; | ||
|
@@ -132,6 +134,7 @@ private ProjectManagerClient(@NotNull String serverUri) | |
this.taskFile = new TaskFileClient(this); | ||
this.taskStatus = new TaskStatusClient(this); | ||
this.taskTag = new TaskTagClient(this); | ||
this.teams = new TeamsClient(this); | ||
this.timesheet = new TimesheetClient(this); | ||
this.userRole = new UserRoleClient(this); | ||
this.workSpace = new WorkSpaceClient(this); | ||
|
@@ -323,6 +326,12 @@ private ProjectManagerClient(@NotNull String serverUri) | |
* @return A collection containing the {@link com.projectmanager.clients.TaskTagClient client} methods in the API. | ||
*/ | ||
public @NotNull TaskTagClient getTaskTagClient() { return this.taskTag; } | ||
/** | ||
* A collection of API methods relating to Teams | ||
* | ||
* @return A collection containing the {@link com.projectmanager.clients.TeamsClient client} methods in the API. | ||
*/ | ||
public @NotNull TeamsClient getTeamsClient() { return this.teams; } | ||
/** | ||
* A collection of API methods relating to Timesheet | ||
* | ||
|
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
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
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
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
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
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
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
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
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
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
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
Oops, something went wrong.