Skip to content

Commit

Permalink
#28827 PP endpoint resource (#31349)
Browse files Browse the repository at this point in the history
Adding first draft for the pp endpoints crud on rest
  • Loading branch information
jdotcms authored Feb 17, 2025
1 parent a626e45 commit 98fbf6e
Show file tree
Hide file tree
Showing 9 changed files with 1,092 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public void addEndpoint(HttpServletRequest request, HttpServletResponse response
return;
}

String serverName = request.getParameter("serverName");
String serverName = request.getParameter("serverName"); // endpoint name
PublishingEndPoint existingServer = APILocator.getPublisherEndPointAPI().findEndPointByName(serverName);

if(existingServer!=null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,10 @@ public interface PublishingEndPointAPI {
* @throws DotDataException
*/
List<String> findSendGroups()throws DotDataException;

/**
* Creates an endPoint of the specified protocol.
* @return PublishingEndPoint
*/
PublishingEndPoint createEndPoint(String protocol) ;
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.dotcms.publisher.endpoint.business;

import java.util.List;

import com.dotcms.business.CloseDBIfOpened;
import com.dotcms.business.WrapInTransaction;
import com.dotcms.integritycheckers.IntegrityUtil;
import com.dotcms.publisher.endpoint.bean.PublishingEndPoint;
import com.dotmarketing.exception.DotDataException;

import java.util.List;

/**
* Implementation of publishing_end_point API.
*
Expand All @@ -17,6 +17,7 @@
*/
public class PublishingEndPointAPIImpl implements PublishingEndPointAPI {

final com.dotcms.publisher.endpoint.bean.factory.PublishingEndPointFactory factory = new com.dotcms.publisher.endpoint.bean.factory.PublishingEndPointFactory();
private PublishingEndPointFactory publishingEndPointFactory;

public PublishingEndPointAPIImpl(PublishingEndPointFactory publishingEndPointFactory){
Expand Down Expand Up @@ -129,4 +130,9 @@ public void setPublishingEndPointFactory(
PublishingEndPointFactory publishingEndPointFactory) {
this.publishingEndPointFactory = publishingEndPointFactory;
}

@Override
public PublishingEndPoint createEndPoint(final String protocol) {
return this.factory.getPublishingEndPoint(protocol);
}
}
4 changes: 3 additions & 1 deletion dotCMS/src/main/java/com/dotcms/rest/CMSConfigResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ public Response deleteEnvironment ( @Context HttpServletRequest request,
/**
* Deletes a given end point
*
* @deprecated use {@link EndpointResource#delete(HttpServletRequest, HttpServletResponse, String)}
* @param request
* @param user
* @param password
Expand All @@ -452,6 +453,7 @@ public Response deleteEnvironment ( @Context HttpServletRequest request,
* @throws JSONException
* @throws IOException
*/
@Deprecated
@POST
@Path ("/deleteEndpoint")
@Produces (MediaType.APPLICATION_JSON)
Expand Down Expand Up @@ -554,4 +556,4 @@ public Response regenerateKey ( @Context final HttpServletRequest request,
}


}
}
95 changes: 95 additions & 0 deletions dotCMS/src/main/java/com/dotcms/rest/EndpointForm.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
package com.dotcms.rest;

import com.dotcms.repackage.javax.validation.constraints.NotNull;
import com.dotcms.rest.api.Validated;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
* Encapsulates the data of an endpoint on an environment
* @author jsanca
*/
public class EndpointForm extends Validated implements java.io.Serializable {

@NotNull
@JsonProperty("name")
private final String name;

@NotNull
@JsonProperty("protocol")
private final String protocol;

@NotNull
@JsonProperty("address")
private final String address;

@NotNull
@JsonProperty("port")
private final String port;

@JsonProperty("authorizationToken")
private final String authorizationToken;

@JsonProperty("enabled")
private final boolean enabled;

@JsonProperty("sending")
private final boolean sending;

@NotNull
@JsonProperty("environmentId")
private final String environmentId;

@JsonCreator
public EndpointForm(@JsonProperty("name") final String name,
@JsonProperty("protocol") final String protocol,
@JsonProperty("address") final String address,
@JsonProperty("port") final String port,
@JsonProperty("authorizationToken") final String authorizationToken,
@JsonProperty("enabled") final boolean enabled,
@JsonProperty("sending") final boolean sending,
@JsonProperty("environmentId") final String environmentId
) {
this.name = name;
this.protocol = protocol;
this.address = address;
this.port = port;
this.authorizationToken = authorizationToken;
this.enabled = enabled;
this.sending = sending;
this.environmentId = environmentId;
checkValid();
}

public String getName() {
return name;
}

public String getProtocol() {
return protocol;
}

public String getAddress() {
return address;
}

public String getPort() {
return port;
}

public String getAuthorizationToken() {
return authorizationToken;
}

public boolean isEnabled() {
return enabled;
}

public String getEnvironmentId() {
return environmentId;
}

public boolean isSending() {
return sending;
}
}
Loading

0 comments on commit 98fbf6e

Please sign in to comment.