/** * Updates additional information about current machine. * * @param machine machine for which need update panel */ public void update(@NotNull MachineEntity machine) { Unmarshallable<ProfileDto> profileUnMarshaller = unmarshallerFactory.newUnmarshaller(ProfileDto.class); userProfile.getCurrentProfile( new AsyncRequestCallback<ProfileDto>(profileUnMarshaller) { @Override protected void onSuccess(ProfileDto result) { Map<String, String> attributes = result.getAttributes(); String firstName = attributes.get(FIRST_NAME_KEY); String lastName = attributes.get(LAST_NAME_KEY); String fullName = firstName + ' ' + lastName; String email = attributes.get(EMAIL_KEY); boolean isNameExist = !firstName.equals("undefined") && !lastName.equals("<none>"); view.setOwner(isNameExist ? fullName : email); } @Override protected void onFailure(Throwable exception) { Log.error(getClass(), exception); } }); wsService .getWorkspace(machine.getWorkspaceId()) .then( new Operation<WorkspaceDto>() { @Override public void apply(WorkspaceDto ws) throws OperationException { view.setWorkspaceName(ws.getConfig().getName()); } }) .catchError( new Operation<PromiseError>() { @Override public void apply(PromiseError err) throws OperationException { Log.error(getClass(), err.getCause()); } }); view.updateInfo(machine); }
/** {@inheritDoc} */ @Override public void setVisible(boolean visible) { view.setVisible(visible); }