Merge pull request #322 from bsinno/fix_optimize_repository

Removed external artifact from repository.
This commit is contained in:
Kai Zimmermann
2016-10-27 15:29:58 +02:00
committed by GitHub
66 changed files with 601 additions and 1471 deletions

View File

@@ -23,9 +23,6 @@ import org.eclipse.hawkbit.repository.exception.GridFSDBFileNotFoundException;
import org.eclipse.hawkbit.repository.exception.InvalidMD5HashException;
import org.eclipse.hawkbit.repository.exception.InvalidSHA1HashException;
import org.eclipse.hawkbit.repository.model.Artifact;
import org.eclipse.hawkbit.repository.model.ExternalArtifact;
import org.eclipse.hawkbit.repository.model.ExternalArtifactProvider;
import org.eclipse.hawkbit.repository.model.LocalArtifact;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.hibernate.validator.constraints.NotEmpty;
import org.springframework.data.domain.Page;
@@ -38,59 +35,12 @@ import org.springframework.security.access.prepost.PreAuthorize;
*
*/
public interface ArtifactManagement {
/**
* Creates {@link ExternalArtifact} based on given provider.
*
* @param externalRepository
* the artifact is located in
* @param urlSuffix
* of the artifact
* {@link ExternalArtifactProvider#getDefaultSuffix()} is used if
* empty.
* @param moduleId
* to assign the artifact to
*
* @return created {@link ExternalArtifact}
*
* @throws EntityNotFoundException
* if {@link SoftwareModule} with given ID does not exist
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
ExternalArtifact createExternalArtifact(@NotNull ExternalArtifactProvider externalRepository, String urlSuffix,
@NotNull Long moduleId);
/**
* @return the total amount of local artifacts stored in the artifact
* management
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Long countLocalArtifactsAll();
/**
* @return the total amount of external artifacts stored in the artifact
* management
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Long countExternalArtifactsAll();
/**
* Persists {@link ExternalArtifactProvider} based on given properties.
*
* @param name
* of the provided
* @param description
* which is optional
* @param basePath
* of all {@link ExternalArtifact}s of the provider
* @param defaultUrlSuffix
* that is used if {@link ExternalArtifact#getUrlSuffix()} is
* empty.
* @return created {@link ExternalArtifactProvider}
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
ExternalArtifactProvider createExternalArtifactProvider(@NotEmpty String name, String description,
@NotNull String basePath, String defaultUrlSuffix);
Long countArtifactsAll();
/**
* Persists artifact binary as provided by given InputStream. assign the
@@ -106,12 +56,12 @@ public interface ArtifactManagement {
* to <code>true</code> if the artifact binary can be overridden
* if it already exists
*
* @return uploaded {@link LocalArtifact}
* @return uploaded {@link Artifact}
*
* @throw ArtifactUploadFailedException if upload fails
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
LocalArtifact createLocalArtifact(@NotNull InputStream inputStream, @NotNull Long moduleId, final String filename,
Artifact createArtifact(@NotNull InputStream inputStream, @NotNull Long moduleId, final String filename,
final boolean overrideExisting);
/**
@@ -130,13 +80,13 @@ public interface ArtifactManagement {
* @param contentType
* the contentType of the file
*
* @return uploaded {@link LocalArtifact}
* @return uploaded {@link Artifact}
*
* @throw ArtifactUploadFailedException if upload fails
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
LocalArtifact createLocalArtifact(@NotNull InputStream inputStream, @NotNull Long moduleId,
@NotNull String filename, final boolean overrideExisting, @NotNull String contentType);
Artifact createArtifact(@NotNull InputStream inputStream, @NotNull Long moduleId, @NotNull String filename,
final boolean overrideExisting, @NotNull String contentType);
/**
* Persists artifact binary as provided by given InputStream. assign the
@@ -157,7 +107,7 @@ public interface ArtifactManagement {
* if it already exists
* @param contentType
* the contentType of the file
* @return uploaded {@link LocalArtifact}
* @return uploaded {@link Artifact}
*
* @throws EntityNotFoundException
* if given software module does not exist
@@ -171,24 +121,12 @@ public interface ArtifactManagement {
* if check against provided SHA1 checksum failed
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
LocalArtifact createLocalArtifact(@NotNull InputStream stream, @NotNull Long moduleId, @NotEmpty String filename,
Artifact createArtifact(@NotNull InputStream stream, @NotNull Long moduleId, @NotEmpty String filename,
String providedMd5Sum, String providedSha1Sum, boolean overrideExisting, String contentType);
/**
* Deletes {@link Artifact} based on given id.
*
* @param id
* of the {@link Artifact} that has to be deleted.
* @throws ArtifactDeleteFailedException
* if deletion failed (MongoDB is not available)
*
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
void deleteExternalArtifact(@NotNull Long id);
/**
* Garbage collects local artifact binary file if only referenced by given
* {@link LocalArtifact} metadata object.
* {@link Artifact} metadata object.
*
* @param onlyByThisReferenced
* the related local artifact
@@ -196,7 +134,7 @@ public interface ArtifactManagement {
* @return <code>true</code> if an binary was actually garbage collected
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
boolean clearLocalArtifactBinary(@NotNull LocalArtifact onlyByThisReferenced);
boolean clearArtifactBinary(@NotNull Artifact onlyByThisReferenced);
/**
* Deletes {@link Artifact} based on given id.
@@ -208,19 +146,19 @@ public interface ArtifactManagement {
*
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
void deleteLocalArtifact(@NotNull Long id);
void deleteArtifact(@NotNull Long id);
/**
* Searches for {@link LocalArtifact} with given {@link Identifiable}.
* Searches for {@link Artifact} with given {@link Identifiable}.
*
* @param id
* to search for
* @return found {@link LocalArtifact} or <code>null</code> is it could not
* be found.
* @return found {@link Artifact} or <code>null</code> is it could not be
* found.
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY + SpringEvalExpressions.HAS_AUTH_OR
+ SpringEvalExpressions.IS_CONTROLLER)
LocalArtifact findLocalArtifact(@NotNull Long id);
Artifact findArtifact(@NotNull Long id);
/**
* Find by artifact by software module id and filename.
@@ -229,11 +167,11 @@ public interface ArtifactManagement {
* file name
* @param softwareModuleId
* software module id.
* @return LocalArtifact if artifact present
* @return Artifact if artifact present
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY + SpringEvalExpressions.HAS_AUTH_OR
+ SpringEvalExpressions.IS_CONTROLLER)
List<LocalArtifact> findByFilenameAndSoftwareModule(@NotNull String filename, @NotNull Long softwareModuleId);
List<Artifact> findByFilenameAndSoftwareModule(@NotNull String filename, @NotNull Long softwareModuleId);
/**
* Find all local artifact by sha1 and return the first artifact.
@@ -244,18 +182,18 @@ public interface ArtifactManagement {
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY + SpringEvalExpressions.HAS_AUTH_OR
+ SpringEvalExpressions.IS_CONTROLLER)
LocalArtifact findFirstLocalArtifactsBySHA1(@NotNull String sha1);
Artifact findFirstArtifactBySHA1(@NotNull String sha1);
/**
* Searches for {@link Artifact} with given file name.
*
* @param filename
* to search for
* @return found List of {@link LocalArtifact}s.
* @return found List of {@link Artifact}s.
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY + SpringEvalExpressions.HAS_AUTH_OR
+ SpringEvalExpressions.IS_CONTROLLER)
List<LocalArtifact> findLocalArtifactByFilename(@NotNull String filename);
List<Artifact> findArtifactByFilename(@NotNull String filename);
/**
* Get local artifact for a base software module.
@@ -264,38 +202,13 @@ public interface ArtifactManagement {
* Pageable
* @param swId
* software module id
* @return Page<LocalArtifact>
* @return Page<Artifact>
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Page<LocalArtifact> findLocalArtifactBySoftwareModule(@NotNull Pageable pageReq, @NotNull Long swId);
Page<Artifact> findArtifactBySoftwareModule(@NotNull Pageable pageReq, @NotNull Long swId);
/**
* Finds {@link SoftwareModule} by given id.
*
* @param id
* to search for
* @return the found {@link SoftwareModule}s or <code>null</code> if not
* found.
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY + SpringEvalExpressions.HAS_AUTH_OR
+ SpringEvalExpressions.IS_CONTROLLER)
SoftwareModule findSoftwareModuleById(@NotNull Long id);
/**
* Retrieves software module including details (
* {@link SoftwareModule#getArtifacts()}).
*
* @param id
* parameter
* @param isDeleted
* parameter
* @return the found {@link SoftwareModule}s
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
SoftwareModule findSoftwareModuleWithDetails(@NotNull Long id);
/**
* Loads {@link DbArtifact} from store for given {@link LocalArtifact}.
* Loads {@link DbArtifact} from store for given {@link Artifact}.
*
* @param artifact
* to search for
@@ -306,6 +219,6 @@ public interface ArtifactManagement {
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DOWNLOAD_ARTIFACT + SpringEvalExpressions.HAS_AUTH_OR
+ SpringEvalExpressions.HAS_CONTROLLER_DOWNLOAD)
DbArtifact loadLocalArtifactBinary(@NotNull LocalArtifact artifact);
DbArtifact loadArtifactBinary(@NotNull Artifact artifact);
}

View File

@@ -24,8 +24,8 @@ import org.eclipse.hawkbit.repository.exception.TooManyStatusEntriesException;
import org.eclipse.hawkbit.repository.model.Action;
import org.eclipse.hawkbit.repository.model.Action.Status;
import org.eclipse.hawkbit.repository.model.ActionStatus;
import org.eclipse.hawkbit.repository.model.Artifact;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.LocalArtifact;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetInfo;
@@ -200,7 +200,7 @@ public interface ControllerManagement {
* otherwise {@code false}
*/
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER)
boolean hasTargetArtifactAssigned(@NotNull String controllerId, @NotNull LocalArtifact localArtifact);
boolean hasTargetArtifactAssigned(@NotNull String controllerId, @NotNull Artifact localArtifact);
/**
* Checks if a given target has currently or has even been assigned to the
@@ -219,7 +219,7 @@ public interface ControllerManagement {
* otherwise {@code false}
*/
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER)
boolean hasTargetArtifactAssigned(@NotNull Long targetId, @NotNull LocalArtifact localArtifact);
boolean hasTargetArtifactAssigned(@NotNull Long targetId, @NotNull Artifact localArtifact);
/**
* Registers retrieved status for given {@link Target} and {@link Action} if

View File

@@ -16,12 +16,12 @@ import javax.validation.constraints.NotNull;
import org.eclipse.hawkbit.repository.model.Action;
import org.eclipse.hawkbit.repository.model.Action.Status;
import org.eclipse.hawkbit.repository.model.ActionStatus;
import org.eclipse.hawkbit.repository.model.Artifact;
import org.eclipse.hawkbit.repository.model.BaseEntity;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.DistributionSetMetadata;
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
import org.eclipse.hawkbit.repository.model.DistributionSetType;
import org.eclipse.hawkbit.repository.model.LocalArtifact;
import org.eclipse.hawkbit.repository.model.Rollout;
import org.eclipse.hawkbit.repository.model.RolloutGroup;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
@@ -376,10 +376,10 @@ public interface EntityFactory {
TargetTag generateTargetTag(@NotNull String name, String description, String colour);
/**
* Generates an empty {@link LocalArtifact} without persisting it.
* Generates an empty {@link Artifact} without persisting it.
*
* @return {@link LocalArtifact} object
* @return {@link Artifact} object
*/
LocalArtifact generateLocalArtifact();
Artifact generateArtifact();
}

View File

@@ -42,12 +42,12 @@ public interface SoftwareManagement {
*
* @param searchText
* to search for in name and version
* @param type
* to filter the result
* @param typeId
* to filter the result by type
* @return number of found {@link SoftwareModule}s
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Long countSoftwareModuleByFilters(String searchText, SoftwareModuleType type);
Long countSoftwareModuleByFilters(String searchText, Long typeId);
/**
* Count all {@link SoftwareModule}s in the repository that are not marked
@@ -58,16 +58,6 @@ public interface SoftwareManagement {
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Long countSoftwareModulesAll();
/**
* Counts {@link SoftwareModule}s with given {@link SoftwareModuleType}.
*
* @param type
* to count
* @return number of found {@link SoftwareModule}s
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Long countSoftwareModulesByType(@NotNull SoftwareModuleType type);
/**
* @return number of {@link SoftwareModuleType}s in the repository.
*/
@@ -128,7 +118,7 @@ public interface SoftwareManagement {
*
* @param types
* to create
* @return created {@link Entity}
* @return created Entity
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
List<SoftwareModuleType> createSoftwareModuleType(@NotNull Collection<SoftwareModuleType> types);
@@ -138,39 +128,39 @@ public interface SoftwareManagement {
*
* @param type
* to create
* @return created {@link Entity}
* @return created Entity
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
SoftwareModuleType createSoftwareModuleType(@NotNull SoftwareModuleType type);
/**
* Deletes the given {@link SoftwareModule} {@link Entity}.
* Deletes the given {@link SoftwareModule} Entity.
*
* @param bsm
* @param moduleId
* is the {@link SoftwareModule} to be deleted
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
void deleteSoftwareModule(@NotNull SoftwareModule bsm);
void deleteSoftwareModule(@NotNull Long moduleId);
/**
* deletes a software module meta data entry.
*
* @param softwareModule
* @param moduleId
* where meta data has to be deleted
* @param key
* of the metda data element
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
void deleteSoftwareModuleMetadata(@NotNull SoftwareModule softwareModule, @NotEmpty String key);
void deleteSoftwareModuleMetadata(@NotNull Long moduleId, @NotEmpty String key);
/**
* Deletes {@link SoftwareModule}s which is any if the given ids.
*
* @param ids
* @param moduleIds
* of the Software Modules to be deleted
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
void deleteSoftwareModules(@NotNull Collection<Long> ids);
void deleteSoftwareModules(@NotNull Collection<Long> moduleIds);
/**
* Deletes or marks as delete in case the type is in use.
@@ -192,20 +182,6 @@ public interface SoftwareManagement {
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Page<SoftwareModule> findSoftwareModuleByAssignedTo(@NotNull Pageable pageable, @NotNull DistributionSet set);
/**
* @param pageable
* the page request to page the result set
* @param set
* to search for
* @param type
* to filter
* @return all {@link SoftwareModule}s that are assigned to given
* {@link DistributionSet} filtered by {@link SoftwareModuleType}.
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Page<SoftwareModule> findSoftwareModuleByAssignedToAndType(@NotNull Pageable pageable, @NotNull DistributionSet set,
@NotNull SoftwareModuleType type);
/**
* Filter {@link SoftwareModule}s with given
* {@link SoftwareModule#getName()} or {@link SoftwareModule#getVersion()}
@@ -215,13 +191,12 @@ public interface SoftwareManagement {
* page parameter
* @param searchText
* to be filtered as "like" on {@link SoftwareModule#getName()}
* @param type
* @param typeId
* to be filtered as "like" on {@link SoftwareModule#getType()}
* @return the page of found {@link SoftwareModule}
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Slice<SoftwareModule> findSoftwareModuleByFilters(@NotNull Pageable pageable, String searchText,
SoftwareModuleType type);
Slice<SoftwareModule> findSoftwareModuleByFilters(@NotNull Pageable pageable, String searchText, Long typeId);
/**
* Finds {@link SoftwareModule} by given id.
@@ -253,7 +228,7 @@ public interface SoftwareManagement {
/**
* finds a single software module meta data by its id.
*
* @param softwareModule
* @param moduleId
* where meta data has to be found
* @param key
* of the meta data element
@@ -262,7 +237,7 @@ public interface SoftwareManagement {
* in case the meta data does not exists for the given key
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
SoftwareModuleMetadata findSoftwareModuleMetadata(@NotNull SoftwareModule softwareModule, @NotEmpty String key);
SoftwareModuleMetadata findSoftwareModuleMetadata(@NotNull Long moduleId, @NotEmpty String key);
/**
* finds all meta data by the given software module id.
@@ -281,7 +256,7 @@ public interface SoftwareManagement {
/**
* finds all meta data by the given software module id.
*
* @param softwareModuleId
* @param moduleId
* the software module id to retrieve the meta data from
* @param rsqlParam
* filter definition in RSQL syntax
@@ -297,7 +272,7 @@ public interface SoftwareManagement {
* if the RSQL syntax is wrong
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Page<SoftwareModuleMetadata> findSoftwareModuleMetadataBySoftwareModuleId(@NotNull Long softwareModuleId,
Page<SoftwareModuleMetadata> findSoftwareModuleMetadataBySoftwareModuleId(@NotNull Long moduleId,
@NotNull String rsqlParam, @NotNull Pageable pageable);
/**
@@ -316,14 +291,13 @@ public interface SoftwareManagement {
* the ID of distribution set to be ordered on top
* @param searchText
* filtered as "like" on {@link SoftwareModule#getName()}
* @param type
* @param typeId
* filtered as "equal" on {@link SoftwareModule#getType()}
* @return the page of found {@link SoftwareModule}
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Slice<AssignedSoftwareModule> findSoftwareModuleOrderBySetAssignmentAndModuleNameAscModuleVersionAsc(
@NotNull Pageable pageable, @NotNull Long orderByDistributionId, String searchText,
SoftwareModuleType type);
@NotNull Pageable pageable, @NotNull Long orderByDistributionId, String searchText, Long typeId);
/**
* Retrieves all software modules. Deleted ones are filtered.
@@ -370,12 +344,12 @@ public interface SoftwareManagement {
*
* @param pageable
* page parameters
* @param type
* @param typeId
* to be filtered on
* @return the found {@link SoftwareModule}s
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Slice<SoftwareModule> findSoftwareModulesByType(@NotNull Pageable pageable, @NotNull SoftwareModuleType type);
Slice<SoftwareModule> findSoftwareModulesByType(@NotNull Pageable pageable, @NotNull Long typeId);
/**
*
@@ -433,19 +407,6 @@ public interface SoftwareManagement {
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
Page<SoftwareModuleType> findSoftwareModuleTypesAll(@NotNull String rsqlParam, @NotNull Pageable pageable);
/**
* Retrieves software module including details (
* {@link SoftwareModule#getArtifacts()}).
*
* @param id
* parameter
* @param isDeleted
* parameter
* @return the found {@link SoftwareModule}s
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
SoftwareModule findSoftwareModuleWithDetails(@NotNull Long id);
/**
* Updates existing {@link SoftwareModule}. Update-able values are
* {@link SoftwareModule#getDescription()}
@@ -454,7 +415,7 @@ public interface SoftwareManagement {
* @param sm
* to update
*
* @return the saved {@link Entity}.
* @return the saved Entity.
*
* @throws NullPointerException
* of {@link SoftwareModule#getId()} is <code>null</code>
@@ -482,7 +443,7 @@ public interface SoftwareManagement {
*
* @param sm
* to update
* @return updated {@link Entity}
* @return updated Entity
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
SoftwareModuleType updateSoftwareModuleType(@NotNull SoftwareModuleType sm);
@@ -502,6 +463,6 @@ public interface SoftwareManagement {
* @return result of all meta data entries for a given software module id.
*/
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
List<SoftwareModuleMetadata> findSoftwareModuleMetadataBySoftwareModuleId(Long softwareModuleId);
List<SoftwareModuleMetadata> findSoftwareModuleMetadataBySoftwareModuleId(@NotNull Long moduleId);
}

View File

@@ -17,6 +17,10 @@ import com.google.common.io.BaseEncoding;
*
*/
public interface Artifact extends TenantAwareBaseEntity {
/**
* @return the filename that was provided during upload.
*/
String getFilename();
/**
* @return {@link SoftwareModule} this {@link Artifact} belongs to.

View File

@@ -1,41 +0,0 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.repository.model;
import java.net.URL;
/**
* External artifact representation with all the necessary information to
* generate an artifact {@link URL} at runtime.
*
*/
public interface ExternalArtifact extends Artifact {
/**
* @return {@link ExternalArtifactProvider} of this {@link Artifact}.
*/
ExternalArtifactProvider getExternalArtifactProvider();
/**
* @return generated download {@link URL}.
*/
String getUrl();
/**
* @return suffix for {@link URL} generation.
*/
String getUrlSuffix();
/**
* @param urlSuffix
* the urlSuffix to set
*/
void setUrlSuffix(String urlSuffix);
}

View File

@@ -1,28 +0,0 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.repository.model;
import org.eclipse.hawkbit.artifact.repository.ArtifactRepository;
/**
* Tenant specific locally stored artifact representation that is used by
* {@link SoftwareModule}s . It contains all information that is provided by the
* user while all update server generated information related to the artifact
* (hash, length) is stored directly with the binary itself in the
* {@link ArtifactRepository}.
*
*/
public interface LocalArtifact extends Artifact {
/**
* @return the filename that was provided during upload.
*/
String getFilename();
}

View File

@@ -16,43 +16,44 @@ import java.util.Optional;
*
*/
public interface SoftwareModule extends NamedVersionedEntity {
/**
* @param artifact
* is added to the assigned {@link Artifact}s.
*/
void addArtifact(LocalArtifact artifact);
/**
* @param artifact
* is added to the assigned {@link Artifact}s.
*/
void addArtifact(ExternalArtifact artifact);
void addArtifact(Artifact artifact);
/**
* @param artifactId
* to look for
* @return found {@link Artifact}
*/
Optional<LocalArtifact> getLocalArtifact(Long artifactId);
default Optional<Artifact> getArtifact(final Long artifactId) {
if (getArtifacts().isEmpty()) {
return Optional.empty();
}
return getArtifacts().stream().filter(artifact -> artifact.getId().equals(artifactId)).findFirst();
}
/**
* @param fileName
* to look for
* @return found {@link Artifact}
*/
Optional<LocalArtifact> getLocalArtifactByFilename(String fileName);
default Optional<Artifact> getArtifactByFilename(final String fileName) {
if (getArtifacts().isEmpty()) {
return Optional.empty();
}
return getArtifacts().stream().filter(artifact -> artifact.getFilename().equalsIgnoreCase(fileName.trim()))
.findFirst();
}
/**
* @return immutable list of all artifacts
*/
List<Artifact> getArtifacts();
/**
* @return immutable list of local artifacts only
*/
List<LocalArtifact> getLocalArtifacts();
/**
* @return the vendor of this software module
*/
@@ -64,18 +65,6 @@ public interface SoftwareModule extends NamedVersionedEntity {
*/
void setVendor(String vendor);
/**
* @param artifact
* is removed from the assigned {@link LocalArtifact}s.
*/
void removeArtifact(LocalArtifact artifact);
/**
* @param artifact
* is removed from the assigned {@link ExternalArtifact}s.
*/
void removeArtifact(ExternalArtifact artifact);
/**
* @return the type of the software module
*/
@@ -87,26 +76,12 @@ public interface SoftwareModule extends NamedVersionedEntity {
*/
boolean isDeleted();
/**
* Marks or un-marks this software module as deleted.
*
* @param deleted
* {@code true} if the software module should be marked as
* deleted otherwise {@code false}
*/
void setDeleted(boolean deleted);
/**
* @param type
* the module type for this software module
*/
void setType(SoftwareModuleType type);
/**
* @return immutable list of meta data elements.
*/
List<SoftwareModuleMetadata> getMetadata();
/**
* @return immutable list of {@link DistributionSet}s the module is assigned
* to