Guest User

Untitled

a guest
Jul 17th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.66 KB | None | 0 0
  1. Index: DefaultFSLocalRepositoryStorage.java
  2. ===================================================================
  3. --- DefaultFSLocalRepositoryStorage.java (revision 5568)
  4. +++ DefaultFSLocalRepositoryStorage.java (working copy)
  5. @@ -33,6 +33,7 @@
  6. import org.sonatype.nexus.proxy.NoSuchRepositoryException;
  7. import org.sonatype.nexus.proxy.ResourceStoreRequest;
  8. import org.sonatype.nexus.proxy.StorageException;
  9. +import org.sonatype.nexus.proxy.access.AccessManager;
  10. import org.sonatype.nexus.proxy.item.AbstractStorageItem;
  11. import org.sonatype.nexus.proxy.item.DefaultStorageCollectionItem;
  12. import org.sonatype.nexus.proxy.item.DefaultStorageFileItem;
  13. @@ -80,7 +81,7 @@
  14.  
  15. if ( !result )
  16. {
  17. - throw new StorageException( "Invalid storage url: " + url );
  18. + throw new StorageException( "Invalid storage URL, not a file based one: " + url );
  19. }
  20. }
  21.  
  22. @@ -113,14 +114,16 @@
  23. {
  24. if ( file.isFile() )
  25. {
  26. - throw new StorageException( "The baseDir property is not a directory: " + file.getAbsolutePath() );
  27. + throw new StorageException( "The \"" + repository.getName() + "\" (ID=\"" + repository.getId()
  28. + + "\") repository's baseDir is not a directory, path: " + file.getAbsolutePath() );
  29. }
  30. }
  31. else
  32. {
  33. if ( !file.mkdirs() )
  34. {
  35. - throw new StorageException( "Could not create the baseDir directory on path " + file.getAbsolutePath() );
  36. + throw new StorageException( "Could not create the baseDir directory for repository \""
  37. + + repository.getName() + "\" (ID=\"" + repository.getId() + "\") on path " + file.getAbsolutePath() );
  38. }
  39. }
  40.  
  41. @@ -166,7 +169,8 @@
  42. // to be foolproof, chrooting it
  43. if ( !result.getAbsolutePath().startsWith( getBaseDir( repository, request ).getAbsolutePath() ) )
  44. {
  45. - throw new StorageException( "FileFromBase evaluated directory wrongly! baseDir="
  46. + throw new StorageException( "getFileFromBase() method evaluated directory wrongly in repository \""
  47. + + repository.getName() + "\" (id=\"" + repository.getId() + "\")! baseDir="
  48. + getBaseDir( repository, request ).getAbsolutePath() + ", target=" + result.getAbsolutePath() );
  49. }
  50. else
  51. @@ -231,6 +235,8 @@
  52. link.setModified( target.lastModified() );
  53. link.setCreated( target.lastModified() );
  54. result = link;
  55. +
  56. + touchItemLastRequested( repository, request );
  57. }
  58. catch ( NoSuchRepositoryException e )
  59. {
  60. @@ -251,6 +257,8 @@
  61. file.setCreated( target.lastModified() );
  62. file.setLength( target.length() );
  63. result = file;
  64. +
  65. + touchItemLastRequested( repository, request );
  66. }
  67. }
  68. else
  69. @@ -281,7 +289,7 @@
  70. return retrieveItemFromFile( repository, request, getFileFromBase( repository, request ) );
  71. }
  72.  
  73. - private synchronized void mkParentDirs( File target )
  74. + private synchronized void mkParentDirs( Repository repository, File target )
  75. throws StorageException
  76. {
  77. if ( !target.getParentFile().exists() && !target.getParentFile().mkdirs() )
  78. @@ -289,7 +297,8 @@
  79. // recheck is it really a "good" parent?
  80. if ( !target.getParentFile().isDirectory() )
  81. {
  82. - throw new StorageException( "Could not create the directory hiearchy to write "
  83. + throw new StorageException( "Could not create the directory hiearchy in repository \""
  84. + + repository.getName() + "\" (id=\"" + repository.getId() + "\") to write "
  85. + target.getAbsolutePath() );
  86. }
  87. }
  88. @@ -316,7 +325,7 @@
  89.  
  90. try
  91. {
  92. - mkParentDirs( target );
  93. + mkParentDirs( repository, target );
  94.  
  95. InputStream is = null;
  96.  
  97. @@ -390,7 +399,7 @@
  98. {
  99. target = getFileFromBase( repository, request );
  100.  
  101. - mkParentDirs( target );
  102. + mkParentDirs( repository, target );
  103.  
  104. target.mkdir();
  105. target.setLastModified( item.getModified() );
  106. @@ -402,7 +411,7 @@
  107. {
  108. target = getFileFromBase( repository, request );
  109.  
  110. - mkParentDirs( target );
  111. + mkParentDirs( repository, target );
  112.  
  113. FileOutputStream os = new FileOutputStream( target );
  114.  
  115. @@ -446,14 +455,16 @@
  116. }
  117. catch ( IOException ex )
  118. {
  119. - throw new StorageException( "Could not delete directory from path " + target.getAbsolutePath(), ex );
  120. + throw new StorageException( "Could not delete File in repository \"" + repository.getName()
  121. + + "\" (id=\"" + repository.getId() + "\") from path " + target.getAbsolutePath(), ex );
  122. }
  123. }
  124. else if ( target.isFile() )
  125. {
  126. if ( !target.delete() )
  127. {
  128. - throw new StorageException( "Could not delete File from path " + target.getAbsolutePath() );
  129. + throw new StorageException( "Could not delete File in repository \"" + repository.getName()
  130. + + "\" (id=\"" + repository.getId() + "\") from path " + target.getAbsolutePath() );
  131. }
  132. }
  133. }
Add Comment
Please, Sign In to add comment