-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
125 additions
and
46 deletions.
There are no files selected for viewing
28 changes: 0 additions & 28 deletions
28
ph-diver-repo/src/main/java/com/helger/diver/repo/IRepoStorageWithToc.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
ph-diver-repo/src/main/java/com/helger/diver/repo/toc/IRepoStorageWithToc.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
package com.helger.diver.repo.toc; | ||
|
||
import javax.annotation.Nonnull; | ||
import javax.annotation.Nullable; | ||
|
||
import com.helger.commons.annotation.Nonempty; | ||
import com.helger.diver.api.version.VESID; | ||
import com.helger.diver.repo.IRepoStorage; | ||
import com.helger.diver.repo.RepoStorageItem; | ||
import com.helger.diver.repo.RepoStorageKey; | ||
import com.helger.diver.repo.toc.jaxb.v10.RepoTocType; | ||
|
||
/** | ||
* Extended {@link IRepoStorage} with support for table of contents. | ||
* | ||
* @author Philip Helger | ||
* @since 1.0.1 | ||
*/ | ||
public interface IRepoStorageWithToc extends IRepoStorage | ||
{ | ||
/** | ||
* Test if the table of contents for the provided Group ID and Artefact ID is | ||
* present or not. | ||
* | ||
* @param sGroupID | ||
* Group ID. May neither be <code>null</code> nor empty. | ||
* @param sArtifactID | ||
* Artifact ID. May neither be <code>null</code> nor empty. | ||
* @return <code>true</code> if it exists, <code>false</code> if not. | ||
*/ | ||
default boolean existsToc (@Nonnull @Nonempty final String sGroupID, @Nonnull @Nonempty final String sArtifactID) | ||
{ | ||
return exists (RepoStorageKey.ofToc (sGroupID, sArtifactID)); | ||
} | ||
|
||
/** | ||
* Read the ToC bytes for the provided Group ID and Artefact ID | ||
* | ||
* @param sGroupID | ||
* Group ID. May neither be <code>null</code> nor empty. | ||
* @param sArtifactID | ||
* Artifact ID. May neither be <code>null</code> nor empty. | ||
* @return <code>null</code> if either group or artifact do not exist, or if | ||
* no ToC is present. | ||
*/ | ||
@Nullable | ||
default RepoStorageItem readToc (@Nonnull @Nonempty final String sGroupID, | ||
@Nonnull @Nonempty final String sArtifactID) | ||
{ | ||
return read (RepoStorageKey.ofToc (sGroupID, sArtifactID)); | ||
} | ||
|
||
/** | ||
* Read the ToC for the provided Group ID and Artefact ID and return the | ||
* parsed data. | ||
* | ||
* @param aVESID | ||
* VESID to take Group ID and Artifact ID from. May not be | ||
* <code>null</code>. | ||
* @return <code>null</code> if either group or artifact do not exist, or if | ||
* no ToC is present. | ||
*/ | ||
@Nullable | ||
default RepoToc readTocModel (@Nonnull final VESID aVESID) | ||
{ | ||
return readTocModel (aVESID.getGroupID (), aVESID.getArtifactID ()); | ||
} | ||
|
||
/** | ||
* Read the ToC for the provided Group ID and Artefact ID and return the | ||
* parsed data. | ||
* | ||
* @param sGroupID | ||
* Group ID. May neither be <code>null</code> nor empty. | ||
* @param sArtifactID | ||
* Artifact ID. May neither be <code>null</code> nor empty. | ||
* @return <code>null</code> if either group or artifact do not exist, or if | ||
* no ToC is present. | ||
*/ | ||
@Nullable | ||
default RepoToc readTocModel (@Nonnull @Nonempty final String sGroupID, @Nonnull @Nonempty final String sArtifactID) | ||
{ | ||
// Read bytes | ||
final RepoStorageItem aItem = readToc (sGroupID, sArtifactID); | ||
if (aItem != null) | ||
{ | ||
// Parse to XML | ||
final RepoTocType aJaxbObject = new RepoToc1Marshaller ().read (aItem.data ().bytes ()); | ||
if (aJaxbObject != null) | ||
{ | ||
// Convert to domain model | ||
return RepoToc.createFromJaxbObject (aJaxbObject); | ||
} | ||
} | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters