Skip to content

Commit

Permalink
better names
Browse files Browse the repository at this point in the history
Signed-off-by: Santhosh Gandhe <[email protected]>
  • Loading branch information
san81 committed Feb 4, 2025
1 parent f8e8d45 commit 47ee223
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
import static org.opensearch.dataprepper.plugins.source.confluence.utils.Constants.SPACE;

/**
* This class represents a Jira client.
* This class represents a Confluence client.
*/
@Named
public class ConfluenceClient implements CrawlerClient {
Expand Down Expand Up @@ -95,7 +95,7 @@ public void executePartition(SaasWorkerProgressState state,
state.getKeyAttributes(), state.getItemIds().size());
List<String> itemIds = state.getItemIds();
Map<String, Object> keyAttributes = state.getKeyAttributes();
String project = (String) keyAttributes.get(SPACE);
String space = (String) keyAttributes.get(SPACE);
Instant eventTime = state.getExportStartTime();
List<ItemInfo> itemInfos = new ArrayList<>();
for (String itemId : itemIds) {
Expand All @@ -105,7 +105,7 @@ public void executePartition(SaasWorkerProgressState state,
ItemInfo itemInfo = ConfluenceItemInfo.builder()
.withItemId(itemId)
.withId(itemId)
.withSpace(project)
.withSpace(space)
.withEventTime(eventTime)
.withMetadata(keyAttributes).build();
itemInfos.add(itemInfo);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,11 @@ public ConfluenceItemInfoBuilder withContentBean(ConfluenceItem contentItem) {
contentItemMetadata.put(CREATED, contentItem.getCreatedTimeMillis());
contentItemMetadata.put(LAST_MODIFIED, contentItem.getUpdatedTimeMillis());
contentItemMetadata.put(CONTENT_ID, contentItem.getId());
contentItemMetadata.put(ConfluenceService.CONTENT_TYPE, ConfluenceContentType.ISSUE.getType());
contentItemMetadata.put(ConfluenceService.CONTENT_TYPE, ConfluenceContentType.PAGE.getType());

this.space = contentItem.getSpaceItem().getKey();
this.id = contentItem.getId();
this.contentType = ConfluenceContentType.ISSUE.getType();
this.contentType = ConfluenceContentType.PAGE.getType();
this.itemId = contentItem.getId();
this.metadata = contentItemMetadata;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ public ItemInfo next() {
/**
* Initialize.
*
* @param jiraChangeLogToken the jira change log token
* @param confluenceChangeLogToken the jira change log token
*/
public void initialize(Instant jiraChangeLogToken) {
public void initialize(Instant confluenceChangeLogToken) {
this.itemInfoQueue = new ConcurrentLinkedQueue<>();
this.lastPollTime = jiraChangeLogToken;
this.lastPollTime = confluenceChangeLogToken;
this.firstTime = true;
}

Expand All @@ -116,9 +116,4 @@ public List<Future<Boolean>> showFutureList() {
return futureList;
}

@VisibleForTesting
public Queue<ItemInfo> showItemInfoQueue() {
return itemInfoQueue;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import java.util.List;

/**
* The result of a JQL search.
* The result of a CQL search.
*/
@Getter
@JsonIgnoreProperties(ignoreUnknown = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,31 +63,31 @@ public ConfluenceRestClient(RestTemplate restTemplate, AtlassianAuthConfig authC
}

/**
* Method to get Issues.
* Method to get all Contents in a paginated fashion.
*
* @param jql input parameter.
* @param cql input parameter.
* @param startAt the start at
* @return InputStream input stream
*/
@Timed(SEARCH_CALL_LATENCY_TIMER)
public ConfluenceSearchResults getAllContent(StringBuilder jql, int startAt) {
public ConfluenceSearchResults getAllContent(StringBuilder cql, int startAt) {

String url = authConfig.getUrl() + REST_API_SEARCH;

URI uri = UriComponentsBuilder.fromHttpUrl(url)
.queryParam(MAX_RESULT, FIFTY)
.queryParam(START_AT, startAt)
.queryParam(CQL_FIELD, jql)
.queryParam(CQL_FIELD, cql)
.queryParam(EXPAND_FIELD, EXPAND_VALUE)
.buildAndExpand().toUri();
return invokeRestApi(uri, ConfluenceSearchResults.class).getBody();
}

/**
* Gets issue.
* Fetches content based on given the content id.
*
* @param contentId the item info
* @return the issue
* @return the content based on the given content id
*/
@Timed(PAGE_FETCH_LATENCY_TIMER)
public String getContent(String contentId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@

@AllArgsConstructor
public enum ConfluenceContentType {
PROJECT("PROJECT"),
ISSUE("ISSUE"),
SPACE("SPACE"),
PAGE("PAGE"),
BLOGPOST("BLOGPOST"),
COMMENT("COMMENT"),
ATTACHMENT("ATTACHMENT"),
WORKLOG("WORKLOG");
ATTACHMENT("ATTACHMENT");

@Getter
private final String type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
*/
public class Constants {

public static final int RETRY_ATTEMPT = 6;

public static final String KEY = "key";
public static final String NAME = "name";
public static final String SPACE = "space";
public static final String OAUTH2 = "OAuth2";
public static final String LAST_MODIFIED = "lastModified";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public class CqlConstants {
public static final String GREATER_THAN_EQUALS = ">=";
public static final String CLOSING_ROUND_BRACKET = ")";

public static final String SLASH = "/";
public static final String SPACE_IN = " AND space in (";
public static final String SPACE_NOT_IN = " AND space not in (";
public static final String DELIMITER = "\",\"";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@
public class ConfluenceContentTypeTest {
@Test
void testEnumConstants() {
assertNotNull(ConfluenceContentType.PROJECT);
assertNotNull(ConfluenceContentType.ISSUE);
assertNotNull(ConfluenceContentType.SPACE);
assertNotNull(ConfluenceContentType.PAGE);
assertNotNull(ConfluenceContentType.COMMENT);
assertNotNull(ConfluenceContentType.ATTACHMENT);
assertNotNull(ConfluenceContentType.WORKLOG);
assertNotNull(ConfluenceContentType.BLOGPOST);
}

@Test
void testTypeValues() {
assertEquals("PROJECT", ConfluenceContentType.PROJECT.getType());
assertEquals("ISSUE", ConfluenceContentType.ISSUE.getType());
assertEquals("SPACE", ConfluenceContentType.SPACE.getType());
assertEquals("PAGE", ConfluenceContentType.PAGE.getType());
assertEquals("COMMENT", ConfluenceContentType.COMMENT.getType());
assertEquals("ATTACHMENT", ConfluenceContentType.ATTACHMENT.getType());
assertEquals("WORKLOG", ConfluenceContentType.WORKLOG.getType());
assertEquals("BLOGPOST", ConfluenceContentType.BLOGPOST.getType());
}
}

0 comments on commit 47ee223

Please sign in to comment.