/** * Adds a new file to this container that will contain the specified * annotation. If the file already exists, then the annotation is only added * to this class. * * @param annotation the new annotation */ private void addFile(final FileAnnotation annotation) { String fileName = annotation.getFileName(); if (!filesByName.containsKey(fileName)) { WorkspaceFile file = new WorkspaceFile(fileName); filesByName.put(fileName, file); filesByHashCode.put(file.getName().hashCode(), file); } filesByName.get(fileName).addAnnotation(annotation); }
/** {@inheritDoc} */ public String getDisplayName() { return file.getShortName(); }
/** * Creates a new instance of <code>ModuleDetail</code>. * * @param owner * current build as owner of this action. * @param detailFactory * factory to create detail objects with * @param file * the file to show the details for * @param defaultEncoding * the default encoding to be used when reading and parsing files * @param header * header to be shown on detail page */ public FileDetail(final Run<?, ?> owner, final DetailFactory detailFactory, final WorkspaceFile file, final String defaultEncoding, final String header) { super(owner, detailFactory, file.getAnnotations(), defaultEncoding, header, Hierarchy.FILE); this.file = file; }
assertEquals(WRONG_FILE_NAME, PATH_TO_FILE1, file.getName()); assertEquals(WRONG_FILE_SHORT_NAME, FILE1, file.getShortName()); assertEquals(WRONG_NUMBER_OF_MODULES, 0, file.getModules().size()); assertEquals(WRONG_NUMBER_OF_PACKAGES, 0, file.getPackages().size()); assertEquals(WRONG_NUMBER_OF_FILES, 0, file.getFiles().size());
assertEquals(WRONG_FILE_NAME, PATH_TO_FILE1, file.getName()); assertEquals(WRONG_FILE_SHORT_NAME, FILE1, file.getShortName()); assertTrue(WRONG_NUMBER_OF_ANNOTATIONS, file.hasAnnotations()); assertEquals(WRONG_NUMBER_OF_ANNOTATIONS, 1, file.getNumberOfAnnotations()); assertFalse(WRONG_NUMBER_OF_ANNOTATIONS, file.hasAnnotations(HIGH)); assertFalse(WRONG_NUMBER_OF_ANNOTATIONS, file.hasAnnotations(Priority.HIGH)); assertEquals(WRONG_NUMBER_OF_ANNOTATIONS, 0, file.getNumberOfAnnotations(Priority.HIGH)); assertTrue(WRONG_NUMBER_OF_ANNOTATIONS, file.hasAnnotations(NORMAL)); assertTrue(WRONG_NUMBER_OF_ANNOTATIONS, file.hasAnnotations(Priority.NORMAL)); assertEquals(WRONG_NUMBER_OF_ANNOTATIONS, 1, file.getNumberOfAnnotations(Priority.NORMAL)); assertFalse(WRONG_NUMBER_OF_ANNOTATIONS, file.hasAnnotations(LOW)); assertFalse(WRONG_NUMBER_OF_ANNOTATIONS, file.hasAnnotations(Priority.LOW)); assertEquals(WRONG_NUMBER_OF_ANNOTATIONS, 0, file.getNumberOfAnnotations(Priority.LOW)); assertEquals(WRONG_TOOLTIP_CREATED, "Normal:1", file.getToolTip());
File masterFile = new File(directory, file.getTempName()); if (!masterFile.exists()) { try { FileOutputStream outputStream = new FileOutputStream(masterFile); new FilePath(channel, file.getName()).copyTo(outputStream); logExceptionToFile(exception, masterFile, file.getName());
assertEquals(WRONG_FILE_NAME, PATH_TO_FILE1, file.getName()); assertEquals(WRONG_FILE_SHORT_NAME, FILE1, file.getShortName()); assertEquals(WRONG_NUMBER_OF_MODULES, 0, file.getModules().size()); assertEquals(WRONG_NUMBER_OF_PACKAGES, 0, file.getPackages().size()); assertEquals(WRONG_NUMBER_OF_FILES, 0, file.getFiles().size());
assertEquals(WRONG_FILE_NAME, PATH_TO_FILE1, file.getName()); assertEquals(WRONG_FILE_SHORT_NAME, FILE1, file.getShortName()); assertTrue(WRONG_NUMBER_OF_ANNOTATIONS, file.hasAnnotations()); assertEquals(WRONG_NUMBER_OF_ANNOTATIONS, 1, file.getNumberOfAnnotations()); assertFalse(WRONG_NUMBER_OF_ANNOTATIONS, file.hasAnnotations(HIGH)); assertFalse(WRONG_NUMBER_OF_ANNOTATIONS, file.hasAnnotations(Priority.HIGH)); assertEquals(WRONG_NUMBER_OF_ANNOTATIONS, 0, file.getNumberOfAnnotations(Priority.HIGH)); assertTrue(WRONG_NUMBER_OF_ANNOTATIONS, file.hasAnnotations(NORMAL)); assertTrue(WRONG_NUMBER_OF_ANNOTATIONS, file.hasAnnotations(Priority.NORMAL)); assertEquals(WRONG_NUMBER_OF_ANNOTATIONS, 1, file.getNumberOfAnnotations(Priority.NORMAL)); assertFalse(WRONG_NUMBER_OF_ANNOTATIONS, file.hasAnnotations(LOW)); assertFalse(WRONG_NUMBER_OF_ANNOTATIONS, file.hasAnnotations(Priority.LOW)); assertEquals(WRONG_NUMBER_OF_ANNOTATIONS, 0, file.getNumberOfAnnotations(Priority.LOW)); assertEquals(WRONG_TOOLTIP_CREATED, "Normal:1", file.getToolTip());
FilePath masterFile = directory.child(file.getTempName()); if (!masterFile.exists()) { try { new FilePath(channel, file.getName()).copyTo(masterFile); logExceptionToFile(exception, masterFile, file.getName(), defaultEncoding);
FilePath masterFile = new FilePath(directory, file.getTempName()); if (!masterFile.exists()) { try { new FilePath((Channel)null, file.getName()).copyTo(masterFile); String message = "Can't copy source file: source=" + file.getName() + ", destination=" + masterFile.getName(); logger.log(message); logger.printStackTrace(exception);
/** * Adds a new file to this container that will contain the specified * annotation. If the file already exists, then the annotation is only added * to this class. * * @param annotation the new annotation */ private void addFile(final FileAnnotation annotation) { String fileName = annotation.getFileName(); if (!filesByName.containsKey(fileName)) { WorkspaceFile file = new WorkspaceFile(fileName); filesByName.put(fileName, file); filesByHashCode.put(file.getName().hashCode(), file); } filesByName.get(fileName).addAnnotation(annotation); }
@Override public String getDisplayName() { return file.getShortName(); }
/** * Returns a file name for a temporary file that will hold the contents of the source. * * @return the temporary name */ public String getTempName() { return Integer.toHexString(getName().hashCode()) + ".tmp"; }
/** * Creates a new instance of <code>ModuleDetail</code>. * * @param owner * current build as owner of this action. * @param detailFactory * factory to create detail objects with * @param file * the file to show the details for * @param defaultEncoding * the default encoding to be used when reading and parsing files * @param header * header to be shown on detail page */ public FileDetail(final AbstractBuild<?, ?> owner, final DetailFactory detailFactory, final WorkspaceFile file, final String defaultEncoding, final String header) { super(owner, detailFactory, file.getAnnotations(), defaultEncoding, header, Hierarchy.FILE); this.file = file; }
FilePath masterFile = new FilePath(directory, file.getTempName()); if (!masterFile.exists()) { try { new FilePath((Channel)null, file.getName()).copyTo(masterFile); String message = "Can't copy source file: source=" + file.getName() + ", destination=" + masterFile.getName(); logger.log(message); logger.printStackTrace(exception);
@Override public int compareTo(final AnnotationContainer other) { if (other instanceof WorkspaceFile) { return getShortName().compareTo(((WorkspaceFile)other).getShortName()); } return super.compareTo(other); } }
/** * Returns a file name for a temporary file that will hold the contents of the source. * * @return the temporary name */ public String getTempName() { return Integer.toHexString(getName().hashCode()) + ".tmp"; }
FilePath masterFile = new FilePath(directory, file.getTempName()); if (!masterFile.exists()) { try { new FilePath((Channel)null, file.getName()).copyTo(masterFile); String message = "Can't copy source file: source=" + file.getName() + ", destination=" + masterFile.getName(); logger.log(message); logger.printStackTrace(exception);