Skip to content

Instantly share code, notes, and snippets.

Avatar

Phil Medcraft pmedcraft

View GitHub Profile
@pmedcraft
pmedcraft / SpringInitializer.java
Created Jan 14, 2020
Enabling https in DXA Spring Boot Application
View SpringInitializer.java
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 Jan 7, 2020
Converting Java DXA Webapp to Spring Boot APP
View SpringInitializer.java
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 Apr 16, 2019
Returns the list of active Projects available in SDL WorldServer using the REST API
View Project.java
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 Apr 16, 2019
Completes a Task Step in SDL WorldServer using the REST API
View CompleteTaskStepRequestBody.java
public class CompleteTaskStepRequestBody {
private int id;
private int transitionId;
private String comment;
public int getId() {
return id;
}
@pmedcraft
pmedcraft / AssetLocationType.java
Last active Apr 16, 2019
Download a Task asset from SDL WorldServer using the REST API returning the path to the downloaded file
View AssetLocationType.java
public enum AssetLocationType {
SOURCE,
TARGET,
SOURCE_TARGET
}
@pmedcraft
pmedcraft / CurrentTaskStep.java
Last active Apr 15, 2019
Gets a list of Tasks (TaskDetails objects) from a Project in SDL WorldServer using the REST API
View CurrentTaskStep.java
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 Aug 12, 2019
Creates a Project Group in SDL WorldServer using the REST API returning a CreateProjectGroupResponse object with data from the newly generated Project Group
View CreateProjectGroupResponse.java
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 Aug 12, 2019
Uploads a collection of files to SDL WorldServer using the REST API returning a list of FileUploadResponse objects containing data from each uploaded asset
View FileUploadResponse.java
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 Apr 15, 2019
Authenticates a user against SDL WorldServer using the REST API returning a Security Token
View WSRestUtils01.java
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 Nov 15, 2017
Uploads asset to WorldServer's Explorer (mounts) by posting to the "upload_assets" servlet.
View WorldServerUploadAssetToExplorer.java
/**
* 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 {