/** {@inheritDoc} */ public void save() throws AccessDeniedException, ConstraintViolationException, InvalidItemStateException, ReferentialIntegrityException, VersionException, LockException, RepositoryException { item.save(); }
public void save() throws RepositoryException { this.item.save(); }
public Item patch(Long id, JsonNode json) { //find the store item Item item = Item.find.byId(id); if(item == null) { return null; } //convert json to update item Item updateItem; updateItem = Json.fromJson(json, Item.class); if(updateItem.name != null){ item.name = updateItem.name; } if(updateItem.price != null){ item.price = updateItem.price; } item.save(); return item; }
Item item = new Item(); item.category = restaurants; item.name = "Outback Steakhouse"; item.save();
/** {@inheritDoc} */ public void save() throws RepositoryException, RemoteException { try { item.save(); } catch (RepositoryException ex) { throw getRepositoryException(ex); } }
/** * @see org.apache.jackrabbit.webdav.jcr.transaction.TxLockManagerImpl.Transaction#commit(TransactionResource) */ public void commit(TransactionResource resource) throws DavException { try { getItem(resource).save(); } catch (RepositoryException e) { throw new JcrDavException(e); } }
public boolean execute(Context context) throws Exception { Session session = ((JCRAppContext)context).getSession(); String relPath = (String)context.get(pathKey); if (relPath == null) session.save(); else ((Item)session.getItem(relPath)).save(); return true; }
/** * @deprecated */ @Deprecated public void save() throws RepositoryException { getActionHandler().beforeItemSave(this); getDelegate().save(); getActionHandler().afterItemSave(this); }
context.getImportRoot().save();
/** * If this resource exists but does not contain a transaction id, complete * will try to persist any modifications present on the underlying * repository item. * * @throws DavException if calling {@link Item#save()} fails */ void complete() throws DavException { if (exists() && getTransactionId() == null) { try { if (item.isModified()) { item.save(); } } catch (RepositoryException e) { // this includes LockException, ConstraintViolationException etc. not detected before log.error("Error while completing request: " + e.getMessage() +" -> reverting changes."); try { item.refresh(false); } catch (RepositoryException re) { log.error("Error while reverting changes: " + re.getMessage()); } throw new JcrDavException(e); } } }
/** * Adds version control to this resource. If the resource is already under * version control, this method has no effect. * * @throws org.apache.jackrabbit.webdav.DavException if this resource does not * exist yet or if an error occurs while making the underlying node versionable. * @see org.apache.jackrabbit.webdav.version.VersionableResource#addVersionControl() */ @Override public void addVersionControl() throws DavException { if (!exists()) { throw new DavException(DavServletResponse.SC_NOT_FOUND); } if (!isVersionControlled()) { try { ((Node)item).addMixin(JcrConstants.MIX_VERSIONABLE); item.save(); } catch (RepositoryException e) { throw new JcrDavException(e); } } // else: is already version controlled -> ignore }
List <Category> categories = new Select() .from(Category.class) .where("your where clause here") // your where clause .execute(); if (categories != null && categories.size() > 0 ) { // data is inserted before } else { Category newCategory = new Category("category"); newCategory.save(); } List <Item> items = new Select() .from(Item.class) .where("your where clause") .execute(); if (items != null && items.size() > 0 ) { // data is inserted before } else { Item item = new Item("item"); item.save(); }
/** * A removed item must throw InvalidItemStateException upon any call to an * item specific method. */ public void testInvalidStateRemovedItem() throws RepositoryException { removeItem.remove(); try { removeItem.getName(); fail("Calling getName() on a removed node must throw InvalidItemStateException."); } catch (InvalidItemStateException e) { //ok } try { removeItem.getPath(); fail("Calling getPath() on a removed node must throw InvalidItemStateException."); } catch (InvalidItemStateException e) { //ok } try { removeItem.save(); fail("Calling save() on a removed node must throw InvalidItemStateException."); } catch (InvalidItemStateException e) { //ok } }
/** * Same as {@link #testInvalidStateRemovedItem()} but calls save() before * executing the test. */ public void testInvalidStateRemovedItem2() throws RepositoryException { removeItem.remove(); testRootNode.save(); try { removeItem.getName(); fail("Calling getName() on a removed node must throw InvalidItemStateException."); } catch (InvalidItemStateException e) { //ok } try { removeItem.getPath(); fail("Calling getPath() on a removed node must throw InvalidItemStateException."); } catch (InvalidItemStateException e) { //ok } try { removeItem.save(); fail("Calling save() on a removed node must throw InvalidItemStateException."); } catch (InvalidItemStateException e) { //ok } } }