use of com.evolveum.midpoint.xml.ns._public.common.common_3.AvailabilityStatusType in project midpoint by Evolveum.
the class ResourceDetailsTabPanel method createLastAvailabilityStatusInfo.
private InfoBoxPanel createLastAvailabilityStatusInfo(ResourceType resource) {
String messageKey = "PageResource.resource.availabilityUnknown";
String backgroundColor = "bg-gray";
String icon = "fa-question";
OperationalStateType operationalState = resource.getOperationalState();
if (operationalState != null) {
AvailabilityStatusType lastAvailabilityStatus = operationalState.getLastAvailabilityStatus();
if (lastAvailabilityStatus != null) {
if (lastAvailabilityStatus == AvailabilityStatusType.UP) {
messageKey = "PageResource.resource.up";
backgroundColor = "bg-green";
icon = "fa-power-off";
} else if (lastAvailabilityStatus == AvailabilityStatusType.DOWN) {
backgroundColor = "bg-red";
messageKey = "PageResource.resource.down";
icon = "fa-ban";
} else if (lastAvailabilityStatus == AvailabilityStatusType.BROKEN) {
backgroundColor = "bg-yellow";
messageKey = "PageResource.resource.broken";
icon = "fa-warning";
}
}
}
InfoBoxType infoBoxType = new InfoBoxType(backgroundColor, icon, parentPage.getString(messageKey));
ConnectorType connectorType = resource.getConnector();
if (connectorType == null) {
// Connector not found. Probably bad connectorRef reference.
infoBoxType.setNumber("--");
infoBoxType.setDescription("--");
} else {
String connectorName = StringUtils.substringAfterLast(WebComponentUtil.getEffectiveName(connectorType, ConnectorType.F_CONNECTOR_TYPE), ".");
String connectorVersion = connectorType.getConnectorVersion();
infoBoxType.setNumber(connectorName);
infoBoxType.setDescription(connectorVersion);
}
Model<InfoBoxType> boxModel = new Model<InfoBoxType>(infoBoxType);
InfoBoxPanel lastAvailabilityStatus = new InfoBoxPanel(ID_LAST_AVAILABILITY_STATUS, boxModel);
lastAvailabilityStatus.setOutputMarkupId(true);
return lastAvailabilityStatus;
}
use of com.evolveum.midpoint.xml.ns._public.common.common_3.AvailabilityStatusType in project midpoint by Evolveum.
the class ResourceManager method modifyResourceAvailabilityStatus.
public void modifyResourceAvailabilityStatus(PrismObject<ResourceType> resource, AvailabilityStatusType status, OperationResult result) {
ResourceType resourceType = resource.asObjectable();
synchronized (resource) {
if (resourceType.getOperationalState() == null || resourceType.getOperationalState().getLastAvailabilityStatus() == null || resourceType.getOperationalState().getLastAvailabilityStatus() != status) {
List<PropertyDelta<?>> modifications = new ArrayList<PropertyDelta<?>>();
PropertyDelta<?> statusDelta = createResourceAvailabilityStatusDelta(resource, status);
modifications.add(statusDelta);
try {
repositoryService.modifyObject(ResourceType.class, resourceType.getOid(), modifications, result);
} catch (SchemaException ex) {
throw new SystemException(ex);
} catch (ObjectAlreadyExistsException ex) {
throw new SystemException(ex);
} catch (ObjectNotFoundException ex) {
throw new SystemException(ex);
}
}
// ugly hack: change object even if it's immutable
boolean immutable = resource.isImmutable();
if (immutable) {
resource.setImmutable(false);
}
if (resourceType.getOperationalState() == null) {
OperationalStateType operationalState = new OperationalStateType();
operationalState.setLastAvailabilityStatus(status);
resourceType.setOperationalState(operationalState);
} else {
resourceType.getOperationalState().setLastAvailabilityStatus(status);
}
if (immutable) {
resource.setImmutable(true);
}
}
}
Aggregations