Changeset 7545

Show
Ignore:
Timestamp:
03/24/09 14:07:08 (16 months ago)
Author:
wtoconnor
Message:

For various reasons an article URI can be in the issue article list and not show up in the table of contents. When this happens the user cannot update the Issue because the number of URIs in the csv list in not consistant with the number of URIs in the actual list.

I have found that articles will not show up in the TOC for the following reasons.

1. The Article Type is not in the configuration file.

2. The user input a URI for an article that does not exist.

3. There may be others.

Addresses #1211

Location:
head/ambra/webapp/src/main
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • head/ambra/webapp/src/main/java/org/topazproject/ambra/admin/action/IssueManagementAction.java

    r7502 r7545  
    22 * $$Id$ 
    33 * 
    4  * Copyright (c) 2006-2007 by Topaz, Inc. 
     4 * Copyright (c) 2006-2009 by Topaz, Inc. 
    55 * http://topazproject.org 
    66 * 
     
    2525import org.topazproject.ambra.admin.service.AdminService; 
    2626import org.topazproject.ambra.admin.service.AdminService.JournalInfo; 
     27import org.topazproject.ambra.model.article.ArticleInfo; 
    2728import org.apache.commons.logging.Log; 
    2829import org.apache.commons.logging.LogFactory; 
     
    3233import java.util.List; 
    3334import java.util.ArrayList; 
     35import java.util.Iterator; 
    3436import java.net.URI; 
    3537import java.net.URISyntaxException; 
     
    5557  private Issue         issue; 
    5658  private String        articleOrderCSV; 
     59  private List<URI>     orphans; 
    5760  private List<TOCArticleGroup> articleGroups = new ArrayList<TOCArticleGroup>(); 
    5861 
     
    142145           */ 
    143146          if (validateCSV(issue, issueURIs)) 
    144             issue = adminService.updateIssue(issueURI,imageURI,displayName, 
    145                 issueURIs,respectOrder); 
     147            issue = adminService.updateIssue(issueURI,imageURI,displayName,issueURIs,respectOrder); 
    146148 
    147149        } catch (Exception e) { 
     
    160162    articleGroups = browseService.getArticleGrpList(issue); 
    161163    articleOrderCSV = browseService.articleGrpListToCSV(articleGroups); 
     164    orphans = getOrphannedArticles(issue, articleGroups); 
     165 
     166    /* 
     167     * Add the Orphans so that validateCSV doesn't prevent 
     168     * all updates. 
     169     */ 
     170    String orphanCSV = convertURIsToCSV(orphans); 
     171    articleOrderCSV = (orphanCSV.length() > 0) ? articleOrderCSV +","+ orphanCSV : articleOrderCSV; 
    162172    journalInfo = adminService.createJournalInfo(); 
    163173     
    164174    return SUCCESS; 
     175  } 
     176 
     177  /** 
     178   * 
     179   * @param uriList 
     180   * @return 
     181   */ 
     182  private String convertURIsToCSV(List<URI> uriList) { 
     183    StringBuilder csv = new StringBuilder(); 
     184 
     185    for(URI uri : uriList) { 
     186      if (csv.length() > 0) 
     187        csv.append(','); 
     188      csv.append(uri.toString()); 
     189    } 
     190 
     191    return csv.toString();  
     192  } 
     193   
     194  /** 
     195   * 
     196   * @param issue 
     197   * @param articleGroups 
     198   * @return 
     199   */ 
     200  private List<URI> getOrphannedArticles(Issue issue, List<TOCArticleGroup> articleGroups) { 
     201    List<URI> articleList = issue.getArticleList(); 
     202    List<URI> orphans = new ArrayList<URI>(); 
     203 
     204    for(URI articleURI : articleList) { 
     205      Boolean found = false; 
     206      for (TOCArticleGroup ag : articleGroups) { 
     207        List<ArticleInfo> infoList = ag.getArticles(); 
     208        for(ArticleInfo info : infoList ) { 
     209          if (info.getId().equals(articleURI)) { 
     210            found = true; 
     211            break; 
     212          } 
     213        } 
     214      } 
     215      if (!found) 
     216        orphans.add(articleURI); 
     217    } 
     218 
     219    return orphans; 
    165220  } 
    166221 
     
    191246    } 
    192247    return true; 
     248  } 
     249 
     250  /** 
     251   * 
     252   * @return 
     253   */ 
     254  public List<URI> getOrphans() { 
     255    return this.orphans;  
    193256  } 
    194257 
     
    254317      this.imageURI = null; 
    255318      if (log.isDebugEnabled()) 
    256         log.debug("setImage URI conversion failed. "); 
     319        log.debug("setImage URI conversion failed."  + 
     320            "imageURI set to null to indicate this: " + uri.trim(), e); 
    257321    } 
    258322  } 
     
    267331      this.volumeURI = null; 
    268332      if (log.isDebugEnabled()) 
    269         log.debug("setVolume URI conversion failed. "); 
     333        log.debug("setVolume URI conversion failed." + 
     334            "volumeURI set to null to indicate this: " + uri.trim(), e); 
    270335    } 
    271336  } 
  • head/ambra/webapp/src/main/webapp/admin/issueManagement.ftl

    r7496 r7545  
    145145         </tr> 
    146146         </#list> 
    147       </table> 
    148       </#list> 
     147       </table> 
     148       </#list> 
     149         <b>Ophanned Articles</b> 
     150         <table border="1" cellpadding="10" cellspacing="0"> 
     151           <tr> 
     152             <td colspan="2"> 
     153               <ul> 
     154               <li><kbd>Articles with types no longer in the configuration file.</kbd></li> 
     155               <li><kbd>Incorrect URIs not associated with an article.</kbd></li> 
     156               </ul> 
     157             </td> 
     158           </tr> 
     159           <tr> 
     160             <th>Delete</th> 
     161             <th>Article URI</th> 
     162           </tr> 
     163           <#list orphans as orphan> 
     164           <tr> 
     165             <td align="center"> 
     166                <@s.checkbox name="articlesToRemove" fieldValue="${orphan}"/> 
     167             </td> 
     168             <td> 
     169               ${orphan} 
     170             </td> 
     171            </tr> 
     172           </#list> 
     173         </table> 
    149174      <@s.submit value="Remove Selected Articles"/> 
    150175      </@s.form>