Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
lincolnthree committed Jun 6, 2014
1 parent 66b2630 commit bb834fb
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ private final class SpacesToDashes implements Transposition<String>
public String transpose(Rewrite event, EvaluationContext context, String value)
{
if (Direction.isOutbound().evaluate(event, context))
return value.replaceAll("\\+|\\s+", "-").toLowerCase();
return value.replaceAll("\\+|\\s+", "-").replaceAll("[-]+", "-").toLowerCase();
else
return value.replaceAll("-", " ");
return value.replaceAll("-", " ").replaceAll("\\s+", " ");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,13 @@ public String download(String url) throws IllegalStateException
throw new IllegalStateException("failed! (server returned status code: "
+ response.getStatusLine().getStatusCode() + ")");
}
catch (IllegalStateException e)
{
throw e;
}
catch (Exception e)
{
throw new RuntimeException("Failed to download: " + url, e);
throw new IllegalStateException("Failed to download: " + url, e);
}

}
Expand Down
27 changes: 22 additions & 5 deletions src/main/java/org/jboss/forge/website/view/DocumentBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,13 @@ public void load()

for (Document document : documents)
{
if (Strings.isNullOrEmpty(searchQuery) ||
if (Strings.isNullOrEmpty(searchQuery)
||
(document.getTitle() != null && document.getTitle().toLowerCase().contains(searchQuery.toLowerCase()))
|| (document.getSummary() != null && document.getSummary().toLowerCase().contains(searchQuery.toLowerCase()))
|| (document.getAuthor() != null && document.getAuthor().toLowerCase().contains(searchQuery.toLowerCase())))
|| (document.getSummary() != null && document.getSummary().toLowerCase()
.contains(searchQuery.toLowerCase()))
|| (document.getAuthor() != null && document.getAuthor().toLowerCase()
.contains(searchQuery.toLowerCase())))
{
if (categoryFilter == null || categoryFilter.isEmpty() || document.getCategory() == null
|| categoryFilter.contains(document.getCategory()))
Expand Down Expand Up @@ -132,7 +135,14 @@ public String getDocumentHTML() throws MalformedURLException
.query("ref", document.getRef())
.query("path", document.getPath()).build();

result = downloader.download(address.toString());
try
{
result = downloader.download(address.toString());
}
catch (IllegalStateException e)
{
System.out.println("Failed to download document: " + address);
}
}

if (Strings.isNullOrEmpty(result))
Expand All @@ -153,7 +163,14 @@ public String getDocumentToC() throws MalformedURLException
.query("ref", document.getRef())
.query("path", document.getPath()).build();

result = downloader.download(address.toString());
try
{
result = downloader.download(address.toString());
}
catch (IllegalStateException e)
{
System.out.println("Failed to download document TOC: " + address);
}
}

if (Strings.isNullOrEmpty(result))
Expand Down

0 comments on commit bb834fb

Please sign in to comment.