Configurable download URL generation (#296)

Configurable download URL generation.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
Kai Zimmermann
2016-09-28 09:18:03 +02:00
committed by GitHub
parent 0cc1cfcc8c
commit 5c53bef164
77 changed files with 2114 additions and 1110 deletions

View File

@@ -29,7 +29,6 @@ import org.eclipse.hawkbit.repository.jpa.model.JpaExternalArtifactProvider;
import org.eclipse.hawkbit.repository.jpa.model.JpaLocalArtifact;
import org.eclipse.hawkbit.repository.jpa.model.JpaSoftwareModule;
import org.eclipse.hawkbit.repository.jpa.specifications.SoftwareModuleSpecification;
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;
@@ -194,7 +193,7 @@ public class JpaArtifactManagement implements ArtifactManagement {
}
@Override
public Artifact findArtifact(final Long id) {
public LocalArtifact findLocalArtifact(final Long id) {
return localArtifactRepository.findOne(id);
}

View File

@@ -158,6 +158,15 @@ public class JpaControllerManagement implements ControllerManagement {
return actionRepository.count(ActionSpecifications.hasTargetAssignedArtifact(target, localArtifact)) > 0;
}
@Override
public boolean hasTargetArtifactAssigned(final Long targetId, final LocalArtifact localArtifact) {
final Target target = targetRepository.findOne(targetId);
if (target == null) {
return false;
}
return actionRepository.count(ActionSpecifications.hasTargetAssignedArtifact(target, localArtifact)) > 0;
}
@Override
public List<Action> findActiveActionByTarget(final Target target) {
return actionRepository.findByTargetAndActiveOrderByIdAsc((JpaTarget) target, true);
@@ -456,12 +465,6 @@ public class JpaControllerManagement implements ControllerManagement {
return actionStatusRepository.save((JpaActionStatus) statusMessage);
}
@Override
public String getSecurityTokenByControllerId(final String controllerId) {
final Target target = targetRepository.findByControllerId(controllerId);
return target != null ? target.getSecurityToken() : null;
}
@Override
@Modifying
@Transactional(isolation = Isolation.READ_UNCOMMITTED)
@@ -475,4 +478,14 @@ public class JpaControllerManagement implements ControllerManagement {
cacheWriteNotify.downloadProgress(statusId, requestedBytes, shippedBytesSinceLast, shippedBytesOverall);
}
@Override
public Target findByControllerId(final String controllerId) {
return targetRepository.findByControllerId(controllerId);
}
@Override
public Target findByTargetId(final long targetId) {
return targetRepository.findOne(targetId);
}
}

View File

@@ -352,14 +352,13 @@ public class JpaDeploymentManagement implements DeploymentManagement {
private void assignDistributionSetEvent(final JpaTarget target, final Long actionId,
final List<JpaSoftwareModule> modules) {
((JpaTargetInfo) target.getTargetInfo()).setUpdateStatus(TargetUpdateStatus.PENDING);
final String targetSecurityToken = systemSecurityContext.runAsSystem(() -> target.getSecurityToken());
@SuppressWarnings({ "unchecked", "rawtypes" })
final Collection<SoftwareModule> softwareModules = (Collection) modules;
afterCommit.afterCommit(() -> {
eventBus.post(new TargetInfoUpdateEvent(target.getTargetInfo()));
eventBus.post(new TargetAssignDistributionSetEvent(target.getOptLockRevision(), target.getTenant(),
target.getControllerId(), actionId, softwareModules, target.getTargetInfo().getAddress(),
targetSecurityToken));
eventBus.post(new TargetAssignDistributionSetEvent(target.getOptLockRevision(), target.getTenant(), target,
actionId, softwareModules));
});
}

View File

@@ -299,4 +299,9 @@ public class JpaSystemManagement implements CurrentTenantCacheKeyGenerator, Syst
Constants.DST_DEFAULT_OS_WITH_APPS_NAME, "Default type with Firmware/OS and optional app(s).")
.addMandatoryModuleType(os).addOptionalModuleType(app));
}
@Override
public TenantMetaData getTenantMetadata(final Long tenantId) {
return tenantMetaDataRepository.findOne(tenantId);
}
}

View File

@@ -125,7 +125,7 @@ public class JpaTagManagement implements TagManagement {
final List<JpaTarget> changed = new LinkedList<>();
for (final JpaTarget target : targetRepository.findByTag(tag)) {
target.getTags().remove(tag);
target.removeTag(tag);
changed.add(target);
}

View File

@@ -75,24 +75,4 @@ public class JpaDistributionSetTag extends AbstractJpaTag implements Distributio
return Collections.unmodifiableList(assignedToDistributionSet);
}
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + this.getClass().getName().hashCode();
return result;
}
@Override
public boolean equals(final Object obj) { // NOSONAR - as this is generated
if (!super.equals(obj)) {
return false;
}
if (!(obj instanceof DistributionSetTag)) {
return false;
}
return true;
}
}

View File

@@ -162,7 +162,7 @@ public class JpaTarget extends AbstractJpaNamedEntity implements Persistable<Lon
return Collections.emptySet();
}
return tags;
return Collections.unmodifiableSet(tags);
}
public List<RolloutTargetGroup> getRolloutTargetGroup() {
@@ -210,7 +210,7 @@ public class JpaTarget extends AbstractJpaNamedEntity implements Persistable<Lon
public boolean addAction(final Action action) {
if (actions == null) {
actions = new ArrayList<>(4);
actions = new ArrayList<>();
}
return actions.add(action);

View File

@@ -73,24 +73,4 @@ public class JpaTargetTag extends AbstractJpaTag implements TargetTag {
return Collections.unmodifiableList(assignedToTargets);
}
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + this.getClass().getName().hashCode();
return result;
}
@Override
public boolean equals(final Object obj) {
if (!super.equals(obj)) {
return false;
}
if (!(obj instanceof TargetTag)) {
return false;
}
return true;
}
}