/** * Creates a new <code>documents.document_alias</code> resource instance. * * @param session the CoralSession * @param name the name of the new resource * @param parent the parent resource. * @param originalDocument the originalDocument attribute * @param preferences the preferences attribute * @param site the site attribute * @param title the title attribute * @return a new DocumentAliasResource instance. * @throws ValueRequiredException if one of the required attribues is undefined. * @throws InvalidResourceNameException if the name argument contains illegal characters. */ public static DocumentAliasResource createDocumentAliasResource( CoralSession session, String name, Resource parent, DocumentNodeResource originalDocument, Parameters preferences, SiteResource site, String title) throws ValueRequiredException, InvalidResourceNameException { try { ResourceClass<DocumentAliasResource> rc = session .getSchema() .getResourceClass("documents.document_alias", DocumentAliasResource.class); Map<AttributeDefinition<?>, Object> attrs = new HashMap<AttributeDefinition<?>, Object>(); attrs.put(rc.getAttribute("originalDocument"), originalDocument); attrs.put(rc.getAttribute("preferences"), preferences); attrs.put(rc.getAttribute("site"), site); attrs.put(rc.getAttribute("title"), title); Resource res = session.getStore().createResource(name, parent, rc, attrs); if (!(res instanceof DocumentAliasResource)) { throw new BackendException( "incosistent schema: created object is " + res.getClass().getName()); } return (DocumentAliasResource) res; } catch (EntityDoesNotExistException e) { throw new BackendException("incompatible schema change", e); } }
/** * Creates a new <code>cms.confirmation.email_confirmation_request</code> resource instance. * * @param session the CoralSession * @param name the name of the new resource * @param parent the parent resource. * @param email the email attribute * @return a new EmailConfirmationRequestResource instance. * @throws ValueRequiredException if one of the required attribues is undefined. * @throws InvalidResourceNameException if the name argument contains illegal characters. */ public static EmailConfirmationRequestResource createEmailConfirmationRequestResource( CoralSession session, String name, Resource parent, String email) throws ValueRequiredException, InvalidResourceNameException { try { ResourceClass<EmailConfirmationRequestResource> rc = session .getSchema() .getResourceClass( "cms.confirmation.email_confirmation_request", EmailConfirmationRequestResource.class); Map<AttributeDefinition<?>, Object> attrs = new HashMap<AttributeDefinition<?>, Object>(); attrs.put(rc.getAttribute("email"), email); Resource res = session.getStore().createResource(name, parent, rc, attrs); if (!(res instanceof EmailConfirmationRequestResource)) { throw new BackendException( "incosistent schema: created object is " + res.getClass().getName()); } return (EmailConfirmationRequestResource) res; } catch (EntityDoesNotExistException e) { throw new BackendException("incompatible schema change", e); } }