Skip to content

Commit

Permalink
Merge branch 'issue-10-sitesearch-publishing-framework' of github.com…
Browse files Browse the repository at this point in the history
…:dotCMS/dotCMS into issue-10-sitesearch-publishing-framework
  • Loading branch information
wezell committed Apr 11, 2012
2 parents 4fd84b0 + 9c4b734 commit 1f7b0d9
Showing 1 changed file with 11 additions and 18 deletions.
29 changes: 11 additions & 18 deletions src/com/dotcms/publishing/bundlers/StaticHTMLPageBundler.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,7 @@ public void generate(File bundleRoot, BundlerStatus status) throws DotBundleExce
deletedIdents.addAll(iAPI.findByURIPattern(new HTMLPage().getType(), "/*",config.liveOnly(),true,include, h, config.getStartDate(), config.getEndDate()));
}catch(NullPointerException e){}
for (Identifier i : pageIdents) {
String html = null;
if(!config.liveOnly()){
try{
html = pAPI.getHTML(i.getURI(), h,false , null, uAPI.getSystemUser());
}catch(Exception e){
Logger.error(this, e.getMessage() + " Unable to get page", e);
}
HTMLPageWrapper w = new HTMLPageWrapper();
try{
w.setIdentifier(i);
Expand All @@ -115,18 +109,12 @@ public void generate(File bundleRoot, BundlerStatus status) throws DotBundleExce
continue;
}
try{
writeFileToDisk(bundleRoot,w, html, i.getURI(), h, false);
writeFileToDisk(bundleRoot,w, i.getURI(), h, false);
}catch (IOException e) {
Logger.error(this, e.getMessage() + " : Unable to write HTML to bundle", e);
}
html=null;
}

try{
html = pAPI.getHTML(i.getURI(), h,true , null, uAPI.getSystemUser());
}catch(Exception e){
Logger.error(this, e.getMessage() + " Unable to get page", e);
}
HTMLPageWrapper w = new HTMLPageWrapper();
try{
w.setIdentifier(i);
Expand All @@ -137,21 +125,20 @@ public void generate(File bundleRoot, BundlerStatus status) throws DotBundleExce
continue;
}
try{
writeFileToDisk(bundleRoot,w, html, i.getURI(), h, true);
writeFileToDisk(bundleRoot,w, i.getURI(), h, true);
}catch (IOException e) {
Logger.error(this, e.getMessage() + " : Unable to write HTML to bundle", e);
}
html=null;
}
}
}catch (DotDataException e) {
Logger.error(this, e.getMessage() + " : Unable to get Pages for Start HTML Bundler",e);
}
}

private void writeFileToDisk(File bundleRoot, HTMLPageWrapper htmlPageWrapper, String html, String uri, Host h, boolean live) throws IOException, DotBundleException{
if(html == null || uri == null){
Logger.warn(this, "HTML or URI is not set for Bundler to write");
private void writeFileToDisk(File bundleRoot, HTMLPageWrapper htmlPageWrapper, String uri, Host h, boolean live) throws IOException, DotBundleException{
if(uri == null){
Logger.warn(this, "URI is not set for Bundler to write");
return;
}
try{
Expand Down Expand Up @@ -186,6 +173,12 @@ private void writeFileToDisk(File bundleRoot, HTMLPageWrapper htmlPageWrapper, S
if(!sf.exists())sf.createNewFile();
FileWriter fstream = new FileWriter(sf);
BufferedWriter out = new BufferedWriter(fstream);
String html = new String();
try{
html = pAPI.getHTML(htmlPageWrapper.getIdentifier().getURI(), h,live , null, uAPI.getSystemUser());
}catch(Exception e){
Logger.error(this, e.getMessage() + " Unable to get page", e);
}
out.write(html);
out.close();
sf.setLastModified(cal.getTimeInMillis());
Expand Down

0 comments on commit 1f7b0d9

Please sign in to comment.