");
- renderTabHeader(out, context, "staticTab", true);
- out.write("
");
-
- List brokenFiles = linkState.getStaticFilesWithBrokenLinks();
- if (brokenFiles == null || brokenFiles.size() == 0)
- {
- renderNoItems(out, context);
- }
- else
- {
- UIActions actions = aquireFileActions("broken_file_actions", getValue().getStore());
- AVMService avmService = Repository.getServiceRegistry(context).getAVMService();
- int rootPathIndex = AVMUtil.buildSandboxRootPath(linkState.getStore()).length();
- // render each broken file
- for (String file : brokenFiles)
- {
- renderBrokenFile(context, out, file, linkState, actions, avmService,
- rootPathIndex, linkState.getStore(), sectionsExpanded);
- }
- }
-
- out.write("
");
-
- // reset the oddRow flag
- this.oddRow = true;
-
- // render the list of broken forms, the files it generated and their contained links
- out.write("");
- renderTabHeader(out, context, "generatedTab", true);
- out.write("
");
-
- List brokenForms = linkState.getFormsWithBrokenLinks();
- if (brokenForms == null || brokenForms.size() == 0)
- {
- renderNoItems(out, context);
- }
- else
- {
- UIActions actions = aquireFileActions("broken_form_actions", getValue().getStore());
- AVMService avmService = Repository.getServiceRegistry(context).getAVMService();
-
- for (String form : brokenForms)
- {
- renderBrokenForm(context, out, form, linkState, actions,
- avmService, sectionsExpanded);
- }
- }
-
- out.write("
");
-
- // reset the oddRow flag
- this.oddRow = true;
-
- // render the list of fixed items
- out.write("");
- renderTabHeader(out, context, "fixedTab", false);
- out.write("
");
-
- int fixedItems = 0;
- List fixedFiles = linkState.getFixedFiles();
- List fixedForms = linkState.getFixedForms();
- if (fixedFiles != null)
- {
- fixedItems = fixedFiles.size();
- }
- if (fixedForms != null)
- {
- fixedItems += fixedForms.size();
- }
-
- if (fixedItems == 0)
- {
- renderNoItems(out, context);
- }
- else
- {
- for (String file : fixedFiles)
- {
- renderFixedItem(context, out, file, linkState);
- }
-
- for (String file : fixedForms)
- {
- renderFixedItem(context, out, file, linkState);
- }
- }
-
- out.write("
");
- }
- else
- {
- out.write("");
-
- // setup the context for the actions
- AVMNodeDescriptor desc = avmService.lookup(-1, file);
- AVMNode node = new AVMNode(desc);
-
- String assetPath = file.substring(rootPathIndex);
- String previewUrl = AVMUtil.getPreviewURI(storeId, assetPath);
- node.getProperties().put("previewUrl", previewUrl);
- actions.setContext(node);
-
- // render the actions
- Utils.encodeRecursive(context, actions);
-
- out.write("
");
-
- // render the file details
- String brokenLinks = getBrokenLinks(context, file, linkState);
- int numBrokenLinks = linkState.getBrokenLinksForFile(file).size();
- renderFileDetails(out, context, fileName, filePath, brokenLinks,
- numBrokenLinks, brokenLinksExpanded);
-
- out.write("
");
- }
-
- protected void renderBrokenForm(FacesContext context, ResponseWriter out,
- String file, LinkValidationState linkState, UIActions actions,
- AVMService avmService, boolean generatedFilesExpanded) throws IOException
- {
- // get the web form name and path
- String[] formNamePath = this.getFileNameAndPath(file);
- String formName = formNamePath[0];
- String formPath = formNamePath[1];
-
- // setup the context for the actions
- AVMNodeDescriptor desc = avmService.lookup(-1, file);
- AVMNode node = new AVMNode(desc);
- actions.setContext(node);
-
- // generate a unique id for this form
- String formId = this.getId() + "_" + desc.getId();
-
- // render the row with the appropriate background style
- out.write("");
-
- // render the actions
- Utils.encodeRecursive(context, actions);
-
- out.write("
");
-
- // render the generated files
- List
brokenFiles = linkState.getBrokenFilesByForm(file);
-
- out.write("");
- out.write(Utils.encode(formName));
- out.write("
");
- out.write(Utils.encode(formPath));
- out.write("
;
- out.write(context.getExternalContext().getRequestContextPath());
- if (generatedFilesExpanded)
- {
- out.write("/images/icons/arrow_open.gif)
");
- out.write(Application.getMessage(context, "generated_files"));
- out.write(" (");
- out.write(Integer.toString(brokenFiles.size()));
- out.write(")
");
- }
-
- protected void renderFixedItem(FacesContext context, ResponseWriter out,
- String file, LinkValidationState linkState) throws IOException
- {
- // gather the data to show for the file
- String[] nameAndPath = this.getFileNameAndPath(file);
- String fileName = nameAndPath[0];
- String filePath = nameAndPath[1];
-
- // render the row with the appropriate background style
- out.write("");
-
- // render the file details
- renderFileDetails(out, context, fileName, filePath, null, 0, false);
- out.write("
");
- }
-
- /**
- * Returns the name and path for the given avm path
- *
- * @param avmPath The path to split
- * @return A String array with the name in the first position and the path in the
- * second position.
- */
- protected String[] getFileNameAndPath(String avmPath)
- {
- String fileName = avmPath;
- String filePath = avmPath;
-
- int idx = avmPath.lastIndexOf("/");
- if (idx != -1)
- {
- fileName = avmPath.substring(idx+1);
-
- int appbaseIdx = avmPath.indexOf(JNDIConstants.DIR_DEFAULT_APPBASE);
- if (appbaseIdx != -1)
- {
- filePath = avmPath.substring(appbaseIdx+JNDIConstants.DIR_DEFAULT_APPBASE.length(), idx);
- }
- else
- {
- filePath = avmPath.substring(0, idx);
- }
- }
-
- return new String[] {fileName, filePath};
- }
-
- /**
- * Constructs a comma separated list of broken links for the given avm path
- *
- * @param avmPath The avm path to get the broken links for
- * @param linkState The current link valiation state
- * @return Comma separated list of broken links
- */
- protected String getBrokenLinks(FacesContext context, String avmPath, LinkValidationState linkState)
- {
- List