Skip to content

Commit

Permalink
replace new line with br
Browse files Browse the repository at this point in the history
  • Loading branch information
kreloaded committed Aug 31, 2023
1 parent e6541a2 commit 2806314
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/salessparrow/api/SalesSparrowApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

@SpringBootApplication(exclude = { UserDetailsServiceAutoConfiguration.class })
@EnableCaching // This enables caching
@EnableAsync // This enables asynchronous processing in Spring
// @EnableAsync // This enables asynchronous processing in Spring
public class SalesSparrowApi {

public static void main(String[] args) {
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/salessparrow/api/lib/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -177,4 +177,8 @@ public String unEscapeSpecialCharactersForPlainText(String input) {
return input.replace("&", "&");
}

public String replaceNewLineWithBreak(String input) {
return input.replace("\n", "<br>");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,17 @@ public class CreateSalesforceNote implements CreateNoteInterface {
public CreateNoteFormatterDto createNote(SalesforceUser user, String accountId, NoteDto note) {
String salesforceUserId = user.getExternalUserId();

logger.info("createNote note text: {}", note.getText());
String noteTitle = getNoteTitleFromContent(note);
String encodedNoteContent = base64Helper.base64Encode(note.getText());
Util util = new Util();
String noteContent = note.getText();
logger.info("createNote noteContent: {}", noteContent);

String noteTitle = getNoteTitleFromContent(noteContent);
logger.info("createNote noteTitle: {}", noteTitle);

noteContent = util.replaceNewLineWithBreak(noteContent);
logger.info("---- noteContent after replacing \\n: {}", noteContent);

String encodedNoteContent = base64Helper.base64Encode(noteContent);
logger.info("---- encodedNoteContent: {}", encodedNoteContent);

Map<String, String> createNoteBody = new HashMap<String, String>();
Expand Down Expand Up @@ -128,17 +136,15 @@ private CreateNoteFormatterDto parseResponse(String createNoteResponse) {
* @param note - note dto
* @return String
*/
private String getNoteTitleFromContent(NoteDto note) {
String noteText = note.getText();

private String getNoteTitleFromContent(String noteContent) {
Util util = new Util();
noteText = util.unEscapeSpecialCharactersForPlainText(noteText);
noteContent = util.unEscapeSpecialCharactersForPlainText(noteContent);

if (noteText.length() < 50) {
return noteText;
if (noteContent.length() < 50) {
return noteContent;
}

return noteText.substring(0, 50);
return noteContent.substring(0, 50);
}

}

0 comments on commit 2806314

Please sign in to comment.