Removed external artifact from repository.
Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
@@ -19,7 +19,7 @@ import java.util.Map;
|
||||
import org.eclipse.hawkbit.repository.ArtifactManagement;
|
||||
import org.eclipse.hawkbit.repository.EntityFactory;
|
||||
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
|
||||
import org.eclipse.hawkbit.repository.model.LocalArtifact;
|
||||
import org.eclipse.hawkbit.repository.model.Artifact;
|
||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
||||
import org.eclipse.hawkbit.ui.utils.SpringContextHelper;
|
||||
import org.springframework.data.domain.Page;
|
||||
@@ -33,12 +33,12 @@ import org.vaadin.addons.lazyquerycontainer.QueryDefinition;
|
||||
* Simple implementation of generics bean query which dynamically loads artifact
|
||||
* beans.
|
||||
*/
|
||||
public class ArtifactBeanQuery extends AbstractBeanQuery<LocalArtifact> {
|
||||
public class ArtifactBeanQuery extends AbstractBeanQuery<Artifact> {
|
||||
private static final long serialVersionUID = -333786310371208962L;
|
||||
private Sort sort = new Sort(Direction.DESC, "filename");
|
||||
private transient ArtifactManagement artifactManagement = null;
|
||||
private transient EntityFactory entityFactory;
|
||||
private transient Page<LocalArtifact> firstPagetArtifacts = null;
|
||||
private transient Page<Artifact> firstPagetArtifacts = null;
|
||||
private Long baseSwModuleId = null;
|
||||
|
||||
/**
|
||||
@@ -72,26 +72,26 @@ public class ArtifactBeanQuery extends AbstractBeanQuery<LocalArtifact> {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected LocalArtifact constructBean() {
|
||||
return getEntityFactory().generateLocalArtifact();
|
||||
protected Artifact constructBean() {
|
||||
return getEntityFactory().generateArtifact();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<LocalArtifact> loadBeans(final int startIndex, final int count) {
|
||||
Page<LocalArtifact> artifactBeans;
|
||||
protected List<Artifact> loadBeans(final int startIndex, final int count) {
|
||||
Page<Artifact> artifactBeans;
|
||||
if (startIndex == 0 && firstPagetArtifacts != null) {
|
||||
artifactBeans = firstPagetArtifacts;
|
||||
} else {
|
||||
artifactBeans = getArtifactManagement().findLocalArtifactBySoftwareModule(
|
||||
new OffsetBasedPageRequest(startIndex, count, sort), baseSwModuleId);
|
||||
artifactBeans = getArtifactManagement()
|
||||
.findArtifactBySoftwareModule(new OffsetBasedPageRequest(startIndex, count, sort), baseSwModuleId);
|
||||
}
|
||||
|
||||
return artifactBeans.getContent();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void saveBeans(final List<LocalArtifact> addedTargets, final List<LocalArtifact> modifiedTargets,
|
||||
final List<LocalArtifact> removedTargets) {
|
||||
protected void saveBeans(final List<Artifact> addedTargets, final List<Artifact> modifiedTargets,
|
||||
final List<Artifact> removedTargets) {
|
||||
// CRUD operations on Target will be done through repository methods
|
||||
}
|
||||
|
||||
@@ -99,8 +99,8 @@ public class ArtifactBeanQuery extends AbstractBeanQuery<LocalArtifact> {
|
||||
public int size() {
|
||||
long size = 0;
|
||||
if (baseSwModuleId != null) {
|
||||
firstPagetArtifacts = getArtifactManagement().findLocalArtifactBySoftwareModule(
|
||||
new PageRequest(0, SPUIDefinitions.PAGE_SIZE, sort), baseSwModuleId);
|
||||
firstPagetArtifacts = getArtifactManagement()
|
||||
.findArtifactBySoftwareModule(new PageRequest(0, SPUIDefinitions.PAGE_SIZE, sort), baseSwModuleId);
|
||||
size = firstPagetArtifacts.getTotalElements();
|
||||
}
|
||||
if (size > Integer.MAX_VALUE) {
|
||||
|
||||
@@ -278,7 +278,7 @@ public class ArtifactDetailsLayout extends VerticalLayout {
|
||||
if (ok) {
|
||||
final ArtifactManagement artifactManagement = SpringContextHelper
|
||||
.getBean(ArtifactManagement.class);
|
||||
artifactManagement.deleteLocalArtifact(id);
|
||||
artifactManagement.deleteArtifact(id);
|
||||
uINotification.displaySuccess(i18n.get("message.artifact.deleted", fileName));
|
||||
if (artifactUploadState.getSelectedBaseSwModuleId().isPresent()) {
|
||||
populateArtifactDetails(artifactUploadState.getSelectedBaseSwModuleId().get(),
|
||||
|
||||
@@ -80,8 +80,8 @@ public class BaseSwModuleBeanQuery extends AbstractBeanQuery<ProxyBaseSoftwareMo
|
||||
.findSoftwareModulesAll(new OffsetBasedPageRequest(startIndex, count, sort));
|
||||
|
||||
} else {
|
||||
swModuleBeans = getSoftwareManagementService()
|
||||
.findSoftwareModuleByFilters(new OffsetBasedPageRequest(startIndex, count, sort), searchText, type);
|
||||
swModuleBeans = getSoftwareManagementService().findSoftwareModuleByFilters(
|
||||
new OffsetBasedPageRequest(startIndex, count, sort), searchText, type.getId());
|
||||
}
|
||||
|
||||
for (final SoftwareModule swModule : swModuleBeans) {
|
||||
@@ -113,7 +113,7 @@ public class BaseSwModuleBeanQuery extends AbstractBeanQuery<ProxyBaseSoftwareMo
|
||||
if (type == null && Strings.isNullOrEmpty(searchText)) {
|
||||
size = getSoftwareManagementService().countSoftwareModulesAll();
|
||||
} else {
|
||||
size = getSoftwareManagementService().countSoftwareModuleByFilters(searchText, type);
|
||||
size = getSoftwareManagementService().countSoftwareModuleByFilters(searchText, type.getId());
|
||||
}
|
||||
|
||||
if (size > Integer.MAX_VALUE) {
|
||||
|
||||
@@ -22,7 +22,7 @@ import org.eclipse.hawkbit.repository.ArtifactManagement;
|
||||
import org.eclipse.hawkbit.repository.exception.ArtifactUploadFailedException;
|
||||
import org.eclipse.hawkbit.repository.exception.InvalidMD5HashException;
|
||||
import org.eclipse.hawkbit.repository.exception.InvalidSHA1HashException;
|
||||
import org.eclipse.hawkbit.repository.model.LocalArtifact;
|
||||
import org.eclipse.hawkbit.repository.model.Artifact;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
|
||||
import org.eclipse.hawkbit.ui.artifacts.state.CustomFile;
|
||||
@@ -191,8 +191,7 @@ public class UploadConfirmationWindow implements Button.ClickListener {
|
||||
final ArtifactManagement artifactManagement = SpringContextHelper.getBean(ArtifactManagement.class);
|
||||
if (HawkbitCommonUtil.trimAndNullIfEmpty(fileName) != null) {
|
||||
final Long baseSwId = (Long) item.getItemProperty(BASE_SOFTWARE_ID).getValue();
|
||||
final List<LocalArtifact> artifactList = artifactManagement.findByFilenameAndSoftwareModule(fileName,
|
||||
baseSwId);
|
||||
final List<Artifact> artifactList = artifactManagement.findByFilenameAndSoftwareModule(fileName, baseSwId);
|
||||
if (!artifactList.isEmpty()) {
|
||||
warningIconLabel.setVisible(true);
|
||||
if (isErrorIcon(warningIconLabel)) {
|
||||
@@ -434,7 +433,7 @@ public class UploadConfirmationWindow implements Button.ClickListener {
|
||||
final Label errorLabel, final String oldFileName, final Long currentSwId) {
|
||||
if (warningLabel == null && (errorLabelCount > 1 || (duplicateCount == 1 && errorLabelCount == 1))) {
|
||||
final ArtifactManagement artifactManagement = SpringContextHelper.getBean(ArtifactManagement.class);
|
||||
final List<LocalArtifact> artifactList = artifactManagement.findByFilenameAndSoftwareModule(oldFileName,
|
||||
final List<Artifact> artifactList = artifactManagement.findByFilenameAndSoftwareModule(oldFileName,
|
||||
currentSwId);
|
||||
errorLabel.removeStyleName(SPUIStyleDefinitions.ERROR_LABEL);
|
||||
errorLabel.setDescription(i18n.get(ALREADY_EXISTS_MSG));
|
||||
@@ -591,7 +590,7 @@ public class UploadConfirmationWindow implements Button.ClickListener {
|
||||
customFile.getBaseSoftwareModuleName(), customFile.getBaseSoftwareModuleVersion());
|
||||
if (customFile.getFileName().equals(fileName)
|
||||
&& baseSwModuleNameVersion.equals(baseSoftwareModuleNameVersion)) {
|
||||
createLocalArtifact(itemId, customFile.getFilePath(), artifactManagement, bSoftwareModule);
|
||||
createArtifact(itemId, customFile.getFilePath(), artifactManagement, bSoftwareModule);
|
||||
}
|
||||
}
|
||||
refreshArtifactDetailsLayout = checkIfArtifactDetailsDispalyed(bSoftwareModule.getId());
|
||||
@@ -619,8 +618,8 @@ public class UploadConfirmationWindow implements Button.ClickListener {
|
||||
currentUploadResultWindow = null;
|
||||
}
|
||||
|
||||
private void createLocalArtifact(final String itemId, final String filePath,
|
||||
final ArtifactManagement artifactManagement, final SoftwareModule baseSw) {
|
||||
private void createArtifact(final String itemId, final String filePath, final ArtifactManagement artifactManagement,
|
||||
final SoftwareModule baseSw) {
|
||||
|
||||
final File newFile = new File(filePath);
|
||||
final Item item = tabelContainer.getItem(itemId);
|
||||
@@ -633,7 +632,7 @@ public class UploadConfirmationWindow implements Button.ClickListener {
|
||||
|
||||
try (FileInputStream fis = new FileInputStream(newFile)) {
|
||||
|
||||
artifactManagement.createLocalArtifact(fis, baseSw.getId(), providedFileName,
|
||||
artifactManagement.createArtifact(fis, baseSw.getId(), providedFileName,
|
||||
HawkbitCommonUtil.trimAndNullIfEmpty(md5Checksum),
|
||||
HawkbitCommonUtil.trimAndNullIfEmpty(sha1Checksum), true, customFile.getMimeType());
|
||||
saveUploadStatus(providedFileName, swModuleNameVersion, SUCCESS, "");
|
||||
|
||||
@@ -43,7 +43,7 @@ public class SwMetadataPopupLayout extends AbstractMetadataPopupLayout<SoftwareM
|
||||
|
||||
@Override
|
||||
protected void checkForDuplicate(final SoftwareModule entity, final String value) {
|
||||
softwareManagement.findSoftwareModuleMetadata(entity, value);
|
||||
softwareManagement.findSoftwareModuleMetadata(entity.getId(), value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,7 +80,7 @@ public class SwMetadataPopupLayout extends AbstractMetadataPopupLayout<SoftwareM
|
||||
@Override
|
||||
protected void deleteMetadata(final SoftwareModule entity, final String key, final String value) {
|
||||
final SoftwareModuleMetadata swMetadata = entityFactory.generateSoftwareModuleMetadata(entity, key, value);
|
||||
softwareManagement.deleteSoftwareModuleMetadata(entity, key);
|
||||
softwareManagement.deleteSoftwareModuleMetadata(entity.getId(), key);
|
||||
eventBus.publish(this, new MetadataEvent(MetadataUIEvent.DELETE_SOFTWARE_MODULE_METADATA, swMetadata));
|
||||
}
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ public class SwModuleBeanQuery extends AbstractBeanQuery<ProxyBaseSwModuleItem>
|
||||
final List<ProxyBaseSwModuleItem> proxyBeans = new ArrayList<>();
|
||||
|
||||
swModuleBeans = getSoftwareManagement().findSoftwareModuleOrderBySetAssignmentAndModuleNameAscModuleVersionAsc(
|
||||
new OffsetBasedPageRequest(startIndex, count), orderByDistId, searchText, type);
|
||||
new OffsetBasedPageRequest(startIndex, count), orderByDistId, searchText, type.getId());
|
||||
|
||||
for (final AssignedSoftwareModule swModule : swModuleBeans) {
|
||||
proxyBeans.add(getProxyBean(swModule));
|
||||
@@ -114,7 +114,7 @@ public class SwModuleBeanQuery extends AbstractBeanQuery<ProxyBaseSwModuleItem>
|
||||
if (type == null && Strings.isNullOrEmpty(searchText)) {
|
||||
size = getSoftwareManagement().countSoftwareModulesAll();
|
||||
} else {
|
||||
size = getSoftwareManagement().countSoftwareModuleByFilters(searchText, type);
|
||||
size = getSoftwareManagement().countSoftwareModuleByFilters(searchText, type.getId());
|
||||
}
|
||||
|
||||
if (size > Integer.MAX_VALUE) {
|
||||
|
||||
Reference in New Issue
Block a user