Skip to content

Commit 98fbf6e

Browse files
authored
dotCMS#28827 PP endpoint resource (dotCMS#31349)
Adding first draft for the pp endpoints crud on rest
1 parent a626e45 commit 98fbf6e

File tree

9 files changed

+1092
-4
lines changed

9 files changed

+1092
-4
lines changed

dotCMS/src/main/java/com/dotcms/publisher/endpoint/ajax/PublishingEndpointAjaxAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public void addEndpoint(HttpServletRequest request, HttpServletResponse response
108108
return;
109109
}
110110

111-
String serverName = request.getParameter("serverName");
111+
String serverName = request.getParameter("serverName"); // endpoint name
112112
PublishingEndPoint existingServer = APILocator.getPublisherEndPointAPI().findEndPointByName(serverName);
113113

114114
if(existingServer!=null) {

dotCMS/src/main/java/com/dotcms/publisher/endpoint/business/PublishingEndPointAPI.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,10 @@ public interface PublishingEndPointAPI {
8888
* @throws DotDataException
8989
*/
9090
List<String> findSendGroups()throws DotDataException;
91+
92+
/**
93+
* Creates an endPoint of the specified protocol.
94+
* @return PublishingEndPoint
95+
*/
96+
PublishingEndPoint createEndPoint(String protocol) ;
9197
}

dotCMS/src/main/java/com/dotcms/publisher/endpoint/business/PublishingEndPointAPIImpl.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package com.dotcms.publisher.endpoint.business;
22

3-
import java.util.List;
4-
53
import com.dotcms.business.CloseDBIfOpened;
64
import com.dotcms.business.WrapInTransaction;
75
import com.dotcms.integritycheckers.IntegrityUtil;
86
import com.dotcms.publisher.endpoint.bean.PublishingEndPoint;
97
import com.dotmarketing.exception.DotDataException;
108

9+
import java.util.List;
10+
1111
/**
1212
* Implementation of publishing_end_point API.
1313
*
@@ -17,6 +17,7 @@
1717
*/
1818
public class PublishingEndPointAPIImpl implements PublishingEndPointAPI {
1919

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

2223
public PublishingEndPointAPIImpl(PublishingEndPointFactory publishingEndPointFactory){
@@ -129,4 +130,9 @@ public void setPublishingEndPointFactory(
129130
PublishingEndPointFactory publishingEndPointFactory) {
130131
this.publishingEndPointFactory = publishingEndPointFactory;
131132
}
133+
134+
@Override
135+
public PublishingEndPoint createEndPoint(final String protocol) {
136+
return this.factory.getPublishingEndPoint(protocol);
137+
}
132138
}

dotCMS/src/main/java/com/dotcms/rest/CMSConfigResource.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@ public Response deleteEnvironment ( @Context HttpServletRequest request,
444444
/**
445445
* Deletes a given end point
446446
*
447+
* @deprecated use {@link EndpointResource#delete(HttpServletRequest, HttpServletResponse, String)}
447448
* @param request
448449
* @param user
449450
* @param password
@@ -452,6 +453,7 @@ public Response deleteEnvironment ( @Context HttpServletRequest request,
452453
* @throws JSONException
453454
* @throws IOException
454455
*/
456+
@Deprecated
455457
@POST
456458
@Path ("/deleteEndpoint")
457459
@Produces (MediaType.APPLICATION_JSON)
@@ -554,4 +556,4 @@ public Response regenerateKey ( @Context final HttpServletRequest request,
554556
}
555557

556558

557-
}
559+
}
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
package com.dotcms.rest;
2+
3+
import com.dotcms.repackage.javax.validation.constraints.NotNull;
4+
import com.dotcms.rest.api.Validated;
5+
import com.fasterxml.jackson.annotation.JsonCreator;
6+
import com.fasterxml.jackson.annotation.JsonProperty;
7+
8+
/**
9+
* Encapsulates the data of an endpoint on an environment
10+
* @author jsanca
11+
*/
12+
public class EndpointForm extends Validated implements java.io.Serializable {
13+
14+
@NotNull
15+
@JsonProperty("name")
16+
private final String name;
17+
18+
@NotNull
19+
@JsonProperty("protocol")
20+
private final String protocol;
21+
22+
@NotNull
23+
@JsonProperty("address")
24+
private final String address;
25+
26+
@NotNull
27+
@JsonProperty("port")
28+
private final String port;
29+
30+
@JsonProperty("authorizationToken")
31+
private final String authorizationToken;
32+
33+
@JsonProperty("enabled")
34+
private final boolean enabled;
35+
36+
@JsonProperty("sending")
37+
private final boolean sending;
38+
39+
@NotNull
40+
@JsonProperty("environmentId")
41+
private final String environmentId;
42+
43+
@JsonCreator
44+
public EndpointForm(@JsonProperty("name") final String name,
45+
@JsonProperty("protocol") final String protocol,
46+
@JsonProperty("address") final String address,
47+
@JsonProperty("port") final String port,
48+
@JsonProperty("authorizationToken") final String authorizationToken,
49+
@JsonProperty("enabled") final boolean enabled,
50+
@JsonProperty("sending") final boolean sending,
51+
@JsonProperty("environmentId") final String environmentId
52+
) {
53+
this.name = name;
54+
this.protocol = protocol;
55+
this.address = address;
56+
this.port = port;
57+
this.authorizationToken = authorizationToken;
58+
this.enabled = enabled;
59+
this.sending = sending;
60+
this.environmentId = environmentId;
61+
checkValid();
62+
}
63+
64+
public String getName() {
65+
return name;
66+
}
67+
68+
public String getProtocol() {
69+
return protocol;
70+
}
71+
72+
public String getAddress() {
73+
return address;
74+
}
75+
76+
public String getPort() {
77+
return port;
78+
}
79+
80+
public String getAuthorizationToken() {
81+
return authorizationToken;
82+
}
83+
84+
public boolean isEnabled() {
85+
return enabled;
86+
}
87+
88+
public String getEnvironmentId() {
89+
return environmentId;
90+
}
91+
92+
public boolean isSending() {
93+
return sending;
94+
}
95+
}

0 commit comments

Comments
 (0)