Skip to content

Commit

Permalink
#182 - add check on name
Browse files Browse the repository at this point in the history
  • Loading branch information
bsorrentino committed Nov 25, 2018
1 parent 8596b25 commit 2eed4ba
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@
*/
package org.bsc.confluence.model;

import static java.lang.String.format;

import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.regex.Pattern;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
Expand Down Expand Up @@ -67,9 +70,14 @@ public void setSpaceKey(String spaceKey) {
*/
@XmlType(namespace = Site.NAMESPACE)
protected static class Source {

private static final Pattern lead_trail_spaces = Pattern.compile("^(.*)\\s+$|^\\s+(.*)");

protected transient final Site site;

public Source() {
this.site = _SITE.peek();
}

private java.net.URI uri;

@XmlAttribute
Expand Down Expand Up @@ -102,13 +110,11 @@ public final Optional<String> optName() {
}

public void setName(String name) {
if( lead_trail_spaces.matcher(name).matches() )
throw new IllegalArgumentException(format("name [%s] is not valid!", name));
this.name = name;
}

public Source() {
this.site = _SITE.peek();
}

@Override
public String toString() {
return getClass().getSimpleName() + ": " + getName() + " - " + String.valueOf(getUri());
Expand Down

0 comments on commit 2eed4ba

Please sign in to comment.