Skip to content

Commit

Permalink
- Comment URL Formatter, Spring 2.2.5 and Gradle 6.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
alegauss committed Mar 7, 2020
1 parent 6bf2b05 commit 84c671a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 36 deletions.
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
buildscript {
ext { springBootVersion = '2.2.4.RELEASE'
hibernateVersion = '5.11.0.Final'
ext { springBootVersion = '2.2.5.RELEASE'
hibernateVersion = '5.11.5.Final'
httpClientVersion = '4.5.11'
swaggerVersion = '2.9.2'
}
Expand Down Expand Up @@ -113,10 +113,10 @@ dependencies {


// Spring
compile group: 'org.springframework', name: 'spring-test', version: '5.2.3.RELEASE'
compile group: 'org.springframework', name: 'spring-test', version: '5.2.4.RELEASE'

// Jackson
compile group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-hibernate5', version: '2.9.8'
compile group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-hibernate5', version: '2.10.3'

// Oracle
compile group: 'com.oracle.ojdbc', name: 'ojdbc8', version: '19.3.0.0'
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.2.2-bin.zip
28 changes: 0 additions & 28 deletions src/main/java/com/viglet/shio/api/ShAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,11 @@
*/
package com.viglet.shio.api;

import java.io.IOException;

import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.api.errors.JGitInternalException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.viglet.shio.provider.storage.ShGitProvider;

import io.swagger.annotations.Api;

/**
Expand All @@ -41,33 +35,11 @@ public class ShAPI {
@Autowired
private ShAPIBean shAPIBean;

@Autowired
private ShGitProvider shGitProvider;

@GetMapping
public ShAPIBean shApiInfo() {

shAPIBean.setProduct("Viglet Shio CMS");

return shAPIBean;
}

@GetMapping("test")
public ShAPIBean testApi() {

shAPIBean.setProduct("Test Api");

shGitProvider.cloneRepository();
try {
shGitProvider.init();

shGitProvider.newItem("174a27fc-337d-49fb-91b5-129baada3d72");
shGitProvider.pushToRepo();
} catch (JGitInternalException | IOException | GitAPIException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return shAPIBean;
}

}
20 changes: 17 additions & 3 deletions src/main/java/com/viglet/shio/url/ShURLFormatter.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,31 @@ public class ShURLFormatter {

public String format(String URL) {

// 1. Covert to Lowercase
String formattedURL = URL.toLowerCase();
formattedURL = formattedURL.replaceAll("&.+?;", " "); // kill entities

// 2. Convert HTML Symbol Entities to space, for examples: € or ®
formattedURL = formattedURL.replaceAll("&.+?;", " ");

// 3. Remove accents
formattedURL = StringUtils.stripAccents(formattedURL);

// 4. Convert dot to hyphen
formattedURL = formattedURL.replaceAll("\\.", "-");

// 5. Remove all characters that are not a-z or 0-9 or space or _ or hyphen
formattedURL = formattedURL.replaceAll("[^a-z0-9 _-]", "");

// 6. Convert one or more spaces to hyphen
formattedURL = formattedURL.replaceAll("\\s+", "-");

// 7. If exist space or hyphen into start or and of string, will be removed
formattedURL = StringUtils.strip(formattedURL, " -");

if (formattedURL.endsWith("-json")) {
// 8. In 4. Convert dot to -, so I need rollback Folders that have .json in its name.
if (formattedURL.endsWith("-json"))
formattedURL = formattedURL.replaceAll("-json$", ".json");
}

return formattedURL;
}
}

0 comments on commit 84c671a

Please sign in to comment.