Split into separate maven modules.
Signed-off-by: Kai Zimmermann <kai.zimmermann@bosch-si.com>
This commit is contained in:
40
hawkbit-repository/hawkbit-repository-api/pom.xml
Normal file
40
hawkbit-repository/hawkbit-repository-api/pom.xml
Normal file
@@ -0,0 +1,40 @@
|
||||
<!--
|
||||
|
||||
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
|
||||
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<artifactId>hawkbit-repository</artifactId>
|
||||
<version>0.2.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>hawkbit-repository-api</artifactId>
|
||||
<name>hawkBit :: Repository API</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.hawkbit</groupId>
|
||||
<artifactId>hawkbit-security-core</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.validation</groupId>
|
||||
<artifactId>validation-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-validator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.hateoas</groupId>
|
||||
<artifactId>spring-hateoas</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,55 @@
|
||||
/**
|
||||
* 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.eventbus.event;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
|
||||
|
||||
/**
|
||||
* An abstract definition class for {@link EntityEvent} for
|
||||
* {@link TenantAwareBaseEntity}s, which holds the {@link TenantAwareBaseEntity}
|
||||
* .
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param <E>
|
||||
* the type of the {@link TenantAwareBaseEntity}
|
||||
*/
|
||||
public abstract class AbstractBaseEntityEvent<E extends TenantAwareBaseEntity> extends AbstractDistributedEvent
|
||||
implements EntityEvent {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final E entity;
|
||||
|
||||
/**
|
||||
* @param baseEntity
|
||||
* the entity which has been created or modified
|
||||
*/
|
||||
public AbstractBaseEntityEvent(final E baseEntity) {
|
||||
super(baseEntity.getOptLockRevision(), baseEntity.getTenant());
|
||||
this.entity = baseEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public E getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getEntity(final Class<T> entityClass) {
|
||||
return entityClass.cast(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTenant() {
|
||||
return entity.getTenant();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
/**
|
||||
* 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.eventbus.event;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
|
||||
|
||||
/**
|
||||
*
|
||||
* A abstract typesafe bulkevent which contains all changed base entities.
|
||||
*
|
||||
* @param <E>
|
||||
*/
|
||||
public abstract class AbstractEntityBulkEvent<E extends TenantAwareBaseEntity> implements EntityBulkEvent<E> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private List<E> entities;
|
||||
|
||||
private String tenant;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param tenant
|
||||
* the tenant
|
||||
* @param entities
|
||||
* the changed entities
|
||||
*/
|
||||
public AbstractEntityBulkEvent(final String tenant, final List<E> entities) {
|
||||
this.entities = entities;
|
||||
this.tenant = tenant;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param tenant
|
||||
* the tenant
|
||||
* @param entitiy
|
||||
* the changed entity
|
||||
*/
|
||||
public AbstractEntityBulkEvent(final String tenant, final E entitiy) {
|
||||
this(tenant, Arrays.asList(entitiy));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<E> getEntities() {
|
||||
return entities;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getRevision() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTenant() {
|
||||
return tenant;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
/**
|
||||
* 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.eventbus.event;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
|
||||
|
||||
/**
|
||||
* Property change event.
|
||||
*
|
||||
* @param <E>
|
||||
*/
|
||||
public class AbstractPropertyChangeEvent<E extends TenantAwareBaseEntity> extends AbstractBaseEntityEvent<E> {
|
||||
|
||||
private static final long serialVersionUID = -3671601415138242311L;
|
||||
private final transient Map<String, Values> changeSet;
|
||||
|
||||
/**
|
||||
* Initialize base entity and property changed with old and new value.
|
||||
*
|
||||
* @param baseEntity
|
||||
* entity changed
|
||||
* @param changeSetValues
|
||||
* details of properties changed and old value and new value of
|
||||
* the changed properties
|
||||
*/
|
||||
public AbstractPropertyChangeEvent(final E baseEntity, final Map<String, Values> changeSetValues) {
|
||||
super(baseEntity);
|
||||
this.changeSet = changeSetValues;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the changeSet
|
||||
*/
|
||||
public Map<String, Values> getChangeSet() {
|
||||
return changeSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Carries old value and new value of a property .
|
||||
*
|
||||
*/
|
||||
public class Values {
|
||||
private final Object oldValue;
|
||||
private final Object newValue;
|
||||
|
||||
/**
|
||||
* Initialize old value and new changes value of property.
|
||||
*
|
||||
* @param oldValue
|
||||
* old value before change
|
||||
* @param newValue
|
||||
* new value after change
|
||||
*/
|
||||
public Values(final Object oldValue, final Object newValue) {
|
||||
super();
|
||||
this.oldValue = oldValue;
|
||||
this.newValue = newValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the oldValue
|
||||
*/
|
||||
public Object getOldValue() {
|
||||
return oldValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the newValue
|
||||
*/
|
||||
public Object getNewValue() {
|
||||
return newValue;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* 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.eventbus.event;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.Action;
|
||||
|
||||
/**
|
||||
* Defines the {@link AbstractBaseEntityEvent} of creating a new {@link Action}.
|
||||
*/
|
||||
public class ActionCreatedEvent extends AbstractBaseEntityEvent<Action> {
|
||||
private static final long serialVersionUID = 181780358321768629L;
|
||||
|
||||
/**
|
||||
* @param action
|
||||
*/
|
||||
public ActionCreatedEvent(final Action action) {
|
||||
super(action);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* 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.eventbus.event;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.Action;
|
||||
|
||||
/**
|
||||
* Defines the {@link AbstractPropertyChangeEvent} of {@link Action}.
|
||||
*/
|
||||
public class ActionPropertyChangeEvent extends AbstractPropertyChangeEvent<Action> {
|
||||
private static final long serialVersionUID = 181780358321768629L;
|
||||
|
||||
/**
|
||||
* @param action
|
||||
* @param changeSetValues
|
||||
*/
|
||||
public ActionPropertyChangeEvent(final Action action,
|
||||
final Map<String, AbstractPropertyChangeEvent<Action>.Values> changeSetValues) {
|
||||
super(action, changeSetValues);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* 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.eventbus.event;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetTagAssignmentResult;
|
||||
|
||||
/**
|
||||
* A event for assignment target tag.
|
||||
*/
|
||||
public class DistributionSetTagAssigmentResultEvent {
|
||||
|
||||
private final DistributionSetTagAssignmentResult assigmentResult;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param assigmentResult
|
||||
* the assignment result-
|
||||
*/
|
||||
public DistributionSetTagAssigmentResultEvent(final DistributionSetTagAssignmentResult assigmentResult) {
|
||||
this.assigmentResult = assigmentResult;
|
||||
}
|
||||
|
||||
public DistributionSetTagAssignmentResult getAssigmentResult() {
|
||||
return assigmentResult;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* 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.eventbus.event;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
||||
|
||||
/**
|
||||
* * A bulk event which contains one or many new ds tag after creating.
|
||||
*/
|
||||
public class DistributionSetTagCreatedBulkEvent extends AbstractEntityBulkEvent<DistributionSetTag> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param tenant
|
||||
* the tenant
|
||||
* @param entities
|
||||
* the new ds tags
|
||||
*/
|
||||
public DistributionSetTagCreatedBulkEvent(final String tenant, final List<DistributionSetTag> entities) {
|
||||
super(tenant, entities);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param tenant
|
||||
* the tenant.
|
||||
* @param entity
|
||||
* the new ds tag
|
||||
*/
|
||||
public DistributionSetTagCreatedBulkEvent(final String tenant, final DistributionSetTag entity) {
|
||||
super(tenant, entity);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* 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.eventbus.event;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
||||
|
||||
/**
|
||||
* Defines the {@link AbstractBaseEntityEvent} of update a
|
||||
* {@link DistributionSetTag}.
|
||||
*
|
||||
*/
|
||||
public class DistributionSetTagDeletedEvent extends AbstractBaseEntityEvent<DistributionSetTag> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param tag
|
||||
* the tag which is deleted
|
||||
*/
|
||||
public DistributionSetTagDeletedEvent(final DistributionSetTag tag) {
|
||||
super(tag);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* 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.eventbus.event;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
||||
|
||||
/**
|
||||
* Defines the {@link AbstractBaseEntityEvent} for update a
|
||||
* {@link DistributionSetTag}.
|
||||
*
|
||||
*/
|
||||
public class DistributionSetTagUpdateEvent extends AbstractBaseEntityEvent<DistributionSetTag> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param tag
|
||||
* the tag which is updated
|
||||
*/
|
||||
public DistributionSetTagUpdateEvent(final DistributionSetTag tag) {
|
||||
super(tag);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* 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.eventbus.event;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.TenantAwareBaseEntity;
|
||||
|
||||
/**
|
||||
* An event interface which declares event types that an entities has been
|
||||
* changed.
|
||||
*
|
||||
* @param <E>
|
||||
* the entity type
|
||||
*/
|
||||
public interface EntityBulkEvent<E extends TenantAwareBaseEntity> extends Serializable, Event {
|
||||
|
||||
/**
|
||||
* A typesafe way to retrieve the the entities from the event, which might
|
||||
* be loaded lazy in case the event has been distributed from another node.
|
||||
*
|
||||
* @return the entities might be lazy loaded. Might be {@code null} in case
|
||||
* the entity e.g. is queried lazy on a different node and has been
|
||||
* already deleted from the database
|
||||
*/
|
||||
List<E> getEntities();
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* 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.eventbus.event;
|
||||
|
||||
/**
|
||||
* Event declaration for the UI to notify the UI that a rollout has been
|
||||
* changed.
|
||||
*
|
||||
* @author Michael Hirsch
|
||||
*
|
||||
*/
|
||||
public class RolloutChangeEvent extends AbstractEvent {
|
||||
|
||||
private final Long rolloutId;
|
||||
|
||||
/**
|
||||
* @param revision
|
||||
* the revision of the event
|
||||
* @param tenant
|
||||
* the tenant of the event
|
||||
* @param rolloutId
|
||||
* the ID of the rollout which has been changed
|
||||
*/
|
||||
public RolloutChangeEvent(final long revision, final String tenant, final Long rolloutId) {
|
||||
super(revision, tenant);
|
||||
this.rolloutId = rolloutId;
|
||||
}
|
||||
|
||||
public Long getRolloutId() {
|
||||
return rolloutId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* 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.eventbus.event;
|
||||
|
||||
/**
|
||||
* Event declaration for the UI to notify the UI that a rollout has been
|
||||
* changed.
|
||||
*
|
||||
* @author Michael Hirsch
|
||||
*
|
||||
*/
|
||||
public class RolloutGroupChangeEvent extends AbstractEvent {
|
||||
|
||||
private final Long rolloutId;
|
||||
private final Long rolloutGroupId;
|
||||
|
||||
/**
|
||||
* @param revision
|
||||
* the revision of the event
|
||||
* @param tenant
|
||||
* the tenant of the event
|
||||
* @param rolloutId
|
||||
* the ID of the rollout which has been changed
|
||||
* @param rolloutGroupId
|
||||
* the ID of the rollout group which has been changed
|
||||
*/
|
||||
public RolloutGroupChangeEvent(final long revision, final String tenant, final Long rolloutId,
|
||||
final Long rolloutGroupId) {
|
||||
super(revision, tenant);
|
||||
this.rolloutId = rolloutId;
|
||||
this.rolloutGroupId = rolloutGroupId;
|
||||
}
|
||||
|
||||
public Long getRolloutId() {
|
||||
return rolloutId;
|
||||
}
|
||||
|
||||
public Long getRolloutGroupId() {
|
||||
return rolloutGroupId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/**
|
||||
* 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.eventbus.event;
|
||||
|
||||
/**
|
||||
* Event definition which is been published in case a rollout group has been
|
||||
* created for a specific rollout.
|
||||
*
|
||||
* @author Michael Hirsch
|
||||
*
|
||||
*/
|
||||
public class RolloutGroupCreatedEvent extends AbstractDistributedEvent {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final Long rolloutId;
|
||||
private final Long rolloutGroupId;
|
||||
private final int totalRolloutGroup;
|
||||
private final int createdRolloutGroup;
|
||||
|
||||
/**
|
||||
* Creating a new rollout group created event for a specific rollout.
|
||||
*
|
||||
* @param tenant
|
||||
* the tenant of this event
|
||||
* @param revision
|
||||
* the revision of the event
|
||||
* @param rolloutId
|
||||
* the ID of the rollout the group has been created
|
||||
* @param totalRolloutGroup
|
||||
* the total number of rollout groups for this rollout
|
||||
* @param createdRolloutGroup
|
||||
* the number of already created groups of the rollout
|
||||
*/
|
||||
public RolloutGroupCreatedEvent(final String tenant, final long revision, final Long rolloutId,
|
||||
final Long rolloutGroupId, final int totalRolloutGroup, final int createdRolloutGroup) {
|
||||
super(revision, tenant);
|
||||
this.rolloutId = rolloutId;
|
||||
this.rolloutGroupId = rolloutGroupId;
|
||||
this.totalRolloutGroup = totalRolloutGroup;
|
||||
this.createdRolloutGroup = createdRolloutGroup;
|
||||
|
||||
}
|
||||
|
||||
public Long getRolloutId() {
|
||||
return rolloutId;
|
||||
}
|
||||
|
||||
public int getTotalRolloutGroup() {
|
||||
return totalRolloutGroup;
|
||||
}
|
||||
|
||||
public int getCreatedRolloutGroup() {
|
||||
return createdRolloutGroup;
|
||||
}
|
||||
|
||||
public Long getRolloutGroupId() {
|
||||
return rolloutGroupId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* 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.eventbus.event;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroup;
|
||||
|
||||
/**
|
||||
* Defines the {@link AbstractPropertyChangeEvent} of {@link RolloutGroup}.
|
||||
*/
|
||||
public class RolloutGroupPropertyChangeEvent extends AbstractPropertyChangeEvent<RolloutGroup> {
|
||||
|
||||
private static final long serialVersionUID = 4026477044419472686L;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param rolloutGroup
|
||||
* @param changeSetValues
|
||||
*/
|
||||
public RolloutGroupPropertyChangeEvent(final RolloutGroup rolloutGroup,
|
||||
final Map<String, AbstractPropertyChangeEvent<RolloutGroup>.Values> changeSetValues) {
|
||||
super(rolloutGroup, changeSetValues);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* 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.eventbus.event;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.Rollout;
|
||||
|
||||
/**
|
||||
* Defines the {@link AbstractPropertyChangeEvent} of {@link Rollout}.
|
||||
*/
|
||||
public class RolloutPropertyChangeEvent extends AbstractPropertyChangeEvent<Rollout> {
|
||||
private static final long serialVersionUID = 1056221355466373514L;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param rollout
|
||||
* @param changeSetValues
|
||||
*/
|
||||
public RolloutPropertyChangeEvent(final Rollout rollout,
|
||||
final Map<String, AbstractPropertyChangeEvent<Rollout>.Values> changeSetValues) {
|
||||
super(rollout, changeSetValues);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
/**
|
||||
* 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.eventbus.event;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||
|
||||
/**
|
||||
* Event that gets sent when a distribution set gets assigned to a target.
|
||||
*
|
||||
*/
|
||||
public class TargetAssignDistributionSetEvent extends AbstractEvent {
|
||||
|
||||
private final Collection<SoftwareModule> softwareModules;
|
||||
private final String controllerId;
|
||||
private final Long actionId;
|
||||
private final URI targetAdress;
|
||||
private final String targetToken;
|
||||
|
||||
/**
|
||||
* Creates a new {@link TargetAssignDistributionSetEvent}.
|
||||
*
|
||||
* @param revision
|
||||
* the revision of the event
|
||||
* @param tenant
|
||||
* the tenant of the event
|
||||
* @param controllerId
|
||||
* the ID of the controller
|
||||
* @param actionId
|
||||
* the action id of the assignment
|
||||
* @param softwareModules
|
||||
* the software modules which have been assigned to the target
|
||||
* @param targetAdress
|
||||
* the targetAdress of the target
|
||||
* @param targetToken
|
||||
* the authentication token of the target
|
||||
*/
|
||||
public TargetAssignDistributionSetEvent(final long revision, final String tenant, final String controllerId,
|
||||
final Long actionId, final Collection<SoftwareModule> softwareModules, final URI targetAdress,
|
||||
final String targetToken) {
|
||||
super(revision, tenant);
|
||||
this.controllerId = controllerId;
|
||||
this.actionId = actionId;
|
||||
this.softwareModules = softwareModules;
|
||||
this.targetAdress = targetAdress;
|
||||
this.targetToken = targetToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the action id of the assignment
|
||||
*/
|
||||
public Long getActionId() {
|
||||
return actionId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the controllerId of the Target which has been assigned to the
|
||||
* distribution set
|
||||
*/
|
||||
public String getControllerId() {
|
||||
return controllerId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the software modules which have been assigned to the target
|
||||
*/
|
||||
public Collection<SoftwareModule> getSoftwareModules() {
|
||||
return softwareModules;
|
||||
}
|
||||
|
||||
public URI getTargetAdress() {
|
||||
return targetAdress;
|
||||
}
|
||||
|
||||
public String getTargetToken() {
|
||||
return targetToken;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* 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.eventbus.event;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
|
||||
/**
|
||||
* Defines the {@link AbstractBaseEntityEvent} of creating a new {@link Target}.
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class TargetCreatedEvent extends AbstractBaseEntityEvent<Target> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* @param target
|
||||
* the target which has been created
|
||||
*/
|
||||
public TargetCreatedEvent(final Target target) {
|
||||
super(target);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
/**
|
||||
* 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.eventbus.event;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.TargetInfo;
|
||||
|
||||
/**
|
||||
* Event for update the targets info.
|
||||
*/
|
||||
public class TargetInfoUpdateEvent implements EntityEvent {
|
||||
|
||||
private final long revision;
|
||||
private final TargetInfo targetInfo;
|
||||
private final String tenant;
|
||||
private String originNodeId;
|
||||
private String nodeId;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param targetInfo
|
||||
* the target info entity
|
||||
*/
|
||||
public TargetInfoUpdateEvent(final TargetInfo targetInfo) {
|
||||
this.targetInfo = targetInfo;
|
||||
this.tenant = targetInfo.getTarget().getTenant();
|
||||
this.revision = -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOriginNodeId(final String originNodeId) {
|
||||
this.originNodeId = originNodeId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNodeId(final String nodeId) {
|
||||
this.nodeId = nodeId;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOriginNodeId() {
|
||||
return this.originNodeId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNodeId() {
|
||||
return this.nodeId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getRevision() {
|
||||
return revision;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <E> E getEntity(final Class<E> entityClass) {
|
||||
return entityClass.cast(targetInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TargetInfo getEntity() {
|
||||
return targetInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTenant() {
|
||||
return tenant;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* 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.eventbus.event;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.TargetTagAssignmentResult;
|
||||
|
||||
/**
|
||||
* A event for assignment target tag.
|
||||
*/
|
||||
public class TargetTagAssigmentResultEvent {
|
||||
|
||||
private final TargetTagAssignmentResult assigmentResult;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param assigmentResult
|
||||
* the assignment result-
|
||||
*/
|
||||
public TargetTagAssigmentResultEvent(final TargetTagAssignmentResult assigmentResult) {
|
||||
this.assigmentResult = assigmentResult;
|
||||
}
|
||||
|
||||
public TargetTagAssignmentResult getAssigmentResult() {
|
||||
return assigmentResult;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* 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.eventbus.event;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.TargetTag;
|
||||
|
||||
/**
|
||||
* A bulk event which contains one or many new target tags after creating.
|
||||
*/
|
||||
public class TargetTagCreatedBulkEvent extends AbstractEntityBulkEvent<TargetTag> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param tenant
|
||||
* the tenant
|
||||
* @param entities
|
||||
* the new targets
|
||||
*/
|
||||
public TargetTagCreatedBulkEvent(final String tenant, final List<TargetTag> entities) {
|
||||
super(tenant, entities);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param tenant
|
||||
* the tenant
|
||||
* @param entity
|
||||
* one new target
|
||||
*/
|
||||
public TargetTagCreatedBulkEvent(final String tenant, final TargetTag entity) {
|
||||
super(tenant, entity);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* 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.eventbus.event;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.TargetTag;
|
||||
|
||||
/**
|
||||
* Defines the {@link AbstractBaseEntityEvent} of update a {@link TargetTag}.
|
||||
*
|
||||
*/
|
||||
public class TargetTagDeletedEvent extends AbstractBaseEntityEvent<TargetTag> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param tag
|
||||
* the tag which is deleted
|
||||
*/
|
||||
public TargetTagDeletedEvent(final TargetTag tag) {
|
||||
super(tag);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* 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.eventbus.event;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.TargetTag;
|
||||
|
||||
/**
|
||||
* Defines the {@link AbstractBaseEntityEvent} for update a {@link TargetTag}.
|
||||
*
|
||||
*/
|
||||
public class TargetTagUpdateEvent extends AbstractBaseEntityEvent<TargetTag> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param tag
|
||||
* the tag which is updated
|
||||
*/
|
||||
public TargetTagUpdateEvent(final TargetTag tag) {
|
||||
super(tag);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* 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.report.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* An abstract report series.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class AbstractReportSeries implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* the name of the series
|
||||
*/
|
||||
public AbstractReportSeries(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name of the series
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
* 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.report.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* A data report series which contains a list of {@link DataReportSeriesItem}.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param <T>
|
||||
* the type of the report series item
|
||||
*/
|
||||
public class DataReportSeries<T extends Serializable> extends AbstractReportSeries {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final List<DataReportSeriesItem<T>> data = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* the name of data series
|
||||
*/
|
||||
public DataReportSeries(final String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a ListSeries with the given series name and array of values.
|
||||
*
|
||||
* @param name
|
||||
* the name of the data series
|
||||
* @param values
|
||||
* data report series item for this data series.
|
||||
*/
|
||||
public DataReportSeries(final String name, final List<DataReportSeriesItem<T>> values) {
|
||||
this(name);
|
||||
setData(values);
|
||||
}
|
||||
|
||||
private void setData(final List<DataReportSeriesItem<T>> values) {
|
||||
data.clear();
|
||||
data.addAll(values);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return An array of the numeric values
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public DataReportSeriesItem<T>[] getData() {
|
||||
return data.toArray(new DataReportSeriesItem[data.size()]);
|
||||
}
|
||||
|
||||
public Stream<DataReportSeriesItem<T>> getDataStream() {
|
||||
return data.stream();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* 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.report.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* An data report series item which contains a type and a value.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param <T>
|
||||
* the type of the report series item
|
||||
*/
|
||||
public class DataReportSeriesItem<T extends Serializable> implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final T type;
|
||||
private final Number data;
|
||||
|
||||
/**
|
||||
* @param type
|
||||
* the type of the data report series item
|
||||
* @param data
|
||||
* the data of the report series item
|
||||
*/
|
||||
public DataReportSeriesItem(final T type, final Number data) {
|
||||
this.type = type;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the type of the data report item
|
||||
*/
|
||||
public T getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the data of the data report item
|
||||
*/
|
||||
public Number getData() {
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* 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.report.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* A double data series which contains an inner and an outer series ideal for
|
||||
* showing donut charts.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param <T>
|
||||
* The type parameter for the report series data
|
||||
*/
|
||||
public class InnerOuterDataReportSeries<T extends Serializable> {
|
||||
|
||||
private final DataReportSeries<T> innerSeries;
|
||||
private final DataReportSeries<T> outerSeries;
|
||||
|
||||
/**
|
||||
* @param innerSeries
|
||||
* the innerseries of an circle donut chart
|
||||
* @param outerSeries
|
||||
* the outer series of an donut chart
|
||||
*/
|
||||
public InnerOuterDataReportSeries(final DataReportSeries<T> innerSeries, final DataReportSeries<T> outerSeries) {
|
||||
this.innerSeries = innerSeries;
|
||||
this.outerSeries = outerSeries;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the innerSeries
|
||||
*/
|
||||
public DataReportSeries<T> getInnerSeries() {
|
||||
return innerSeries;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the outerSeries
|
||||
*/
|
||||
public DataReportSeries<T> getOuterSeries() {
|
||||
return outerSeries;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* 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.report.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A simple list report series which just contains a list of values of a report.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class ListReportSeries extends AbstractReportSeries {
|
||||
|
||||
private final List<Number> data = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* the name of the list report series
|
||||
*/
|
||||
public ListReportSeries(final String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a ListSeries with the given series name and array of values.
|
||||
*
|
||||
* @param name
|
||||
* the name of the list report series
|
||||
* @param values
|
||||
* the values of the list report series
|
||||
*/
|
||||
public ListReportSeries(final String name, final Number... values) {
|
||||
this(name);
|
||||
setData(values);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the values in the list series to the ones provided.
|
||||
*
|
||||
* @param values
|
||||
*/
|
||||
private void setData(final Number... values) {
|
||||
this.data.clear();
|
||||
Collections.addAll(this.data, values);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return An array of the numeric values
|
||||
*/
|
||||
public Number[] getData() {
|
||||
return data.toArray(new Number[data.size()]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* 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.report.model;
|
||||
|
||||
/**
|
||||
* A series time enum definition for {@link DataReportSeriesItem}s.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public enum SeriesTime {
|
||||
|
||||
/**
|
||||
* hour.
|
||||
*/
|
||||
HOUR,
|
||||
/**
|
||||
* day.
|
||||
*/
|
||||
DAY,
|
||||
/**
|
||||
* week.
|
||||
*/
|
||||
WEEK,
|
||||
/**
|
||||
* month.
|
||||
*/
|
||||
MONTH,
|
||||
/**
|
||||
* year.
|
||||
*/
|
||||
YEAR,
|
||||
|
||||
/**
|
||||
* more than one year.
|
||||
*/
|
||||
MORE_THAN_YEAR,
|
||||
|
||||
/**
|
||||
* never.
|
||||
*/
|
||||
NEVER;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
/**
|
||||
* 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.report.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
/**
|
||||
* Bean for holding the system usage stats.
|
||||
*
|
||||
*/
|
||||
public class SystemUsageReport {
|
||||
private final long overallTargets;
|
||||
private final long overallArtifacts;
|
||||
private final long overallArtifactVolumeInBytes;
|
||||
private final long overallActions;
|
||||
|
||||
private final List<TenantUsage> tenants = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param overallTargets
|
||||
* of the system
|
||||
* @param overallArtifacts
|
||||
* of the system
|
||||
* @param overallActions
|
||||
* of the system
|
||||
* @param overallArtifactVolumeInBytes
|
||||
* of the system
|
||||
*/
|
||||
public SystemUsageReport(final long overallTargets, final long overallArtifacts, final long overallActions,
|
||||
final long overallArtifactVolumeInBytes) {
|
||||
super();
|
||||
this.overallTargets = overallTargets;
|
||||
this.overallArtifacts = overallArtifacts;
|
||||
this.overallActions = overallActions;
|
||||
|
||||
this.overallArtifactVolumeInBytes = overallArtifactVolumeInBytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return overallTargets in the system
|
||||
*/
|
||||
public long getOverallTargets() {
|
||||
return overallTargets;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return overallArtifacts in the system
|
||||
*/
|
||||
public long getOverallArtifacts() {
|
||||
return overallArtifacts;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return overallArtifactVolumeInBytes of the system
|
||||
*/
|
||||
public long getOverallArtifactVolumeInBytes() {
|
||||
return overallArtifactVolumeInBytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param tenantUsage
|
||||
* of one tenant
|
||||
* @return updated bean
|
||||
*/
|
||||
public SystemUsageReport addTenantData(final TenantUsage tenantUsage) {
|
||||
tenants.add(tenantUsage);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return actions of system
|
||||
*/
|
||||
public long getOverallActions() {
|
||||
return overallActions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return tenant data
|
||||
*/
|
||||
public List<TenantUsage> getTenants() {
|
||||
return ImmutableList.copyOf(tenants);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
/**
|
||||
* 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.report.model;
|
||||
|
||||
/**
|
||||
* System usage stats element for a tenant.
|
||||
*
|
||||
*/
|
||||
public class TenantUsage {
|
||||
|
||||
private final String tenantName;
|
||||
private long targets;
|
||||
private long artifacts;
|
||||
private long actions;
|
||||
private long overallArtifactVolumeInBytes;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param tenantName
|
||||
*/
|
||||
public TenantUsage(final String tenantName) {
|
||||
super();
|
||||
this.tenantName = tenantName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return name of the tenant
|
||||
*/
|
||||
public String getTenantName() {
|
||||
return tenantName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return number of targets of the tenant
|
||||
*/
|
||||
public long getTargets() {
|
||||
return targets;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param targets
|
||||
* of the tenant
|
||||
* @return updated tenant stats element
|
||||
*/
|
||||
public TenantUsage setTargets(final long targets) {
|
||||
this.targets = targets;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return number of undeleted artifacts of the tenant
|
||||
*/
|
||||
public long getArtifacts() {
|
||||
return artifacts;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param artifacts
|
||||
* of tenant
|
||||
* @return updated tenant stats element
|
||||
*/
|
||||
public TenantUsage setArtifacts(final long artifacts) {
|
||||
this.artifacts = artifacts;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return current overallArtifactVolumeInBytes
|
||||
*/
|
||||
public long getOverallArtifactVolumeInBytes() {
|
||||
return overallArtifactVolumeInBytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param overallArtifactVolumeInBytes
|
||||
* of the tenant in bytes
|
||||
* @return updated tenant stats element
|
||||
*/
|
||||
public TenantUsage setOverallArtifactVolumeInBytes(final long overallArtifactVolumeInBytes) {
|
||||
this.overallArtifactVolumeInBytes = overallArtifactVolumeInBytes;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return number of actions of tenant
|
||||
*/
|
||||
public long getActions() {
|
||||
return actions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param actions
|
||||
* of the tenant
|
||||
* @return updated tenant stats element
|
||||
*/
|
||||
public TenantUsage setActions(final long actions) {
|
||||
this.actions = actions;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() { // NOSONAR - as this is generated code
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + (int) (actions ^ (actions >>> 32));
|
||||
result = prime * result + (int) (artifacts ^ (artifacts >>> 32));
|
||||
result = prime * result + (int) (overallArtifactVolumeInBytes ^ (overallArtifactVolumeInBytes >>> 32));
|
||||
result = prime * result + (int) (targets ^ (targets >>> 32));
|
||||
result = prime * result + ((tenantName == null) ? 0 : tenantName.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) { // NOSONAR - as this is generated
|
||||
// code
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final TenantUsage other = (TenantUsage) obj;
|
||||
if (actions != other.actions) {
|
||||
return false;
|
||||
}
|
||||
if (artifacts != other.artifacts) {
|
||||
return false;
|
||||
}
|
||||
if (overallArtifactVolumeInBytes != other.overallArtifactVolumeInBytes) {
|
||||
return false;
|
||||
}
|
||||
if (targets != other.targets) {
|
||||
return false;
|
||||
}
|
||||
if (tenantName == null) {
|
||||
if (other.tenantName != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!tenantName.equals(other.tenantName)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SystemUsage [tenantName=" + tenantName + ", targets=" + targets + ", artifacts=" + artifacts
|
||||
+ ", actions=" + actions + ", overallArtifactVolumeInBytes=" + overallArtifactVolumeInBytes + "]";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,293 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import org.eclipse.hawkbit.artifact.repository.model.DbArtifact;
|
||||
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
|
||||
import org.eclipse.hawkbit.repository.exception.ArtifactDeleteFailedException;
|
||||
import org.eclipse.hawkbit.repository.exception.ArtifactUploadFailedException;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||
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;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.hateoas.Identifiable;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
||||
/**
|
||||
* Service for {@link Artifact} management operations.
|
||||
*
|
||||
*/
|
||||
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);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* Persists artifact binary as provided by given InputStream. assign the
|
||||
* artifact in addition to given {@link SoftwareModule}.
|
||||
*
|
||||
* @param inputStream
|
||||
* to read from for artifact binary
|
||||
* @param moduleId
|
||||
* to assign the new artifact to
|
||||
* @param filename
|
||||
* of the artifact
|
||||
* @param overrideExisting
|
||||
* to <code>true</code> if the artifact binary can be overridden
|
||||
* if it already exists
|
||||
*
|
||||
* @return uploaded {@link LocalArtifact}
|
||||
*
|
||||
* @throw ArtifactUploadFailedException if upload fails
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||
LocalArtifact createLocalArtifact(@NotNull InputStream inputStream, @NotNull Long moduleId, final String filename,
|
||||
final boolean overrideExisting);
|
||||
|
||||
/**
|
||||
* Persists artifact binary as provided by given InputStream. assign the
|
||||
* artifact in addition to given {@link SoftwareModule}.
|
||||
*
|
||||
* @param inputStream
|
||||
* to read from for artifact binary
|
||||
* @param moduleId
|
||||
* to assign the new artifact to
|
||||
* @param filename
|
||||
* of the artifact
|
||||
* @param overrideExisting
|
||||
* to <code>true</code> if the artifact binary can be overridden
|
||||
* if it already exists
|
||||
* @param contentType
|
||||
* the contentType of the file
|
||||
*
|
||||
* @return uploaded {@link LocalArtifact}
|
||||
*
|
||||
* @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);
|
||||
|
||||
/**
|
||||
* Persists artifact binary as provided by given InputStream. assign the
|
||||
* artifact in addition to given {@link SoftwareModule}.
|
||||
*
|
||||
* @param stream
|
||||
* to read from for artifact binary
|
||||
* @param moduleId
|
||||
* to assign the new artifact to
|
||||
* @param filename
|
||||
* of the artifact
|
||||
* @param providedSha1Sum
|
||||
* optional sha1 checksum to check the new file against
|
||||
* @param providedMd5Sum
|
||||
* optional md5 checksum to check the new file against
|
||||
* @param overrideExisting
|
||||
* to <code>true</code> if the artifact binary can be overdiden
|
||||
* if it already exists
|
||||
* @param contentType
|
||||
* the contentType of the file
|
||||
* @return uploaded {@link LocalArtifact}
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if given software module does not exist
|
||||
* @throws EntityAlreadyExistsException
|
||||
* if File with that name already exists in the Software Module
|
||||
* @throws ArtifactUploadFailedException
|
||||
* if upload fails with internal server errors
|
||||
* @throws InvalidMD5HashException
|
||||
* if check against provided MD5 checksum failed
|
||||
* @throws InvalidSHA1HashException
|
||||
* if check against provided SHA1 checksum failed
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
||||
LocalArtifact createLocalArtifact(@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);
|
||||
|
||||
/**
|
||||
* Deletes a local artifact.
|
||||
*
|
||||
* @param existing
|
||||
* the related local artifact
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
|
||||
void deleteLocalArtifact(@NotNull LocalArtifact existing);
|
||||
|
||||
/**
|
||||
* 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 deleteLocalArtifact(@NotNull Long id);
|
||||
|
||||
/**
|
||||
* Searches for {@link Artifact} with given {@link Identifiable}.
|
||||
*
|
||||
* @param id
|
||||
* to search for
|
||||
* @return found {@link Artifact} or <code>null</code> is it could not be
|
||||
* found.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Artifact findArtifact(@NotNull Long id);
|
||||
|
||||
/**
|
||||
* Find by artifact by software module id and filename.
|
||||
*
|
||||
* @param filename
|
||||
* file name
|
||||
* @param softwareModuleId
|
||||
* software module id.
|
||||
* @return LocalArtifact 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);
|
||||
|
||||
/**
|
||||
* Find all local artifact by sha1 and return the first artifact.
|
||||
*
|
||||
* @param sha1
|
||||
* the sha1
|
||||
* @return the first local artifact
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY + SpringEvalExpressions.HAS_AUTH_OR
|
||||
+ SpringEvalExpressions.IS_CONTROLLER)
|
||||
LocalArtifact findFirstLocalArtifactsBySHA1(@NotNull String sha1);
|
||||
|
||||
/**
|
||||
* Searches for {@link Artifact} with given file name.
|
||||
*
|
||||
* @param filename
|
||||
* to search for
|
||||
* @return found List of {@link LocalArtifact}s.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY + SpringEvalExpressions.HAS_AUTH_OR
|
||||
+ SpringEvalExpressions.IS_CONTROLLER)
|
||||
List<LocalArtifact> findLocalArtifactByFilename(@NotNull String filename);
|
||||
|
||||
/**
|
||||
* Get local artifact for a base software module.
|
||||
*
|
||||
* @param pageReq
|
||||
* Pageable
|
||||
* @param swId
|
||||
* software module id
|
||||
* @return Page<LocalArtifact>
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Page<LocalArtifact> findLocalArtifactBySoftwareModule(@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}.
|
||||
*
|
||||
* @param artifact
|
||||
* to search for
|
||||
* @return loaded {@link DbArtifact}
|
||||
*
|
||||
* @throws GridFSDBFileNotFoundException
|
||||
* if file could not be found in store
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DOWNLOAD_ARTIFACT + SpringEvalExpressions.HAS_AUTH_OR
|
||||
+ SpringEvalExpressions.HAS_CONTROLLER_DOWNLOAD)
|
||||
DbArtifact loadLocalArtifactBinary(@NotNull LocalArtifact artifact);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,286 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||
import org.eclipse.hawkbit.repository.exception.ToManyAttributeEntriesException;
|
||||
import org.eclipse.hawkbit.repository.exception.ToManyStatusEntriesException;
|
||||
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.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;
|
||||
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
|
||||
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationKey;
|
||||
import org.hibernate.validator.constraints.NotEmpty;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
||||
/**
|
||||
* Service layer for all operations of the DDI API (with access permissions only
|
||||
* for the controller).
|
||||
*
|
||||
*/
|
||||
public interface ControllerManagement {
|
||||
|
||||
String SERVER_MESSAGE_PREFIX = "Update Server: ";
|
||||
|
||||
/**
|
||||
* Adds an {@link ActionStatus} for a cancel {@link Action} including
|
||||
* potential state changes for the target and the {@link Action} itself.
|
||||
*
|
||||
* @param actionStatus
|
||||
* to be added
|
||||
* @return the persisted {@link Action}
|
||||
*
|
||||
* @throws EntityAlreadyExistsException
|
||||
* if a given entity already exists
|
||||
*
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER)
|
||||
Action addCancelActionStatus(@NotNull ActionStatus actionStatus);
|
||||
|
||||
/**
|
||||
* Simple addition of a new {@link ActionStatus} entry to the {@link Action}
|
||||
* . No state changes.
|
||||
*
|
||||
* @param statusMessage
|
||||
* to add to the action
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER)
|
||||
void addInformationalActionStatus(@NotNull ActionStatus statusMessage);
|
||||
|
||||
/**
|
||||
* Adds an {@link ActionStatus} entry for an update {@link Action} including
|
||||
* potential state changes for the target and the {@link Action} itself.
|
||||
*
|
||||
* @param actionStatus
|
||||
* to be added
|
||||
* @return the updated {@link Action}
|
||||
*
|
||||
* @throws EntityAlreadyExistsException
|
||||
* if a given entity already exists
|
||||
* @throws ToManyStatusEntriesException
|
||||
* if more than the allowed number of status entries are
|
||||
* inserted
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER)
|
||||
Action addUpdateActionStatus(@NotNull ActionStatus actionStatus);
|
||||
|
||||
/**
|
||||
* Retrieves all {@link Action}s which are active and assigned to a
|
||||
* {@link Target}.
|
||||
*
|
||||
* @param target
|
||||
* the target to retrieve the actions from
|
||||
* @return a list of actions assigned to given target which are active
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER)
|
||||
List<Action> findActionByTargetAndActive(@NotNull Target target);
|
||||
|
||||
/**
|
||||
* Get the {@link Action} entity for given actionId with all lazy
|
||||
* attributes.
|
||||
*
|
||||
* @param actionId
|
||||
* to be id of the action
|
||||
* @return the corresponding {@link Action}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER)
|
||||
Action findActionWithDetails(@NotNull Long actionId);
|
||||
|
||||
/**
|
||||
* register new target in the repository (plug-and-play).
|
||||
*
|
||||
* @param controllerId
|
||||
* reference
|
||||
* @param address
|
||||
* the client IP address of the target, might be {@code null}
|
||||
* @return target reference
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER)
|
||||
Target findOrRegisterTargetIfItDoesNotexist(@NotEmpty String controllerId, URI address);
|
||||
|
||||
/**
|
||||
* Retrieves all {@link SoftwareModule}s which are assigned to the given
|
||||
* {@link DistributionSet}.
|
||||
*
|
||||
* @param distributionSet
|
||||
* the distribution set which should be assigned to the returned
|
||||
* {@link SoftwareModule}s
|
||||
* @return a list of {@link SoftwareModule}s assigned to given
|
||||
* {@code distributionSet}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER)
|
||||
List<SoftwareModule> findSoftwareModulesByDistributionSet(@NotNull DistributionSet distributionSet);
|
||||
|
||||
/**
|
||||
* Retrieves last {@link Action} for a download of an artifact of given
|
||||
* module and target.
|
||||
*
|
||||
* @param controllerId
|
||||
* to look for
|
||||
* @param module
|
||||
* that should be assigned to the target
|
||||
* @return last {@link Action} for given combination
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if action for given combination could not be found
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER)
|
||||
Action getActionForDownloadByTargetAndSoftwareModule(@NotEmpty String controllerId, @NotNull SoftwareModule module);
|
||||
|
||||
/**
|
||||
* @return current {@link TenantConfigurationKey#POLLING_TIME_INTERVAL}.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER)
|
||||
String getPollingTime();
|
||||
|
||||
/**
|
||||
* An direct access to the security token of an
|
||||
* {@link Target#getSecurityToken()} without authorization. This is
|
||||
* necessary to be able to access the security-token without any
|
||||
* security-context information because the security-token is used for
|
||||
* authentication.
|
||||
*
|
||||
* @param controllerId
|
||||
* the ID of the controller to retrieve the security token for
|
||||
* @return the security context of the target, in case no target exists for
|
||||
* the given controllerId {@code null} is returned
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER)
|
||||
String getSecurityTokenByControllerId(@NotEmpty String controllerId);
|
||||
|
||||
/**
|
||||
* Checks if a given target has currently or has even been assigned to the
|
||||
* given artifact through the action history list. This can e.g. indicate if
|
||||
* a target is allowed to download a given artifact because it has currently
|
||||
* assigned or had ever been assigned to the target and so it's visible to a
|
||||
* specific target e.g. for downloading.
|
||||
*
|
||||
* @param controllerId
|
||||
* the ID of the target to check
|
||||
* @param localArtifact
|
||||
* the artifact to verify if the given target had even been
|
||||
* assigned to
|
||||
* @return {@code true} if the given target has currently or had ever a
|
||||
* relation to the given artifact through the action history,
|
||||
* otherwise {@code false}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER)
|
||||
boolean hasTargetArtifactAssigned(@NotNull String controllerId, @NotNull LocalArtifact localArtifact);
|
||||
|
||||
/**
|
||||
* Registers retrieved status for given {@link Target} and {@link Action} if
|
||||
* it does not exist yet.
|
||||
*
|
||||
* @param action
|
||||
* to the handle status for
|
||||
* @param message
|
||||
* for the status
|
||||
* @return the update action in case the status has been changed to
|
||||
* {@link Status#RETRIEVED}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER)
|
||||
Action registerRetrieved(@NotNull Action action, String message);
|
||||
|
||||
/**
|
||||
* Updates attributes of the controller.
|
||||
*
|
||||
* @param controllerId
|
||||
* to update
|
||||
* @param attributes
|
||||
* to insert
|
||||
*
|
||||
* @return updated {@link Target}
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if target that has to be updated could not be found
|
||||
* @throws ToManyAttributeEntriesException
|
||||
* if maximum
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER)
|
||||
Target updateControllerAttributes(@NotEmpty String controllerId, @NotNull Map<String, String> attributes);
|
||||
|
||||
/**
|
||||
* Refreshes the time of the last time the controller has been connected to
|
||||
* the server.
|
||||
*
|
||||
* @param controllerId
|
||||
* of the target to to update
|
||||
* @param address
|
||||
* the client address of the target, might be {@code null}
|
||||
* @return the updated target
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if target with given ID could not be found
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER)
|
||||
Target updateLastTargetQuery(@NotEmpty String controllerId, URI address);
|
||||
|
||||
/**
|
||||
* Refreshes the time of the last time the controller has been connected to
|
||||
* the server.
|
||||
*
|
||||
* @param target
|
||||
* to update
|
||||
* @param address
|
||||
* the client address of the target, might be {@code null}
|
||||
* @return the updated target
|
||||
*
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER)
|
||||
TargetInfo updateLastTargetQuery(@NotNull TargetInfo target, @NotNull URI address);
|
||||
|
||||
/**
|
||||
* Update selective the target status of a given {@code target}.
|
||||
*
|
||||
* @param targetInfo
|
||||
* the target to update the target status
|
||||
* @param status
|
||||
* the status to be set of the target. Might be {@code null} if
|
||||
* the target status should not be updated
|
||||
* @param lastTargetQuery
|
||||
* the last target query to be set of the target. Might be
|
||||
* {@code null} if the target lastTargetQuery should not be
|
||||
* updated
|
||||
* @param address
|
||||
* the client address of the target, might be {@code null}
|
||||
* @return the updated TargetInfo
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.IS_CONTROLLER)
|
||||
TargetInfo updateTargetStatus(@NotNull TargetInfo targetInfo, TargetUpdateStatus status, Long lastTargetQuery,
|
||||
URI address);
|
||||
|
||||
/**
|
||||
* Generates an empty {@link ActionStatus} without persisting it.
|
||||
*
|
||||
* @return {@link ActionStatus} object
|
||||
*/
|
||||
ActionStatus generateActionStatus();
|
||||
|
||||
ActionStatus generateActionStatus(Action action, Status status, Long occurredAt, final String message);
|
||||
|
||||
ActionStatus generateActionStatus(Action action, final Status status, Long occurredAt,
|
||||
final Collection<String> messages);
|
||||
|
||||
ActionStatus generateActionStatus(Action action, Status status, Long occurredAt);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,449 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
|
||||
import org.eclipse.hawkbit.repository.exception.CancelActionNotAllowedException;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||
import org.eclipse.hawkbit.repository.model.Action;
|
||||
import org.eclipse.hawkbit.repository.model.Action.ActionType;
|
||||
import org.eclipse.hawkbit.repository.model.ActionStatus;
|
||||
import org.eclipse.hawkbit.repository.model.ActionWithStatusCount;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||
import org.eclipse.hawkbit.repository.model.Rollout;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroup;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.hibernate.validator.constraints.NotEmpty;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Slice;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
||||
/**
|
||||
* A DeploymentManagement service provides operations for the deployment of
|
||||
* {@link DistributionSet}s to {@link Target}s.
|
||||
*
|
||||
*/
|
||||
public interface DeploymentManagement {
|
||||
|
||||
/**
|
||||
* method assigns the {@link DistributionSet} to all {@link Target}s.
|
||||
*
|
||||
* @param pset
|
||||
* {@link DistributionSet} which is assigned to the
|
||||
* {@link Target}s
|
||||
* @param targets
|
||||
* the {@link Target}s which should obtain the
|
||||
* {@link DistributionSet}
|
||||
*
|
||||
* @return the changed targets
|
||||
*
|
||||
* @throw IncompleteDistributionSetException if mandatory
|
||||
* {@link SoftwareModuleType} are not assigned as define by the
|
||||
* {@link DistributionSetType}. *
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_UPDATE_TARGET)
|
||||
DistributionSetAssignmentResult assignDistributionSet(@NotNull DistributionSet pset,
|
||||
@NotEmpty List<Target> targets);
|
||||
|
||||
/**
|
||||
* method assigns the {@link DistributionSet} to all {@link Target}s by
|
||||
* their IDs with a specific {@link ActionType} and {@code forcetime}.
|
||||
*
|
||||
* @param dsID
|
||||
* the ID of the distribution set to assign
|
||||
* @param actionType
|
||||
* the type of the action to apply on the assignment
|
||||
* @param forcedTimestamp
|
||||
* the time when the action should be forced, only necessary for
|
||||
* {@link ActionType#TIMEFORCED}
|
||||
* @param targetIDs
|
||||
* the IDs of the target to assign the distribution set
|
||||
* @return the assignment result
|
||||
*
|
||||
* @throw IncompleteDistributionSetException if mandatory
|
||||
* {@link SoftwareModuleType} are not assigned as define by the
|
||||
* {@link DistributionSetType}.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_UPDATE_TARGET)
|
||||
DistributionSetAssignmentResult assignDistributionSet(@NotNull final Long dsID, final ActionType actionType,
|
||||
final long forcedTimestamp, @NotEmpty final String... targetIDs);
|
||||
|
||||
/**
|
||||
* method assigns the {@link DistributionSet} to all {@link Target}s by
|
||||
* their IDs with a specific {@link ActionType} and {@code forcetime}.
|
||||
*
|
||||
* @param dsID
|
||||
* the ID of the distribution set to assign
|
||||
* @param targets
|
||||
* a list of all targets and their action type
|
||||
* @return the assignment result
|
||||
*
|
||||
* @throw IncompleteDistributionSetException if mandatory
|
||||
* {@link SoftwareModuleType} are not assigned as define by the
|
||||
* {@link DistributionSetType}.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_UPDATE_TARGET)
|
||||
DistributionSetAssignmentResult assignDistributionSet(@NotNull Long dsID,
|
||||
@NotEmpty Collection<TargetWithActionType> targets);
|
||||
|
||||
/**
|
||||
* method assigns the {@link DistributionSet} to all {@link Target}s by
|
||||
* their IDs with a specific {@link ActionType} and {@code forcetime}.
|
||||
*
|
||||
* @param dsID
|
||||
* the ID of the distribution set to assign
|
||||
* @param targets
|
||||
* a list of all targets and their action type
|
||||
* @param rollout
|
||||
* the rollout for this assignment
|
||||
* @param rolloutGroup
|
||||
* the rollout group for this assignment
|
||||
* @return the assignment result
|
||||
*
|
||||
* @throw IncompleteDistributionSetException if mandatory
|
||||
* {@link SoftwareModuleType} are not assigned as define by the
|
||||
* {@link DistributionSetType}.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_UPDATE_TARGET)
|
||||
DistributionSetAssignmentResult assignDistributionSet(@NotNull Long dsID,
|
||||
@NotEmpty Collection<TargetWithActionType> targets, Rollout rollout, RolloutGroup rolloutGroup);
|
||||
|
||||
/**
|
||||
* method assigns the {@link DistributionSet} to all {@link Target}s by
|
||||
* their IDs.
|
||||
*
|
||||
* @param dsID
|
||||
* {@link DistributionSet} which is assigned to the
|
||||
* {@link Target}s
|
||||
* @param targetIDs
|
||||
* IDs of the {@link Target}s which should obtain the
|
||||
* {@link DistributionSet}
|
||||
*
|
||||
* @return the changed targets
|
||||
*
|
||||
* @throws EntityNotFoundException
|
||||
* if {@link DistributionSet} does not exist.
|
||||
*
|
||||
* @throw IncompleteDistributionSetException if mandatory
|
||||
* {@link SoftwareModuleType} are not assigned as define by the
|
||||
* {@link DistributionSetType}.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_UPDATE_TARGET)
|
||||
DistributionSetAssignmentResult assignDistributionSet(@NotNull Long dsID, @NotEmpty String... targetIDs);
|
||||
|
||||
/**
|
||||
* Cancels given {@link Action} for given {@link Target}. The method will
|
||||
* immediately add a {@link ActionStatus.Status#CANCELED} status to the
|
||||
* action. However, it might be possible that the controller will continue
|
||||
* to work on the cancellation.
|
||||
*
|
||||
* @param action
|
||||
* to be canceled
|
||||
* @param target
|
||||
* for which the action needs cancellation
|
||||
*
|
||||
* @return generated {@link CancelAction} or <code>null</code> if not in
|
||||
* {@link Target#getActiveActions()}.
|
||||
* @throws CancelActionNotAllowedException
|
||||
* in case the given action is not active or is already a cancel
|
||||
* action
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
|
||||
Action cancelAction(@NotNull Action action, @NotNull Target target);
|
||||
|
||||
/**
|
||||
* counts all actions associated to a specific target.
|
||||
*
|
||||
* @param rsqlParam
|
||||
* rsql query string
|
||||
* @param target
|
||||
* the target associated to the actions to count
|
||||
* @return the count value of found actions associated to the target
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Long countActionsByTarget(@NotNull String rsqlParam, @NotNull Target target);
|
||||
|
||||
/**
|
||||
* counts all actions associated to a specific target.
|
||||
*
|
||||
* @param target
|
||||
* the target associated to the actions to count
|
||||
* @return the count value of found actions associated to the target
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Long countActionsByTarget(@NotNull Target target);
|
||||
|
||||
/**
|
||||
* Creates an action entry into the action repository. In case of existing
|
||||
* scheduled actions the scheduled actions gets canceled. A scheduled action
|
||||
* is created in-active.
|
||||
*
|
||||
* @param targets
|
||||
* the targets to create scheduled actions for
|
||||
* @param distributionSet
|
||||
* the distribution set for the actions
|
||||
* @param actionType
|
||||
* the action type for the action
|
||||
* @param forcedTime
|
||||
* the forcedTime of the action
|
||||
* @param rollout
|
||||
* the roll out for this action
|
||||
* @param rolloutGroup
|
||||
* the roll out group for this action
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
|
||||
void createScheduledAction(@NotEmpty Collection<Target> targets, @NotNull DistributionSet distributionSet,
|
||||
@NotNull ActionType actionType, Long forcedTime, @NotNull Rollout rollout,
|
||||
@NotNull RolloutGroup rolloutGroup);
|
||||
|
||||
/**
|
||||
* Get the {@link Action} entity for given actionId.
|
||||
*
|
||||
* @param actionId
|
||||
* to be id of the action
|
||||
* @return the corresponding {@link Action}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Action findAction(@NotNull Long actionId);
|
||||
|
||||
/**
|
||||
* Retrieves all actions for a specific rollout and in a specific status.
|
||||
*
|
||||
* @param rollout
|
||||
* the rollout the actions beglong to
|
||||
* @param actionStatus
|
||||
* the status of the actions
|
||||
* @return the actions referring a specific rollout an in a specific status
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
List<Action> findActionsByRolloutAndStatus(@NotNull Rollout rollout, @NotNull Action.Status actionStatus);
|
||||
|
||||
/**
|
||||
* Retrieving all actions referring to a given rollout with a specific
|
||||
* action as parent reference and a specific status.
|
||||
*
|
||||
* Finding all actions of a specific rolloutgroup parent relation.
|
||||
*
|
||||
* @param rollout
|
||||
* the rollout the actions belong to
|
||||
* @param rolloutGroupParent
|
||||
* the parent rollout group the actions should reference
|
||||
* @param actionStatus
|
||||
* the status the actions have
|
||||
* @return the actions referring a specific rollout and a specific parent
|
||||
* rollout group in a specific status
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET + SpringEvalExpressions.HAS_AUTH_OR
|
||||
+ SpringEvalExpressions.IS_SYSTEM_CODE)
|
||||
List<Action> findActionsByRolloutGroupParentAndStatus(@NotNull Rollout rollout,
|
||||
@NotNull RolloutGroup rolloutGroupParent, @NotNull Action.Status actionStatus);
|
||||
|
||||
/**
|
||||
* Retrieves all {@link Action}s of a specific target.
|
||||
*
|
||||
* @param pageable
|
||||
* pagination parameter
|
||||
* @param target
|
||||
* of which the actions have to be searched
|
||||
* @return a paged list of actions associated with the given target
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Slice<Action> findActionsByTarget(@NotNull Pageable pageable, @NotNull Target target);
|
||||
|
||||
/**
|
||||
* Retrieves all {@link Action}s assigned to a specific {@link Target} and a
|
||||
* given specification.
|
||||
*
|
||||
* @param rsqlParam
|
||||
* rsql query string
|
||||
* @param target
|
||||
* the target which must be assigned to the actions
|
||||
* @param pageable
|
||||
* the page request
|
||||
* @return a slice of actions assigned to the specific target and the
|
||||
* specification
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Slice<Action> findActionsByTarget(@NotNull String rsqlParam, @NotNull Target target, @NotNull Pageable pageable);
|
||||
|
||||
/**
|
||||
* Retrieves all {@link Action}s of a specific target ordered by action ID.
|
||||
*
|
||||
* @param target
|
||||
* the target associated with the actions
|
||||
* @return a list of actions associated with the given target ordered by
|
||||
* action ID
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
List<Action> findActionsByTarget(@NotNull Target target);
|
||||
|
||||
/**
|
||||
* Retrieves all {@link Action}s which are referring the given
|
||||
* {@link Target}.
|
||||
*
|
||||
* @param foundTarget
|
||||
* the target to find actions for
|
||||
* @param pageable
|
||||
* the pageable request to limit, sort the actions
|
||||
* @return a slice of actions found for a specific target
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Slice<Action> findActionsByTarget(@NotNull Target foundTarget, @NotNull Pageable pageable);
|
||||
|
||||
/**
|
||||
* Retrieves all the {@link ActionStatus} entries of the given
|
||||
* {@link Action} and {@link Target}.
|
||||
*
|
||||
* @param pageReq
|
||||
* pagination parameter
|
||||
* @param action
|
||||
* to be filtered on
|
||||
* @param withMessages
|
||||
* to <code>true</code> if {@link ActionStatus#getMessages()}
|
||||
* need to be fetched.
|
||||
* @return the corresponding {@link Page} of {@link ActionStatus}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Page<ActionStatus> findActionStatusByAction(@NotNull Pageable pageReq, @NotNull Action action);
|
||||
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Page<ActionStatus> findActionStatusByActionWithMessages(@NotNull Pageable pageReq, @NotNull Action action);
|
||||
|
||||
/**
|
||||
* Retrieves all {@link Action}s of a specific target ordered by action ID.
|
||||
*
|
||||
* @param target
|
||||
* the target associated with the actions
|
||||
* @return a list of actions associated with the given target ordered by
|
||||
* action ID
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
List<ActionWithStatusCount> findActionsWithStatusCountByTargetOrderByIdDesc(@NotNull Target target);
|
||||
|
||||
/**
|
||||
* Get the {@link Action} entity for given actionId with all lazy attributes
|
||||
* (i.e. distributionSet, target, target.assignedDs).
|
||||
*
|
||||
* @param actionId
|
||||
* to be id of the action
|
||||
* @return the corresponding {@link Action}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Action findActionWithDetails(@NotNull Long actionId);
|
||||
|
||||
/**
|
||||
* Retrieves all active {@link Action}s of a specific target ordered by
|
||||
* action ID.
|
||||
*
|
||||
* @param pageable
|
||||
* the pagination parameter
|
||||
* @param target
|
||||
* the target associated with the actions
|
||||
* @return a paged list of actions associated with the given target
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Page<Action> findActiveActionsByTarget(@NotNull Pageable pageable, @NotNull Target target);
|
||||
|
||||
/**
|
||||
* Retrieves all active {@link Action}s of a specific target ordered by
|
||||
* action ID.
|
||||
*
|
||||
* @param target
|
||||
* the target associated with the actions
|
||||
* @return a list of actions associated with the given target
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
List<Action> findActiveActionsByTarget(@NotNull Target target);
|
||||
|
||||
/**
|
||||
* Retrieves all inactive {@link Action}s of a specific target ordered by
|
||||
* action ID.
|
||||
*
|
||||
* @param pageable
|
||||
* the pagination parameter
|
||||
* @param target
|
||||
* the target associated with the actions
|
||||
* @return a paged list of actions associated with the given target
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Page<Action> findInActiveActionsByTarget(@NotNull Pageable pageable, @NotNull Target target);
|
||||
|
||||
/**
|
||||
* Retrieves all inactive {@link Action}s of a specific target ordered by
|
||||
* action ID.
|
||||
*
|
||||
* @param target
|
||||
* the target associated with the actions
|
||||
* @return a list of actions associated with the given target
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
List<Action> findInActiveActionsByTarget(@NotNull Target target);
|
||||
|
||||
/**
|
||||
* Force cancels given {@link Action} for given {@link Target}. Force
|
||||
* canceling means that the action is marked as canceled on the SP server
|
||||
* and a cancel request is sent to the target. But however it's not tracked,
|
||||
* if the targets handles the cancel request or not.
|
||||
*
|
||||
* @param action
|
||||
* to be canceled
|
||||
* @param target
|
||||
* for which the action needs cancellation
|
||||
*
|
||||
* @return generated {@link CancelAction} or <code>null</code> if not in
|
||||
* {@link Target#getActiveActions()}.
|
||||
* @throws CancelActionNotAllowedException
|
||||
* in case the given action is not active
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
|
||||
Action forceQuitAction(@NotNull Action action);
|
||||
|
||||
/**
|
||||
* Updates a {@link TargetAction} and forces the {@link TargetAction} if
|
||||
* it's not already forced.
|
||||
*
|
||||
* @param targetId
|
||||
* the ID of the target
|
||||
* @param actionId
|
||||
* the ID of the action
|
||||
* @return the updated or the found {@link TargetAction}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
|
||||
Action forceTargetAction(@NotNull Long actionId);
|
||||
|
||||
/**
|
||||
* Starting an action which is scheduled, e.g. in case of roll out a
|
||||
* scheduled action must be started now.
|
||||
*
|
||||
* @param action
|
||||
* the action to start now.
|
||||
* @return the action which has been started
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET + SpringEvalExpressions.HAS_AUTH_OR
|
||||
+ SpringEvalExpressions.IS_SYSTEM_CODE)
|
||||
Action startScheduledAction(@NotNull Action action);
|
||||
|
||||
/**
|
||||
* Generates an empty {@link Action} without persisting it.
|
||||
*
|
||||
* @return {@link Action} object
|
||||
*/
|
||||
Action generateAction();
|
||||
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Page<ActionStatus> findActionStatusAll(@NotNull Pageable pageable);
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.AssignmentResult;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
|
||||
/**
|
||||
* A bean which holds a complex result of an service operation to combine the
|
||||
* information of an assignment and how much of the assignment has been done and
|
||||
* how much of the assignments had already been existed.
|
||||
*
|
||||
*/
|
||||
public class DistributionSetAssignmentResult extends AssignmentResult<Target> {
|
||||
|
||||
private final List<String> assignedTargets;
|
||||
private final List<Long> actions;
|
||||
|
||||
private final TargetManagement targetManagement;
|
||||
|
||||
/**
|
||||
*
|
||||
* Constructor.
|
||||
*
|
||||
* @param assignedTargets
|
||||
* the target objects which have been assigned to the
|
||||
* distribution set
|
||||
* @param assigned
|
||||
* count of the assigned targets
|
||||
* @param alreadyAssigned
|
||||
* the count of the already assigned targets
|
||||
* @param targetManagement
|
||||
* to retrieve the assigned targets
|
||||
* @param actions
|
||||
* of the assignment
|
||||
*
|
||||
*/
|
||||
public DistributionSetAssignmentResult(final List<String> assignedTargets, final int assigned,
|
||||
final int alreadyAssigned, final List<Long> actions, final TargetManagement targetManagement) {
|
||||
super(assigned, alreadyAssigned, 0, Collections.emptyList(), Collections.emptyList());
|
||||
this.assignedTargets = assignedTargets;
|
||||
this.actions = actions;
|
||||
this.targetManagement = targetManagement;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the actionIds
|
||||
*/
|
||||
public List<Long> getActions() {
|
||||
return actions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Target> getAssignedEntity() {
|
||||
return targetManagement.findTargetByControllerID(assignedTargets);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||
|
||||
/**
|
||||
* Holds distribution set filter parameters.
|
||||
*/
|
||||
public final class DistributionSetFilter {
|
||||
/**
|
||||
*
|
||||
* Distribution set filter builder.
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public static class DistributionSetFilterBuilder {
|
||||
private Boolean isDeleted;
|
||||
private Boolean isComplete;
|
||||
private DistributionSetType type;
|
||||
private String searchText;
|
||||
private Boolean selectDSWithNoTag;
|
||||
private Collection<String> tagNames;
|
||||
private String assignedTargetId;
|
||||
private String installedTargetId;
|
||||
|
||||
/**
|
||||
* Build filter.
|
||||
*
|
||||
* @return DistributionSetFilter
|
||||
*/
|
||||
public DistributionSetFilter build() {
|
||||
return new DistributionSetFilter(this);
|
||||
}
|
||||
|
||||
public DistributionSetFilterBuilder setAssignedTargetId(final String assignedTargetId) {
|
||||
this.assignedTargetId = assignedTargetId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DistributionSetFilterBuilder setInstalledTargetId(final String installedTargetId) {
|
||||
this.installedTargetId = installedTargetId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DistributionSetFilterBuilder setIsComplete(final Boolean isComplete) {
|
||||
this.isComplete = isComplete;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DistributionSetFilterBuilder setIsDeleted(final Boolean isDeleted) {
|
||||
this.isDeleted = isDeleted;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DistributionSetFilterBuilder setSearchText(final String searchText) {
|
||||
this.searchText = searchText;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DistributionSetFilterBuilder setSelectDSWithNoTag(final Boolean selectDSWithNoTag) {
|
||||
this.selectDSWithNoTag = selectDSWithNoTag;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DistributionSetFilterBuilder setTagNames(final Collection<String> tagNames) {
|
||||
this.tagNames = tagNames;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DistributionSetFilterBuilder setType(final DistributionSetType type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
private final Boolean isDeleted;
|
||||
private final Boolean isComplete;
|
||||
private final DistributionSetType type;
|
||||
private final String searchText;
|
||||
private final Boolean selectDSWithNoTag;
|
||||
private final Collection<String> tagNames;
|
||||
private final String assignedTargetId;
|
||||
|
||||
private final String installedTargetId;
|
||||
|
||||
/**
|
||||
* Parametric constructor.
|
||||
*
|
||||
* @param builder
|
||||
* DistributionSetFilterBuilder
|
||||
*/
|
||||
public DistributionSetFilter(final DistributionSetFilterBuilder builder) {
|
||||
this.isDeleted = builder.isDeleted;
|
||||
this.isComplete = builder.isComplete;
|
||||
this.type = builder.type;
|
||||
this.searchText = builder.searchText;
|
||||
this.selectDSWithNoTag = builder.selectDSWithNoTag;
|
||||
this.tagNames = builder.tagNames;
|
||||
this.assignedTargetId = builder.assignedTargetId;
|
||||
this.installedTargetId = builder.installedTargetId;
|
||||
}
|
||||
|
||||
public String getAssignedTargetId() {
|
||||
return assignedTargetId;
|
||||
}
|
||||
|
||||
public String getInstalledTargetId() {
|
||||
return installedTargetId;
|
||||
}
|
||||
|
||||
public Boolean getIsComplete() {
|
||||
return isComplete;
|
||||
}
|
||||
|
||||
public Boolean getIsDeleted() {
|
||||
return isDeleted;
|
||||
}
|
||||
|
||||
public String getSearchText() {
|
||||
return searchText;
|
||||
}
|
||||
|
||||
public Boolean getSelectDSWithNoTag() {
|
||||
return selectDSWithNoTag;
|
||||
}
|
||||
|
||||
public Collection<String> getTagNames() {
|
||||
return tagNames;
|
||||
}
|
||||
|
||||
public DistributionSetType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,600 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
|
||||
import org.eclipse.hawkbit.repository.DistributionSetFilter.DistributionSetFilterBuilder;
|
||||
import org.eclipse.hawkbit.repository.exception.DistributionSetCreationFailedMissingMandatoryModuleException;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityReadOnlyException;
|
||||
import org.eclipse.hawkbit.repository.model.Action;
|
||||
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.DistributionSetTagAssignmentResult;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||
import org.eclipse.hawkbit.repository.model.Tag;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.hibernate.validator.constraints.NotEmpty;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
||||
/**
|
||||
* Management service for {@link DistributionSet}s.
|
||||
*
|
||||
*/
|
||||
public interface DistributionSetManagement {
|
||||
|
||||
// TODO rename/document the whole with details thing (document what the
|
||||
// details are and maybe find a better name, e.g. with dependencies?)
|
||||
|
||||
/**
|
||||
* Assigns {@link SoftwareModule} to existing {@link DistributionSet}.
|
||||
*
|
||||
* @param ds
|
||||
* to assign and update
|
||||
* @param softwareModules
|
||||
* to get assigned
|
||||
* @return the updated {@link DistributionSet}.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||
DistributionSet assignSoftwareModules(@NotNull DistributionSet ds, Set<SoftwareModule> softwareModules);
|
||||
|
||||
/**
|
||||
* Assign a {@link DistributionSetTag} assignment to given
|
||||
* {@link DistributionSet}s.
|
||||
*
|
||||
* @param dsIds
|
||||
* to assign for
|
||||
* @param tag
|
||||
* to assign
|
||||
* @return list of assigned ds
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||
List<DistributionSet> assignTag(@NotEmpty Collection<Long> dsIds, @NotNull DistributionSetTag tag);
|
||||
|
||||
/**
|
||||
* Count all {@link DistributionSet}s in the repository that are not marked
|
||||
* as deleted.
|
||||
*
|
||||
* @return number of {@link DistributionSet}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Long countDistributionSetsAll();
|
||||
|
||||
/**
|
||||
* Count all {@link DistributionSet}s in the repository that are not marked
|
||||
* as deleted.
|
||||
*
|
||||
* @param type
|
||||
* to look for
|
||||
*
|
||||
* @return number of {@link DistributionSet}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Long countDistributionSetsByType(@NotNull DistributionSetType type);
|
||||
|
||||
/**
|
||||
* @return number of {@link DistributionSetType}s in the repository.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Long countDistributionSetTypesAll();
|
||||
|
||||
/**
|
||||
* Creates a new {@link DistributionSet}.
|
||||
*
|
||||
* @param dSet
|
||||
* {@link DistributionSet} to be created
|
||||
* @return the new persisted {@link DistributionSet}
|
||||
*
|
||||
* @throws EntityAlreadyExistsException
|
||||
* if a given entity already exists
|
||||
* @throws DistributionSetCreationFailedMissingMandatoryModuleException
|
||||
* is {@link DistributionSet} does not contain mandatory
|
||||
* {@link SoftwareModule}s.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
||||
DistributionSet createDistributionSet(@NotNull DistributionSet dSet);
|
||||
|
||||
/**
|
||||
* creates a list of distribution set meta data entries.
|
||||
*
|
||||
* @param metadata
|
||||
* the meta data entries to create or update
|
||||
* @return the updated or created distribution set meta data entries
|
||||
* @throws EntityAlreadyExistsException
|
||||
* in case one of the meta data entry already exists for the
|
||||
* specific key
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||
List<DistributionSetMetadata> createDistributionSetMetadata(@NotEmpty Collection<DistributionSetMetadata> metadata);
|
||||
|
||||
/**
|
||||
* creates or updates a single distribution set meta data entry.
|
||||
*
|
||||
* @param metadata
|
||||
* the meta data entry to create or update
|
||||
* @return the updated or created distribution set meta data entry
|
||||
* @throws EntityAlreadyExistsException
|
||||
* in case the meta data entry already exists for the specific
|
||||
* key
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||
DistributionSetMetadata createDistributionSetMetadata(@NotNull DistributionSetMetadata metadata);
|
||||
|
||||
/**
|
||||
* Creates multiple {@link DistributionSet}s.
|
||||
*
|
||||
* @param distributionSets
|
||||
* to be created
|
||||
* @return the new {@link DistributionSet}s
|
||||
* @throws EntityAlreadyExistsException
|
||||
* if a given entity already exists
|
||||
* @throws DistributionSetCreationFailedMissingMandatoryModuleException
|
||||
* is {@link DistributionSet} does not contain mandatory
|
||||
* {@link SoftwareModule}s.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
||||
List<DistributionSet> createDistributionSets(@NotNull Collection<DistributionSet> distributionSets);
|
||||
|
||||
/**
|
||||
* Creates new {@link DistributionSetType}.
|
||||
*
|
||||
* @param type
|
||||
* to create
|
||||
* @return created {@link Entity}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
||||
DistributionSetType createDistributionSetType(@NotNull DistributionSetType type);
|
||||
|
||||
/**
|
||||
* Creates multiple {@link DistributionSetType}s.
|
||||
*
|
||||
* @param types
|
||||
* to create
|
||||
* @return created {@link Entity}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
||||
List<DistributionSetType> createDistributionSetTypes(@NotNull Collection<DistributionSetType> types);
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* {@link DistributionSet} can be deleted/erased from the repository if they
|
||||
* have never been assigned to any {@link UpdateAction} or {@link Target}.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* If they have been assigned that need to be marked as deleted which as a
|
||||
* result means that they cannot be assigned anymore to any targets. (define
|
||||
* e.g. findByDeletedFalse())
|
||||
* </p>
|
||||
*
|
||||
* @param set
|
||||
* to delete
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
|
||||
void deleteDistributionSet(@NotNull DistributionSet set);
|
||||
|
||||
/**
|
||||
* Deleted {@link DistributionSet}s by their IDs. That is either a soft
|
||||
* delete of the entities have been linked to an {@link UpdateAction} before
|
||||
* or a hard delete if not.
|
||||
*
|
||||
* @param distributionSetIDs
|
||||
* to be deleted
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
|
||||
void deleteDistributionSet(@NotEmpty Long... distributionSetIDs);
|
||||
|
||||
/**
|
||||
* deletes a distribution set meta data entry.
|
||||
*
|
||||
* @param id
|
||||
* the ID of the distribution set meta data to delete
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||
void deleteDistributionSetMetadata(@NotNull final DistributionSet distributionSet, @NotNull final String key);
|
||||
|
||||
/**
|
||||
* Deletes or mark as delete in case the type is in use.
|
||||
*
|
||||
* @param type
|
||||
* to delete
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
|
||||
void deleteDistributionSetType(@NotNull DistributionSetType type);
|
||||
|
||||
/**
|
||||
* retrieves the distribution set for a given action.
|
||||
*
|
||||
* @param action
|
||||
* the action associated with the distribution set
|
||||
* @return the distribution set which is associated with the action
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
DistributionSet findDistributionSetByAction(@NotNull Action action);
|
||||
|
||||
/**
|
||||
* Find {@link DistributionSet} based on given ID without details, e.g.
|
||||
* {@link DistributionSet#getAgentHub()}.
|
||||
*
|
||||
* @param distid
|
||||
* to look for.
|
||||
* @return {@link DistributionSet} or <code>null</code> if it does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
DistributionSet findDistributionSetById(@NotNull Long distid);
|
||||
|
||||
/**
|
||||
* Find {@link DistributionSet} based on given ID including (lazy loaded)
|
||||
* details, e.g. {@link DistributionSet#getAgentHub()}.
|
||||
*
|
||||
* Note: for performance reasons it is recommended to use
|
||||
* {@link #findDistributionSetById(Long)} if details are not necessary.
|
||||
*
|
||||
* @param distid
|
||||
* to look for.
|
||||
* @return {@link DistributionSet} or <code>null</code> if it does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
DistributionSet findDistributionSetByIdWithDetails(@NotNull Long distid);
|
||||
|
||||
/**
|
||||
* Find distribution set by name and version.
|
||||
*
|
||||
* @param distributionName
|
||||
* name of {@link DistributionSet}; case insensitive
|
||||
* @param version
|
||||
* version of {@link DistributionSet}
|
||||
* @return the page with the found {@link DistributionSet}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
DistributionSet findDistributionSetByNameAndVersion(@NotEmpty String distributionName, @NotEmpty String version);
|
||||
|
||||
/**
|
||||
* finds all meta data by the given distribution set id.
|
||||
*
|
||||
* @param distributionSetId
|
||||
* the distribution set id to retrieve the meta data from
|
||||
* @param pageable
|
||||
* the page request to page the result
|
||||
* @return a paged result of all meta data entries for a given distribution
|
||||
* set id
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Page<DistributionSetMetadata> findDistributionSetMetadataByDistributionSetId(@NotNull Long distributionSetId,
|
||||
@NotNull Pageable pageable);
|
||||
|
||||
/**
|
||||
* finds all meta data by the given distribution set id.
|
||||
*
|
||||
* @param distributionSetId
|
||||
* the distribution set id to retrieve the meta data from
|
||||
* @param rsqlParam
|
||||
* rsql query string
|
||||
* @param pageable
|
||||
* the page request to page the result
|
||||
* @return a paged result of all meta data entries for a given distribution
|
||||
* set id
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Page<DistributionSetMetadata> findDistributionSetMetadataByDistributionSetId(@NotNull Long distributionSetId,
|
||||
@NotNull String rsqlParam, @NotNull Pageable pageable);
|
||||
|
||||
/**
|
||||
* Retrieves {@link DistributionSet} List for overview purposes (no
|
||||
* {@link SoftwareModule}s and {@link DistributionSetTag}s).
|
||||
*
|
||||
* Please use {@link #findDistributionSetListWithDetails(Iterable)} if
|
||||
* details are required.
|
||||
*
|
||||
* @param dist
|
||||
* List of {@link DistributionSet} IDs to be found
|
||||
* @return the found {@link DistributionSet}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
List<DistributionSet> findDistributionSetsAll(Collection<Long> dist);
|
||||
|
||||
// TODO discuss: use enum instead of the true,false,null switch ?
|
||||
/**
|
||||
* finds all {@link DistributionSet}s.
|
||||
*
|
||||
* @param pageReq
|
||||
* the pagination parameter
|
||||
* @param deleted
|
||||
* if TRUE, {@link DistributionSet}s marked as deleted are
|
||||
* returned. If FALSE, on {@link DistributionSet}s with
|
||||
* {@link DistributionSet#isDeleted()} == FALSE are returned.
|
||||
* <code>null</code> if both are to be returned
|
||||
* @param complete
|
||||
* to <code>true</code> for returning only completed distribution
|
||||
* sets or <code>false</code> for only incomplete ones nor
|
||||
* <code>null</code> to return both.
|
||||
* @param complete
|
||||
* set to if <code>false</code> incomplete DS should also be
|
||||
* shown.
|
||||
*
|
||||
*
|
||||
* @return all found {@link DistributionSet}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Page<DistributionSet> findDistributionSetsByDeletedAndOrCompleted(@NotNull Pageable pageReq, Boolean deleted,
|
||||
Boolean complete);
|
||||
|
||||
/**
|
||||
* finds all {@link DistributionSet}s.
|
||||
*
|
||||
* @param rsqlParam
|
||||
* rsql query string
|
||||
* @param pageReq
|
||||
* the pagination parameter
|
||||
* @param deleted
|
||||
* if TRUE, {@link DistributionSet}s marked as deleted are
|
||||
* returned. If FALSE, on {@link DistributionSet}s with
|
||||
* {@link DistributionSet#isDeleted()} == FALSE are returned.
|
||||
* <code>null</code> if both are to be returned
|
||||
* @return all found {@link DistributionSet}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Page<DistributionSet> findDistributionSetsAll(@NotNull String rsqlParam, @NotNull Pageable pageReq,
|
||||
Boolean deleted);
|
||||
|
||||
/**
|
||||
* method retrieves all {@link DistributionSet}s from the repository in the
|
||||
* following order:
|
||||
* <p>
|
||||
* 1) {@link DistributionSet}s which have the given {@link Target} as
|
||||
* {@link TargetStatus#getInstalledDistributionSet()}
|
||||
* <p>
|
||||
* 2) {@link DistributionSet}s which have the given {@link Target} as
|
||||
* {@link Target#getAssignedDistributionSet()}
|
||||
* <p>
|
||||
* 3) {@link DistributionSet}s which have no connection to the given
|
||||
* {@link Target} ordered by ID of the DistributionSet.
|
||||
*
|
||||
* @param pageable
|
||||
* the page request to page the result set *
|
||||
* @param distributionSetFilterBuilder
|
||||
* has details of filters to be applied
|
||||
* @param assignedOrInstalled
|
||||
* the controllerID of the Target to be ordered by
|
||||
* @return
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Page<DistributionSet> findDistributionSetsAllOrderedByLinkTarget(@NotNull Pageable pageable,
|
||||
@NotNull DistributionSetFilterBuilder distributionSetFilterBuilder, @NotEmpty String assignedOrInstalled);
|
||||
|
||||
/**
|
||||
* retrieves {@link DistributionSet}s by filtering on the given parameters.
|
||||
*
|
||||
* @param pageable
|
||||
* page parameter
|
||||
* @param distributionSetFilter
|
||||
* has details of filters to be applied.
|
||||
* @return the page of found {@link DistributionSet}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Page<DistributionSet> findDistributionSetsByFilters(@NotNull Pageable pageable,
|
||||
@NotNull DistributionSetFilter distributionSetFilter);
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* as {@link DistributionSetType#getId()}
|
||||
* @return {@link DistributionSetType} if found or <code>null</code> if not
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
DistributionSetType findDistributionSetTypeById(@NotNull Long id);
|
||||
|
||||
/**
|
||||
* @param key
|
||||
* as {@link DistributionSetType#getKey()}
|
||||
* @return {@link DistributionSetType} if found or <code>null</code> if not
|
||||
*/
|
||||
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
DistributionSetType findDistributionSetTypeByKey(@NotNull String key);
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* as {@link DistributionSetType#getName()}
|
||||
* @return {@link DistributionSetType} if found or <code>null</code> if not
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
DistributionSetType findDistributionSetTypeByName(@NotEmpty String name);
|
||||
|
||||
/**
|
||||
* @param pageable
|
||||
* parameter
|
||||
* @return all {@link DistributionSetType}s in the repository.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Page<DistributionSetType> findDistributionSetTypesAll(@NotNull Pageable pageable);
|
||||
|
||||
/**
|
||||
* Generic predicate based query for {@link DistributionSetType}.
|
||||
*
|
||||
* @param rsqlParam
|
||||
* rsql query string
|
||||
* @param pageable
|
||||
* parameter for paging
|
||||
*
|
||||
* @return the found {@link SoftwareModuleType}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Page<DistributionSetType> findDistributionSetTypesAll(@NotNull String rsqlParam, @NotNull Pageable pageable);
|
||||
|
||||
/**
|
||||
* finds a single distribution set meta data by its id.
|
||||
*
|
||||
* @param id
|
||||
* the id of the distribution set meta data containing the meta
|
||||
* data key and the ID of the distribution set
|
||||
* @return the found DistributionSetMetadata or {@code null} if not exits
|
||||
* @throws EntityNotFoundException
|
||||
* in case the meta data does not exists for the given key
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
DistributionSetMetadata findOne(@NotNull DistributionSet distributionSet, @NotNull String key);
|
||||
|
||||
/**
|
||||
* Generates an empty {@link DistributionSet} without persisting it.
|
||||
*
|
||||
* @return {@link DistributionSet} object
|
||||
*/
|
||||
DistributionSet generateDistributionSet();
|
||||
|
||||
DistributionSetMetadata generateDistributionSetMetadata();
|
||||
|
||||
DistributionSetMetadata generateDistributionSetMetadata(DistributionSet distributionSet, String key, String value);
|
||||
|
||||
/**
|
||||
* Generates an empty {@link DistributionSetType} without persisting it.
|
||||
*
|
||||
* @return {@link DistributionSetType} object
|
||||
*/
|
||||
DistributionSetType generateDistributionSetType();
|
||||
|
||||
DistributionSetType generateDistributionSetType(String key, String name, String description);
|
||||
|
||||
/**
|
||||
* Checks if a {@link DistributionSet} is currently in use by a target in
|
||||
* the repository.
|
||||
*
|
||||
* @param distributionSet
|
||||
* to check
|
||||
*
|
||||
* @return <code>true</code> if in use
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
boolean isDistributionSetInUse(@NotNull DistributionSet distributionSet);
|
||||
|
||||
/**
|
||||
* {@link Entity} based method call for
|
||||
* {@link #toggleTagAssignment(Collection, String)}.
|
||||
*
|
||||
* @param sets
|
||||
* to toggle for
|
||||
* @param tag
|
||||
* to toggle
|
||||
* @return {@link DistributionSetTagAssignmentResult} with all meta data of
|
||||
* the assignment outcome.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||
DistributionSetTagAssignmentResult toggleTagAssignment(@NotEmpty Collection<DistributionSet> sets,
|
||||
@NotNull DistributionSetTag tag);
|
||||
|
||||
/**
|
||||
* Toggles {@link DistributionSetTag} assignment to given
|
||||
* {@link DistributionSet}s by means that if some (or all) of the targets in
|
||||
* the list have the {@link Tag} not yet assigned, they will be. If all of
|
||||
* theme have the tag already assigned they will be removed instead.
|
||||
*
|
||||
* @param dsIds
|
||||
* to toggle for
|
||||
* @param tagName
|
||||
* to toggle
|
||||
* @return {@link DistributionSetTagAssignmentResult} with all meta data of
|
||||
* the assignment outcome.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||
DistributionSetTagAssignmentResult toggleTagAssignment(@NotEmpty Collection<Long> dsIds, @NotNull String tagName);
|
||||
|
||||
/**
|
||||
* Unassign all {@link DistributionSet} from a given
|
||||
* {@link DistributionSetTag} .
|
||||
*
|
||||
* @param tag
|
||||
* to unassign all ds
|
||||
* @return list of unassigned ds
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||
List<DistributionSet> unAssignAllDistributionSetsByTag(@NotNull DistributionSetTag tag);
|
||||
|
||||
/**
|
||||
* Unassigns a {@link SoftwareModule} form an existing
|
||||
* {@link DistributionSet}.
|
||||
*
|
||||
* @param ds
|
||||
* to get unassigned form
|
||||
* @param softwareModule
|
||||
* to get unassigned
|
||||
* @return the updated {@link DistributionSet}.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||
DistributionSet unassignSoftwareModule(@NotNull DistributionSet ds, @NotNull SoftwareModule softwareModule);
|
||||
|
||||
/**
|
||||
* Unassign a {@link DistributionSetTag} assignment to given
|
||||
* {@link DistributionSet}.
|
||||
*
|
||||
* @param dsId
|
||||
* to unassign for
|
||||
* @param distributionSetTag
|
||||
* to unassign
|
||||
* @return the unassigned ds or <null> if no ds is unassigned
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||
DistributionSet unAssignTag(@NotNull Long dsId, @NotNull DistributionSetTag distributionSetTag);
|
||||
|
||||
/**
|
||||
* Updates existing {@link DistributionSet}.
|
||||
*
|
||||
* @param ds
|
||||
* to update
|
||||
* @return the saved {@link Entity}.
|
||||
* @throws NullPointerException
|
||||
* of {@link DistributionSet#getId()} is <code>null</code>
|
||||
* @throw DataDependencyViolationException in case of illegal update
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||
DistributionSet updateDistributionSet(@NotNull DistributionSet ds);
|
||||
|
||||
/**
|
||||
* updates a distribution set meta data value if corresponding entry exists.
|
||||
*
|
||||
* @param metadata
|
||||
* the meta data entry to be updated
|
||||
* @return the updated meta data entry
|
||||
* @throws EntityNotFoundException
|
||||
* in case the meta data entry does not exists and cannot be
|
||||
* updated
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||
DistributionSetMetadata updateDistributionSetMetadata(@NotNull DistributionSetMetadata metadata);
|
||||
|
||||
/**
|
||||
* Updates existing {@link DistributionSetType}. However, keep in mind that
|
||||
* is not possible to change the {@link DistributionSetTypeElement}s while
|
||||
* the DS type is already in use.
|
||||
*
|
||||
* @param dsType
|
||||
* to update
|
||||
* @return updated {@link Entity}
|
||||
*
|
||||
* @throws EntityReadOnlyException
|
||||
* if use tries to change the {@link DistributionSetTypeElement}
|
||||
* s while the DS type is already in use.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||
DistributionSetType updateDistributionSetType(@NotNull DistributionSetType dsType);
|
||||
|
||||
DistributionSet generateDistributionSet(String name, String version, String description, DistributionSetType type,
|
||||
Collection<SoftwareModule> moduleList);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Sort;
|
||||
|
||||
/**
|
||||
* An implementation of the {@link PageRequest} which is offset based by means
|
||||
* the offset is given and not the page number as in the original
|
||||
* {@link PageRequest} implementation where the offset is generated. Due that
|
||||
* the REST-API is working with {@code offset} and {@code limit} parameter we
|
||||
* need an offset based page request.
|
||||
*/
|
||||
public final class OffsetBasedPageRequest extends PageRequest {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final int offset;
|
||||
|
||||
/**
|
||||
* Creates a new {@link OffsetBasedPageRequest}. Offsets are zero indexed,
|
||||
* thus providing 0 for {@code offset} will return the first entry.
|
||||
*
|
||||
* @param offset
|
||||
* zero-based offset index.
|
||||
* @param limit
|
||||
* the limit of the page to be returned.
|
||||
*/
|
||||
public OffsetBasedPageRequest(final int offset, final int limit) {
|
||||
this(offset, limit, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link OffsetBasedPageRequest}. Offsets are zero indexed,
|
||||
* thus providing 0 for {@code offset} will return the first entry.
|
||||
*
|
||||
* @param offset
|
||||
* zero-based offset index.
|
||||
* @param limit
|
||||
* the limit of the page to be returned.
|
||||
* @param sort
|
||||
* sort can be {@literal null}.
|
||||
*/
|
||||
public OffsetBasedPageRequest(final int offset, final int limit, final Sort sort) {
|
||||
super(0, limit, sort);
|
||||
this.offset = offset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOffset() {
|
||||
return offset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "OffsetBasedPageRequest [offset=" + offset + ", getPageSize()=" + getPageSize() + ", getPageNumber()="
|
||||
+ getPageNumber() + "]";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,210 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.YearMonth;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
|
||||
import org.eclipse.hawkbit.report.model.DataReportSeries;
|
||||
import org.eclipse.hawkbit.report.model.InnerOuterDataReportSeries;
|
||||
import org.eclipse.hawkbit.report.model.ListReportSeries;
|
||||
import org.eclipse.hawkbit.report.model.SeriesTime;
|
||||
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
||||
/**
|
||||
* Service layer for generating hawkBit statistics and reports.
|
||||
*
|
||||
*/
|
||||
public interface ReportManagement {
|
||||
|
||||
/**
|
||||
* Data base format.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param <T>
|
||||
*/
|
||||
public interface DateType<T> {
|
||||
/**
|
||||
* @param s
|
||||
* @return T
|
||||
*/
|
||||
T format(String s);
|
||||
|
||||
/**
|
||||
* h2 format.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
String h2Format();
|
||||
|
||||
/**
|
||||
* mysql format.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
String mySqlFormat();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return DateTypes.
|
||||
*/
|
||||
public static final class DateTypes implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final PerMonth PER_MONTH = new PerMonth();
|
||||
|
||||
private DateTypes() {
|
||||
// Utility class
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PerMonth
|
||||
*/
|
||||
public static PerMonth perMonth() {
|
||||
return PER_MONTH;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gives the date format based on DB H2 or mySql.
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public static final class PerMonth implements DateType<LocalDate>, Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final String DATE_PATTERN = "yyyy-MM";
|
||||
|
||||
@Override
|
||||
public LocalDate format(final String s) {
|
||||
final DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DATE_PATTERN);
|
||||
final YearMonth ym = YearMonth.parse(s, formatter);
|
||||
return ym.atDay(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String h2Format() {
|
||||
return DATE_PATTERN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String mySqlFormat() {
|
||||
return "%Y-%m";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a report of the top x distribution set assigned usage as a list
|
||||
* of {@link InnerOuterDataReportSeries} which is ideal for generate a donut
|
||||
* chart out of it. The inner series contains the distribution set names and
|
||||
* total count usage. The outer series contains each version usage and its
|
||||
* usage count. {@code inner: ds1:5 -> outer: vers 0.0.0:3, vers 1.0.0:2}
|
||||
* {@code inner: ds2:1 -> outer: vers 0.0.1:1}
|
||||
*
|
||||
* The top x entries are seperated within the series, the rest of the
|
||||
* distribution sets usage are summarized to a "misc" series.
|
||||
*
|
||||
* @param topXEntries
|
||||
* the top entries which should be shown, the rest distribution
|
||||
* set entries are summarized as "misc"
|
||||
* @return a list of inner and outer series of distribution set usage
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
List<InnerOuterDataReportSeries<String>> distributionUsageAssigned(int topXEntries);
|
||||
|
||||
/**
|
||||
* Generates a report of the top x distribution set installed usage as a
|
||||
* list of {@link InnerOuterDataReportSeries} which is ideal for generate a
|
||||
* donut chart out of it. The inner series contains the distribution set
|
||||
* names and total count usage. The outer series contains each version usage
|
||||
* and its usage count.
|
||||
* {@code inner: ds1:5 -> outer: vers 0.0.0:3, vers 1.0.0:2}
|
||||
* {@code inner: ds2:1 -> outer: vers 0.0.1:1}
|
||||
*
|
||||
* The top x entries are seperated within the series, the rest of the
|
||||
* distribution sets usage are summarized to a "misc" series.
|
||||
*
|
||||
* @param topXEntries
|
||||
* the top entries which should be shown, the rest distribution
|
||||
* set entries are summarized as "misc"
|
||||
* @return a list of inner and outer series of distribution set usage
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
List<InnerOuterDataReportSeries<String>> distributionUsageInstalled(int topXEntries);
|
||||
|
||||
/**
|
||||
* Generates report for feedback over period.
|
||||
*
|
||||
* @param dateType
|
||||
* {@link PerMonth}
|
||||
* @param from
|
||||
* start date
|
||||
* @param to
|
||||
* end date
|
||||
* @return <T> DataReportSeries<T> ListReportSeries list of action status
|
||||
* count
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
<T extends Serializable> DataReportSeries<T> feedbackReceivedOverTime(@NotNull DateType<T> dateType,
|
||||
@NotNull LocalDateTime from, @NotNull LocalDateTime to);
|
||||
|
||||
/**
|
||||
* Generates report for target created over period.
|
||||
*
|
||||
* @param dateType
|
||||
* {@link PerMonth}
|
||||
* @param from
|
||||
* start date
|
||||
* @param to
|
||||
* end date
|
||||
* @return <T> DataReportSeries<T> ListReportSeries list of target created
|
||||
* count
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
<T extends Serializable> DataReportSeries<T> targetsCreatedOverPeriod(@NotNull DateType<T> dateType,
|
||||
@NotNull LocalDateTime from, @NotNull LocalDateTime to);
|
||||
|
||||
/**
|
||||
* Generates a report as a {@link ListReportSeries} targets polled based on
|
||||
* the {@link TargetStatus#getLastTargetQuery()} within an hour, day, week,
|
||||
* month, year, more than a year, never.
|
||||
*
|
||||
* The order of the numbers within the {@link DataReportSeries} is the order
|
||||
* hour, day, week, month, year, more than a year, never.
|
||||
*
|
||||
* @return a {@link DataReportSeries} which contains the number of targets
|
||||
* which have not been polled in the last hour, day, ... year,more
|
||||
* than a year, never.
|
||||
*
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
DataReportSeries<SeriesTime> targetsLastPoll();
|
||||
|
||||
/**
|
||||
* Generates a report of all targets of their current update status count.
|
||||
* For each {@link TargetUpdateStatus} an total count of targets which are
|
||||
* in this status currently.
|
||||
*
|
||||
* @return a data report series which contains the target count for each
|
||||
* target update status
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
DataReportSeries<TargetUpdateStatus> targetStatus();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
|
||||
import org.eclipse.hawkbit.repository.model.Rollout;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroup;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.eclipse.hawkbit.repository.model.TargetWithActionStatus;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
||||
/**
|
||||
* Repository management service for RolloutGroup.
|
||||
*
|
||||
*/
|
||||
public interface RolloutGroupManagement {
|
||||
|
||||
/**
|
||||
* Retrieves a page of {@link RolloutGroup}s filtered by a given
|
||||
* {@link Rollout} with the detailed status.
|
||||
*
|
||||
* @param rolloutId
|
||||
* the ID of the rollout to filter the {@link RolloutGroup}s
|
||||
* @param pageable
|
||||
* the page request to sort and limit the result
|
||||
* @return a page of found {@link RolloutGroup}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||
Page<RolloutGroup> findAllRolloutGroupsWithDetailedStatus(@NotNull Long rolloutId, @NotNull Pageable pageable);
|
||||
|
||||
/**
|
||||
*
|
||||
* Find all targets with action status by rollout group id. The action
|
||||
* status might be {@code null} if for the target within the rollout no
|
||||
* actions as been created, e.g. the target already had assigned the same
|
||||
* distribution set we do not create an action for it but the target is in
|
||||
* the result list of the rollout-group.
|
||||
*
|
||||
* @param pageRequest
|
||||
* the page request to sort and limit the result
|
||||
* @param rolloutGroup
|
||||
* rollout group
|
||||
* @return {@link TargetWithActionStatus} target with action status
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ_AND_TARGET_READ)
|
||||
Page<TargetWithActionStatus> findAllTargetsWithActionStatus(@NotNull PageRequest pageRequest,
|
||||
@NotNull RolloutGroup rolloutGroup);
|
||||
|
||||
/**
|
||||
* Retrieves a single {@link RolloutGroup} by its ID.
|
||||
*
|
||||
* @param rolloutGroupId
|
||||
* the ID of the rollout group to find
|
||||
* @return the found {@link RolloutGroup} by its ID or {@code null} if it
|
||||
* does not exists
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||
RolloutGroup findRolloutGroupById(@NotNull Long rolloutGroupId);
|
||||
|
||||
/**
|
||||
* Retrieves a page of {@link RolloutGroup}s filtered by a given
|
||||
* {@link Rollout} and the given {@link Specification}.
|
||||
*
|
||||
* @param rolloutId
|
||||
* the ID of the rollout to filter the {@link RolloutGroup}s
|
||||
* @param specification
|
||||
* the specification to filter the result set based on attributes
|
||||
* of the {@link RolloutGroup}
|
||||
* @param pageable
|
||||
* the page request to sort and limit the result
|
||||
* @return a page of found {@link RolloutGroup}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||
Page<RolloutGroup> findRolloutGroupsAll(@NotNull Rollout rollout, @NotNull String rsqlParam,
|
||||
@NotNull Pageable pageable);
|
||||
|
||||
/**
|
||||
* Retrieves a page of {@link RolloutGroup}s filtered by a given
|
||||
* {@link Rollout}.
|
||||
*
|
||||
* @param rolloutId
|
||||
* the ID of the rollout to filter the {@link RolloutGroup}s
|
||||
* @param pageable
|
||||
* the page request to sort and limit the result
|
||||
* @return a page of found {@link RolloutGroup}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||
Page<RolloutGroup> findRolloutGroupsByRolloutId(@NotNull Long rolloutId, @NotNull Pageable pageable);
|
||||
|
||||
/**
|
||||
* Get targets of specified rollout group.
|
||||
*
|
||||
* @param rolloutGroup
|
||||
* rollout group
|
||||
* @param page
|
||||
* the page request to sort and limit the result
|
||||
*
|
||||
* @return Page<Target> list of targets of a rollout group
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ_AND_TARGET_READ)
|
||||
Page<Target> findRolloutGroupTargets(@NotNull RolloutGroup rolloutGroup, @NotNull Pageable page);
|
||||
|
||||
/**
|
||||
* Get targets of specified rollout group.
|
||||
*
|
||||
* @param rolloutGroup
|
||||
* rollout group
|
||||
* @param specification
|
||||
* the specification for filtering the targets of a rollout group
|
||||
* @param pageable
|
||||
* the page request to sort and limit the result
|
||||
*
|
||||
* @return Page<Target> list of targets of a rollout group
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ_AND_TARGET_READ)
|
||||
Page<Target> findRolloutGroupTargets(@NotNull RolloutGroup rolloutGroup, @NotNull String rsqlParam,
|
||||
@NotNull Pageable pageable);
|
||||
|
||||
/**
|
||||
* Get count of targets in different status in rollout group.
|
||||
*
|
||||
* @param rolloutGroupId
|
||||
* rollout group id
|
||||
* @return rolloutGroup with details of targets count for different statuses
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||
RolloutGroup findRolloutGroupWithDetailedStatus(@NotNull Long rolloutGroupId);
|
||||
|
||||
/**
|
||||
* Generates an empty {@link RolloutGroup} without persisting it.
|
||||
*
|
||||
* @return {@link RolloutGroup} object
|
||||
*/
|
||||
RolloutGroup generateRolloutGroup();
|
||||
}
|
||||
@@ -0,0 +1,343 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import org.eclipse.hawkbit.eventbus.event.RolloutGroupCreatedEvent;
|
||||
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
|
||||
import org.eclipse.hawkbit.repository.exception.RolloutIllegalStateException;
|
||||
import org.eclipse.hawkbit.repository.model.Rollout;
|
||||
import org.eclipse.hawkbit.repository.model.Rollout.RolloutStatus;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroup;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupStatus;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroupConditions;
|
||||
import org.hibernate.validator.constraints.NotEmpty;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Slice;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
||||
/**
|
||||
* RolloutManagement to control rollouts e.g. like creating, starting, resuming
|
||||
* and pausing rollouts. This service secures all the functionality based on the
|
||||
* {@link PreAuthorize} annotation on methods.
|
||||
*/
|
||||
public interface RolloutManagement {
|
||||
|
||||
/**
|
||||
* Checking running rollouts. Rollouts which are checked updating the
|
||||
* {@link Rollout#setLastCheck(long)} to indicate that the current instance
|
||||
* is handling the specific rollout. This code should run as system-code.
|
||||
*
|
||||
* <pre>
|
||||
* {@code
|
||||
* SystemSecurityContext.runAsSystem(new Callable<Void>() {
|
||||
* public Void call() throws Exception {
|
||||
* //run system-code
|
||||
* }
|
||||
* });
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* This method is attend to be called by a scheduler.
|
||||
* {@link RolloutScheduler}. And must be running in an transaction so it's
|
||||
* splitted from the scheduler.
|
||||
*
|
||||
* Rollouts which are currently running are investigated, by means the
|
||||
* error- and finish condition of running groups in this rollout are
|
||||
* evaluated.
|
||||
*
|
||||
* @param delayBetweenChecks
|
||||
* the time in milliseconds of the delay between the further and
|
||||
* this check. This check is only applied if the last check is
|
||||
* less than (lastcheck-delay).
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_WRITE + SpringEvalExpressions.HAS_AUTH_OR
|
||||
+ SpringEvalExpressions.IS_SYSTEM_CODE)
|
||||
void checkRunningRollouts(long delayBetweenChecks);
|
||||
|
||||
/**
|
||||
* Counts all {@link Rollout}s in the repository.
|
||||
*
|
||||
* @return number of roll outs
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||
Long countRolloutsAll();
|
||||
|
||||
/**
|
||||
* Count rollouts by given text in name or description.
|
||||
*
|
||||
* @param searchText
|
||||
* name or description
|
||||
* @return total count rollouts for specified filter text.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||
Long countRolloutsAllByFilters(@NotEmpty String searchText);
|
||||
|
||||
/**
|
||||
* Persists a new rollout entity. The filter within the
|
||||
* {@link Rollout#getTargetFilterQuery()} is used to retrieve the targets
|
||||
* which are effected by this rollout to create. The targets will then be
|
||||
* split up into groups. The size of the groups can be defined in the
|
||||
* {@code groupSize} parameter.
|
||||
*
|
||||
* The rollout is not started. Only the preparation of the rollout is done,
|
||||
* persisting and creating all the necessary groups. The Rollout and the
|
||||
* groups are persisted in {@link RolloutStatus#READY} and
|
||||
* {@link RolloutGroupStatus#READY} so they can be started
|
||||
* {@link #startRollout(Rollout)}.
|
||||
*
|
||||
* @param rollout
|
||||
* the rollout entity to create
|
||||
* @param amountGroup
|
||||
* the amount of groups to split the rollout into
|
||||
* @param conditions
|
||||
* the rolloutgroup conditions and actions which should be
|
||||
* applied for each {@link RolloutGroup}
|
||||
* @return the persisted rollout.
|
||||
*
|
||||
* @throws IllegalArgumentException
|
||||
* in case the given groupSize is zero or lower.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_WRITE)
|
||||
Rollout createRollout(@NotNull Rollout rollout, int amountGroup, @NotNull RolloutGroupConditions conditions);
|
||||
|
||||
/**
|
||||
* Persists a new rollout entity. The filter within the
|
||||
* {@link Rollout#getTargetFilterQuery()} is used to retrieve the targets
|
||||
* which are effected by this rollout to create. The creation of the rollout
|
||||
* will be done synchronously and will be returned. The targets will then be
|
||||
* split up into groups. The size of the groups can be defined in the
|
||||
* {@code groupSize} parameter.
|
||||
*
|
||||
* The creation of the rollout groups is executed asynchronously due it
|
||||
* might take some time to split up the targets into groups. The creation of
|
||||
* the {@link RolloutGroup} is published as event
|
||||
* {@link RolloutGroupCreatedEvent}.
|
||||
*
|
||||
* The rollout is in status {@link RolloutStatus#CREATING} until all rollout
|
||||
* groups has been created and the targets are split up, then the rollout
|
||||
* will change the status to {@link RolloutStatus#READY}.
|
||||
*
|
||||
* The rollout is not started. Only the preparation of the rollout is done,
|
||||
* persisting and creating all the necessary groups. The Rollout and the
|
||||
* groups are persisted in {@link RolloutStatus#READY} and
|
||||
* {@link RolloutGroupStatus#READY} so they can be started
|
||||
* {@link #startRollout(Rollout)}.
|
||||
*
|
||||
* @param rollout
|
||||
* the rollout to be created
|
||||
* @param amountGroup
|
||||
* the number of groups should be created for the rollout and
|
||||
* split up the targets
|
||||
* @param conditions
|
||||
* the rolloutgroup conditions and actions which should be
|
||||
* applied for each {@link RolloutGroup}
|
||||
* @return the created rollout entity in state
|
||||
* {@link RolloutStatus#CREATING}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_WRITE)
|
||||
Rollout createRolloutAsync(@NotNull Rollout rollout, int amountGroup, @NotNull RolloutGroupConditions conditions);
|
||||
|
||||
/**
|
||||
* Retrieves all rollouts.
|
||||
*
|
||||
* @param pageable
|
||||
* the page request to sort and limit the result
|
||||
* @return a page of found rollouts
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||
Page<Rollout> findAll(@NotNull Pageable pageable);
|
||||
|
||||
/**
|
||||
* Get count of targets in different status in rollout.
|
||||
*
|
||||
* @param pageable
|
||||
* the page request to sort and limit the result
|
||||
* @return a list of rollouts with details of targets count for different
|
||||
* statuses
|
||||
*
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||
Page<Rollout> findAllRolloutsWithDetailedStatus(@NotNull Pageable pageable);
|
||||
|
||||
/**
|
||||
* Retrieves all rollouts found by the given specification.
|
||||
*
|
||||
* @param specification
|
||||
* the specification to filter rollouts
|
||||
* @param pageable
|
||||
* the page request to sort and limit the result
|
||||
* @return a page of found rollouts
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||
Page<Rollout> findAllWithDetailedStatusByPredicate(@NotNull String rsqlParam, @NotNull Pageable pageable);
|
||||
|
||||
/**
|
||||
* Finds rollouts by given text in name or description.
|
||||
*
|
||||
* @param pageable
|
||||
* the page request to sort and limit the result
|
||||
* @param searchText
|
||||
* search text which matches name or description of rollout
|
||||
* @return the founded rollout or {@code null} if rollout with given ID does
|
||||
* not exists
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||
Slice<Rollout> findRolloutByFilters(@NotNull Pageable pageable, @NotEmpty String searchText);
|
||||
|
||||
/**
|
||||
* Retrieves a specific rollout by its ID.
|
||||
*
|
||||
* @param rolloutId
|
||||
* the ID of the rollout to retrieve
|
||||
* @return the founded rollout or {@code null} if rollout with given ID does
|
||||
* not exists
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||
Rollout findRolloutById(@NotNull Long rolloutId);
|
||||
|
||||
/**
|
||||
* Retrieves a specific rollout by its name.
|
||||
*
|
||||
* @param rolloutName
|
||||
* the name of the rollout to retrieve
|
||||
* @return the founded rollout or {@code null} if rollout with given name
|
||||
* does not exists
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||
Rollout findRolloutByName(@NotNull String rolloutName);
|
||||
|
||||
/**
|
||||
* Get count of targets in different status in rollout.
|
||||
*
|
||||
* @param rolloutId
|
||||
* rollout id
|
||||
* @return rollout details of targets count for different statuses
|
||||
*
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||
Rollout findRolloutWithDetailedStatus(@NotNull Long rolloutId);
|
||||
|
||||
/***
|
||||
* Get finished percentage details for a specified group which is in running
|
||||
* state.
|
||||
*
|
||||
* @param rolloutId
|
||||
* the ID of the {@link Rollout}
|
||||
* @param rolloutGroup
|
||||
* the ID of the {@link RolloutGroup}
|
||||
* @return percentage finished
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_READ)
|
||||
float getFinishedPercentForRunningGroup(@NotNull Long rolloutId, @NotNull RolloutGroup rolloutGroup);
|
||||
|
||||
/**
|
||||
* Pauses a rollout which is currently running. The Rollout switches
|
||||
* {@link RolloutStatus#PAUSED}. {@link RolloutGroup}s which are currently
|
||||
* running will be untouched. {@link RolloutGroup}s which are
|
||||
* {@link RolloutGroupStatus#SCHEDULED} will not be started and keep in
|
||||
* {@link RolloutGroupStatus#SCHEDULED} state until the rollout is
|
||||
* {@link RolloutManagement#resumeRollout(Rollout)}.
|
||||
*
|
||||
* Switching the rollout status to {@link RolloutStatus#PAUSED} is
|
||||
* sufficient due the {@link #checkRunningRollouts(long)} will not check
|
||||
* this rollout anymore.
|
||||
*
|
||||
* @param rollout
|
||||
* the rollout to be paused.
|
||||
*
|
||||
* @throws RolloutIllegalStateException
|
||||
* if given rollout is not in {@link RolloutStatus#RUNNING}.
|
||||
* Only running rollouts can be paused.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_WRITE + SpringEvalExpressions.HAS_AUTH_OR
|
||||
+ SpringEvalExpressions.IS_SYSTEM_CODE)
|
||||
void pauseRollout(@NotNull Rollout rollout);
|
||||
|
||||
/**
|
||||
* Resumes a paused rollout. The rollout switches back to
|
||||
* {@link RolloutStatus#RUNNING} state which is then picked up again by the
|
||||
* {@link #checkRunningRollouts(long)}.
|
||||
*
|
||||
* @param rollout
|
||||
* the rollout to be resumed
|
||||
* @throws RolloutIllegalStateException
|
||||
* if given rollout is not in {@link RolloutStatus#PAUSED}. Only
|
||||
* paused rollouts can be resumed.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_WRITE + SpringEvalExpressions.HAS_AUTH_OR
|
||||
+ SpringEvalExpressions.IS_SYSTEM_CODE)
|
||||
void resumeRollout(@NotNull Rollout rollout);
|
||||
|
||||
/**
|
||||
* Starts a rollout which has been created. The rollout must be in
|
||||
* {@link RolloutStatus#READY} state. The according actions will be created
|
||||
* for each affected target in the rollout. The actions of the first group
|
||||
* will be started immediately {@link RolloutGroupStatus#RUNNING} as the
|
||||
* other groups will be {@link RolloutGroupStatus#SCHEDULED} state.
|
||||
*
|
||||
* The rollout itself will be then also in {@link RolloutStatus#RUNNING}.
|
||||
*
|
||||
* @param rollout
|
||||
* the rollout to be started
|
||||
*
|
||||
* @return started rollout
|
||||
*
|
||||
* @throws RolloutIllegalStateException
|
||||
* if given rollout is not in {@link RolloutStatus#READY}. Only
|
||||
* ready rollouts can be started.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_WRITE + SpringEvalExpressions.HAS_AUTH_OR
|
||||
+ SpringEvalExpressions.IS_SYSTEM_CODE)
|
||||
Rollout startRollout(@NotNull Rollout rollout);
|
||||
|
||||
/**
|
||||
* Starts a rollout asynchronously which has been created. The rollout must
|
||||
* be in {@link RolloutStatus#READY} state. The according actions will be
|
||||
* created asynchronously for each affected target in the rollout. The
|
||||
* actions of the first group will be started immediately
|
||||
* {@link RolloutGroupStatus#RUNNING} as the other groups will be
|
||||
* {@link RolloutGroupStatus#SCHEDULED} state.
|
||||
*
|
||||
* The rollout itself will be then also in {@link RolloutStatus#RUNNING}.
|
||||
*
|
||||
* @param rollout
|
||||
* the rollout to be started
|
||||
*
|
||||
* @return the started rollout
|
||||
*
|
||||
* @throws RolloutIllegalStateException
|
||||
* if given rollout is not in {@link RolloutStatus#READY}. Only
|
||||
* ready rollouts can be started.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_WRITE + SpringEvalExpressions.HAS_AUTH_OR
|
||||
+ SpringEvalExpressions.IS_SYSTEM_CODE)
|
||||
Rollout startRolloutAsync(@NotNull Rollout rollout);
|
||||
|
||||
/**
|
||||
* Update rollout details.
|
||||
*
|
||||
* @param rollout
|
||||
* rollout to be updated
|
||||
*
|
||||
* @return Rollout updated rollout
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_ROLLOUT_MANAGEMENT_WRITE)
|
||||
Rollout updateRollout(@NotNull Rollout rollout);
|
||||
|
||||
/**
|
||||
* Generates an empty {@link Rollout} without persisting it.
|
||||
*
|
||||
* @return {@link Rollout} object
|
||||
*/
|
||||
Rollout generateRollout();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* Rollout Management properties.
|
||||
*
|
||||
*/
|
||||
@Component
|
||||
@ConfigurationProperties("hawkbit.rollout")
|
||||
public class RolloutProperties {
|
||||
/**
|
||||
* Rollout scheduler configuration.
|
||||
*/
|
||||
public static class Scheduler {
|
||||
// used by @Scheduled annotation which needs constant
|
||||
public static final String PROP_SCHEDULER_DELAY_PLACEHOLDER = "${hawkbit.rollout.scheduler.fixedDelay:30000}";
|
||||
|
||||
/**
|
||||
* Schedule where the rollout scheduler looks necessary state changes in
|
||||
* milliseconds.
|
||||
*/
|
||||
private long fixedDelay = 30000L;
|
||||
|
||||
public long getFixedDelay() {
|
||||
return fixedDelay;
|
||||
}
|
||||
|
||||
public void setFixedDelay(final long fixedDelay) {
|
||||
this.fixedDelay = fixedDelay;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private final Scheduler scheduler = new Scheduler();
|
||||
|
||||
public Scheduler getScheduler() {
|
||||
return scheduler;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.hawkbit.security.SystemSecurityContext;
|
||||
import org.eclipse.hawkbit.tenancy.TenantAware;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* Scheduler to schedule the
|
||||
* {@link RolloutManagement#checkRunningRollouts(long)}. The delay between the
|
||||
* checks be be configured using the property
|
||||
* {@link #PROP_SCHEDULER_DELAY_PLACEHOLDER}.
|
||||
*/
|
||||
@Component
|
||||
// don't active the rollout scheduler in test, otherwise it is hard to test
|
||||
// rolloutmanagement and leads weird side-effects maybe.
|
||||
@Profile("!test")
|
||||
public class RolloutScheduler {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(RolloutScheduler.class);
|
||||
|
||||
@Autowired
|
||||
private TenantAware tenantAware;
|
||||
|
||||
@Autowired
|
||||
private SystemManagement systemManagement;
|
||||
|
||||
@Autowired
|
||||
private RolloutManagement rolloutManagement;
|
||||
|
||||
@Autowired
|
||||
private SystemSecurityContext systemSecurityContext;
|
||||
|
||||
@Autowired
|
||||
private RolloutProperties rolloutProperties;
|
||||
|
||||
/**
|
||||
* Scheduler method called by the spring-async mechanism. Retrieves all
|
||||
* tenants from the {@link SystemManagement#findTenants()} and runs for each
|
||||
* tenant the {@link RolloutManagement#checkRunningRollouts(long)} in the
|
||||
* {@link SystemSecurityContext}.
|
||||
*/
|
||||
@Scheduled(initialDelayString = RolloutProperties.Scheduler.PROP_SCHEDULER_DELAY_PLACEHOLDER, fixedDelayString = RolloutProperties.Scheduler.PROP_SCHEDULER_DELAY_PLACEHOLDER)
|
||||
public void rolloutScheduler() {
|
||||
LOGGER.debug("rollout schedule checker has been triggered.");
|
||||
// run this code in system code privileged to have the necessary
|
||||
// permission to query and create entities.
|
||||
systemSecurityContext.runAsSystem(() -> {
|
||||
// workaround eclipselink that is currently not possible to
|
||||
// execute a query without multitenancy if MultiTenant
|
||||
// annotation is used.
|
||||
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=355458. So
|
||||
// iterate through all tenants and execute the rollout check for
|
||||
// each tenant seperately.
|
||||
final List<String> tenants = systemManagement.findTenants();
|
||||
LOGGER.info("Checking rollouts for {} tenants", tenants.size());
|
||||
for (final String tenant : tenants) {
|
||||
tenantAware.runAsTenant(tenant, () -> {
|
||||
rolloutManagement.checkRunningRollouts(rolloutProperties.getScheduler().getFixedDelay());
|
||||
return null;
|
||||
});
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,512 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
|
||||
import org.eclipse.hawkbit.repository.model.AssignedSoftwareModule;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
|
||||
import org.hibernate.validator.constraints.NotEmpty;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Slice;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
||||
/**
|
||||
* Service for managing {@link SoftwareModule}s.
|
||||
*
|
||||
*/
|
||||
public interface SoftwareManagement {
|
||||
|
||||
/**
|
||||
* Counts {@link SoftwareModule}s with given
|
||||
* {@link SoftwareModule#getName()} or {@link SoftwareModule#getVersion()}
|
||||
* and {@link SoftwareModule#getType()} that are not marked as deleted.
|
||||
*
|
||||
* @param searchText
|
||||
* to search for in name and version
|
||||
* @param type
|
||||
* to filter the result
|
||||
* @return number of found {@link SoftwareModule}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Long countSoftwareModuleByFilters(String searchText, SoftwareModuleType type);
|
||||
|
||||
/**
|
||||
* Count all {@link SoftwareModule}s in the repository that are not marked
|
||||
* as deleted.
|
||||
*
|
||||
* @return number of {@link SoftwareModule}s
|
||||
*/
|
||||
@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.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Long countSoftwareModuleTypesAll();
|
||||
|
||||
/**
|
||||
* Create {@link SoftwareModule}s in the repository.
|
||||
*
|
||||
* @param swModules
|
||||
* {@link SoftwareModule}s to create
|
||||
* @return SoftwareModule
|
||||
* @throws EntityAlreadyExistsException
|
||||
* if a given entity already exists
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
||||
List<SoftwareModule> createSoftwareModule(@NotNull Collection<SoftwareModule> swModules);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param swModule
|
||||
* SoftwareModule to create
|
||||
* @return SoftwareModule
|
||||
* @throws EntityAlreadyExistsException
|
||||
* if a given entity already exists
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
||||
SoftwareModule createSoftwareModule(@NotNull SoftwareModule swModule);
|
||||
|
||||
/**
|
||||
* creates a list of software module meta data entries.
|
||||
*
|
||||
* @param metadata
|
||||
* the meta data entries to create or update
|
||||
* @return the updated or created software module meta data entries
|
||||
* @throws EntityAlreadyExistsException
|
||||
* in case one of the meta data entry already exists for the
|
||||
* specific key
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||
List<SoftwareModuleMetadata> createSoftwareModuleMetadata(@NotNull Collection<SoftwareModuleMetadata> metadata);
|
||||
|
||||
/**
|
||||
* creates or updates a single software module meta data entry.
|
||||
*
|
||||
* @param metadata
|
||||
* the meta data entry to create or update
|
||||
* @return the updated or created software module meta data entry
|
||||
* @throws EntityAlreadyExistsException
|
||||
* in case the meta data entry already exists for the specific
|
||||
* key
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||
SoftwareModuleMetadata createSoftwareModuleMetadata(@NotNull SoftwareModuleMetadata metadata);
|
||||
|
||||
/**
|
||||
* Creates multiple {@link SoftwareModuleType}s.
|
||||
*
|
||||
* @param types
|
||||
* to create
|
||||
* @return created {@link Entity}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
||||
List<SoftwareModuleType> createSoftwareModuleType(@NotNull final Collection<SoftwareModuleType> types);
|
||||
|
||||
/**
|
||||
* Creates new {@link SoftwareModuleType}.
|
||||
*
|
||||
* @param type
|
||||
* to create
|
||||
* @return created {@link Entity}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
||||
SoftwareModuleType createSoftwareModuleType(@NotNull SoftwareModuleType type);
|
||||
|
||||
/**
|
||||
* Deletes the given {@link SoftwareModule} {@link Entity}.
|
||||
*
|
||||
* @param bsm
|
||||
* is the {@link SoftwareModule} to be deleted
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
|
||||
void deleteSoftwareModule(@NotNull SoftwareModule bsm);
|
||||
|
||||
/**
|
||||
* deletes a software module meta data entry.
|
||||
*
|
||||
* @param id
|
||||
* the ID of the software module meta data to delete
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||
void deleteSoftwareModuleMetadata(@NotNull SoftwareModule softwareModule, @NotNull String key);
|
||||
|
||||
/**
|
||||
* Deletes {@link SoftwareModule}s which is any if the given ids.
|
||||
*
|
||||
* @param ids
|
||||
* of the Software Modules to be deleted
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
|
||||
void deleteSoftwareModules(@NotNull Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* Deletes or marks as delete in case the type is in use.
|
||||
*
|
||||
* @param type
|
||||
* to delete
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
|
||||
void deleteSoftwareModuleType(@NotNull SoftwareModuleType type);
|
||||
|
||||
/**
|
||||
* @param pageable
|
||||
* the page request to page the result set
|
||||
* @param set
|
||||
* to search for
|
||||
* @return all {@link SoftwareModule}s that are assigned to given
|
||||
* {@link DistributionSet}.
|
||||
*/
|
||||
@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()}
|
||||
* and {@link SoftwareModule#getType()} that are not marked as deleted.
|
||||
*
|
||||
* @param pageable
|
||||
* page parameter
|
||||
* @param searchText
|
||||
* to be filtered as "like" on {@link SoftwareModule#getName()}
|
||||
* @param type
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* 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 {@link SoftwareModule} by their name AND version AND type..
|
||||
*
|
||||
* @param name
|
||||
* of the {@link SoftwareModule}
|
||||
* @param version
|
||||
* of the {@link SoftwareModule}
|
||||
* @param type
|
||||
* of the {@link SoftwareModule}
|
||||
* @return the found {@link SoftwareModule} or <code>null</code>
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
SoftwareModule findSoftwareModuleByNameAndVersion(@NotEmpty String name, @NotEmpty String version,
|
||||
@NotNull SoftwareModuleType type);
|
||||
|
||||
/**
|
||||
* finds a single software module meta data by its id.
|
||||
*
|
||||
* @param id
|
||||
* the id of the software module meta data containing the meta
|
||||
* data key and the ID of the software module
|
||||
* @return the found SoftwareModuleMetadata or {@code null} if not exits
|
||||
* @throws EntityNotFoundException
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* finds all meta data by the given software module id.
|
||||
*
|
||||
* @param swId
|
||||
* the software module id to retrieve the meta data from
|
||||
* @param pageable
|
||||
* the page request to page the result
|
||||
* @return a paged result of all meta data entries for a given software
|
||||
* module id
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Page<SoftwareModuleMetadata> findSoftwareModuleMetadataBySoftwareModuleId(@NotNull Long swId,
|
||||
@NotNull Pageable pageable);
|
||||
|
||||
/**
|
||||
* finds all meta data by the given software module id.
|
||||
*
|
||||
* @param softwareModuleId
|
||||
* the software module id to retrieve the meta data from
|
||||
* @param spec
|
||||
* the specification to filter the result
|
||||
* @param pageable
|
||||
* the page request to page the result
|
||||
* @return a paged result of all meta data entries for a given software
|
||||
* module id
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Page<SoftwareModuleMetadata> findSoftwareModuleMetadataBySoftwareModuleId(@NotNull Long softwareModuleId,
|
||||
@NotNull String rsqlParam, @NotNull Pageable pageable);
|
||||
|
||||
/**
|
||||
* Filter {@link SoftwareModule}s with given
|
||||
* {@link SoftwareModule#getName()} or {@link SoftwareModule#getVersion()}
|
||||
* search text and {@link SoftwareModule#getType()} that are not marked as
|
||||
* deleted and sort them by means of given distribution set related modules
|
||||
* on top of the list.
|
||||
*
|
||||
* After that the modules are sorted by {@link SoftwareModule#getName()} and
|
||||
* {@link SoftwareModule#getVersion()} in ascending order.
|
||||
*
|
||||
* @param pageable
|
||||
* page parameter
|
||||
* @param orderByDistributionId
|
||||
* the ID of distribution set to be ordered on top
|
||||
* @param searchText
|
||||
* filtered as "like" on {@link SoftwareModule#getName()}
|
||||
* @param type
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* Retrieves all software modules. Deleted ones are filtered.
|
||||
*
|
||||
* @param pageable
|
||||
* pagination parameter
|
||||
* @return the found {@link SoftwareModule}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Slice<SoftwareModule> findSoftwareModulesAll(@NotNull Pageable pageable);
|
||||
|
||||
/**
|
||||
* Retrieves all software modules with a given list of ids
|
||||
* {@link SoftwareModule#getId()}.
|
||||
*
|
||||
* @param ids
|
||||
* to search for
|
||||
* @return {@link List} of found {@link SoftwareModule}s
|
||||
*/
|
||||
List<SoftwareModule> findSoftwareModulesById(@NotEmpty Collection<Long> ids);
|
||||
|
||||
/**
|
||||
* Retrieves all {@link SoftwareModule}s with a given specification.
|
||||
*
|
||||
* @param spec
|
||||
* the specification to filter the software modules
|
||||
* @param pageable
|
||||
* pagination parameter
|
||||
* @return the found {@link SoftwareModule}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Page<SoftwareModule> findSoftwareModulesByPredicate(@NotNull String rsqlParam, @NotNull Pageable pageable);
|
||||
|
||||
/**
|
||||
* retrieves the {@link SoftwareModule}s by their {@link SoftwareModuleType}
|
||||
* .
|
||||
*
|
||||
* @param pageable
|
||||
* page parameters
|
||||
* @param type
|
||||
* 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);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param id
|
||||
* to search for
|
||||
* @return {@link SoftwareModuleType} in the repository with given
|
||||
* {@link SoftwareModuleType#getId()}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
SoftwareModuleType findSoftwareModuleTypeById(@NotNull Long id);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param key
|
||||
* to search for
|
||||
* @return {@link SoftwareModuleType} in the repository with given
|
||||
* {@link SoftwareModuleType#getKey()}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
SoftwareModuleType findSoftwareModuleTypeByKey(@NotNull String key);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param name
|
||||
* to search for
|
||||
* @return all {@link SoftwareModuleType}s in the repository with given
|
||||
* {@link SoftwareModuleType#getName()}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
SoftwareModuleType findSoftwareModuleTypeByName(@NotNull String name);
|
||||
|
||||
/**
|
||||
* @param pageable
|
||||
* parameter
|
||||
* @return all {@link SoftwareModuleType}s in the repository.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Page<SoftwareModuleType> findSoftwareModuleTypesAll(@NotNull Pageable pageable);
|
||||
|
||||
/**
|
||||
* Retrieves all {@link SoftwareModuleType}s with a given specification.
|
||||
*
|
||||
* @param spec
|
||||
* the specification to filter the software modules types
|
||||
* @param pageable
|
||||
* pagination parameter
|
||||
* @return the found {@link SoftwareModuleType}s
|
||||
*/
|
||||
@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()}
|
||||
* {@link SoftwareModule#getVendor()}.
|
||||
*
|
||||
* @param sm
|
||||
* to update
|
||||
*
|
||||
* @return the saved {@link Entity}.
|
||||
*
|
||||
* @throws NullPointerException
|
||||
* of {@link SoftwareModule#getId()} is <code>null</code>
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||
SoftwareModule updateSoftwareModule(@NotNull SoftwareModule sm);
|
||||
|
||||
/**
|
||||
* updates a distribution set meta data value if corresponding entry exists.
|
||||
*
|
||||
* @param metadata
|
||||
* the meta data entry to be updated
|
||||
* @return the updated meta data entry
|
||||
* @throws EntityNotFoundException
|
||||
* in case the meta data entry does not exists and cannot be
|
||||
* updated
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||
SoftwareModuleMetadata updateSoftwareModuleMetadata(@NotNull SoftwareModuleMetadata metadata);
|
||||
|
||||
/**
|
||||
* Updates existing {@link SoftwareModuleType}. Update-able value is
|
||||
* {@link SoftwareModuleType#getDescription()} and
|
||||
* {@link SoftwareModuleType#getColour()}.
|
||||
*
|
||||
* @param sm
|
||||
* to update
|
||||
* @return updated {@link Entity}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||
SoftwareModuleType updateSoftwareModuleType(@NotNull SoftwareModuleType sm);
|
||||
|
||||
/**
|
||||
* Generates an empty {@link SoftwareModuleType} without persisting it.
|
||||
*
|
||||
* @return {@link SoftwareModuleType} object
|
||||
*/
|
||||
SoftwareModuleType generateSoftwareModuleType();
|
||||
|
||||
/**
|
||||
* Generates an empty {@link SoftwareModule} without persisting it.
|
||||
*
|
||||
* @return {@link SoftwareModule} object
|
||||
*/
|
||||
SoftwareModule generateSoftwareModule();
|
||||
|
||||
/**
|
||||
* Generates a {@link SoftwareModule} without persisting it.
|
||||
*
|
||||
* @param type
|
||||
* of the {@link SoftwareModule}
|
||||
* @param name
|
||||
* abstract name of the {@link SoftwareModule}
|
||||
* @param version
|
||||
* of the {@link SoftwareModule}
|
||||
* @param description
|
||||
* of the {@link SoftwareModule}
|
||||
* @param vendor
|
||||
* of the {@link SoftwareModule}
|
||||
*
|
||||
* @return {@link SoftwareModule} object
|
||||
*/
|
||||
SoftwareModule generateSoftwareModule(SoftwareModuleType type, String name, String version, String description,
|
||||
String vendor);
|
||||
|
||||
/**
|
||||
* Generates an empty {@link SoftwareModuleMetadata} pair without persisting
|
||||
* it.
|
||||
*
|
||||
* @return {@link SoftwareModuleMetadata} object
|
||||
*/
|
||||
SoftwareModuleMetadata generateSoftwareModuleMetadata();
|
||||
|
||||
SoftwareModuleMetadata generateSoftwareModuleMetadata(SoftwareModule softwareModule, String key, String value);
|
||||
|
||||
SoftwareModuleType generateSoftwareModuleType(final String key, final String name, final String description,
|
||||
final int maxAssignments);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
|
||||
import org.eclipse.hawkbit.report.model.SystemUsageReport;
|
||||
import org.eclipse.hawkbit.repository.model.TenantMetaData;
|
||||
import org.eclipse.hawkbit.tenancy.TenantAware;
|
||||
import org.springframework.cache.interceptor.KeyGenerator;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
||||
/**
|
||||
* Central system management operations of the update server.
|
||||
*
|
||||
*/
|
||||
public interface SystemManagement {
|
||||
|
||||
/**
|
||||
* Checks if a specific tenant exists. The tenant will not be created lazy.
|
||||
*
|
||||
* @return {@code true} in case the tenant exits or {@code false} if not
|
||||
*/
|
||||
String currentTenant();
|
||||
|
||||
/**
|
||||
* Deletes all data related to a given tenant.
|
||||
*
|
||||
* @param tenant
|
||||
* to delete
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_SYSTEM_ADMIN)
|
||||
void deleteTenant(@NotNull String tenant);
|
||||
|
||||
/**
|
||||
*
|
||||
* @return list of all tenant names in the system.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_SYSTEM_ADMIN + SpringEvalExpressions.HAS_AUTH_OR
|
||||
+ SpringEvalExpressions.IS_SYSTEM_CODE)
|
||||
List<String> findTenants();
|
||||
|
||||
/**
|
||||
* Calculated system usage statistics, both overall for the entire system
|
||||
* and per tenant;
|
||||
*
|
||||
* @return SystemUsageReport of the current system
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_SYSTEM_ADMIN)
|
||||
SystemUsageReport getSystemUsageStatistics();
|
||||
|
||||
/**
|
||||
* @return {@link TenantMetaData} of {@link TenantAware#getCurrentTenant()}
|
||||
*/
|
||||
TenantMetaData getTenantMetadata();
|
||||
|
||||
// TODO figure out why this is necessary and clean this up
|
||||
@Bean
|
||||
KeyGenerator currentTenantKeyGenerator();
|
||||
|
||||
/**
|
||||
* Returns {@link TenantMetaData} of given and current tenant.
|
||||
*
|
||||
* DISCLAIMER: this variant is used during initial login (where the tenant
|
||||
* is not yet in the session). Please user {@link #getTenantMetadata()} for
|
||||
* regular requests.
|
||||
*
|
||||
* @param tenant
|
||||
* to retrieve data for
|
||||
* @return {@link TenantMetaData} of given tenant
|
||||
*/
|
||||
TenantMetaData getTenantMetadata(@NotNull String tenant);
|
||||
|
||||
/**
|
||||
* Update call for {@link TenantMetaData}.
|
||||
*
|
||||
* @param metaData
|
||||
* to update
|
||||
* @return updated {@link TenantMetaData} entity
|
||||
*/
|
||||
TenantMetaData updateTenantMetadata(@NotNull TenantMetaData metaData);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,292 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
||||
import org.eclipse.hawkbit.repository.model.Tag;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.eclipse.hawkbit.repository.model.TargetTag;
|
||||
import org.hibernate.validator.constraints.NotEmpty;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
||||
/**
|
||||
* Management service for {@link Tag}s.
|
||||
*
|
||||
*/
|
||||
public interface TagManagement {
|
||||
|
||||
/**
|
||||
* count {@link TargetTag}s.
|
||||
*
|
||||
* @return size of {@link TargetTag}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
long countTargetTags();
|
||||
|
||||
/**
|
||||
* Creates a {@link DistributionSet}.
|
||||
*
|
||||
* @param distributionSetTag
|
||||
* to be created.
|
||||
* @return the new {@link DistributionSet}
|
||||
* @throws EntityAlreadyExistsException
|
||||
* if distributionSetTag already exists
|
||||
*
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
||||
DistributionSetTag createDistributionSetTag(@NotNull DistributionSetTag distributionSetTag);
|
||||
|
||||
/**
|
||||
* Creates multiple {@link DistributionSetTag}s.
|
||||
*
|
||||
* @param distributionSetTags
|
||||
* to be created
|
||||
* @return the new {@link DistributionSetTag}
|
||||
* @throws EntityAlreadyExistsException
|
||||
* if a given entity already exists
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY)
|
||||
List<DistributionSetTag> createDistributionSetTags(@NotNull Collection<DistributionSetTag> distributionSetTags);
|
||||
|
||||
/**
|
||||
* Creates a new {@link TargetTag}.
|
||||
*
|
||||
* @param targetTag
|
||||
* to be created
|
||||
*
|
||||
* @return the new created {@link TargetTag}
|
||||
*
|
||||
* @throws EntityAlreadyExistsException
|
||||
* if given object already exists
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET)
|
||||
TargetTag createTargetTag(@NotNull TargetTag targetTag);
|
||||
|
||||
/**
|
||||
* created multiple {@link TargetTag}s.
|
||||
*
|
||||
* @param targetTags
|
||||
* to be created
|
||||
* @return the new created {@link TargetTag}s
|
||||
*
|
||||
* @throws EntityAlreadyExistsException
|
||||
* if given object has already an ID.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET)
|
||||
List<TargetTag> createTargetTags(@NotNull Collection<TargetTag> targetTags);
|
||||
|
||||
/**
|
||||
* Deletes {@link DistributionSetTag} by given
|
||||
* {@link DistributionSetTag#getName()}.
|
||||
*
|
||||
* @param tagName
|
||||
* to be deleted
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_REPOSITORY)
|
||||
void deleteDistributionSetTag(@NotEmpty String tagName);
|
||||
|
||||
/**
|
||||
* Deletes {@link TargetTag} with given name.
|
||||
*
|
||||
* @param targetTagName
|
||||
* tag name of the {@link TargetTag} to be deleted
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_TARGET)
|
||||
void deleteTargetTag(@NotEmpty String targetTagName);
|
||||
|
||||
/**
|
||||
*
|
||||
* @return all {@link DistributionSetTag}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
List<DistributionSetTag> findAllDistributionSetTags();
|
||||
|
||||
/**
|
||||
* returns all {@link DistributionSetTag}s.
|
||||
*
|
||||
* @param pageReq
|
||||
* page parameter
|
||||
* @return all {@link DistributionSetTag}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Page<DistributionSetTag> findAllDistributionSetTags(@NotNull Pageable pageReq);
|
||||
|
||||
/**
|
||||
* Retrieves all DistributionSet tags based on the given specification.
|
||||
*
|
||||
* @param rsqlParam
|
||||
* rsql query string
|
||||
* @param pageable
|
||||
* pagination parameter
|
||||
* @return the found {@link DistributionSetTag}s, never {@code null}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
Page<DistributionSetTag> findAllDistributionSetTags(@NotNull String rsqlParam, @NotNull Pageable pageable);
|
||||
|
||||
/**
|
||||
* @return all {@link TargetTag}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
List<TargetTag> findAllTargetTags();
|
||||
|
||||
/**
|
||||
* returns all {@link TargetTag}s.
|
||||
*
|
||||
* @param pageable
|
||||
* page parameter
|
||||
*
|
||||
* @return all {@link TargetTag}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Page<TargetTag> findAllTargetTags(@NotNull Pageable pageable);
|
||||
|
||||
/**
|
||||
* Retrieves all target tags based on the given specification.
|
||||
*
|
||||
* @param rsqlParam
|
||||
* rsql query string
|
||||
* @param pageable
|
||||
* pagination parameter
|
||||
* @return the found {@link Target}s, never {@code null}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Page<TargetTag> findAllTargetTags(@NotNull String rsqlParam, @NotNull Pageable pageable);
|
||||
|
||||
/**
|
||||
* Find {@link DistributionSet} based on given name.
|
||||
*
|
||||
* @param name
|
||||
* to look for.
|
||||
* @return {@link DistributionSet} or <code>null</code> if it does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
DistributionSetTag findDistributionSetTag(@NotEmpty String name);
|
||||
|
||||
/**
|
||||
* Finds {@link DistributionSetTag} by given id.
|
||||
*
|
||||
* @param id
|
||||
* to search for
|
||||
* @return the found {@link DistributionSetTag}s or <code>null</code> if not
|
||||
* found.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY)
|
||||
DistributionSetTag findDistributionSetTagById(@NotNull Long id);
|
||||
|
||||
/**
|
||||
* Find {@link TargetTag} based on given Name.
|
||||
*
|
||||
* @param name
|
||||
* to look for.
|
||||
* @return {@link TargetTag} or <code>null</code> if it does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
TargetTag findTargetTag(@NotEmpty String name);
|
||||
|
||||
/**
|
||||
* Finds {@link TargetTag} by given id.
|
||||
*
|
||||
* @param id
|
||||
* to search for
|
||||
* @return the found {@link TargetTag}s or <code>null</code> if not found.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
TargetTag findTargetTagById(@NotNull Long id);
|
||||
|
||||
/**
|
||||
* Updates an existing {@link DistributionSetTag}.
|
||||
*
|
||||
* @param distributionSetTag
|
||||
* to be updated
|
||||
* @return the updated {@link DistributionSet}
|
||||
* @throws NullPointerException
|
||||
* of {@link DistributionSetTag#getName()} is <code>null</code>
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY)
|
||||
DistributionSetTag updateDistributionSetTag(@NotNull DistributionSetTag distributionSetTag);
|
||||
|
||||
/**
|
||||
* updates the {@link TargetTag}.
|
||||
*
|
||||
* @param targetTag
|
||||
* the {@link TargetTag} with updated values
|
||||
* @return the updated {@link TargetTag}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
|
||||
TargetTag updateTargetTag(@NotNull TargetTag targetTag);
|
||||
|
||||
/**
|
||||
* Generates an empty {@link TargetTag} without persisting it.
|
||||
*
|
||||
* @return {@link TargetTag} object
|
||||
*/
|
||||
TargetTag generateTargetTag();
|
||||
|
||||
/**
|
||||
* Generates an empty {@link DistributionSetTag} without persisting it.
|
||||
*
|
||||
* @return {@link DistributionSetTag} object
|
||||
*/
|
||||
DistributionSetTag generateDistributionSetTag();
|
||||
|
||||
/**
|
||||
* Generates a {@link TargetTag} without persisting it.
|
||||
*
|
||||
* @param name
|
||||
* of the tag
|
||||
* @param description
|
||||
* of the tag
|
||||
* @param colour
|
||||
* of the tag
|
||||
* @return {@link TargetTag} object
|
||||
*/
|
||||
TargetTag generateTargetTag(String name, String description, String colour);
|
||||
|
||||
/**
|
||||
* Generates a {@link TargetTag} without persisting it.
|
||||
*
|
||||
* @param name
|
||||
* of the tag
|
||||
* @return {@link TargetTag} object
|
||||
*/
|
||||
TargetTag generateTargetTag(String name);
|
||||
|
||||
/**
|
||||
* Generates a {@link DistributionSetTag} without persisting it.
|
||||
*
|
||||
* @param name
|
||||
* of the tag
|
||||
* @param description
|
||||
* of the tag
|
||||
* @param colour
|
||||
* of the tag
|
||||
* @return {@link DistributionSetTag} object
|
||||
*/
|
||||
DistributionSetTag generateDistributionSetTag(String name, String description, String colour);
|
||||
|
||||
/**
|
||||
* Generates a {@link DistributionSetTag} without persisting it.
|
||||
*
|
||||
* @param name
|
||||
* of the tag
|
||||
* @return {@link DistributionSetTag} object
|
||||
*/
|
||||
DistributionSetTag generateDistributionSetTag(String name);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
|
||||
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
||||
/**
|
||||
* Management service for {@link TargetFilterQuery}s.
|
||||
*
|
||||
*/
|
||||
public interface TargetFilterQueryManagement {
|
||||
|
||||
/**
|
||||
* creating new {@link TargetFilterQuery}.
|
||||
*
|
||||
* @param customTargetFilter
|
||||
* @return the created {@link TargetFilterQuery}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET)
|
||||
TargetFilterQuery createTargetFilterQuery(@NotNull TargetFilterQuery customTargetFilter);
|
||||
|
||||
/**
|
||||
* Delete target filter query.
|
||||
*
|
||||
* @param targetFilterQueryId
|
||||
* IDs of target filter query to be deleted
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_TARGET)
|
||||
void deleteTargetFilterQuery(@NotNull Long targetFilterQueryId);
|
||||
|
||||
/**
|
||||
*
|
||||
* Retrieves all target filter query{@link TargetFilterQuery}.
|
||||
*
|
||||
* @param pageable
|
||||
* pagination parameter
|
||||
* @return the found {@link TargetFilterQuery}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Page<TargetFilterQuery> findAllTargetFilterQuery(@NotNull Pageable pageable);
|
||||
|
||||
/**
|
||||
* Retrieves all target filter query which {@link TargetFilterQuery}.
|
||||
*
|
||||
*
|
||||
* @param pageable
|
||||
* pagination parameter
|
||||
* @param name
|
||||
* target filter query name
|
||||
* @return the page with the found {@link TargetFilterQuery}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Page<TargetFilterQuery> findTargetFilterQueryByFilters(@NotNull Pageable pageable, String name);
|
||||
|
||||
/**
|
||||
* Find target filter query by id.
|
||||
*
|
||||
* @param targetFilterQueryId
|
||||
* Target filter query id
|
||||
* @return the found {@link TargetFilterQuery}
|
||||
*
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
TargetFilterQuery findTargetFilterQueryById(@NotNull Long targetFilterQueryId);
|
||||
|
||||
/**
|
||||
* Find target filter query by name.
|
||||
*
|
||||
* @param targetFilterQueryName
|
||||
* Target filter query name
|
||||
* @return the found {@link TargetFilterQuery}
|
||||
*
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
TargetFilterQuery findTargetFilterQueryByName(@NotNull String targetFilterQueryName);
|
||||
|
||||
/**
|
||||
* updates the {@link TargetFilterQuery}.
|
||||
*
|
||||
* @param targetFilterQuery
|
||||
* to be updated
|
||||
* @return the updated {@link TargetFilterQuery}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
|
||||
TargetFilterQuery updateTargetFilterQuery(@NotNull TargetFilterQuery targetFilterQuery);
|
||||
|
||||
/**
|
||||
* Generates an empty {@link TargetFilterQuery} without persisting it.
|
||||
*
|
||||
* @return {@link TargetFilterQuery} object
|
||||
*/
|
||||
TargetFilterQuery generateTargetFilterQuery();
|
||||
}
|
||||
@@ -0,0 +1,600 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
|
||||
import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.Tag;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
|
||||
import org.eclipse.hawkbit.repository.model.TargetIdName;
|
||||
import org.eclipse.hawkbit.repository.model.TargetInfo;
|
||||
import org.eclipse.hawkbit.repository.model.TargetTag;
|
||||
import org.eclipse.hawkbit.repository.model.TargetTagAssignmentResult;
|
||||
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
|
||||
import org.hibernate.validator.constraints.NotEmpty;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Slice;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
||||
/**
|
||||
* Management service for {@link Target}s.
|
||||
*
|
||||
*/
|
||||
public interface TargetManagement {
|
||||
|
||||
/**
|
||||
* Assign a {@link TargetTag} assignment to given {@link Target}s.
|
||||
*
|
||||
* @param targetIds
|
||||
* to assign for
|
||||
* @param tag
|
||||
* to assign
|
||||
* @return list of assigned targets
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
|
||||
List<Target> assignTag(@NotEmpty Collection<String> targetIds, @NotNull TargetTag tag);
|
||||
|
||||
/**
|
||||
* Counts number of targets with given
|
||||
* {@link Target#getAssignedDistributionSet()}.
|
||||
*
|
||||
* @param distId
|
||||
* to search for
|
||||
*
|
||||
* @return number of found {@link Target}s.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Long countTargetByAssignedDistributionSet(@NotNull Long distId);
|
||||
|
||||
/**
|
||||
* Count {@link Target}s for all the given filter parameters.
|
||||
*
|
||||
* @param status
|
||||
* find targets having on of these {@link TargetUpdateStatus}s.
|
||||
* Set to <code>null</code> in case this is not required.
|
||||
* @param searchText
|
||||
* to find targets having the text anywhere in name or
|
||||
* description. Set <code>null</code> in case this is not
|
||||
* required.
|
||||
* @param installedOrAssignedDistributionSetId
|
||||
* to find targets having the {@link DistributionSet} as
|
||||
* installed or assigned. Set to <code>null</code> in case this
|
||||
* is not required.
|
||||
* @param tagNames
|
||||
* to find targets which are having any one in this tag names.
|
||||
* Set <code>null</code> in case this is not required.
|
||||
* @param selectTargetWithNoTag
|
||||
* flag to select targets with no tag assigned
|
||||
*
|
||||
* @return the found number {@link Target}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Long countTargetByFilters(Collection<TargetUpdateStatus> status, String searchText,
|
||||
Long installedOrAssignedDistributionSetId, Boolean selectTargetWithNoTag, String... tagNames);
|
||||
|
||||
/**
|
||||
* Counts number of targets with given
|
||||
* {@link TargetInfo#getInstalledDistributionSet()}.
|
||||
*
|
||||
* @param distId
|
||||
* to search for
|
||||
* @return number of found {@link Target}s.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Long countTargetByInstalledDistributionSet(@NotNull Long distId);
|
||||
|
||||
/**
|
||||
* Count {@link TargetFilterQuery}s for given target filter query.
|
||||
*
|
||||
* @param targetFilterQuery
|
||||
* {link TargetFilterQuery}
|
||||
* @return the found number {@link TargetFilterQuery}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Long countTargetByTargetFilterQuery(@NotEmpty String targetFilterQuery);
|
||||
|
||||
/**
|
||||
* Count {@link TargetFilterQuery}s for given filter parameter.
|
||||
*
|
||||
* @param targetFilterQuery
|
||||
* {link TargetFilterQuery}
|
||||
* @return the found number {@link TargetFilterQuery}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Long countTargetByTargetFilterQuery(@NotNull TargetFilterQuery targetFilterQuery);
|
||||
|
||||
/**
|
||||
* Counts all {@link Target}s in the repository.
|
||||
*
|
||||
* @return number of targets
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Long countTargetsAll();
|
||||
|
||||
/**
|
||||
* creating a new {@link Target}.
|
||||
*
|
||||
* @param target
|
||||
* to be created
|
||||
* @return the created {@link Target}
|
||||
*
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET + SpringEvalExpressions.HAS_AUTH_OR
|
||||
+ SpringEvalExpressions.IS_CONTROLLER)
|
||||
Target createTarget(@NotNull Target target);
|
||||
|
||||
/**
|
||||
* creating new {@link Target}s including poll status data. useful
|
||||
* especially in plug and play scenarios.
|
||||
*
|
||||
* @param target
|
||||
* to be created *
|
||||
* @param status
|
||||
* of the target
|
||||
* @param lastTargetQuery
|
||||
* if a plug and play case
|
||||
* @param address
|
||||
* if a plug and play case
|
||||
*
|
||||
* @throws EntityAlreadyExistsException
|
||||
* if {@link Target} with given {@link Target#getControllerId()}
|
||||
* already exists.
|
||||
*
|
||||
* @return created {@link Target}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET + SpringEvalExpressions.HAS_AUTH_OR
|
||||
+ SpringEvalExpressions.IS_CONTROLLER)
|
||||
Target createTarget(@NotNull Target target, @NotNull TargetUpdateStatus status, Long lastTargetQuery, URI address);
|
||||
|
||||
/**
|
||||
* creates multiple {@link Target}s. If some of the given {@link Target}s
|
||||
* already exists in the DB a {@link EntityAlreadyExistsException} is
|
||||
* thrown. {@link Target}s contain all objects of the parameter targets,
|
||||
* including duplicates.
|
||||
*
|
||||
* @param targets
|
||||
* to be created.
|
||||
* @return the created {@link Target}s
|
||||
*
|
||||
* @throws EntityAlreadyExistsException
|
||||
* of one of the given targets already exist.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET)
|
||||
List<Target> createTargets(@NotNull Collection<Target> targets);
|
||||
|
||||
/**
|
||||
* creating a new {@link Target} including poll status data. useful
|
||||
* especially in plug and play scenarios.
|
||||
*
|
||||
* @param targets
|
||||
* to be created *
|
||||
* @param status
|
||||
* of the target
|
||||
* @param lastTargetQuery
|
||||
* if a plug and play case
|
||||
* @param address
|
||||
* if a plug and play case
|
||||
*
|
||||
* @return newly created target
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET)
|
||||
List<Target> createTargets(@NotNull Collection<Target> targets, @NotNull TargetUpdateStatus status,
|
||||
Long lastTargetQuery, URI address);
|
||||
|
||||
/**
|
||||
* Deletes all targets with the given IDs.
|
||||
*
|
||||
* @param targetIDs
|
||||
* the technical IDs of the targets to be deleted
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_DELETE_TARGET)
|
||||
void deleteTargets(@NotEmpty Long... targetIDs);
|
||||
|
||||
/**
|
||||
* finds all {@link Target#getControllerId()} which are currently in the
|
||||
* database.
|
||||
*
|
||||
* @return all IDs of all {@link Target} in the system
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
List<TargetIdName> findAllTargetIds();
|
||||
|
||||
/**
|
||||
* Finds all targets for all the given parameters but returns not the full
|
||||
* target but {@link TargetIdName}.
|
||||
*
|
||||
* @param pageRequest
|
||||
* the pageRequest to enhance the query for paging and sorting
|
||||
*
|
||||
* @param filterByStatus
|
||||
* find targets having this {@link TargetUpdateStatus}s. Set to
|
||||
* <code>null</code> in case this is not required.
|
||||
* @param filterBySearchText
|
||||
* to find targets having the text anywhere in name or
|
||||
* description. Set <code>null</code> in case this is not
|
||||
* required.
|
||||
* @param installedOrAssignedDistributionSetId
|
||||
* to find targets having the {@link DistributionSet} as
|
||||
* installed or assigned. Set to <code>null</code> in case this
|
||||
* is not required.
|
||||
* @param filterByTagNames
|
||||
* to find targets which are having any one in this tag names.
|
||||
* Set <code>null</code> in case this is not required.
|
||||
* @param selectTargetWithNoTag
|
||||
* flag to select targets with no tag assigned
|
||||
*
|
||||
* @return the found {@link TargetIdName}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
List<TargetIdName> findAllTargetIdsByFilters(@NotNull Pageable pageRequest,
|
||||
Collection<TargetUpdateStatus> filterByStatus, String filterBySearchText,
|
||||
Long installedOrAssignedDistributionSetId, Boolean selectTargetWithNoTag, String... filterByTagNames);
|
||||
|
||||
/**
|
||||
* Finds all targets for all the given parameter {@link TargetFilterQuery}
|
||||
* and returns not the full target but {@link TargetIdName}.
|
||||
*
|
||||
* @param pageRequest
|
||||
* the pageRequest to enhance the query for paging and sorting
|
||||
* @param targetFilterQuery
|
||||
* {@link TargetFilterQuery}
|
||||
* @return the found {@link TargetIdName}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
List<TargetIdName> findAllTargetIdsByTargetFilterQuery(@NotNull Pageable pageRequest,
|
||||
@NotNull TargetFilterQuery targetFilterQuery);
|
||||
|
||||
/**
|
||||
* retrieves {@link Target}s by the assigned {@link DistributionSet} without
|
||||
* details, i.e. NO {@link Target#getTags()} and {@link Target#getActions()}
|
||||
* possible.
|
||||
*
|
||||
*
|
||||
* @param distributionSetID
|
||||
* the ID of the {@link DistributionSet}
|
||||
* @param pageReq
|
||||
* page parameter
|
||||
* @return the found {@link Target}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_READ_TARGET)
|
||||
Page<Target> findTargetByAssignedDistributionSet(@NotNull Long distributionSetID, @NotNull Pageable pageReq);
|
||||
|
||||
/**
|
||||
* Retrieves {@link Target}s by the assigned {@link DistributionSet} without
|
||||
* details, i.e. NO {@link Target#getTags()} and {@link Target#getActions()}
|
||||
* possible including additional filtering based on the given {@code spec}.
|
||||
*
|
||||
* @param distributionSetID
|
||||
* the ID of the {@link DistributionSet}
|
||||
* @param spec
|
||||
* the specification to filter the result set
|
||||
* @param pageReq
|
||||
* page parameter
|
||||
* @return the found {@link Target}s, never {@code null}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_READ_TARGET)
|
||||
Page<Target> findTargetByAssignedDistributionSet(@NotNull Long distributionSetID, @NotNull String rsqlParam,
|
||||
@NotNull Pageable pageReq);
|
||||
|
||||
/**
|
||||
* Find {@link Target} based on given ID returns found Target without
|
||||
* details, i.e. NO {@link Target#getTags()} and {@link Target#getActions()}
|
||||
* possible.
|
||||
*
|
||||
* @param controllerIDs
|
||||
* to look for.
|
||||
* @return List of found{@link Target}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
List<Target> findTargetByControllerID(@NotEmpty Collection<String> controllerIDs);
|
||||
|
||||
/**
|
||||
* Find {@link Target} based on given ID returns found Target without
|
||||
* details, i.e. NO {@link Target#getTags()} and {@link Target#getActions()}
|
||||
* possible.
|
||||
*
|
||||
* @param controllerId
|
||||
* to look for.
|
||||
* @return {@link Target} or <code>null</code> if it does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Target findTargetByControllerID(@NotEmpty String controllerId);
|
||||
|
||||
/**
|
||||
* Find {@link Target} based on given ID returns found Target with details,
|
||||
* i.e. {@link Target#getTags()} and {@link Target#getActions()} are
|
||||
* possible.
|
||||
*
|
||||
* Note: try to use {@link #findTargetByControllerID(String)} as much as
|
||||
* possible.
|
||||
*
|
||||
* @param controllerId
|
||||
* to look for.
|
||||
* @return {@link Target} or <code>null</code> if it does not exist
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Target findTargetByControllerIDWithDetails(@NotEmpty String controllerId);
|
||||
|
||||
/**
|
||||
* Filter {@link Target}s for all the given parameters. If all parameters
|
||||
* except pageable are null, all available {@link Target}s are returned.
|
||||
*
|
||||
* @param pageable
|
||||
* page parameters
|
||||
* @param status
|
||||
* find targets having this {@link TargetUpdateStatus}s. Set to
|
||||
* <code>null</code> in case this is not required.
|
||||
* @param searchText
|
||||
* to find targets having the text anywhere in name or
|
||||
* description. Set <code>null</code> in case this is not
|
||||
* required.
|
||||
* @param installedOrAssignedDistributionSetId
|
||||
* to find targets having the {@link DistributionSet} as
|
||||
* installed or assigned. Set to <code>null</code> in case this
|
||||
* is not required.
|
||||
* @param tagNames
|
||||
* to find targets which are having any one in this tag names.
|
||||
* Set <code>null</code> in case this is not required.
|
||||
* @param selectTargetWithNoTag
|
||||
* flag to select targets with no tag assigned
|
||||
*
|
||||
* @return the found {@link Target}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Slice<Target> findTargetByFilters(@NotNull Pageable pageable, Collection<TargetUpdateStatus> status,
|
||||
String searchText, Long installedOrAssignedDistributionSetId, Boolean selectTargetWithNoTag,
|
||||
String... tagNames);
|
||||
|
||||
/**
|
||||
* retrieves {@link Target}s by the installed {@link DistributionSet}without
|
||||
* details, i.e. NO {@link Target#getTags()} and {@link Target#getActions()}
|
||||
* possible.
|
||||
*
|
||||
* @param distributionSetID
|
||||
* the ID of the {@link DistributionSet}
|
||||
* @param pageReq
|
||||
* page parameter
|
||||
* @return the found {@link Target}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_READ_TARGET)
|
||||
Page<Target> findTargetByInstalledDistributionSet(@NotNull Long distributionSetID, @NotNull Pageable pageReq);
|
||||
|
||||
/**
|
||||
* retrieves {@link Target}s by the installed {@link DistributionSet}without
|
||||
* details, i.e. NO {@link Target#getTags()} and {@link Target#getActions()}
|
||||
* possible including additional filtering based on the given {@code spec}.
|
||||
*
|
||||
* @param distributionSetId
|
||||
* the ID of the {@link DistributionSet}
|
||||
* @param spec
|
||||
* the specification to filter the result
|
||||
* @param pageable
|
||||
* page parameter
|
||||
* @return the found {@link Target}s, never {@code null}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_READ_TARGET)
|
||||
Page<Target> findTargetByInstalledDistributionSet(@NotNull Long distributionSetId, @NotNull String rsqlParam,
|
||||
@NotNull Pageable pageable);
|
||||
|
||||
/**
|
||||
* Retrieves the {@link Target} which have a certain
|
||||
* {@link TargetUpdateStatus} without details, i.e. NO
|
||||
* {@link Target#getTags()} and {@link Target#getActions()} possible.
|
||||
*
|
||||
* @param pageable
|
||||
* page parameter
|
||||
* @param status
|
||||
* the {@link TargetUpdateStatus} to be filtered on
|
||||
* @return the found {@link Target}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Page<Target> findTargetByUpdateStatus(@NotNull Pageable pageable, @NotNull TargetUpdateStatus status);
|
||||
|
||||
/**
|
||||
* Retrieves all targets without details, i.e. NO {@link Target#getTags()}
|
||||
* and {@link Target#getActions()} possible
|
||||
*
|
||||
* @param pageable
|
||||
* pagination parameter
|
||||
* @return the found {@link Target}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Slice<Target> findTargetsAll(@NotNull Pageable pageable);
|
||||
|
||||
/**
|
||||
* Retrieves all targets without details, i.e. NO {@link Target#getTags()}
|
||||
* and {@link Target#getActions()} possible based on
|
||||
* {@link TargetFilterQuery#getQuery()}
|
||||
*
|
||||
* @param targetFilterQuery
|
||||
* in string notation
|
||||
* @param pageable
|
||||
* pagination parameter
|
||||
* @return the found {@link Target}s, never {@code null}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Page<Target> findTargetsAll(@NotNull String targetFilterQuery, @NotNull Pageable pageable);
|
||||
|
||||
/**
|
||||
* Retrieves all targets without details, i.e. NO {@link Target#getTags()}
|
||||
* and {@link Target#getActions()} possible based on
|
||||
* {@link TargetFilterQuery#getQuery()}
|
||||
*
|
||||
* @param targetFilterQuery
|
||||
* the specification for the query
|
||||
* @param pageable
|
||||
* pagination parameter
|
||||
*
|
||||
* @return the found {@link Target}s, never {@code null}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Slice<Target> findTargetsAll(@NotNull TargetFilterQuery targetFilterQuery, @NotNull Pageable pageable);
|
||||
|
||||
/**
|
||||
* method retrieves all {@link Target}s from the repo in the following
|
||||
* order:
|
||||
* <p>
|
||||
* 1) {@link Target}s which have the given {@link DistributionSet} as
|
||||
* {@link Target#getTargetInfo()}
|
||||
* {@link TargetInfo#getInstalledDistributionSet()}
|
||||
* <p>
|
||||
* 2) {@link Target}s which have the given {@link DistributionSet} as
|
||||
* {@link Target#getAssignedDistributionSet()}
|
||||
* <p>
|
||||
* 3) {@link Target}s which have no connection to the given
|
||||
* {@link DistributionSet}.
|
||||
*
|
||||
* @param pageable
|
||||
* the page request to page the result set
|
||||
* @param orderByDistributionId
|
||||
* {@link DistributionSet#getId()} to be ordered by
|
||||
* @param filterByDistributionId
|
||||
* {@link DistributionSet#getId()} to be filter the result. Set
|
||||
* to <code>null</code> in case this is not required.
|
||||
* @param filterByStatus
|
||||
* find targets having this {@link TargetUpdateStatus}s. Set to
|
||||
* <code>null</code> in case this is not required.
|
||||
* @param filterBySearchText
|
||||
* to find targets having the text anywhere in name or
|
||||
* description. Set <code>null</code> in case this is not
|
||||
* required.
|
||||
* @param installedOrAssignedDistributionSetId
|
||||
* to find targets having the {@link DistributionSet} as
|
||||
* installed or assigned. Set to <code>null</code> in case this
|
||||
* is not required.
|
||||
* @param filterByTagNames
|
||||
* to find targets which are having any one in this tag names.
|
||||
* Set <code>null</code> in case this is not required.
|
||||
* @param selectTargetWithNoTag
|
||||
* flag to select targets with no tag assigned
|
||||
* @return a paged result {@link Page} of the {@link Target}s in a defined
|
||||
* order.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
Slice<Target> findTargetsAllOrderByLinkedDistributionSet(@NotNull Pageable pageable,
|
||||
@NotNull Long orderByDistributionId, Long filterByDistributionId,
|
||||
Collection<TargetUpdateStatus> filterByStatus, String filterBySearchText, Boolean selectTargetWithNoTag,
|
||||
String... filterByTagNames);
|
||||
|
||||
/**
|
||||
* retrieves a list of {@link Target}s by their controller ID with details,
|
||||
* i.e. {@link Target#getTags()} are possible.
|
||||
*
|
||||
* Note: try to use {@link #findTargetByControllerID(String)} as much as
|
||||
* possible.
|
||||
*
|
||||
* @param controllerIDs
|
||||
* {@link Target}s Names parameter
|
||||
* @return the found {@link Target}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
List<Target> findTargetsByControllerIDsWithTags(@NotNull List<String> controllerIDs);
|
||||
|
||||
/**
|
||||
* Find targets by tag name.
|
||||
*
|
||||
* @param tagName
|
||||
* tag name
|
||||
* @return list of matching targets
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET)
|
||||
List<Target> findTargetsByTag(@NotEmpty String tagName);
|
||||
|
||||
/**
|
||||
* Toggles {@link TargetTag} assignment to given {@link Target}s by means
|
||||
* that if some (or all) of the targets in the list have the {@link Tag} not
|
||||
* yet assigned, they will be. If all of theme have the tag already assigned
|
||||
* they will be removed instead.
|
||||
*
|
||||
* @param targetIds
|
||||
* to toggle for
|
||||
* @param tagName
|
||||
* to toggle
|
||||
* @return TagAssigmentResult with all meta data of the assignment outcome.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
|
||||
TargetTagAssignmentResult toggleTagAssignment(@NotEmpty Collection<String> targetIds, @NotEmpty String tagName);
|
||||
|
||||
/**
|
||||
* {@link Entity} based method call for
|
||||
* {@link #toggleTagAssignment(Collection, String)}.
|
||||
*
|
||||
* @param targets
|
||||
* to toggle for
|
||||
* @param tag
|
||||
* to toggle
|
||||
* @return TagAssigmentResult with all meta data of the assignment outcome.
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
|
||||
TargetTagAssignmentResult toggleTagAssignment(@NotEmpty Collection<Target> targets, @NotNull TargetTag tag);
|
||||
|
||||
/**
|
||||
* Un-assign all {@link Target} from a given {@link TargetTag} .
|
||||
*
|
||||
* @param tag
|
||||
* to un-assign all targets
|
||||
* @return list of unassigned targets
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
|
||||
List<Target> unAssignAllTargetsByTag(@NotNull TargetTag tag);
|
||||
|
||||
/**
|
||||
* Un-assign a {@link TargetTag} assignment to given {@link Target}.
|
||||
*
|
||||
* @param controllerID
|
||||
* to un-assign for
|
||||
* @param targetTag
|
||||
* to un-assign
|
||||
* @return the unassigned target or <null> if no target is unassigned
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET)
|
||||
Target unAssignTag(@NotEmpty String controllerID, @NotNull TargetTag targetTag);
|
||||
|
||||
/**
|
||||
* updates the {@link Target}.
|
||||
*
|
||||
* @param target
|
||||
* to be updated
|
||||
* @return the updated {@link Target}
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET + SpringEvalExpressions.HAS_AUTH_OR
|
||||
+ SpringEvalExpressions.IS_CONTROLLER)
|
||||
Target updateTarget(@NotNull Target target);
|
||||
|
||||
/**
|
||||
* updates multiple {@link Target}s.
|
||||
*
|
||||
* @param targets
|
||||
* to be updated
|
||||
* @return the updated {@link Target}s
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET + SpringEvalExpressions.HAS_AUTH_OR
|
||||
+ SpringEvalExpressions.IS_CONTROLLER)
|
||||
List<Target> updateTargets(@NotNull Collection<Target> targets);
|
||||
|
||||
/**
|
||||
* Generates an empty {@link Target} without persisting it.
|
||||
*
|
||||
* @param controllerID
|
||||
* of the {@link Target}
|
||||
*
|
||||
* @return {@link Target} object
|
||||
*/
|
||||
Target generateTarget(@NotEmpty String controllerID);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.Action;
|
||||
import org.eclipse.hawkbit.repository.model.Action.ActionType;
|
||||
import org.eclipse.hawkbit.repository.model.Target;
|
||||
|
||||
/**
|
||||
* A custom view on {@link Target} with {@link ActionType}.
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class TargetWithActionType {
|
||||
|
||||
private final String targetId;
|
||||
private final ActionType actionType;
|
||||
private final long forceTime;
|
||||
|
||||
/**
|
||||
* @param targetId
|
||||
* @param actionType
|
||||
* @param forceTime
|
||||
*/
|
||||
public TargetWithActionType(final String targetId, final ActionType actionType, final long forceTime) {
|
||||
this.targetId = targetId;
|
||||
this.actionType = actionType;
|
||||
this.forceTime = forceTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the actionType
|
||||
*/
|
||||
public ActionType getActionType() {
|
||||
if (actionType != null) {
|
||||
return actionType;
|
||||
}
|
||||
// default value
|
||||
return ActionType.FORCED;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the forceTime
|
||||
*/
|
||||
public long getForceTime() {
|
||||
if (actionType == ActionType.TIMEFORCED) {
|
||||
return forceTime;
|
||||
}
|
||||
return Action.NO_FORCE_TIME;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the targetId
|
||||
*/
|
||||
public String getTargetId() {
|
||||
return targetId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
|
||||
import org.eclipse.hawkbit.repository.model.TenantConfiguration;
|
||||
import org.eclipse.hawkbit.repository.model.TenantConfigurationValue;
|
||||
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationKey;
|
||||
import org.eclipse.hawkbit.tenancy.configuration.validator.TenantConfigurationValidatorException;
|
||||
import org.springframework.core.convert.ConversionFailedException;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
||||
/**
|
||||
* Management service for tenant configurations.
|
||||
*
|
||||
*/
|
||||
public interface TenantConfigurationManagement {
|
||||
|
||||
/**
|
||||
* Adds or updates a specific configuration for a specific tenant.
|
||||
*
|
||||
*
|
||||
* @param configurationKey
|
||||
* the key of the configuration
|
||||
* @param value
|
||||
* the configuration value which will be written into the
|
||||
* database.
|
||||
* @return the configuration value which was just written into the database.
|
||||
* @throws TenantConfigurationValidatorException
|
||||
* if the {@code propertyType} and the value in general does not
|
||||
* match the expected type and format defined by the Key
|
||||
* @throws ConversionFailedException
|
||||
* if the property cannot be converted to the given
|
||||
*/
|
||||
@PreAuthorize(value = SpringEvalExpressions.HAS_AUTH_TENANT_CONFIGURATION)
|
||||
<T> TenantConfigurationValue<T> addOrUpdateConfiguration(TenantConfigurationKey configurationKey, T value);
|
||||
|
||||
/**
|
||||
* Build the tenant configuration by the given key
|
||||
*
|
||||
* @param configurationKey
|
||||
* the key
|
||||
* @param propertyType
|
||||
* the property type
|
||||
* @param tenantConfiguration
|
||||
* the configuration
|
||||
* @return <null> if no default value is set and no database value available
|
||||
* or returns the tenant configuration value
|
||||
*/
|
||||
@PreAuthorize(value = SpringEvalExpressions.HAS_AUTH_TENANT_CONFIGURATION + SpringEvalExpressions.HAS_AUTH_OR
|
||||
+ SpringEvalExpressions.IS_SYSTEM_CODE)
|
||||
<T> TenantConfigurationValue<T> buildTenantConfigurationValueByKey(TenantConfigurationKey configurationKey,
|
||||
Class<T> propertyType, TenantConfiguration tenantConfiguration);
|
||||
|
||||
/**
|
||||
* Deletes a specific configuration for the current tenant. Does nothing in
|
||||
* case there is no tenant specific configuration value.
|
||||
*
|
||||
* @param configurationKey
|
||||
* the configuration key to be deleted
|
||||
*/
|
||||
@PreAuthorize(value = SpringEvalExpressions.HAS_AUTH_TENANT_CONFIGURATION)
|
||||
void deleteConfiguration(TenantConfigurationKey configurationKey);
|
||||
|
||||
/**
|
||||
* Retrieves a configuration value from the e.g. tenant overwritten
|
||||
* configuration values or in case the tenant does not a have a specific
|
||||
* configuration the global default value hold in the {@link Environment}.
|
||||
*
|
||||
* @param configurationKey
|
||||
* the key of the configuration
|
||||
* @return the converted configuration value either from the tenant specific
|
||||
* configuration stored or from the fall back default values or
|
||||
* {@code null} in case key has not been configured and not default
|
||||
* value exists
|
||||
* @throws TenantConfigurationValidatorException
|
||||
* if the {@code propertyType} and the value in general does not
|
||||
* match the expected type and format defined by the Key
|
||||
* @throws ConversionFailedException
|
||||
* if the property cannot be converted to the given
|
||||
* {@code propertyType}
|
||||
*/
|
||||
@PreAuthorize(value = SpringEvalExpressions.HAS_AUTH_TENANT_CONFIGURATION + SpringEvalExpressions.HAS_AUTH_OR
|
||||
+ SpringEvalExpressions.IS_SYSTEM_CODE)
|
||||
TenantConfigurationValue<?> getConfigurationValue(TenantConfigurationKey configurationKey);
|
||||
|
||||
/**
|
||||
* Retrieves a configuration value from the e.g. tenant overwritten
|
||||
* configuration values or in case the tenant does not a have a specific
|
||||
* configuration the global default value hold in the {@link Environment}.
|
||||
*
|
||||
* @param <T>
|
||||
* the type of the configuration value
|
||||
* @param configurationKey
|
||||
* the key of the configuration
|
||||
* @param propertyType
|
||||
* the type of the configuration value, e.g. {@code String.class}
|
||||
* , {@code Integer.class}, etc
|
||||
* @return the converted configuration value either from the tenant specific
|
||||
* configuration stored or from the fallback default values or
|
||||
* {@code null} in case key has not been configured and not default
|
||||
* value exists
|
||||
* @throws TenantConfigurationValidatorException
|
||||
* if the {@code propertyType} and the value in general does not
|
||||
* match the expected type and format defined by the Key
|
||||
* @throws ConversionFailedException
|
||||
* if the property cannot be converted to the given
|
||||
* {@code propertyType}
|
||||
*/
|
||||
@PreAuthorize(value = SpringEvalExpressions.HAS_AUTH_TENANT_CONFIGURATION + SpringEvalExpressions.HAS_AUTH_OR
|
||||
+ SpringEvalExpressions.IS_SYSTEM_CODE)
|
||||
<T> TenantConfigurationValue<T> getConfigurationValue(TenantConfigurationKey configurationKey,
|
||||
Class<T> propertyType);
|
||||
|
||||
/**
|
||||
* returns the global configuration property either defined in the property
|
||||
* file or an default value otherwise.
|
||||
*
|
||||
* @param <T>
|
||||
* the type of the configuration value
|
||||
* @param configurationKey
|
||||
* the key of the configuration
|
||||
* @param propertyType
|
||||
* the type of the configuration value, e.g. {@code String.class}
|
||||
* , {@code Integer.class}, etc
|
||||
* @return the global configured value
|
||||
* @throws TenantConfigurationValidatorException
|
||||
* if the {@code propertyType} and the value in the property
|
||||
* file or the default value does not match the expected type
|
||||
* and format defined by the Key
|
||||
* @throws ConversionFailedException
|
||||
* if the property cannot be converted to the given
|
||||
* {@code propertyType}
|
||||
*/
|
||||
@PreAuthorize(value = SpringEvalExpressions.HAS_AUTH_TENANT_CONFIGURATION + SpringEvalExpressions.HAS_AUTH_OR
|
||||
+ SpringEvalExpressions.IS_SYSTEM_CODE)
|
||||
<T> T getGlobalConfigurationValue(TenantConfigurationKey configurationKey, Class<T> propertyType);
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
|
||||
import org.eclipse.hawkbit.report.model.TenantUsage;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
||||
/**
|
||||
* Management service for statistics of a single tenant.
|
||||
*
|
||||
*/
|
||||
public interface TenantStatsManagement {
|
||||
|
||||
/**
|
||||
* Service for stats of a single tenant. Opens a new transaction and as a
|
||||
* result can an be used for multiple tenants, i.e. to allow in one session
|
||||
* to collect data of all tenants in the system.
|
||||
*
|
||||
* @param tenant
|
||||
* to collect for
|
||||
* @return collected statistics
|
||||
*/
|
||||
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_SYSTEM_ADMIN)
|
||||
TenantUsage getStatsOfTenant(String tenant);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* 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.exception;
|
||||
|
||||
import org.eclipse.hawkbit.exception.SpServerError;
|
||||
import org.eclipse.hawkbit.exception.SpServerRtException;
|
||||
|
||||
/**
|
||||
* Thrown if artifact deletion failed.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public final class ArtifactDeleteFailedException extends SpServerRtException {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Creates a new FileUploadFailedException with
|
||||
* {@link SpServerError#SP_REST_BODY_NOT_READABLE} error.
|
||||
*/
|
||||
public ArtifactDeleteFailedException() {
|
||||
super(SpServerError.SP_ARTIFACT_DELETE_FAILED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cause
|
||||
* for the exception
|
||||
*/
|
||||
public ArtifactDeleteFailedException(final Throwable cause) {
|
||||
super(SpServerError.SP_ARTIFACT_DELETE_FAILED, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message
|
||||
* of the error
|
||||
*/
|
||||
public ArtifactDeleteFailedException(final String message) {
|
||||
super(message, SpServerError.SP_ARTIFACT_DELETE_FAILED);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/**
|
||||
* 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.exception;
|
||||
|
||||
import org.eclipse.hawkbit.exception.SpServerError;
|
||||
import org.eclipse.hawkbit.exception.SpServerRtException;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public final class ArtifactUploadFailedException extends SpServerRtException {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Creates a new FileUploadFailedException with
|
||||
* {@link SpServerError#SP_REST_BODY_NOT_READABLE} error.
|
||||
*/
|
||||
public ArtifactUploadFailedException() {
|
||||
super(SpServerError.SP_ARTIFACT_UPLOAD_FAILED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cause
|
||||
* for the exception
|
||||
*/
|
||||
public ArtifactUploadFailedException(final Throwable cause) {
|
||||
super(SpServerError.SP_ARTIFACT_UPLOAD_FAILED, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message
|
||||
* of the error
|
||||
*/
|
||||
public ArtifactUploadFailedException(final String message) {
|
||||
super(message, SpServerError.SP_ARTIFACT_UPLOAD_FAILED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message
|
||||
* for the error
|
||||
* @param cause
|
||||
* of the error
|
||||
*/
|
||||
public ArtifactUploadFailedException(final String message, final Throwable cause) {
|
||||
super(message, SpServerError.SP_ARTIFACT_UPLOAD_FAILED, cause);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* 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.exception;
|
||||
|
||||
import org.eclipse.hawkbit.exception.SpServerError;
|
||||
import org.eclipse.hawkbit.exception.SpServerRtException;
|
||||
|
||||
/**
|
||||
* Thrown if cancelation of actions is performened where the action is not
|
||||
* cancelable, e.g. the action is not active or is already a cancel action.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public final class CancelActionNotAllowedException extends SpServerRtException {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Creates a new CancelActionNotAllowed with
|
||||
* {@link SpServerError#SP_ACTION_NOT_CANCELABLE} error.
|
||||
*/
|
||||
public CancelActionNotAllowedException() {
|
||||
super(SpServerError.SP_ACTION_NOT_CANCELABLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cause
|
||||
* for the exception
|
||||
*/
|
||||
public CancelActionNotAllowedException(final Throwable cause) {
|
||||
super(SpServerError.SP_ACTION_NOT_CANCELABLE, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message
|
||||
* of the error
|
||||
*/
|
||||
public CancelActionNotAllowedException(final String message) {
|
||||
super(message, SpServerError.SP_ACTION_NOT_CANCELABLE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/**
|
||||
* 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.exception;
|
||||
|
||||
import org.eclipse.hawkbit.exception.SpServerError;
|
||||
import org.eclipse.hawkbit.exception.SpServerRtException;
|
||||
|
||||
/**
|
||||
* {@link ConcurrentModificationException} is thrown when a given entity in's
|
||||
* actual and cannot be stored within the current session. Reason could be that
|
||||
* it has been changed within another session.
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class ConcurrentModificationException extends SpServerRtException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final SpServerError THIS_ERROR = SpServerError.SP_REPO_CONCURRENT_MODIFICATION;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public ConcurrentModificationException() {
|
||||
super(THIS_ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameterized constructor.
|
||||
*
|
||||
* @param cause
|
||||
* of the exception
|
||||
*/
|
||||
public ConcurrentModificationException(final Throwable cause) {
|
||||
super(THIS_ERROR, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameterized constructor.
|
||||
*
|
||||
* @param message
|
||||
* custom error message
|
||||
* @param cause
|
||||
* of the exception
|
||||
*/
|
||||
public ConcurrentModificationException(final String message, final Throwable cause) {
|
||||
super(message, THIS_ERROR, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameterized constructor.
|
||||
*
|
||||
* @param message
|
||||
* custom error message
|
||||
*/
|
||||
public ConcurrentModificationException(final String message) {
|
||||
super(message, THIS_ERROR);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* 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.exception;
|
||||
|
||||
import org.eclipse.hawkbit.exception.SpServerError;
|
||||
import org.eclipse.hawkbit.exception.SpServerRtException;
|
||||
|
||||
/**
|
||||
* Thrown if DS creation failed.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public final class DistributionSetCreationFailedMissingMandatoryModuleException extends SpServerRtException {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Creates a new FileUploadFailedException with
|
||||
* {@link SpServerError#SP_DS_CREATION_FAILED_MISSING_MODULE} error.
|
||||
*/
|
||||
public DistributionSetCreationFailedMissingMandatoryModuleException() {
|
||||
super(SpServerError.SP_DS_CREATION_FAILED_MISSING_MODULE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cause
|
||||
* for the exception
|
||||
*/
|
||||
public DistributionSetCreationFailedMissingMandatoryModuleException(final Throwable cause) {
|
||||
super(SpServerError.SP_DS_CREATION_FAILED_MISSING_MODULE, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message
|
||||
* of the error
|
||||
*/
|
||||
public DistributionSetCreationFailedMissingMandatoryModuleException(final String message) {
|
||||
super(message, SpServerError.SP_DS_CREATION_FAILED_MISSING_MODULE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* 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.exception;
|
||||
|
||||
import org.eclipse.hawkbit.exception.SpServerError;
|
||||
import org.eclipse.hawkbit.exception.SpServerRtException;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||
|
||||
/**
|
||||
* Thrown if the user tries to assign modules to a {@link DistributionSet} that
|
||||
* has to {@link DistributionSetType} defined.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class DistributionSetTypeUndefinedException extends SpServerRtException {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Creates a new FileUploadFailedException with
|
||||
* {@link SpServerError#SP_DS_TYPE_UNDEFINED} error.
|
||||
*/
|
||||
public DistributionSetTypeUndefinedException() {
|
||||
super(SpServerError.SP_DS_TYPE_UNDEFINED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cause
|
||||
* for the exception
|
||||
*/
|
||||
public DistributionSetTypeUndefinedException(final Throwable cause) {
|
||||
super(SpServerError.SP_DS_TYPE_UNDEFINED, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message
|
||||
* of the error
|
||||
*/
|
||||
public DistributionSetTypeUndefinedException(final String message) {
|
||||
super(message, SpServerError.SP_DS_TYPE_UNDEFINED);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/**
|
||||
* 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.exception;
|
||||
|
||||
import org.eclipse.hawkbit.exception.SpServerError;
|
||||
import org.eclipse.hawkbit.exception.SpServerRtException;
|
||||
|
||||
/**
|
||||
* the {@link EntityAlreadyExistsException} is thrown when a entity is tried to
|
||||
* be saved which already exists or which violates unique key constraints.
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class EntityAlreadyExistsException extends SpServerRtException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final SpServerError THIS_ERROR = SpServerError.SP_REPO_ENTITY_ALRREADY_EXISTS;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
public EntityAlreadyExistsException() {
|
||||
super(THIS_ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameterized constructor.
|
||||
*
|
||||
* @param cause
|
||||
* of the exception
|
||||
*/
|
||||
public EntityAlreadyExistsException(final Throwable cause) {
|
||||
super(THIS_ERROR, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameterized constructor.
|
||||
*
|
||||
* @param message
|
||||
* of the exception
|
||||
* @param cause
|
||||
* of the exception
|
||||
*/
|
||||
public EntityAlreadyExistsException(final String message, final Throwable cause) {
|
||||
super(message, THIS_ERROR, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameterized constructor.
|
||||
*
|
||||
* @param message
|
||||
* of the exception
|
||||
*/
|
||||
public EntityAlreadyExistsException(final String message) {
|
||||
super(message, THIS_ERROR);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/**
|
||||
* 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.exception;
|
||||
|
||||
import org.eclipse.hawkbit.exception.SpServerError;
|
||||
import org.eclipse.hawkbit.exception.SpServerRtException;
|
||||
|
||||
/**
|
||||
* The {@link EntityLockedException} is thrown when an entity has been locked by
|
||||
* the server to prevent modification.
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class EntityLockedException extends SpServerRtException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final SpServerError THIS_ERROR = SpServerError.SP_ENTITY_LOCKED;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
public EntityLockedException() {
|
||||
super(THIS_ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameterized constructor.
|
||||
*
|
||||
* @param cause
|
||||
* of the exception
|
||||
*/
|
||||
public EntityLockedException(final Throwable cause) {
|
||||
super(THIS_ERROR, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameterized constructor.
|
||||
*
|
||||
* @param message
|
||||
* of the exception
|
||||
* @param cause
|
||||
* of the exception
|
||||
*/
|
||||
public EntityLockedException(final String message, final Throwable cause) {
|
||||
super(message, THIS_ERROR, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameterized constructor.
|
||||
*
|
||||
* @param message
|
||||
* of the exception
|
||||
*/
|
||||
public EntityLockedException(final String message) {
|
||||
super(message, THIS_ERROR);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/**
|
||||
* 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.exception;
|
||||
|
||||
import org.eclipse.hawkbit.exception.SpServerError;
|
||||
import org.eclipse.hawkbit.exception.SpServerRtException;
|
||||
|
||||
/**
|
||||
* the {@link EntityNotFoundException} is thrown when a entity is tried find but
|
||||
* not found.
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class EntityNotFoundException extends SpServerRtException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final SpServerError THIS_ERROR = SpServerError.SP_REPO_ENTITY_NOT_EXISTS;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
public EntityNotFoundException() {
|
||||
super(THIS_ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameterized constructor.
|
||||
*
|
||||
* @param cause
|
||||
* of the exception
|
||||
*/
|
||||
public EntityNotFoundException(final Throwable cause) {
|
||||
super(THIS_ERROR, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameterized constructor.
|
||||
*
|
||||
* @param message
|
||||
* of the exception
|
||||
* @param cause
|
||||
* of the exception
|
||||
*/
|
||||
public EntityNotFoundException(final String message, final Throwable cause) {
|
||||
super(message, THIS_ERROR, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameterized constructor.
|
||||
*
|
||||
* @param message
|
||||
* of the exception
|
||||
*/
|
||||
public EntityNotFoundException(final String message) {
|
||||
super(message, THIS_ERROR);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* 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.exception;
|
||||
|
||||
import org.eclipse.hawkbit.exception.SpServerError;
|
||||
import org.eclipse.hawkbit.exception.SpServerRtException;
|
||||
|
||||
/**
|
||||
* the {@link EntityReadOnlyException} is thrown when a entity is in read only
|
||||
* mode and a user tries to change it.
|
||||
*/
|
||||
public class EntityReadOnlyException extends SpServerRtException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final SpServerError THIS_ERROR = SpServerError.SP_REPO_ENTITY_READ_ONLY;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
public EntityReadOnlyException() {
|
||||
super(THIS_ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameterized constructor.
|
||||
*
|
||||
* @param cause
|
||||
* of the exception
|
||||
*/
|
||||
public EntityReadOnlyException(final Throwable cause) {
|
||||
super(THIS_ERROR, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameterized constructor.
|
||||
*
|
||||
* @param message
|
||||
* of the exception
|
||||
* @param cause
|
||||
* of the exception
|
||||
*/
|
||||
public EntityReadOnlyException(final String message, final Throwable cause) {
|
||||
super(message, THIS_ERROR, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameterized constructor.
|
||||
*
|
||||
* @param message
|
||||
* of the exception
|
||||
*/
|
||||
public EntityReadOnlyException(final String message) {
|
||||
super(message, THIS_ERROR);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* 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.exception;
|
||||
|
||||
import org.eclipse.hawkbit.exception.SpServerError;
|
||||
import org.eclipse.hawkbit.exception.SpServerRtException;
|
||||
|
||||
/**
|
||||
* Thrown when force quitting an actions is not allowed. e.g. the action is not
|
||||
* active or it is not canceled before.
|
||||
*
|
||||
*/
|
||||
public final class ForceQuitActionNotAllowedException extends SpServerRtException {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Creates a new CancelActionNotAllowed with
|
||||
* {@link SpServerError#SP_ACTION_NOT_CANCELABLE} error.
|
||||
*/
|
||||
public ForceQuitActionNotAllowedException() {
|
||||
super(SpServerError.SP_ACTION_NOT_FORCE_QUITABLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cause
|
||||
* for the exception
|
||||
*/
|
||||
public ForceQuitActionNotAllowedException(final Throwable cause) {
|
||||
super(SpServerError.SP_ACTION_NOT_FORCE_QUITABLE, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message
|
||||
* of the error
|
||||
*/
|
||||
public ForceQuitActionNotAllowedException(final String message) {
|
||||
super(message, SpServerError.SP_ACTION_NOT_FORCE_QUITABLE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* 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.exception;
|
||||
|
||||
import org.eclipse.hawkbit.exception.SpServerError;
|
||||
import org.eclipse.hawkbit.exception.SpServerRtException;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public final class GridFSDBFileNotFoundException extends SpServerRtException {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Creates a new FileUploadFailedException with
|
||||
* {@link SpServerError#SP_REST_BODY_NOT_READABLE} error.
|
||||
*/
|
||||
public GridFSDBFileNotFoundException() {
|
||||
super(SpServerError.SP_ARTIFACT_LOAD_FAILED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cause
|
||||
* for the exception
|
||||
*/
|
||||
public GridFSDBFileNotFoundException(final Throwable cause) {
|
||||
super(SpServerError.SP_ARTIFACT_LOAD_FAILED, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message
|
||||
* of the error
|
||||
*/
|
||||
public GridFSDBFileNotFoundException(final String message) {
|
||||
super(message, SpServerError.SP_ARTIFACT_LOAD_FAILED);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* 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.exception;
|
||||
|
||||
import org.eclipse.hawkbit.exception.SpServerError;
|
||||
import org.eclipse.hawkbit.exception.SpServerRtException;
|
||||
|
||||
/**
|
||||
* Thrown if a distribution set is assigned to a a target that is incomplete
|
||||
* (i.e. mandatory modules are missing).
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public final class IncompleteDistributionSetException extends SpServerRtException {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Creates a new IncompleteDistributionSetException with
|
||||
* {@link SpServerError#SP_DS_INCOMPLETE} error.
|
||||
*/
|
||||
public IncompleteDistributionSetException() {
|
||||
super(SpServerError.SP_DS_INCOMPLETE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cause
|
||||
* for the exception
|
||||
*/
|
||||
public IncompleteDistributionSetException(final Throwable cause) {
|
||||
super(SpServerError.SP_DS_INCOMPLETE, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message
|
||||
* of the error
|
||||
*/
|
||||
public IncompleteDistributionSetException(final String message) {
|
||||
super(message, SpServerError.SP_DS_INCOMPLETE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* 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.exception;
|
||||
|
||||
import org.eclipse.hawkbit.exception.SpServerError;
|
||||
import org.eclipse.hawkbit.exception.SpServerRtException;
|
||||
|
||||
/**
|
||||
* Exception which is thrown in case the current security context object does
|
||||
* not hold a required authority/permission.
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class InsufficientPermissionException extends SpServerRtException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* creates new InsufficientPermissionException.
|
||||
*
|
||||
* @param cause
|
||||
* the cause of the exception
|
||||
*/
|
||||
public InsufficientPermissionException(final Throwable cause) {
|
||||
super(SpServerError.SP_INSUFFICIENT_PERMISSION, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* creates new InsufficientPermissionException.
|
||||
*/
|
||||
public InsufficientPermissionException() {
|
||||
this(null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* 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.exception;
|
||||
|
||||
import org.eclipse.hawkbit.exception.SpServerError;
|
||||
import org.eclipse.hawkbit.exception.SpServerRtException;
|
||||
|
||||
/**
|
||||
* Thrown if MD5 checksum check fails.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class InvalidMD5HashException extends SpServerRtException {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Creates a new FileUploadFailedException with
|
||||
* {@link SpServerError#SP_ARTIFACT_UPLOAD_FAILED_MD5_MATCH} error.
|
||||
*/
|
||||
public InvalidMD5HashException() {
|
||||
super(SpServerError.SP_ARTIFACT_UPLOAD_FAILED_MD5_MATCH);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message
|
||||
* of the error
|
||||
* @param cause
|
||||
* for the exception
|
||||
*/
|
||||
public InvalidMD5HashException(final String message, final Throwable cause) {
|
||||
super(message, SpServerError.SP_ARTIFACT_UPLOAD_FAILED_MD5_MATCH, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message
|
||||
* of the error
|
||||
*/
|
||||
public InvalidMD5HashException(final String message) {
|
||||
super(message, SpServerError.SP_ARTIFACT_UPLOAD_FAILED_MD5_MATCH);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* 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.exception;
|
||||
|
||||
import org.eclipse.hawkbit.exception.SpServerError;
|
||||
import org.eclipse.hawkbit.exception.SpServerRtException;
|
||||
|
||||
/**
|
||||
* Thrown if SHA1 checksum check fails.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class InvalidSHA1HashException extends SpServerRtException {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Creates a new FileUploadFailedException with
|
||||
* {@link SpServerError#SP_ARTIFACT_UPLOAD_FAILED_SHA1_MATCH} error.
|
||||
*/
|
||||
public InvalidSHA1HashException() {
|
||||
super(SpServerError.SP_ARTIFACT_UPLOAD_FAILED_SHA1_MATCH);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message
|
||||
* of the error
|
||||
* @param cause
|
||||
* for the exception
|
||||
*/
|
||||
public InvalidSHA1HashException(final String message, final Throwable cause) {
|
||||
super(message, SpServerError.SP_ARTIFACT_UPLOAD_FAILED_SHA1_MATCH, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message
|
||||
* of the error
|
||||
*/
|
||||
public InvalidSHA1HashException(final String message) {
|
||||
super(message, SpServerError.SP_ARTIFACT_UPLOAD_FAILED_SHA1_MATCH);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* 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.exception;
|
||||
|
||||
import org.eclipse.hawkbit.exception.SpServerError;
|
||||
import org.eclipse.hawkbit.exception.SpServerRtException;
|
||||
|
||||
/**
|
||||
* Exception used by the REST API in case of RSQL search filter query.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class RSQLParameterSyntaxException extends SpServerRtException {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Creates a new RSQLSyntaxException with
|
||||
* {@link SpServerError#SP_REST_RSQL_SEARCH_PARAM_SYNTAX} error.
|
||||
*/
|
||||
public RSQLParameterSyntaxException() {
|
||||
super(SpServerError.SP_REST_RSQL_SEARCH_PARAM_SYNTAX);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new RSQLSyntaxException with
|
||||
* {@link SpServerError#SP_REST_RSQL_SEARCH_PARAM_SYNTAX} error.
|
||||
*
|
||||
* @param cause
|
||||
* the cause of this exception
|
||||
*/
|
||||
public RSQLParameterSyntaxException(final Throwable cause) {
|
||||
super(SpServerError.SP_REST_RSQL_SEARCH_PARAM_SYNTAX, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new RSQLParameterSyntaxException with
|
||||
* {@link SpServerError#SP_REST_RSQL_SEARCH_PARAM_SYNTAX} error.
|
||||
*
|
||||
* @param message
|
||||
* the message of the exception
|
||||
* @param cause
|
||||
* the cause (which is saved for later retrieval by the
|
||||
* getCause() method). (A null value is permitted, and indicates
|
||||
* that the cause is nonexistent or unknown.)
|
||||
*/
|
||||
public RSQLParameterSyntaxException(final String message, final Throwable cause) {
|
||||
super(message, SpServerError.SP_REST_RSQL_SEARCH_PARAM_SYNTAX, cause);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
/**
|
||||
* 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.exception;
|
||||
|
||||
import org.eclipse.hawkbit.exception.SpServerError;
|
||||
import org.eclipse.hawkbit.exception.SpServerRtException;
|
||||
|
||||
/**
|
||||
* Exception used by the REST API in case of invalid field name in the rsql
|
||||
* search parameter.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class RSQLParameterUnsupportedFieldException extends SpServerRtException {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Creates a new RSQLParameterUnsupportedFieldException with
|
||||
* {@link SpServerError#SP_REST_RSQL_PARAM_INVALID_FIELD} error.
|
||||
*/
|
||||
public RSQLParameterUnsupportedFieldException() {
|
||||
super(SpServerError.SP_REST_RSQL_PARAM_INVALID_FIELD);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new RSQLParameterUnsupportedFieldException with
|
||||
* {@link SpServerError#SP_REST_RSQL_PARAM_INVALID_FIELD} error.
|
||||
*
|
||||
* @param cause
|
||||
* the cause (which is saved for later retrieval by the
|
||||
* getCause() method). (A null value is permitted, and indicates
|
||||
* that the cause is nonexistent or unknown.)
|
||||
*/
|
||||
public RSQLParameterUnsupportedFieldException(final Throwable cause) {
|
||||
super(SpServerError.SP_REST_RSQL_PARAM_INVALID_FIELD, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new RSQLParameterUnsupportedFieldException with
|
||||
* {@link SpServerError#SP_REST_RSQL_PARAM_INVALID_FIELD} error.
|
||||
*
|
||||
* @param message
|
||||
* the message of the exception
|
||||
* @param cause
|
||||
* the cause (which is saved for later retrieval by the
|
||||
* getCause() method). (A null value is permitted, and indicates
|
||||
* that the cause is nonexistent or unknown.)
|
||||
*/
|
||||
public RSQLParameterUnsupportedFieldException(final String message, final Throwable cause) {
|
||||
super(message, SpServerError.SP_REST_RSQL_PARAM_INVALID_FIELD, cause);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* 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.exception;
|
||||
|
||||
import org.eclipse.hawkbit.exception.SpServerError;
|
||||
import org.eclipse.hawkbit.exception.SpServerRtException;
|
||||
|
||||
/**
|
||||
* the {@link RolloutIllegalStateException} is thrown when a rollout is changing
|
||||
* it's state which is not valid. E.g. trying to start a already running
|
||||
* rollout, or trying to resume a already finished rollout.
|
||||
*
|
||||
*/
|
||||
public class RolloutIllegalStateException extends SpServerRtException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final SpServerError THIS_ERROR = SpServerError.SP_ROLLOUT_ILLEGAL_STATE;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
public RolloutIllegalStateException() {
|
||||
super(THIS_ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameterized constructor.
|
||||
*
|
||||
* @param cause
|
||||
* of the exception
|
||||
*/
|
||||
public RolloutIllegalStateException(final Throwable cause) {
|
||||
super(THIS_ERROR, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameterized constructor.
|
||||
*
|
||||
* @param message
|
||||
* of the exception
|
||||
* @param cause
|
||||
* of the exception
|
||||
*/
|
||||
public RolloutIllegalStateException(final String message, final Throwable cause) {
|
||||
super(message, THIS_ERROR, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameterized constructor.
|
||||
*
|
||||
* @param message
|
||||
* of the exception
|
||||
*/
|
||||
public RolloutIllegalStateException(final String message) {
|
||||
super(message, THIS_ERROR);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/**
|
||||
* 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.exception;
|
||||
|
||||
import org.eclipse.hawkbit.exception.SpServerError;
|
||||
import org.eclipse.hawkbit.exception.SpServerRtException;
|
||||
|
||||
/**
|
||||
* the {@link TenantNotExistException} is thrown when e.g. a controller tries to
|
||||
* register itself at SP as plug'n play target and the tenant specified in the
|
||||
* URL for this target does not exist. To avoid that targets could register
|
||||
* automatically new tenants.
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class TenantNotExistException extends SpServerRtException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final SpServerError THIS_ERROR = SpServerError.SP_REPO_TENANT_NOT_EXISTS;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
public TenantNotExistException() {
|
||||
super(THIS_ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameterized constructor.
|
||||
*
|
||||
* @param cause
|
||||
* of the exception
|
||||
*/
|
||||
public TenantNotExistException(final Throwable cause) {
|
||||
super(THIS_ERROR, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameterized constructor.
|
||||
*
|
||||
* @param message
|
||||
* of the exception
|
||||
* @param cause
|
||||
* of the exception
|
||||
*/
|
||||
public TenantNotExistException(final String message, final Throwable cause) {
|
||||
super(message, THIS_ERROR, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameterized constructor.
|
||||
*
|
||||
* @param message
|
||||
* of the exception
|
||||
*/
|
||||
public TenantNotExistException(final String message) {
|
||||
super(message, THIS_ERROR);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* 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.exception;
|
||||
|
||||
import org.eclipse.hawkbit.exception.SpServerError;
|
||||
import org.eclipse.hawkbit.exception.SpServerRtException;
|
||||
|
||||
/**
|
||||
* Thrown if too many status entries have been inserted.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public final class ToManyAttributeEntriesException extends SpServerRtException {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Creates a new FileUploadFailedException with
|
||||
* {@link SpServerError#SP_ATTRIBUTES_TO_MANY_ENTRIES} error.
|
||||
*/
|
||||
public ToManyAttributeEntriesException() {
|
||||
super(SpServerError.SP_ATTRIBUTES_TO_MANY_ENTRIES);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cause
|
||||
* for the exception
|
||||
*/
|
||||
public ToManyAttributeEntriesException(final Throwable cause) {
|
||||
super(SpServerError.SP_ATTRIBUTES_TO_MANY_ENTRIES, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message
|
||||
* of the error
|
||||
*/
|
||||
public ToManyAttributeEntriesException(final String message) {
|
||||
super(message, SpServerError.SP_ATTRIBUTES_TO_MANY_ENTRIES);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* 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.exception;
|
||||
|
||||
import org.eclipse.hawkbit.exception.SpServerError;
|
||||
import org.eclipse.hawkbit.exception.SpServerRtException;
|
||||
|
||||
/**
|
||||
* Thrown if too many status entries have been inserted.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public final class ToManyStatusEntriesException extends SpServerRtException {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Creates a new FileUploadFailedException with
|
||||
* {@link SpServerError#SP_REST_BODY_NOT_READABLE} error.
|
||||
*/
|
||||
public ToManyStatusEntriesException() {
|
||||
super(SpServerError.SP_ACTION_STATUS_TO_MANY_ENTRIES);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cause
|
||||
* for the exception
|
||||
*/
|
||||
public ToManyStatusEntriesException(final Throwable cause) {
|
||||
super(SpServerError.SP_ACTION_STATUS_TO_MANY_ENTRIES, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message
|
||||
* of the error
|
||||
*/
|
||||
public ToManyStatusEntriesException(final String message) {
|
||||
super(message, SpServerError.SP_ACTION_STATUS_TO_MANY_ENTRIES);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/**
|
||||
* 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.exception;
|
||||
|
||||
import org.eclipse.hawkbit.exception.SpServerError;
|
||||
import org.eclipse.hawkbit.exception.SpServerRtException;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSet;
|
||||
import org.eclipse.hawkbit.repository.model.DistributionSetType;
|
||||
import org.eclipse.hawkbit.repository.model.SoftwareModule;
|
||||
|
||||
/**
|
||||
* Thrown if user tries to add a {@link SoftwareModule} to a
|
||||
* {@link DistributionSet} that is not defined by< the
|
||||
* {@link DistributionSetType}.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class UnsupportedSoftwareModuleForThisDistributionSetException extends SpServerRtException {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Creates a new UnsupportedSoftwareModuleForThisDistributionSetException
|
||||
* with {@link SpServerError#SP_DS_MODULE_UNSUPPORTED} error.
|
||||
*/
|
||||
public UnsupportedSoftwareModuleForThisDistributionSetException() {
|
||||
super(SpServerError.SP_DS_MODULE_UNSUPPORTED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param cause
|
||||
* for the exception
|
||||
*/
|
||||
public UnsupportedSoftwareModuleForThisDistributionSetException(final Throwable cause) {
|
||||
super(SpServerError.SP_DS_MODULE_UNSUPPORTED, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message
|
||||
* of the error
|
||||
*/
|
||||
public UnsupportedSoftwareModuleForThisDistributionSetException(final String message) {
|
||||
super(message, SpServerError.SP_DS_MODULE_UNSUPPORTED);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,230 @@
|
||||
/**
|
||||
* 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.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Operations to be executed by the target. Usually a software update. Other
|
||||
* supported actions are the cancellation of a running update action or a
|
||||
* refresh request for target attributes.
|
||||
*
|
||||
*/
|
||||
public interface Action extends TenantAwareBaseEntity {
|
||||
|
||||
/**
|
||||
* indicating that target action has no force time which is only needed in
|
||||
* case of {@link ActionType#TIMEFORCED}.
|
||||
*/
|
||||
long NO_FORCE_TIME = 0L;
|
||||
|
||||
/**
|
||||
* @return the distributionSet
|
||||
*/
|
||||
DistributionSet getDistributionSet();
|
||||
|
||||
/**
|
||||
* @param distributionSet
|
||||
* the distributionSet to set
|
||||
*/
|
||||
void setDistributionSet(DistributionSet distributionSet);
|
||||
|
||||
/**
|
||||
* @return <code>true</code> when action is in state
|
||||
* {@link Status#CANCELING} or {@link Status#CANCELED}, false
|
||||
* otherwise
|
||||
*/
|
||||
default boolean isCancelingOrCanceled() {
|
||||
return Status.CANCELING.equals(getStatus()) || Status.CANCELED.equals(getStatus());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return current {@link Status#DOWNLOAD} progress if known by the update
|
||||
* server.
|
||||
*/
|
||||
int getDownloadProgressPercent();
|
||||
|
||||
/**
|
||||
* @return current {@link Status} of the {@link Action}.
|
||||
*/
|
||||
Status getStatus();
|
||||
|
||||
/**
|
||||
* @param status
|
||||
* of the {@link Action}
|
||||
*/
|
||||
void setStatus(Status status);
|
||||
|
||||
/**
|
||||
* @return <code>true</code> if {@link Action} is still running.
|
||||
*/
|
||||
boolean isActive();
|
||||
|
||||
/**
|
||||
* @return the {@link ActionType}
|
||||
*/
|
||||
ActionType getActionType();
|
||||
|
||||
/**
|
||||
* @return list of {@link ActionStatus} entries.
|
||||
*/
|
||||
List<ActionStatus> getActionStatus();
|
||||
|
||||
/**
|
||||
* @param target
|
||||
* of this {@link Action}
|
||||
*/
|
||||
void setTarget(Target target);
|
||||
|
||||
/**
|
||||
* @return {@link Target} of this {@link Action}.
|
||||
*/
|
||||
Target getTarget();
|
||||
|
||||
/**
|
||||
* @return time in {@link TimeUnit#MILLISECONDS} after which
|
||||
* {@link #isForced()} switches to <code>true</code> in case of
|
||||
* {@link ActionType#TIMEFORCED}.
|
||||
*/
|
||||
long getForcedTime();
|
||||
|
||||
/**
|
||||
* @return rolloutGroup related to this {@link Action}.
|
||||
*/
|
||||
RolloutGroup getRolloutGroup();
|
||||
|
||||
/**
|
||||
* @return rollout related to this {@link Action}.
|
||||
*/
|
||||
Rollout getRollout();
|
||||
|
||||
/**
|
||||
* checks if the {@link #getForcedTime()} is hit by the given
|
||||
* {@code hitTimeMillis}, by means if the given milliseconds are greater
|
||||
* than the forcedTime.
|
||||
*
|
||||
* @param hitTimeMillis
|
||||
* the milliseconds, mostly the
|
||||
* {@link System#currentTimeMillis()}
|
||||
* @return {@code true} if this {@link #getActionType()} is in
|
||||
* {@link ActionType#TIMEFORCED} and the given {@code hitTimeMillis}
|
||||
* is greater than the {@link #getForcedTime()} otherwise
|
||||
* {@code false}
|
||||
*/
|
||||
default boolean isHitAutoForceTime(final long hitTimeMillis) {
|
||||
if (ActionType.TIMEFORCED.equals(getActionType())) {
|
||||
return hitTimeMillis >= getForcedTime();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@code true} if either the {@link #getActionType()} is
|
||||
* {@link ActionType#FORCED} or {@link ActionType#TIMEFORCED} but
|
||||
* then if the {@link #getForcedTime()} has been exceeded otherwise
|
||||
* always {@code false}
|
||||
*/
|
||||
default boolean isForce() {
|
||||
switch (getActionType()) {
|
||||
case FORCED:
|
||||
return true;
|
||||
case TIMEFORCED:
|
||||
return isHitAutoForceTime(System.currentTimeMillis());
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true when action is forced, false otherwise
|
||||
*/
|
||||
default boolean isForced() {
|
||||
return ActionType.FORCED.equals(getActionType());
|
||||
}
|
||||
|
||||
/**
|
||||
* Action status as reported by the controller.
|
||||
*
|
||||
* Be aware that JPA is persisting the ordinal number of the enum by means
|
||||
* the ordered number in the enum. So don't re-order the enums within the
|
||||
* Status enum declaration!
|
||||
*
|
||||
*/
|
||||
public enum Status {
|
||||
/**
|
||||
* Action is finished successfully for this target.
|
||||
*/
|
||||
FINISHED,
|
||||
|
||||
/**
|
||||
* Action has failed for this target.
|
||||
*/
|
||||
ERROR,
|
||||
|
||||
/**
|
||||
* Action is still running but with warnings.
|
||||
*/
|
||||
WARNING,
|
||||
|
||||
/**
|
||||
* Action is still running for this target.
|
||||
*/
|
||||
RUNNING,
|
||||
|
||||
/**
|
||||
* Action has been canceled for this target.
|
||||
*/
|
||||
CANCELED,
|
||||
|
||||
/**
|
||||
* Action is in canceling state and waiting for controller confirmation.
|
||||
*/
|
||||
CANCELING,
|
||||
|
||||
/**
|
||||
* Action has been send to the target.
|
||||
*/
|
||||
RETRIEVED,
|
||||
|
||||
/**
|
||||
* Action requests download by this target which has now started.
|
||||
*/
|
||||
DOWNLOAD,
|
||||
|
||||
/**
|
||||
* Action is in waiting state, e.g. the action is scheduled in a rollout
|
||||
* but not yet activated.
|
||||
*/
|
||||
SCHEDULED;
|
||||
}
|
||||
|
||||
/**
|
||||
* The action type for this action relation.
|
||||
*
|
||||
*/
|
||||
public enum ActionType {
|
||||
/**
|
||||
* Forced action execution. Target is advised to executed immediately.
|
||||
*/
|
||||
FORCED,
|
||||
|
||||
/**
|
||||
* Soft action execution. Target is advised to execute when it fits.
|
||||
*/
|
||||
SOFT,
|
||||
|
||||
/**
|
||||
* {@link #SOFT} action execution until
|
||||
* {@link Action#isHitAutoForceTime(long)} is reached, {@link #FORCED}
|
||||
* after that.
|
||||
*/
|
||||
TIMEFORCED;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/**
|
||||
* 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.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.Action.Status;
|
||||
|
||||
/**
|
||||
* Status information of an {@link Action} which can be provided by the
|
||||
* {@link Target} or is added by the update server itself. This can be the start
|
||||
* of the {@link Action} life cycle, the end and update notifications in
|
||||
* between.
|
||||
*
|
||||
*/
|
||||
public interface ActionStatus extends TenantAwareBaseEntity {
|
||||
|
||||
/**
|
||||
* @return time in {@link TimeUnit#MILLISECONDS} when the status was
|
||||
* reported.
|
||||
*/
|
||||
Long getOccurredAt();
|
||||
|
||||
/**
|
||||
* @param occurredAt
|
||||
* time in {@link TimeUnit#MILLISECONDS} when the status was
|
||||
* reported.
|
||||
*/
|
||||
void setOccurredAt(Long occurredAt);
|
||||
|
||||
/**
|
||||
* Adds message including splitting in case it exceeds 512 length.
|
||||
*
|
||||
* @param message
|
||||
* to add
|
||||
*/
|
||||
void addMessage(String message);
|
||||
|
||||
/**
|
||||
* @return list of message entries that can be added to the
|
||||
* {@link ActionStatus}.
|
||||
*/
|
||||
List<String> getMessages();
|
||||
|
||||
/**
|
||||
* @return {@link Action} this {@link ActionStatus} belongs to.
|
||||
*/
|
||||
Action getAction();
|
||||
|
||||
/**
|
||||
* @param action
|
||||
* this {@link ActionStatus} belongs to.
|
||||
*/
|
||||
void setAction(Action action);
|
||||
|
||||
/**
|
||||
* @return the {@link Status} of this {@link ActionStatus}. Caused
|
||||
* potentially a transition change of the {@link #getAction()} if
|
||||
* different from the previous {@link ActionStatus#getStatus()}.
|
||||
*/
|
||||
Status getStatus();
|
||||
|
||||
/**
|
||||
* @param status
|
||||
* of this {@link ActionStatus}. May cause a transition change of
|
||||
* the {@link #getAction()} if different from the previous
|
||||
* {@link ActionStatus#getStatus()}.
|
||||
*/
|
||||
void setStatus(Status status);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* View for querying {@link Action} include the count of the action's
|
||||
* {@link ActionStatus} entries.
|
||||
*
|
||||
*/
|
||||
public interface ActionWithStatusCount {
|
||||
|
||||
/**
|
||||
* @return {@link Action}
|
||||
*/
|
||||
Action getAction();
|
||||
|
||||
/**
|
||||
* @return {@link DistributionSet} ID.
|
||||
*/
|
||||
Long getDsId();
|
||||
|
||||
/**
|
||||
* @return {@link DistributionSet} name.
|
||||
*/
|
||||
String getDsName();
|
||||
|
||||
/**
|
||||
* @return {@link DistributionSet} version.
|
||||
*/
|
||||
String getDsVersion();
|
||||
|
||||
/**
|
||||
* @return number of {@link ActionStatus} entries
|
||||
*/
|
||||
Long getActionStatusCount();
|
||||
|
||||
/**
|
||||
* @return name of the {@link Rollout}.
|
||||
*/
|
||||
String getRolloutName();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* 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 com.google.common.io.BaseEncoding;
|
||||
|
||||
/**
|
||||
* Binaries for a {@link SoftwareModule} Note: the decision which artifacts have
|
||||
* to be downloaded are done on the device side. e.g. Full Package, Signatures,
|
||||
* binary deltas
|
||||
*
|
||||
*/
|
||||
public interface Artifact extends TenantAwareBaseEntity {
|
||||
|
||||
/**
|
||||
* @return {@link SoftwareModule} this {@link Artifact} belongs to.
|
||||
*/
|
||||
SoftwareModule getSoftwareModule();
|
||||
|
||||
/**
|
||||
* @return MD5 hash of the artifact.
|
||||
*/
|
||||
String getMd5Hash();
|
||||
|
||||
/**
|
||||
* @return SHA-1 hash of the artifact in {@link BaseEncoding#base16()}
|
||||
* format.
|
||||
*/
|
||||
String getSha1Hash();
|
||||
|
||||
/**
|
||||
* @return size of the artifact in bytes.
|
||||
*/
|
||||
Long getSize();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
/**
|
||||
* 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.io.Serializable;
|
||||
|
||||
/**
|
||||
* Use to display software modules for the selected distribution.
|
||||
*
|
||||
*/
|
||||
public class AssignedSoftwareModule implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 6144585781451168439L;
|
||||
|
||||
private final SoftwareModule softwareModule;
|
||||
|
||||
private final boolean assigned;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param softwareModule
|
||||
* entity.
|
||||
* @param assigned
|
||||
* as true if the software module is assigned and false if not
|
||||
* assigned.
|
||||
*/
|
||||
public AssignedSoftwareModule(final SoftwareModule softwareModule, final boolean assigned) {
|
||||
this.softwareModule = softwareModule;
|
||||
this.assigned = assigned;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@link SoftwareModule}
|
||||
*/
|
||||
public SoftwareModule getSoftwareModule() {
|
||||
return softwareModule;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>true</code> if assigned
|
||||
*/
|
||||
public boolean isAssigned() {
|
||||
return assigned;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AssignedSoftwareModule [softwareModule=" + softwareModule + ", assigned=" + assigned + "]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + (assigned ? 1231 : 1237);
|
||||
result = prime * result + (softwareModule == null ? 0 : softwareModule.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (!(obj instanceof AssignedSoftwareModule)) {
|
||||
return false;
|
||||
}
|
||||
final AssignedSoftwareModule other = (AssignedSoftwareModule) obj;
|
||||
if (assigned != other.assigned) {
|
||||
return false;
|
||||
}
|
||||
if (softwareModule == null) {
|
||||
if (other.softwareModule != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!softwareModule.equals(other.softwareModule)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
/**
|
||||
* 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.util.List;
|
||||
|
||||
/**
|
||||
* Generic assignment result bean.
|
||||
*
|
||||
*/
|
||||
public class AssignmentResult<T extends BaseEntity> {
|
||||
|
||||
private final int total;
|
||||
private final int assigned;
|
||||
private final int alreadyAssigned;
|
||||
private final int unassigned;
|
||||
private final List<T> assignedEntity;
|
||||
private final List<T> unassignedEntity;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param assigned
|
||||
* is the number of newly assigned elements.
|
||||
* @param alreadyAssigned
|
||||
* number of already assigned/ignored elements
|
||||
* @param unassigned
|
||||
* number of newly assigned elements
|
||||
* @param assignedEntity
|
||||
* {@link List} of assigned entity.
|
||||
* @param unassignedEntity
|
||||
* {@link List} of unassigned entity.
|
||||
*/
|
||||
public AssignmentResult(final int assigned, final int alreadyAssigned, final int unassigned,
|
||||
final List<T> assignedEntity, final List<T> unassignedEntity) {
|
||||
this.assigned = assigned;
|
||||
this.alreadyAssigned = alreadyAssigned;
|
||||
total = assigned + alreadyAssigned;
|
||||
this.unassigned = unassigned;
|
||||
this.assignedEntity = assignedEntity;
|
||||
this.unassignedEntity = unassignedEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return number of newly assigned elements.
|
||||
*/
|
||||
public int getAssigned() {
|
||||
return assigned;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return total number (assigned and already assigned).
|
||||
*/
|
||||
public int getTotal() {
|
||||
return total;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return number of already assigned/ignored elements.
|
||||
*/
|
||||
public int getAlreadyAssigned() {
|
||||
return alreadyAssigned;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return number of unsassigned elements
|
||||
*/
|
||||
public int getUnassigned() {
|
||||
return unassigned;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@link List} of assigned entity.
|
||||
*/
|
||||
public List<T> getAssignedEntity() {
|
||||
return assignedEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return {@link List} of unassigned entity.
|
||||
*/
|
||||
public List<T> getUnassignedEntity() {
|
||||
return unassignedEntity;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* 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.io.Serializable;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.springframework.hateoas.Identifiable;
|
||||
|
||||
/**
|
||||
* Core information of all entities.
|
||||
*
|
||||
*/
|
||||
public interface BaseEntity extends Serializable, Identifiable<Long> {
|
||||
|
||||
/**
|
||||
* @return time in {@link TimeUnit#MILLISECONDS} when the {@link BaseEntity}
|
||||
* was created.
|
||||
*/
|
||||
Long getCreatedAt();
|
||||
|
||||
/**
|
||||
* @return user that created the {@link BaseEntity}.
|
||||
*/
|
||||
String getCreatedBy();
|
||||
|
||||
/**
|
||||
* @return time in {@link TimeUnit#MILLISECONDS} when the {@link BaseEntity}
|
||||
* was last time changed.
|
||||
*/
|
||||
Long getLastModifiedAt();
|
||||
|
||||
/**
|
||||
* @return user that updated the {@link BaseEntity} last.
|
||||
*/
|
||||
String getLastModifiedBy();
|
||||
|
||||
/**
|
||||
* @return version of the {@link BaseEntity}.
|
||||
*/
|
||||
long getOptLockRevision();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
/**
|
||||
* 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.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.eclipse.hawkbit.repository.DistributionSetManagement;
|
||||
|
||||
/**
|
||||
* A {@link DistributionSet} defines a meta package that combines a set of
|
||||
* {@link SoftwareModule}s which have to be or are provisioned to a
|
||||
* {@link Target}.
|
||||
*
|
||||
* <p>
|
||||
* A {@link Target} has exactly one target {@link DistributionSet} assigned.
|
||||
* </p>
|
||||
*
|
||||
*/
|
||||
public interface DistributionSet extends NamedVersionedEntity {
|
||||
|
||||
/**
|
||||
* @return {@link Set} of assigned {@link DistributionSetTag}s.
|
||||
*/
|
||||
Set<DistributionSetTag> getTags();
|
||||
|
||||
/**
|
||||
* @return <code>true</code> if the set is deleted and only kept for history
|
||||
* purposes.
|
||||
*/
|
||||
boolean isDeleted();
|
||||
|
||||
/**
|
||||
* @return immutable {@link List} of {@link DistributionSetMetadata}
|
||||
* elements. See {@link DistributionSetManagement} to alter.
|
||||
*/
|
||||
List<DistributionSetMetadata> getMetadata();
|
||||
|
||||
/**
|
||||
* @return <code>true</code> if {@link DistributionSet} contains a mandatory
|
||||
* migration step, i.e. unfinished {@link Action}s will kept active
|
||||
* and not automatically canceled if overridden by a newer update.
|
||||
*/
|
||||
boolean isRequiredMigrationStep();
|
||||
|
||||
/**
|
||||
* @param deleted
|
||||
* to <code>true</code> if {@link DistributionSet} is no longer
|
||||
* be usage but kept for history purposes.
|
||||
* @return updated {@link DistributionSet}
|
||||
*/
|
||||
DistributionSet setDeleted(boolean deleted);
|
||||
|
||||
/**
|
||||
* @param isRequiredMigrationStep
|
||||
* to <code>true</code> if {@link DistributionSet} contains a
|
||||
* mandatory migration step, i.e. unfinished {@link Action}s will
|
||||
* kept active and not automatically canceled if overridden by a
|
||||
* newer update.
|
||||
*
|
||||
* @return updated {@link DistributionSet}
|
||||
*/
|
||||
DistributionSet setRequiredMigrationStep(boolean isRequiredMigrationStep);
|
||||
|
||||
/**
|
||||
* @return the assignedTargets
|
||||
*/
|
||||
List<Target> getAssignedTargets();
|
||||
|
||||
/**
|
||||
* @return the installedTargets
|
||||
*/
|
||||
List<TargetInfo> getInstalledTargets();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return unmodifiableSet of {@link SoftwareModule}.
|
||||
*/
|
||||
Set<SoftwareModule> getModules();
|
||||
|
||||
/**
|
||||
* @return {@link DistributionSetIdName} view.
|
||||
*/
|
||||
DistributionSetIdName getDistributionSetIdName();
|
||||
|
||||
/**
|
||||
* @param softwareModule
|
||||
* @return <code>true</code> if the module was added and <code>false</code>
|
||||
* if it already existed in the set
|
||||
*
|
||||
*/
|
||||
boolean addModule(SoftwareModule softwareModule);
|
||||
|
||||
/**
|
||||
* Removed given {@link SoftwareModule} from this DS instance.
|
||||
*
|
||||
* @param softwareModule
|
||||
* to remove
|
||||
* @return <code>true</code> if element was found and removed
|
||||
*/
|
||||
boolean removeModule(SoftwareModule softwareModule);
|
||||
|
||||
/**
|
||||
* Searches through modules for the given type.
|
||||
*
|
||||
* @param type
|
||||
* to search for
|
||||
* @return SoftwareModule of given type or <code>null</code> if not in the
|
||||
* list.
|
||||
*/
|
||||
SoftwareModule findFirstModuleByType(SoftwareModuleType type);
|
||||
|
||||
/**
|
||||
* @return type of the {@link DistributionSet}.
|
||||
*/
|
||||
DistributionSetType getType();
|
||||
|
||||
/**
|
||||
* @param type
|
||||
* of the {@link DistributionSet}.
|
||||
*/
|
||||
void setType(DistributionSetType type);
|
||||
|
||||
/**
|
||||
* @return <code>true</code> if all defined
|
||||
* {@link DistributionSetType#getMandatoryModuleTypes()} of
|
||||
* {@link #getType()} are present in this {@link DistributionSet}.
|
||||
*/
|
||||
boolean isComplete();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
/**
|
||||
* 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.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class DistributionSetIdName implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final Long id;
|
||||
private final String name;
|
||||
private final String version;
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* the {@link DistributionSet#getId()}
|
||||
* @param name
|
||||
* the {@link DistributionSet#getName()}
|
||||
* @param version
|
||||
* the {@link DistributionSet#getVersion()}
|
||||
*
|
||||
*/
|
||||
public DistributionSetIdName(final Long id, final String name, final String version) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + (id == null ? 0 : id.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (!(obj instanceof DistributionSetIdName)) {
|
||||
return false;
|
||||
}
|
||||
final DistributionSetIdName other = (DistributionSetIdName) obj;
|
||||
if (id == null) {
|
||||
if (other.id != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!id.equals(other.id)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
// only return the ID because it's used in vaadin for setting the item
|
||||
// id in the dom
|
||||
return id.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* {@link MetaData} of a {@link DistributionSet}.
|
||||
*
|
||||
*/
|
||||
public interface DistributionSetMetadata extends MetaData {
|
||||
|
||||
/**
|
||||
* @return {@link DistributionSet} of this {@link MetaData} entry.
|
||||
*/
|
||||
DistributionSet getDistributionSet();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* 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.util.List;
|
||||
|
||||
/**
|
||||
* {@link Tag} of a {@link DistributionSet}.
|
||||
*
|
||||
*/
|
||||
public interface DistributionSetTag extends Tag {
|
||||
|
||||
/**
|
||||
* @return {@link List} of {@link DistributionSet}s this {@link Tag} is
|
||||
* assigned to.
|
||||
*/
|
||||
List<DistributionSet> getAssignedToDistributionSet();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* 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.util.List;
|
||||
|
||||
/**
|
||||
* Result object for {@link DistributionSetTag} assignments.
|
||||
*
|
||||
*/
|
||||
public class DistributionSetTagAssignmentResult extends AssignmentResult<DistributionSet> {
|
||||
|
||||
private final DistributionSetTag distributionSetTag;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param alreadyAssigned
|
||||
* number of already assigned/ignored elements
|
||||
* @param assigned
|
||||
* number of newly assigned elements
|
||||
* @param unassigned
|
||||
* number of newly assigned elements
|
||||
* @param assignedDs
|
||||
* {@link List} of assigned {@link DistributionSet}s.
|
||||
* @param unassignedDs
|
||||
* {@link List} of unassigned {@link DistributionSet}s.
|
||||
* @param distributionSetTag
|
||||
* the assigned or unassigned tag
|
||||
*/
|
||||
public DistributionSetTagAssignmentResult(final int alreadyAssigned, final int assigned, final int unassigned,
|
||||
final List<DistributionSet> assignedDs, final List<DistributionSet> unassignedDs,
|
||||
final DistributionSetTag distributionSetTag) {
|
||||
super(assigned, alreadyAssigned,unassigned, assignedDs, unassignedDs);
|
||||
this.distributionSetTag = distributionSetTag;
|
||||
}
|
||||
|
||||
public DistributionSetTag getDistributionSetTag() {
|
||||
return distributionSetTag;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
/**
|
||||
* 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.util.Set;
|
||||
|
||||
/**
|
||||
* A {@link DistributionSetType} is an abstract definition for
|
||||
* {@link DistributionSet} that defines what {@link SoftwareModule}s can be
|
||||
* added (optional) to {@link DistributionSet} of that type or have to added
|
||||
* (mandatory) in order to be considered complete. Only complete DS can be
|
||||
* assigned to a {@link Target}.
|
||||
*
|
||||
*/
|
||||
public interface DistributionSetType extends NamedEntity {
|
||||
|
||||
/**
|
||||
* @return <code>true</code> if the type is deleted and only kept for
|
||||
* history purposes.
|
||||
*/
|
||||
boolean isDeleted();
|
||||
|
||||
/**
|
||||
* @return set of {@link SoftwareModuleType}s that need to be in a
|
||||
* {@link DistributionSet} of this type to be
|
||||
* {@link DistributionSet#isComplete()}.
|
||||
*/
|
||||
Set<SoftwareModuleType> getMandatoryModuleTypes();
|
||||
|
||||
/**
|
||||
* @return set of optional {@link SoftwareModuleType}s that can be in a
|
||||
* {@link DistributionSet} of this type.
|
||||
*/
|
||||
Set<SoftwareModuleType> getOptionalModuleTypes();
|
||||
|
||||
/**
|
||||
* Checks if the given {@link SoftwareModuleType} is in this
|
||||
* {@link DistributionSetType}.
|
||||
*
|
||||
* @param softwareModuleType
|
||||
* search for
|
||||
* @return <code>true</code> if found
|
||||
*/
|
||||
boolean containsModuleType(SoftwareModuleType softwareModuleType);
|
||||
|
||||
/**
|
||||
* Checks if the given {@link SoftwareModuleType} is in this
|
||||
* {@link DistributionSetType} and defined as
|
||||
* {@link DistributionSetTypeElement#isMandatory()}.
|
||||
*
|
||||
* @param softwareModuleType
|
||||
* search for
|
||||
* @return <code>true</code> if found
|
||||
*/
|
||||
boolean containsMandatoryModuleType(SoftwareModuleType softwareModuleType);
|
||||
|
||||
/**
|
||||
* Checks if the given {@link SoftwareModuleType} is in this
|
||||
* {@link DistributionSetType} and defined as
|
||||
* {@link DistributionSetTypeElement#isMandatory()}.
|
||||
*
|
||||
* @param softwareModuleTypeId
|
||||
* search for by {@link SoftwareModuleType#getId()}
|
||||
* @return <code>true</code> if found
|
||||
*/
|
||||
boolean containsMandatoryModuleType(Long softwareModuleTypeId);
|
||||
|
||||
/**
|
||||
* Checks if the given {@link SoftwareModuleType} is in this
|
||||
* {@link DistributionSetType} and NOT defined as
|
||||
* {@link DistributionSetTypeElement#isMandatory()}.
|
||||
*
|
||||
* @param softwareModuleType
|
||||
* search for
|
||||
* @return <code>true</code> if found
|
||||
*/
|
||||
boolean containsOptionalModuleType(SoftwareModuleType softwareModuleType);
|
||||
|
||||
/**
|
||||
* Checks if the given {@link SoftwareModuleType} is in this
|
||||
* {@link DistributionSetType} and NOT defined as
|
||||
* {@link DistributionSetTypeElement#isMandatory()}.
|
||||
*
|
||||
* @param softwareModuleTypeId
|
||||
* search by {@link SoftwareModuleType#getId()}
|
||||
* @return <code>true</code> if found
|
||||
*/
|
||||
boolean containsOptionalModuleType(Long softwareModuleTypeId);
|
||||
|
||||
/**
|
||||
* Compares the modules of this {@link DistributionSetType} and the given
|
||||
* one.
|
||||
*
|
||||
* @param dsType
|
||||
* to compare with
|
||||
* @return <code>true</code> if the lists are identical.
|
||||
*/
|
||||
boolean areModuleEntriesIdentical(DistributionSetType dsType);
|
||||
|
||||
/**
|
||||
* Adds {@link SoftwareModuleType} that is optional for the
|
||||
* {@link DistributionSet}.
|
||||
*
|
||||
* @param smType
|
||||
* to add
|
||||
* @return updated instance
|
||||
*/
|
||||
DistributionSetType addOptionalModuleType(SoftwareModuleType smType);
|
||||
|
||||
/**
|
||||
* Adds {@link SoftwareModuleType} that is mandatory for the
|
||||
* {@link DistributionSet}.
|
||||
*
|
||||
* @param smType
|
||||
* to add
|
||||
* @return updated instance
|
||||
*/
|
||||
DistributionSetType addMandatoryModuleType(SoftwareModuleType smType);
|
||||
|
||||
/**
|
||||
* Removes {@link SoftwareModuleType} from the list.
|
||||
*
|
||||
* @param smTypeId
|
||||
* to remove
|
||||
* @return updated instance
|
||||
*/
|
||||
DistributionSetType removeModuleType(Long smTypeId);
|
||||
|
||||
/**
|
||||
* @return business key of this {@link DistributionSetType}.
|
||||
*/
|
||||
String getKey();
|
||||
|
||||
/**
|
||||
* @param key
|
||||
* of this {@link DistributionSetType}.
|
||||
*/
|
||||
void setKey(String key);
|
||||
|
||||
/**
|
||||
* @param distributionSet
|
||||
* to check for completeness
|
||||
* @return <code>true</code> if the all mandatory software module types are
|
||||
* in the system.
|
||||
*/
|
||||
boolean checkComplete(DistributionSet distributionSet);
|
||||
|
||||
/**
|
||||
* @return get color code to by used in management UI views.
|
||||
*/
|
||||
String getColour();
|
||||
|
||||
/**
|
||||
* @param colour
|
||||
* code to by used in management UI views.
|
||||
*/
|
||||
void setColour(final String colour);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* 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);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* External repositories for artifact storage. The update server provides URLs
|
||||
* for the targets to download from these external resources but does not access
|
||||
* them itself.
|
||||
*
|
||||
*/
|
||||
public interface ExternalArtifactProvider extends NamedEntity {
|
||||
|
||||
/**
|
||||
* @return prefix for url generation
|
||||
*/
|
||||
String getBasePath();
|
||||
|
||||
/**
|
||||
* @return default for {@link ExternalArtifact#getUrlSuffix()}.
|
||||
*/
|
||||
String getDefaultSuffix();
|
||||
|
||||
/**
|
||||
* @param basePath
|
||||
* prefix for url generation
|
||||
*/
|
||||
void setBasePath(String basePath);
|
||||
|
||||
/**
|
||||
* @param defaultSuffix
|
||||
* for {@link ExternalArtifact#getUrlSuffix()}.
|
||||
*/
|
||||
void setDefaultSuffix(String defaultSuffix);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* 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();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* 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.io.Serializable;
|
||||
|
||||
/**
|
||||
* Meta data for entities, a (key/value) store.
|
||||
*
|
||||
*/
|
||||
public interface MetaData extends Serializable {
|
||||
|
||||
/**
|
||||
* @return the key
|
||||
*/
|
||||
String getKey();
|
||||
|
||||
/**
|
||||
* @param key
|
||||
*/
|
||||
void setKey(String key);
|
||||
|
||||
/**
|
||||
* @return the value
|
||||
*/
|
||||
String getValue();
|
||||
|
||||
/**
|
||||
* @param value
|
||||
*/
|
||||
void setValue(String value);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Entities that have a name and description.
|
||||
*
|
||||
*/
|
||||
public interface NamedEntity extends TenantAwareBaseEntity {
|
||||
|
||||
/**
|
||||
* @return the description of the entity.
|
||||
*/
|
||||
String getDescription();
|
||||
|
||||
/**
|
||||
* @return the name of the entity.
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* @param description
|
||||
* of the entity.
|
||||
*/
|
||||
void setDescription(String description);
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* of the entity.
|
||||
*/
|
||||
void setName(String name);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Entities that have a name and a description.
|
||||
*
|
||||
*/
|
||||
public interface NamedVersionedEntity extends NamedEntity {
|
||||
|
||||
/**
|
||||
* @return the version of entity.
|
||||
*/
|
||||
String getVersion();
|
||||
|
||||
/**
|
||||
* @param version
|
||||
* of the entity.
|
||||
*/
|
||||
void setVersion(String version);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/**
|
||||
* 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.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* The poll time object which holds all the necessary information around the
|
||||
* target poll time, e.g. the last poll time, the next poll time and the overdue
|
||||
* poll time.
|
||||
*
|
||||
*/
|
||||
public class PollStatus {
|
||||
private final LocalDateTime lastPollDate;
|
||||
private final LocalDateTime nextPollDate;
|
||||
private final LocalDateTime overdueDate;
|
||||
private final LocalDateTime currentDate;
|
||||
|
||||
public PollStatus(final LocalDateTime lastPollDate, final LocalDateTime nextPollDate,
|
||||
final LocalDateTime overdueDate, final LocalDateTime currentDate) {
|
||||
this.lastPollDate = lastPollDate;
|
||||
this.nextPollDate = nextPollDate;
|
||||
this.overdueDate = overdueDate;
|
||||
this.currentDate = currentDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* calculates if the target poll time is overdue and the target has not been
|
||||
* polled in the configured poll time interval.
|
||||
*
|
||||
* @return {@code true} if the current time is after the poll time overdue
|
||||
* date otherwise {@code false}.
|
||||
*/
|
||||
public boolean isOverdue() {
|
||||
return currentDate.isAfter(overdueDate);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the lastPollDate
|
||||
*/
|
||||
public LocalDateTime getLastPollDate() {
|
||||
return lastPollDate;
|
||||
}
|
||||
|
||||
public LocalDateTime getNextPollDate() {
|
||||
return nextPollDate;
|
||||
}
|
||||
|
||||
public LocalDateTime getOverdueDate() {
|
||||
return overdueDate;
|
||||
}
|
||||
|
||||
public LocalDateTime getCurrentDate() {
|
||||
return currentDate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PollTime [lastPollDate=" + lastPollDate + ", nextPollDate=" + nextPollDate + ", overdueDate="
|
||||
+ overdueDate + ", currentDate=" + currentDate + "]";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
/**
|
||||
* 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.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.eclipse.hawkbit.repository.model.Action.ActionType;
|
||||
import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus.Status;
|
||||
|
||||
/**
|
||||
* Software update operations in large scale IoT scenarios with hundred of
|
||||
* thousands of devices require special handling.
|
||||
*
|
||||
* That includes secure handling of large volumes of devices at rollout creation
|
||||
* time. Monitoring of the rollout progress. Emergency rollout shutdown in case
|
||||
* of problems on to many devices and reporting capabilities for a complete
|
||||
* understanding of the rollout progress at each point in time.
|
||||
*
|
||||
*/
|
||||
public interface Rollout extends NamedEntity {
|
||||
|
||||
/**
|
||||
* @return {@link DistributionSet} that is rolled out
|
||||
*/
|
||||
DistributionSet getDistributionSet();
|
||||
|
||||
/**
|
||||
* @param distributionSet
|
||||
* that is rolled out
|
||||
*/
|
||||
void setDistributionSet(DistributionSet distributionSet);
|
||||
|
||||
/**
|
||||
* @return list of deployment groups of the rollout.
|
||||
*/
|
||||
List<RolloutGroup> getRolloutGroups();
|
||||
|
||||
/**
|
||||
* @return rsql query that identifies the targets that are part of this
|
||||
* rollout.
|
||||
*/
|
||||
String getTargetFilterQuery();
|
||||
|
||||
/**
|
||||
* @param targetFilterQuery
|
||||
* that identifies the targets that are part of this rollout.
|
||||
*/
|
||||
void setTargetFilterQuery(String targetFilterQuery);
|
||||
|
||||
/**
|
||||
* @return status of the rollout
|
||||
*/
|
||||
RolloutStatus getStatus();
|
||||
|
||||
/**
|
||||
* @return {@link ActionType} of the rollout.
|
||||
*/
|
||||
ActionType getActionType();
|
||||
|
||||
/**
|
||||
* @param actionType
|
||||
* of the rollout.
|
||||
*/
|
||||
void setActionType(ActionType actionType);
|
||||
|
||||
/**
|
||||
* @return time in {@link TimeUnit#MILLISECONDS} after which
|
||||
* {@link #isForced()} switches to <code>true</code> in case of
|
||||
* {@link ActionType#TIMEFORCED}.
|
||||
*/
|
||||
long getForcedTime();
|
||||
|
||||
/**
|
||||
* @param forcedTime
|
||||
* in {@link TimeUnit#MILLISECONDS} after which
|
||||
* {@link #isForced()} switches to <code>true</code> in case of
|
||||
* {@link ActionType#TIMEFORCED}.
|
||||
*/
|
||||
void setForcedTime(long forcedTime);
|
||||
|
||||
/**
|
||||
* @return number of {@link Target}s in this rollout.
|
||||
*/
|
||||
long getTotalTargets();
|
||||
|
||||
/**
|
||||
* @return number of {@link RolloutGroup}s.
|
||||
*/
|
||||
int getRolloutGroupsCreated();
|
||||
|
||||
/**
|
||||
* @return all states with the respective target count in that
|
||||
* {@link Status}.
|
||||
*/
|
||||
TotalTargetCountStatus getTotalTargetCountStatus();
|
||||
|
||||
/**
|
||||
*
|
||||
* State machine for rollout.
|
||||
*
|
||||
*/
|
||||
public enum RolloutStatus {
|
||||
|
||||
/**
|
||||
* Rollouts is being created.
|
||||
*/
|
||||
CREATING,
|
||||
|
||||
/**
|
||||
* Rollout is ready to start.
|
||||
*/
|
||||
READY,
|
||||
|
||||
/**
|
||||
* Rollout is paused.
|
||||
*/
|
||||
PAUSED,
|
||||
|
||||
/**
|
||||
* Rollout is starting.
|
||||
*/
|
||||
STARTING,
|
||||
|
||||
/**
|
||||
* Rollout is stopped.
|
||||
*/
|
||||
STOPPED,
|
||||
|
||||
/**
|
||||
* Rollout is running.
|
||||
*/
|
||||
RUNNING,
|
||||
|
||||
/**
|
||||
* Rollout is finished.
|
||||
*/
|
||||
FINISHED,
|
||||
|
||||
/**
|
||||
* Rollout could not be created due to errors, might be a database
|
||||
* problem during asynchronous creating.
|
||||
*/
|
||||
ERROR_CREATING,
|
||||
|
||||
/**
|
||||
* Rollout could not be started due to errors, might be database problem
|
||||
* during asynchronous starting.
|
||||
*/
|
||||
ERROR_STARTING;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,183 @@
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* The core functionality of a {@link Rollout} is the cascading processing of
|
||||
* (sub) deployment groups. The group defines under which conditions the
|
||||
* following group is processed.
|
||||
*
|
||||
*/
|
||||
public interface RolloutGroup extends NamedEntity {
|
||||
|
||||
Rollout getRollout();
|
||||
|
||||
void setRollout(Rollout rollout);
|
||||
|
||||
RolloutGroupStatus getStatus();
|
||||
|
||||
void setStatus(RolloutGroupStatus status);
|
||||
|
||||
RolloutGroup getParent();
|
||||
|
||||
RolloutGroupSuccessCondition getSuccessCondition();
|
||||
|
||||
void setSuccessCondition(RolloutGroupSuccessCondition finishCondition);
|
||||
|
||||
String getSuccessConditionExp();
|
||||
|
||||
void setSuccessConditionExp(String finishExp);
|
||||
|
||||
RolloutGroupErrorCondition getErrorCondition();
|
||||
|
||||
void setErrorCondition(RolloutGroupErrorCondition errorCondition);
|
||||
|
||||
String getErrorConditionExp();
|
||||
|
||||
void setErrorConditionExp(String errorExp);
|
||||
|
||||
RolloutGroupErrorAction getErrorAction();
|
||||
|
||||
void setErrorAction(RolloutGroupErrorAction errorAction);
|
||||
|
||||
String getErrorActionExp();
|
||||
|
||||
void setErrorActionExp(String errorActionExp);
|
||||
|
||||
RolloutGroupSuccessAction getSuccessAction();
|
||||
|
||||
String getSuccessActionExp();
|
||||
|
||||
long getTotalTargets();
|
||||
|
||||
/**
|
||||
* @return the totalTargetCountStatus
|
||||
*/
|
||||
TotalTargetCountStatus getTotalTargetCountStatus();
|
||||
|
||||
/**
|
||||
* @param totalTargetCountStatus
|
||||
* the totalTargetCountStatus to set
|
||||
*/
|
||||
void setTotalTargetCountStatus(TotalTargetCountStatus totalTargetCountStatus);
|
||||
|
||||
/**
|
||||
* Rollout goup state machine.
|
||||
*
|
||||
*/
|
||||
public enum RolloutGroupStatus {
|
||||
|
||||
/**
|
||||
* Ready to start the group.
|
||||
*/
|
||||
READY,
|
||||
|
||||
/**
|
||||
* Group is scheduled and started sometime, e.g. trigger of group
|
||||
* before.
|
||||
*/
|
||||
SCHEDULED,
|
||||
|
||||
/**
|
||||
* Group is finished.
|
||||
*/
|
||||
FINISHED,
|
||||
|
||||
/**
|
||||
* Group is finished and has errors.
|
||||
*/
|
||||
ERROR,
|
||||
|
||||
/**
|
||||
* Group is running.
|
||||
*/
|
||||
RUNNING;
|
||||
}
|
||||
|
||||
/**
|
||||
* The condition to evaluate if an group is success state.
|
||||
*/
|
||||
public enum RolloutGroupSuccessCondition {
|
||||
THRESHOLD("thresholdRolloutGroupSuccessCondition");
|
||||
|
||||
private final String beanName;
|
||||
|
||||
private RolloutGroupSuccessCondition(final String beanName) {
|
||||
this.beanName = beanName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the beanName
|
||||
*/
|
||||
public String getBeanName() {
|
||||
return beanName;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The condition to evaluate if an group is in error state.
|
||||
*/
|
||||
public enum RolloutGroupErrorCondition {
|
||||
THRESHOLD("thresholdRolloutGroupErrorCondition");
|
||||
|
||||
private final String beanName;
|
||||
|
||||
private RolloutGroupErrorCondition(final String beanName) {
|
||||
this.beanName = beanName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the beanName
|
||||
*/
|
||||
public String getBeanName() {
|
||||
return beanName;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The actions executed when the {@link RolloutGroup#errorCondition} is hit.
|
||||
*/
|
||||
public enum RolloutGroupErrorAction {
|
||||
PAUSE("pauseRolloutGroupAction");
|
||||
|
||||
private final String beanName;
|
||||
|
||||
private RolloutGroupErrorAction(final String beanName) {
|
||||
this.beanName = beanName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the beanName
|
||||
*/
|
||||
public String getBeanName() {
|
||||
return beanName;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The actions executed when the {@link RolloutGroup#successCondition} is
|
||||
* hit.
|
||||
*/
|
||||
public enum RolloutGroupSuccessAction {
|
||||
NEXTGROUP("startNextRolloutGroupAction");
|
||||
|
||||
private final String beanName;
|
||||
|
||||
private RolloutGroupSuccessAction(final String beanName) {
|
||||
this.beanName = beanName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the beanName
|
||||
*/
|
||||
public String getBeanName() {
|
||||
return beanName;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
/**
|
||||
* 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.repository.model.RolloutGroup.RolloutGroupErrorAction;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupErrorCondition;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupSuccessAction;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupSuccessCondition;
|
||||
|
||||
/**
|
||||
* Builder to build easily the {@link RolloutGroupConditions}.
|
||||
*
|
||||
*/
|
||||
public class RolloutGroupConditionBuilder {
|
||||
private final RolloutGroupConditions conditions = new RolloutGroupConditions();
|
||||
|
||||
/**
|
||||
* @return completed {@link RolloutGroupConditions}.
|
||||
*/
|
||||
public RolloutGroupConditions build() {
|
||||
return conditions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the finish condition and expression on the builder.
|
||||
*
|
||||
* @param condition
|
||||
* the finish condition
|
||||
* @param expression
|
||||
* the finish expression
|
||||
* @return the builder itself
|
||||
*/
|
||||
public RolloutGroupConditionBuilder successCondition(final RolloutGroupSuccessCondition condition,
|
||||
final String expression) {
|
||||
conditions.setSuccessCondition(condition);
|
||||
conditions.setSuccessConditionExp(expression);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the success action and expression on the builder.
|
||||
*
|
||||
* @param action
|
||||
* the success action
|
||||
* @param expression
|
||||
* the error expression
|
||||
* @return the builder itself
|
||||
*/
|
||||
public RolloutGroupConditionBuilder successAction(final RolloutGroupSuccessAction action, final String expression) {
|
||||
conditions.setSuccessAction(action);
|
||||
conditions.setSuccessActionExp(expression);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the error condition and expression on the builder.
|
||||
*
|
||||
* @param condition
|
||||
* the error condition
|
||||
* @param expression
|
||||
* the error expression
|
||||
* @return the builder itself
|
||||
*/
|
||||
public RolloutGroupConditionBuilder errorCondition(final RolloutGroupErrorCondition condition,
|
||||
final String expression) {
|
||||
conditions.setErrorCondition(condition);
|
||||
conditions.setErrorConditionExp(expression);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the error action and expression on the builder.
|
||||
*
|
||||
* @param action
|
||||
* the error action
|
||||
* @param expression
|
||||
* the error expression
|
||||
* @return the builder itself
|
||||
*/
|
||||
public RolloutGroupConditionBuilder errorAction(final RolloutGroupErrorAction action, final String expression) {
|
||||
conditions.setErrorAction(action);
|
||||
conditions.setErrorActionExp(expression);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
/**
|
||||
* 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.repository.model.RolloutGroup.RolloutGroupErrorAction;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupErrorCondition;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupSuccessAction;
|
||||
import org.eclipse.hawkbit.repository.model.RolloutGroup.RolloutGroupSuccessCondition;
|
||||
|
||||
/**
|
||||
* Object which holds all {@link RolloutGroup} conditions together which can
|
||||
* easily built.
|
||||
*/
|
||||
public class RolloutGroupConditions {
|
||||
private RolloutGroupSuccessCondition successCondition;
|
||||
private String successConditionExp;
|
||||
private RolloutGroupSuccessAction successAction;
|
||||
private String successActionExp;
|
||||
private RolloutGroupErrorCondition errorCondition;
|
||||
private String errorConditionExp;
|
||||
private RolloutGroupErrorAction errorAction;
|
||||
private String errorActionExp;
|
||||
|
||||
public RolloutGroupSuccessCondition getSuccessCondition() {
|
||||
return successCondition;
|
||||
}
|
||||
|
||||
public void setSuccessCondition(final RolloutGroupSuccessCondition finishCondition) {
|
||||
successCondition = finishCondition;
|
||||
}
|
||||
|
||||
public String getSuccessConditionExp() {
|
||||
return successConditionExp;
|
||||
}
|
||||
|
||||
public void setSuccessConditionExp(final String finishConditionExp) {
|
||||
successConditionExp = finishConditionExp;
|
||||
}
|
||||
|
||||
public RolloutGroupSuccessAction getSuccessAction() {
|
||||
return successAction;
|
||||
}
|
||||
|
||||
public void setSuccessAction(final RolloutGroupSuccessAction successAction) {
|
||||
this.successAction = successAction;
|
||||
}
|
||||
|
||||
public String getSuccessActionExp() {
|
||||
return successActionExp;
|
||||
}
|
||||
|
||||
public void setSuccessActionExp(final String successActionExp) {
|
||||
this.successActionExp = successActionExp;
|
||||
}
|
||||
|
||||
public RolloutGroupErrorCondition getErrorCondition() {
|
||||
return errorCondition;
|
||||
}
|
||||
|
||||
public void setErrorCondition(final RolloutGroupErrorCondition errorCondition) {
|
||||
this.errorCondition = errorCondition;
|
||||
}
|
||||
|
||||
public String getErrorConditionExp() {
|
||||
return errorConditionExp;
|
||||
}
|
||||
|
||||
public void setErrorConditionExp(final String errorConditionExp) {
|
||||
this.errorConditionExp = errorConditionExp;
|
||||
}
|
||||
|
||||
public RolloutGroupErrorAction getErrorAction() {
|
||||
return errorAction;
|
||||
}
|
||||
|
||||
public void setErrorAction(final RolloutGroupErrorAction errorAction) {
|
||||
this.errorAction = errorAction;
|
||||
}
|
||||
|
||||
public String getErrorActionExp() {
|
||||
return errorActionExp;
|
||||
}
|
||||
|
||||
public void setErrorActionExp(final String errorActionExp) {
|
||||
this.errorActionExp = errorActionExp;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
/**
|
||||
* 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.util.List;
|
||||
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);
|
||||
|
||||
/**
|
||||
* @param artifactId
|
||||
* to look for
|
||||
* @return found {@link Artifact}
|
||||
*/
|
||||
Optional<LocalArtifact> getLocalArtifact(Long artifactId);
|
||||
|
||||
/**
|
||||
* @param fileName
|
||||
* to look for
|
||||
* @return found {@link Artifact}
|
||||
*/
|
||||
Optional<LocalArtifact> getLocalArtifactByFilename(String fileName);
|
||||
|
||||
/**
|
||||
* @return the artifacts
|
||||
*/
|
||||
List<Artifact> getArtifacts();
|
||||
|
||||
/**
|
||||
* @return local artifacts only
|
||||
*/
|
||||
List<LocalArtifact> getLocalArtifacts();
|
||||
|
||||
String getVendor();
|
||||
|
||||
/**
|
||||
* @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);
|
||||
|
||||
void setVendor(String vendor);
|
||||
|
||||
SoftwareModuleType getType();
|
||||
|
||||
boolean isDeleted();
|
||||
|
||||
void setDeleted(boolean deleted);
|
||||
|
||||
void setType(SoftwareModuleType type);
|
||||
|
||||
/**
|
||||
* @return immutable list of meta data elements.
|
||||
*/
|
||||
List<SoftwareModuleMetadata> getMetadata();
|
||||
|
||||
/**
|
||||
* @return the assignedTo
|
||||
*/
|
||||
List<DistributionSet> getAssignedTo();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/**
|
||||
* 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.io.Serializable;
|
||||
|
||||
/**
|
||||
* To hold software module name and Id.
|
||||
*
|
||||
*/
|
||||
public class SoftwareModuleIdName implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -6317413180936148514L;
|
||||
|
||||
private final Long id;
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* @param id
|
||||
* if the {@link SoftwareModule}
|
||||
* @param name
|
||||
* of the {@link SoftwareModule}
|
||||
*/
|
||||
public SoftwareModuleIdName(final Long id, final String name) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {// NOSONAR - as this is generated
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + (id == null ? 0 : id.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) {// NOSONAR - as this is generated
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final SoftwareModuleIdName other = (SoftwareModuleIdName) obj;
|
||||
if (id == null) {
|
||||
if (other.id != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!id.equals(other.id)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user