Maria Odea Ching wrote:
Brett Porter wrote:
Hi Deng,

On 15/10/2007, at 7:16 PM, [EMAIL PROTECTED] wrote:

[MRM-37 and MRM-527]
- added code for cleaning up the database of artifacts that are no longer existing in the repository (DatabaseCleanupRemoveArtifactConsumer and DatabaseCleanupRemoveProjectConsumer)
- created tests for database cleanup of removed artifacts
- updated some of the test cases (in archiva-database and archiva-scheduled modules) to reflect the changes in thedb cleanup consumers

Cool - looks good. A couple of quick questions :)

+ /**
+ * @plexus.requirement
+ */
+ private BidirectionalRepositoryLayoutFactory layoutFactory;
+
+ /**
+ * @plexus.requirement
+ */
+ private RepositoryContentFactory repositoryFactory;
+

I'm probably wrong, but I understood the content factory should be used instead of the layoutFactory - does it provide a way to do this instead, or did I misunderstand?


I think the content factory only provides the repository configuration while the layout factory provides a means of getting the layout (BidirectionalRepositoryLayout) of the repository where the artifact is located and converting the path from the given artifact. I needed the content factory to get the repository url and the layout factory for the artifact path so I could get the absolute path to the actual artifact and check if it still exists. :)

BidirectionalRepositoryLayout is going away.
They are broken.
They do not work.
They will not be fixed.
They encourage shortcuts (which is bad).
Shortcuts encourage bugs (which is also bad).
Bad code is ... uhm ... bad (which is also also bad).  ;-)

Use the repositoryFactory.getManagedRepository(repoId) to get a ManagedRepositoryContent object. Then use the .toFile() .toPath() .toArtifactReference() methods in there. They should have the same method signature that you are familiar with in the old BidirectionalRepositoryLayout classes.

I want to encourage operations against the repository to utilize those objects, we have plenty of find/get methods already, and we even a .deleteVersion(VersionedReference) method in there too. If you can think of more, let me know.

--
- Joakim Erdfelt
 [EMAIL PROTECTED]
 Open Source Software (OSS) Developer

Reply via email to