/*
@Override
public boolean onSaveStartImpl(Result<Boolean> result)
{
SaveResult saveResult = new SaveResult(result);

_stubClass.onSaveStart(this, saveResult.addBean());

onSaveChildren(saveResult);

saveResult.completeBean();

return true;
}
504794
@Override
  public void onSave(Result<Void> result)
  {
    StubContainerAmp container = _container;
    
    if (container != null) {
      container.onSave(result);
    }
    else {
      onSaveChild(result);
    }
  }
153931
private void saveInitialChildState(FacesContext facesContext, UIComponent component) {
        if (component instanceof EditableValueHolder && !component.isTransient()) {
            String clientId = component.getClientId(facesContext);
            SavedState state = new SavedState();
            initialChildState.put(clientId, state);
            state.populate((EditableValueHolder) component);
        }

        Iterator<UIComponent> iterator = component.getFacetsAndChildren();
        while (iterator.hasNext()) {
            saveChildState(facesContext, iterator.next());
        }
    }
647916
protected final PrcEntitySave<RS, IHasId<Object>, Object>
    createPutPrcEntitySave() throws Exception {
    PrcEntitySave<RS, IHasId<Object>, Object> proc =
      new PrcEntitySave<RS, IHasId<Object>, Object>();
    proc.setSrvOrm(getSrvOrm());
    //assigning fully initialized object:
    this.processorsMap
      .put(PrcEntitySave.class.getSimpleName(), proc);
    return proc;
  }
968826
private static <T> void _logResult(T result, int level, int indentSize, StringBuilder info) {
        if(result instanceof Map) {
            level += 1;
            int finalLevel = level;
            ((Map)result).forEach((k, v) -> {
                info.append("\n");
                info.append(getTabBasedOnLevel(finalLevel, indentSize))
                        .append(k.toString())
                        .append(":");
                _logResult(v, finalLevel, indentSize, info);
            });
        } else if(result instanceof List) {
            int finalLevel = level;
            ((List)result).forEach(element -> _logResult(element, finalLevel, indentSize, info));
        } else if(result instanceof String) {
            info.append(" ").append(result);
        } else if(result != null) {
            try {
                logger.warn(getTabBasedOnLevel(level, indentSize) + "{}", result);
            } catch (Exception e) {
                logger.error("Cannot handle this type: {}", result.getClass().getTypeName());
            }
        }
    }
351275
public function save()
    {
        $this->triggerEvent('onBeforeSave');

        $result = $this->getFlexDirectory()->getStorage()->replaceRows([$this->getStorageKey() => $this->prepareStorage()]);

        $value = reset($result);
        $storageKey = key($result);
        if ($value && $storageKey) {
            $this->setStorageKey($storageKey);
            if (!$this->hasKey()) {
                $this->setKey($storageKey);
            }
        }

        if (method_exists($this, 'saveUpdatedMedia')) {
            $this->saveUpdatedMedia();
        }

        try {
            $this->getFlexDirectory()->clearCache();
            if (method_exists($this, 'clearMediaCache')) {
                $this->clearMediaCache();
            }
        } catch (InvalidArgumentException $e) {
            /** @var Debugger $debugger */
            $debugger = Grav::instance()['debugger'];
            $debugger->addException($e);

            // Caching failed, but we can ignore that for now.
        }

        $this->triggerEvent('onAfterSave');

        return $this;
    }
886052
final public void saveAsync(final OnSavedCallback callback) {
		new AsyncTask<Model, Void, Boolean>() {

			protected Boolean doInBackground(Model... params) {
				return params[0].save();
			}

			protected void onPostExecute(Boolean result) {
				if (result && callback != null) {
					callback.onSaved();
				}
			}

		}.execute(this);
	}
1103069
protected final PrcEntityPbSave<RS, IPersistableBase>
    createPutPrcEntityPbSave() throws Exception {
    PrcEntityPbSave<RS, IPersistableBase> proc =
      new PrcEntityPbSave<RS, IPersistableBase>();
    proc.setSrvOrm(getSrvOrm());
    //assigning fully initialized object:
    this.processorsMap
      .put(PrcEntityPbSave.class.getSimpleName(), proc);
    return proc;
  }
934898
public void onSaveInstanceState(Bundle outState) {
    int bottomSheetBehaviorState = summaryBehavior == null ? INVALID_STATE : summaryBehavior.getState();
    boolean isWayNameVisible = wayNameView.getVisibility() == VISIBLE;
    NavigationViewInstanceState navigationViewInstanceState = new NavigationViewInstanceState(
      bottomSheetBehaviorState, recenterBtn.getVisibility(), instructionView.isShowingInstructionList(),
      isWayNameVisible, wayNameView.retrieveWayNameText(), navigationViewModel.isMuted());
    String instanceKey = getContext().getString(R.string.navigation_view_instance_state);
    outState.putParcelable(instanceKey, navigationViewInstanceState);
    outState.putBoolean(getContext().getString(R.string.navigation_running), navigationViewModel.isRunning());
    mapView.onSaveInstanceState(outState);
    saveNavigationMapInstanceState(outState);
  }
374603
@Override
  public void onActive(Result<? super Boolean> result)
  {
    _stubClass.onActive(this, result);
    
    if (_container != null) {
      _container.onActive();
      
      _stubClass.onActive(_container);
    }
  }
102284
@Override
    public void actionSave() throws JspException {

        CmsFile editFile = null;
        try {
            editFile = getCms().readFile(getParamResource(), CmsResourceFilter.ALL);
            String decodedContent = decodeContentParameter(getParamContent(), getFileEncoding(), editFile);
            try {
                editFile.setContents(decodedContent.getBytes(getFileEncoding()));
            } catch (UnsupportedEncodingException e) {
                throw new CmsException(
                    Messages.get().container(Messages.ERR_INVALID_CONTENT_ENC_1, getParamResource()),
                    e);
            }
            if (OpenCms.getWorkplaceManager().isXmlContentAutoCorrect()
                && (CmsResourceTypeXmlContent.isXmlContent(editFile))) {
                // enable auto correction in case of XML content (if configured)
                getCms().getRequestContext().setAttribute(CmsXmlContent.AUTO_CORRECTION_ATTRIBUTE, Boolean.TRUE);
            }
            // the file content might have been modified during the write operation
            CmsFile writtenFile = getCms().writeFile(editFile);
            decodedContent = CmsEncoder.createString(writtenFile.getContents(), getFileEncoding());
            setParamContent(encodeContent(decodedContent));
            // set the modified parameter
            setParamModified(Boolean.TRUE.toString());
        } catch (CmsException e) {
            showErrorPage(e);
        }

        if (getAction() != ACTION_CANCEL) {
            // save successful, set save action
            setAction(ACTION_SAVE);
        }
    }
931181
public ListenableFuture<Boolean> saveAsync(@NotNull V entity) {
        Timer saveAsyncTimer = METRICS.getTimer(MetricsType.DATA_PROVIDER_SAVE.name());

        Insert insert = QueryBuilder.insertInto(getEntityMetadata().getTableName());

        List<ColumnMetadata> columns = getEntityMetadata().getFieldMetaData();

        columns.forEach(column -> insert.value(column.getName(), QueryBuilder.bindMarker()));

        ListenableFuture<Boolean> resultFuture;

        try {
            PreparedStatement prepare = getCassandraClient().prepare(getEntityMetadata().getKeyspace(), insert.getQueryString());
            prepare.setConsistencyLevel(getWriteConsistencyLevel());

            BoundStatement boundStatement = createBoundStatement(prepare, entity, columns);

            ResultSetFuture input = getCassandraClient().executeAsync(boundStatement);
            resultFuture = Futures.transform(input, ResultSet::wasApplied, getExecutorService());
        } catch (SyntaxError e) {
            LOGGER.warn("Can't prepare query: " + insert.getQueryString(), e);

            resultFuture = Futures.immediateFailedFuture(e);
        }

        monitorFuture(saveAsyncTimer, resultFuture);

        return resultFuture;
    }
134421
@Override
    public IPromise<T> onResult(Consumer<T> resultHandler) {
        if (realCallback instanceof IPromise == false)
            throw new RuntimeException("this is an error.");
        else
            return ((IPromise)realCallback).onResult(resultHandler);
    }
44416
public void allocateLobForResult(ResultLob result,
                                     InputStream inputStream) {

        long                 resultLobId = result.getLobID();
        CountdownInputStream countStream;

        switch (result.getSubType()) {

            case ResultLob.LobResultTypes.REQUEST_CREATE_BYTES : {
                long blobId;
                long blobLength = result.getBlockLength();

                if (inputStream == null) {
                    blobId      = resultLobId;
                    inputStream = result.getInputStream();
                } else {
                    BlobData blob = session.createBlob(blobLength);

                    blobId = blob.getId();

                    resultLobs.put(resultLobId, blobId);
                }

                countStream = new CountdownInputStream(inputStream);

                countStream.setCount(blobLength);
                database.lobManager.setBytesForNewBlob(
                    blobId, countStream, result.getBlockLength());

                break;
            }
            case ResultLob.LobResultTypes.REQUEST_CREATE_CHARS : {
                long clobId;
                long clobLength = result.getBlockLength();

                if (inputStream == null) {
                    clobId = resultLobId;

                    if (result.getReader() != null) {
                        inputStream =
                            new ReaderInputStream(result.getReader());
                    } else {
                        inputStream = result.getInputStream();
                    }
                } else {
                    ClobData clob = session.createClob(clobLength);

                    clobId = clob.getId();

                    resultLobs.put(resultLobId, clobId);
                }

                countStream = new CountdownInputStream(inputStream);

                countStream.setCount(clobLength * 2);
                database.lobManager.setCharsForNewClob(
                    clobId, countStream, result.getBlockLength());

                break;
            }
        }
    }
1032807
synchronized void result(@Nullable T res) {
        if (isFinished) {
            throw new RuntimeException("Promise " + this + " already completed!");
        }
        isFinished = true;
        result = res;
        deliverResult();
    }
848264
public boolean copyMessageToResult( javax.xml.transform.Result resultTarget)
    {
        Object root = m_message.getRawData();
        try {
            String strSOAPPackage = (String)((TrxMessageHeader)this.getMessage().getMessageHeader()).get(SOAPMessageTransport.SOAP_PACKAGE);

            Marshaller m = JaxbContexts.getJAXBContexts().getMarshaller(strSOAPPackage);
            if (m != null)
            {
                synchronized(m)
                {   // Since the marshaller is shared (may want to tweek this for multi-cpu implementations)
                    m.marshal( root, resultTarget );
                }
                return true;    // Success
            }
        } catch (JAXBException ex)   {
            ex.printStackTrace();
        } catch (java.lang.IllegalArgumentException ex)   {
            ex.printStackTrace();
        }
        return super.copyMessageToResult(resultTarget);        
    }
703534
@InService(TableWriterService.class)
  public void writeBlobPage(PageBlob page,
                               int saveSequence,
                               Result<Integer> result)
  {
    SegmentStream sOut = getBlobStream();
    
    int saveLength = 0;
    int saveTail = 0;
    
    if (_blobSizeMax < page.getLength()) {
      _blobSizeMax = page.getLength();
      calculateSegmentSize();
    }
    
    sOut.writePage(this, page, saveLength, saveTail, saveSequence, result);
    
    _isBlobDirty = true;
  }
1351121
public void save(HttpServletRequest req, HttpServletResponse res, AuthenticationResult authResult) {
		save(req, res, authResult, false);
	}