Package com.dotmarketing.business

Examples of com.dotmarketing.business.PermissionAPI


      htmlPage.setWebEndDate( "" );
      htmlPage.setWebStartDate( "" );

      htmlPage = APILocator.getHTMLPageAPI().saveHTMLPage( htmlPage, template, testFolder, user, false );

      PermissionAPI permissionAPI = APILocator.getPermissionAPI();
      RoleAPI roleAPI = APILocator.getRoleAPI();

      Permission newPermission = new Permission( htmlPage.getPermissionId(), roleAPI.loadCMSAnonymousRole().getId(), PermissionAPI.PERMISSION_READ, true );
      permissionAPI.save( newPermission, htmlPage, user, false );

      //Make it working and live
      APILocator.getVersionableAPI().setWorking( htmlPage );
      APILocator.getVersionableAPI().setLive( htmlPage );

      // WIDGET


      widget = new Contentlet();
      widget.setReviewInterval("1m");
      widget.setStructureInode(simpleWidgetSt.getInode());
      widget.setHost(demoHost.getIdentifier());

      Field widgetTitle =  simpleWidgetSt.getFieldVar("widgetTitle");
      Field widgetCode = simpleWidgetSt.getFieldVar("code");


      ContentletAPI contentletAPI = APILocator.getContentletAPI();

      contentletAPI.setContentletProperty( widget, widgetTitle, "newsTestWidget" );
      contentletAPI.setContentletProperty( widget, widgetCode, "$URLMapContent.story" );

      widget = contentletAPI.checkin( widget, null, permissionAPI.getPermissions( simpleWidgetSt ), user, false );
      APILocator.getVersionableAPI().setLive(widget);

      // add the widget to the detail page
      MultiTreeFactory.saveMultiTree( new MultiTree( htmlPage.getIdentifier(), container.getIdentifier(), widget.getIdentifier() ) );

     
      // STRUCTURE
      testSt = new Structure();

      testSt.setDefaultStructure( false );
      testSt.setDescription( "News Test" );
      testSt.setFixed( false );
      testSt.setIDate( new Date() );
      testSt.setName( "NewsTest" +salt);
      testSt.setOwner( user.getUserId() );
      testSt.setStructureType( Structure.STRUCTURE_TYPE_CONTENT );
      testSt.setType( "structure" );
      testSt.setVelocityVarName( "NewsTest" +salt );
      testSt.setUrlMapPattern("/newstest"+salt+"/{urlNewsTitle}");
      testSt.setDetailPage( htmlPage.getIdentifier() );

      StructureFactory.saveStructure( testSt );

      //Creating and adding permissions
      Permission permissionRead = new Permission( testSt.getInode(), roleAPI.loadCMSAnonymousRole().getId(), PermissionAPI.PERMISSION_READ );
      Permission permissionEdit = new Permission( testSt.getInode(), roleAPI.loadCMSAnonymousRole().getId(), PermissionAPI.PERMISSION_EDIT );
      Permission permissionWrite = new Permission( testSt.getInode(), roleAPI.loadCMSAnonymousRole().getId(), PermissionAPI.PERMISSION_WRITE );

      permissionAPI.save( permissionRead, testSt, user, false );
      permissionAPI.save( permissionEdit, testSt, user, false );
      permissionAPI.save( permissionWrite, testSt, user, false );

      // FIELDS

      // headline
      Field headline = new Field();
      headline.setFieldName("Headline");
      headline.setFieldType(FieldType.TEXT.toString());
      headline.setListed(true);
      headline.setRequired(true);
      headline.setSearchable(true);
      headline.setStructureInode(testSt.getInode());
      headline.setType("field");
      headline.setValues("");
      headline.setVelocityVarName("testTitle");
      headline.setIndexed(true);
      headline.setFieldContentlet("text4");
      FieldFactory.saveField( headline );

      // URL Title
      Field urlTitle = new Field();
      urlTitle.setFieldName("URL Title");
      urlTitle.setFieldType(FieldType.CUSTOM_FIELD.toString());
      urlTitle.setRequired(true);
      urlTitle.setStructureInode(testSt.getInode());
      urlTitle.setType("field");
      urlTitle.setValues("#dotParse('//shared/vtl/custom-fields/url-title.vtl')");
      urlTitle.setVelocityVarName("urlNewsTitle");
      urlTitle.setSearchable(true);
      urlTitle.setIndexed(true);
      urlTitle.setFieldContentlet("text_area4");
      FieldFactory.saveField( urlTitle );

      // WYSIWYG
      Field story = new Field();
      story.setFieldName("Story");
      story.setFieldType(FieldType.WYSIWYG.toString());
      story.setRequired(true);
      story.setStructureInode(testSt.getInode());
      story.setType("field");
      story.setValues("");
      story.setVelocityVarName("story");
      story.setFieldContentlet("text_area3");
      FieldFactory.saveField( story );

      // ENGLISH CONTENT
      Contentlet englishContent = new Contentlet();
      englishContent.setReviewInterval( "1m" );
      englishContent.setStructureInode( testSt.getInode() );
      englishContent.setHost( demoHost.getIdentifier() );
      englishContent.setLanguageId(1);


      contentletAPI.setContentletProperty( englishContent, headline, "the-gas-price" );
      contentletAPI.setContentletProperty( englishContent, story, "the-gas-price" );
      contentletAPI.setContentletProperty( englishContent, urlTitle, "the-gas-price" );

      englishContent = contentletAPI.checkin( englishContent, null, permissionAPI.getPermissions( testSt ), user, false );
      APILocator.getVersionableAPI().setLive(englishContent);

      // SPANISH CONTENT
      Contentlet spanishContent = new Contentlet();
      spanishContent.setReviewInterval("1m");
      spanishContent.setStructureInode(testSt.getInode());
      spanishContent.setHost(demoHost.getIdentifier());
      spanishContent.setLanguageId(2);
      spanishContent.setIdentifier(englishContent.getIdentifier());

      contentletAPI.setContentletProperty( spanishContent, headline, "el-precio-del-gas" );
      contentletAPI.setContentletProperty( spanishContent, story, "el-precio-del-gas" );
      contentletAPI.setContentletProperty( spanishContent, urlTitle, "el-precio-del-gas" );

      spanishContent = contentletAPI.checkin( spanishContent, null, permissionAPI.getPermissions( testSt ), user, false );
      APILocator.getVersionableAPI().setLive(spanishContent);

      HibernateUtil.commitTransaction();

      if(!(contentletAPI.isInodeIndexed(englishContent.getInode(), true) &&
View Full Code Here

TOP

Related Classes of com.dotmarketing.business.PermissionAPI

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.