protected DocumentModel doGetOrCreateDoc(AdministrativeStatus status) { DocumentModel administrativeContainer = doGetOrCreateContainer(); DocumentRef statusDocRef = new PathRef( administrativeContainer.getPathAsString() + "/" + getAdministrativeStatusDocName(status)); DocumentModel doc; boolean create = false; if (!session.exists(statusDocRef)) { create = true; doc = session.createDocumentModel( administrativeContainer.getPathAsString(), getAdministrativeStatusDocName(status), ADMINISTRATIVE_STATUS_DOCUMENT_TYPE); } else { doc = session.getDocument(statusDocRef); } doc.setPropertyValue(LOGIN_PROPERTY, status.getUserLogin()); doc.setPropertyValue(INSTANCE_PROPERTY, status.getInstanceIdentifier()); doc.setPropertyValue(SERVICE_PROPERTY, status.getServiceIdentifier()); doc.setPropertyValue(MESSAGE_PROPERTY, status.getMessage()); doc.setPropertyValue(STATUS_PROPERTY, status.getState()); doc.setPropertyValue("dc:title", getAdministrativeStatusDocName(status)); if (create) { doc = session.createDocument(doc); } else { doc = session.saveDocument(doc); } session.save(); return doc; }
@GET public Object doGet() { return getView("index") .arg("serverInstanceId", administrativeStatus.getInstanceIdentifier()) .arg("administrativeStatus", administrativeStatus.getState()); }
protected String getAdministrativeStatusDocName(AdministrativeStatus status) { return status.getInstanceIdentifier() + "--" + status.getServiceIdentifier(); }