Skip to content

Instantly share code, notes, and snippets.

View pmedcraft's full-sized avatar

Phil Medcraft pmedcraft

View GitHub Profile
@pmedcraft
pmedcraft / SpringInitializer.java
Created January 14, 2020 21:36
Enabling https in DXA Spring Boot Application
package com.sdl.webapp.main;
import com.sdl.dxa.DxaSpringInitialization;
import org.apache.coyote.http11.Http11NioProtocol;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@pmedcraft
pmedcraft / SpringInitializer.java
Last active January 7, 2020 21:43
Converting Java DXA Webapp to Spring Boot APP
package com.sdl.webapp.main;
import com.sdl.dxa.DxaSpringInitialization;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
@Import(DxaSpringInitialization.class)
@Configuration
public class SpringInitializer {
@pmedcraft
pmedcraft / Project.java
Last active April 16, 2019 16:01
Returns the list of active Projects available in SDL WorldServer using the REST API
public class Project {
private int id;
private int projectGroupId;
private String name;
private String description;
public int getId() {
return id;
}
@pmedcraft
pmedcraft / CompleteTaskStepRequestBody.java
Last active April 16, 2019 15:55
Completes a Task Step in SDL WorldServer using the REST API
public class CompleteTaskStepRequestBody {
private int id;
private int transitionId;
private String comment;
public int getId() {
return id;
}
@pmedcraft
pmedcraft / AssetLocationType.java
Last active April 16, 2019 15:40
Download a Task asset from SDL WorldServer using the REST API returning the path to the downloaded file
public enum AssetLocationType {
SOURCE,
TARGET,
SOURCE_TARGET
}
@pmedcraft
pmedcraft / CurrentTaskStep.java
Last active April 15, 2019 19:42
Gets a list of Tasks (TaskDetails objects) from a Project in SDL WorldServer using the REST API
public class CurrentTaskStep {
private int id;
private String name;
private String displayName;
private String type;
private String typeName;
private List<WorkflowTransition> workflowTransitions;
public int getId() {
@pmedcraft
pmedcraft / CreateProjectGroupResponse.java
Last active August 12, 2019 16:14
Creates a Project Group in SDL WorldServer using the REST API returning a CreateProjectGroupResponse object with data from the newly generated Project Group
public class CreateProjectGroupResponse {
private String status;
private List<Response> response;
public String getStatus() {
return status;
}
public void setStatus(String status) {
@pmedcraft
pmedcraft / FileUploadResponse.java
Last active August 12, 2019 16:26
Uploads a collection of files to SDL WorldServer using the REST API returning a list of FileUploadResponse objects containing data from each uploaded asset
public class FileUploadResponse {
private String name;
private String internalName;
private String fullName;
private String url;
private double size;
private long creationTime;
private boolean exists;
private File[] files;
@pmedcraft
pmedcraft / WSRestUtils01.java
Last active April 15, 2019 18:48
Authenticates a user against SDL WorldServer using the REST API returning a Security Token
public static String getSecurityToken(String wsBaseUrl, String username, String password) throws IOException {
StringBuilder loginJson = new StringBuilder();
loginJson.append("{");
loginJson.append("\"username\":\"" + username + "\",");
loginJson.append("\"password\":\"" + password + "\"");
loginJson.append("}");
HttpClient httpClient = HttpClientBuilder.create().build();
HttpPost httpPostRequest = new HttpPost(wsBaseUrl + "/ws-api/v1/login");
httpPostRequest.setHeader(new BasicHeader("Content-Type", "application/json"));
@pmedcraft
pmedcraft / WorldServerUploadAssetToExplorer.java
Created November 15, 2017 18:33
Uploads asset to WorldServer's Explorer (mounts) by posting to the "upload_assets" servlet.
/**
* Uploads assets to WorldServer's Explorer (mounts) by posting to the "upload_assets" servlet.
*
* @param wsBaseUrl
* @param token
* @param explorerFolder
* @param inputFile
* @throws IOException
*/
private void uploadAssetsToExplorer(String wsBaseUrl, String token, String explorerFolder, File inputFile) throws IOException {