Codota Logo
EntityBuilder.instance
Code IndexAdd Codota to your IDE (free)

How to use
instance
method
in
org.qi4j.api.entity.EntityBuilder

Best Java code snippets using org.qi4j.api.entity.EntityBuilder.instance (Showing top 20 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
FileOutputStream f =
  • Codota IconFile file;new FileOutputStream(file)
  • Codota IconString name;new FileOutputStream(name)
  • Codota IconFile file;new FileOutputStream(file, true)
  • Smart code suggestions by Codota
}
origin: org.qi4j.library/org.qi4j.library.conversion

@Override
public <T> T create( Class<T> entityType, Object value, Function<T, T> prototypeOpportunity )
{
  EntityBuilder<?> builder = doConversion( entityType, null, value );
  prototypeOpportunity.map( (T) builder.instance() );
  return createInstance( builder );
}
origin: org.qi4j.library/org.qi4j.library.conversion

@Override
public <T> T create( Class<T> entityType, String identity, Object value, Function<T, T> prototypeOpportunity )
{
  EntityBuilder<?> builder = doConversion( entityType, identity, value );
  prototypeOpportunity.map( (T) builder.instance() );
  return createInstance( builder );
}
origin: org.qi4j.core/org.qi4j.core.api

  public T newInstance( Module module )
  {
    EntityBuilder<T> builder = module.currentUnitOfWork().newEntityBuilder( type );
    build( builder.instance() );
    return builder.newInstance();
  }
}
origin: org.codeartisans.qipki/qipki-ca

@Override
public CRL create( X509CRL x509crl )
{
  EntityBuilder<CRL> crlBuilder = uowf.currentUnitOfWork().newEntityBuilder( CRL.class );
  CRL crl = crlBuilder.instance();
  crl.lastCRLNumber().set( BigInteger.ZERO );
  crl = crlBuilder.newInstance();
  FileWriter fileWriter = null;
  try {
    fileWriter = new FileWriter( crl.managedFile() );
    fileWriter.write( cryptIO.asPEM( x509crl ).toString() );
    fileWriter.flush();
    return crl;
  } catch ( IOException ex ) {
    throw new QiPkiFailure( "Unable to revoke X509", ex );
  } finally {
    try {
      if ( fileWriter != null ) {
        fileWriter.close();
      }
    } catch ( IOException ex ) {
      throw new QiPkiFailure( "Unable to revoke X509", ex );
    }
  }
}
origin: org.qi4j.core/org.qi4j.core.testsupport

private BarEntity buildBarEntity( String cathedral )
{
  EntityBuilder<BarEntity> barBuilder = module.currentUnitOfWork().newEntityBuilder( BarEntity.class );
  barBuilder.instance().cathedral().set( cathedral );
  return barBuilder.newInstance();
}
origin: org.qi4j.core/org.qi4j.core.api

private <C, V> V tryLoadPropertiesFile( UnitOfWork buildUow,
                    Class<C> compositeType,
                    Class<V> configType,
                    String identity
)
  throws InstantiationException
{
  EntityBuilder<V> configBuilder = buildUow.newEntityBuilder( configType, identity );
  String resourceName = identity + ".properties";
  InputStream asStream = getResource( compositeType, resourceName );
  if( asStream != null )
  {
    try
    {
      PropertyMapper.map( asStream, (Composite) configBuilder.instance() );
      return configBuilder.newInstance();
    }
    catch( IOException e1 )
    {
      InstantiationException exception = new InstantiationException(
        "Could not read underlying Properties file." );
      exception.initCause( e1 );
      throw exception;
    }
  }
  return null;
}
origin: org.qi4j.library/org.qi4j.library.sql

if ( asStream != null ) {
  try {
    PropertyMapper.map( asStream, configBuilder.instance() );
  } catch ( IOException e1 ) {
    uow.discard();
origin: org.codeartisans.qipki/qipki-ca

@Override
public Revocation create( X509 x509, RevocationReason reason )
{
  EntityBuilder<Revocation> builder = uowf.currentUnitOfWork().newEntityBuilder( Revocation.class );
  Revocation revocation = builder.instance();
  revocation.x509().set( x509 );
  revocation.reason().set( reason );
  return builder.newInstance();
}
origin: org.codeartisans.qipki/qipki-ca

@Override
public X509ProfileAssignment create( KeyEscrowPolicy keyEscrowPolicy, X509Profile profile )
{
  EntityBuilder<X509ProfileAssignment> profileAssignmentBuilder = uowf.currentUnitOfWork().newEntityBuilder( X509ProfileAssignment.class );
  X509ProfileAssignment profileAssignment = profileAssignmentBuilder.instance();
  profileAssignment.keyEscrowPolicy().set( keyEscrowPolicy );
  profileAssignment.x509Profile().set( profile );
  return profileAssignmentBuilder.newInstance();
}
origin: org.codeartisans.qipki/qipki-ca

@Override
public X509 create( X509Certificate cert, CA issuer, X509Profile profile )
{
  try {
    EntityBuilder<X509> x509Builder = uowf.currentUnitOfWork().newEntityBuilder( X509.class );
    X509 x509 = x509Builder.instance();
    x509.pem().set( cryptIO.asPEM( cert ).toString() );
    x509.canonicalSubjectDN().set( cert.getSubjectX500Principal().getName( X500Principal.CANONICAL ) );
    x509.canonicalIssuerDN().set( cert.getIssuerX500Principal().getName( X500Principal.CANONICAL ) );
    x509.hexSerialNumber().set( cert.getSerialNumber().toString( 16 ) );
    x509.validityInterval().set( commonValuesFactory.buildValidityInterval( cert.getNotBefore(), cert.getNotAfter() ) );
    x509.md5Fingerprint().set( digester.hexDigest( cert.getEncoded(), new DigestParameters( DigestAlgorithm.MD5 ) ) );
    x509.sha1Fingerprint().set( digester.hexDigest( cert.getEncoded(), new DigestParameters( DigestAlgorithm.SHA_1 ) ) );
    x509.sha256Fingerprint().set( digester.hexDigest( cert.getEncoded(), new DigestParameters( DigestAlgorithm.SHA_256 ) ) );
    x509.issuer().set( issuer );
    x509.profile().set( profile );
    return x509Builder.newInstance();
  } catch ( CertificateEncodingException ex ) {
    throw new QiPkiFailure( "Unable to calculate X509Certificate fingerprints", ex );
  }
}
origin: org.qi4j.library/org.qi4j.library.logging

private void createDebugRecord( UnitOfWork uow, Composite composite, String message, List<Serializable> params )
{
  if( composite instanceof ServiceComposite )
  {
    EntityBuilder<ServiceDebugRecordEntity> builder = uow.newEntityBuilder( ServiceDebugRecordEntity.class );
    ServiceDebugRecordEntity state = builder.instance();
    setStandardStuff( composite, message, state, params );
    state.source().set( ( (ServiceComposite) composite ).identity().get() );
    ServiceDebugRecordEntity slr = builder.newInstance();
  }
  else if( composite instanceof EntityComposite )
  {
    EntityBuilder<EntityDebugRecordEntity> builder = uow.newEntityBuilder( EntityDebugRecordEntity.class );
    EntityDebugRecordEntity state = builder.instance();
    setStandardStuff( composite, message, state, params );
    state.source().set( (EntityComposite) composite );
    EntityDebugRecordEntity elr = builder.newInstance();
  }
  else
  {
    EntityBuilder<CompositeDebugRecordEntity> builder = uow.newEntityBuilder( CompositeDebugRecordEntity.class );
    CompositeDebugRecordEntity state = builder.instance();
    setStandardStuff( composite, message, state, params );
    state.source().set( composite );
    CompositeDebugRecordEntity clr = builder.newInstance();
  }
}
origin: org.qi4j.library/org.qi4j.library.logging

private void createLogRecord( UnitOfWork uow, LogType type, Composite composite, String category, String message, List<Serializable> params )
{
  if( composite instanceof ServiceComposite )
  {
    EntityBuilder<ServiceLogRecord> builder = uow.newEntityBuilder( ServiceLogRecord.class );
    ServiceLogRecord state = builder.instance();
    setStandardStuff( type, composite, category, message, state, params );
    state.source().set( ( (ServiceComposite) composite ).identity().get() );
    ServiceLogRecord slr = builder.newInstance();
  }
  else if( composite instanceof EntityComposite )
  {
    EntityBuilder<EntityLogRecord> builder = uow.newEntityBuilder( EntityLogRecord.class );
    EntityLogRecord state = builder.instance();
    setStandardStuff( type, composite, category, message, state, params );
    state.source().set( (EntityComposite) composite );
    EntityLogRecord elr = builder.newInstance();
  }
  else
  {
    EntityBuilder<CompositeLogRecord> builder = uow.newEntityBuilder( CompositeLogRecord.class );
    CompositeLogRecord state = builder.instance();
    setStandardStuff( type, composite, category, message, state, params );
    state.source().set( composite );
    CompositeLogRecord clr = builder.newInstance();
  }
}
origin: org.qi4j.library/org.qi4j.library.scheduler

  private Schedule newPersistentOnceSchedule( Task task, DateTime runAt )
  {
    UnitOfWork uow = module.currentUnitOfWork();
    EntityBuilder<OnceSchedule> builder = uow.newEntityBuilder( OnceSchedule.class );
    OnceSchedule builderInstance = builder.instance();
    builderInstance.task().set( task );
    builderInstance.start().set( runAt );
    builderInstance.identity().set( uuid.generate( CronSchedule.class ) );
    OnceSchedule schedule = builder.newInstance();
    logger.info( "Schedule {} created: {}", schedule.presentationString(), schedule.identity().get() );
    return schedule;
  }
}
origin: org.qi4j.library/org.qi4j.library.logging

  Qi4j.FUNCTION_DESCRIPTOR_FOR.map( entity ).types() ), identity );
EntityBuilder<EntityTraceRecordEntity> builder = uow.newEntityBuilder( EntityTraceRecordEntity.class );
EntityTraceRecordEntity state = builder.instance();
setStandardStuff( compositeType, method, args, entryTime, durationNano, state, exception );
state.source().set( source );
ServiceTraceRecordEntity state = builder.instance();
setStandardStuff( compositeType, method, args, entryTime, durationNano, state, exception );
state.source().set( service.toString() );
CompositeTraceRecordEntity state = builder.instance();
state.source().set( object );
setStandardStuff( compositeType, method, args, entryTime, durationNano, state, exception );
origin: org.qi4j.library/org.qi4j.library.scheduler

private CronSchedule newPersistentCronSchedule( Task task, String cronExpression, DateTime start )
{
  UnitOfWork uow = module.currentUnitOfWork();
  EntityBuilder<CronSchedule> builder = uow.newEntityBuilder( CronSchedule.class );
  CronSchedule builderInstance = builder.instance();
  builderInstance.task().set( task );
  builderInstance.start().set( start );
  builderInstance.identity().set( uuid.generate( CronSchedule.class ) );
  builderInstance.cronExpression().set( cronExpression );
  CronSchedule schedule = builder.newInstance();
  logger.info( "Schedule {} created: {}", schedule.presentationString(), schedule.identity().get() );
  return schedule;
}
origin: org.codeartisans.qipki/qipki-ca

@Override
public EscrowedKeyPair create( AsymetricAlgorithm algorithm, Integer length )
{
  EntityBuilder<EscrowedKeyPair> builder = uowf.currentUnitOfWork().newEntityBuilder( EscrowedKeyPair.class );
  EscrowedKeyPair ekp = builder.instance();
  ekp.algorithm().set( algorithm );
  ekp.length().set( length );
  ekp = builder.newInstance();
  KeyPair keyPair = asymGenerator.generateKeyPair( new AsymetricGeneratorParameters( algorithm, length ) );
  writeToFile( cryptIO.asPEM( keyPair ), ekp.managedFile() );
  return ekp;
}
origin: org.codeartisans.qipki/qipki-ca

@Override
public RootCA createRootCA( String name, Integer validityDays, DistinguishedName distinguishedName,
              KeyPairSpecValue keySpec, CryptoStore cryptoStore,
              String... crlDistPoints )
{
  try {
    // Self signed CA
    KeyPair keyPair = asymGenerator.generateKeyPair( new AsymetricGeneratorParameters( keySpec.algorithm().get(), keySpec.length().get() ) );
    PKCS10CertificationRequest pkcs10 = x509Generator.generatePKCS10( distinguishedName, keyPair );
    List<X509ExtensionHolder> extensions = generateCAExtensions( pkcs10.getPublicKey(), pkcs10.getPublicKey() );
    X509Certificate cert = x509Generator.generateX509Certificate( keyPair.getPrivate(),
                                   distinguishedName,
                                   BigInteger.probablePrime( 120, new SecureRandom() ),
                                   distinguishedName,
                                   pkcs10.getPublicKey(),
                                   Duration.standardDays( validityDays ),
                                   extensions );
    EntityBuilder<RootCA> caBuilder = uowf.currentUnitOfWork().newEntityBuilder( RootCA.class );
    RootCA ca = caBuilder.instance();
    createCa( ca, name, cryptoStore, keyPair, cert );
    return caBuilder.newInstance();
  } catch ( GeneralSecurityException ex ) {
    throw new QiPkiFailure( "Unable to create self signed keypair plus certificate", ex );
  }
}
origin: org.codeartisans.qipki/qipki-ca

@Override
public CryptoStore create( String name, KeyStoreType storeType, char[] password )
{
  EntityBuilder<CryptoStoreEntity> csBuilder = uowf.currentUnitOfWork().newEntityBuilder( CryptoStoreEntity.class );
  CryptoStoreEntity cryptoStore = csBuilder.instance();
  cryptoStore.name().set( name );
  cryptoStore.storeType().set( storeType );
  cryptoStore.password().set( password );
  cryptoStore = csBuilder.newInstance();
  // Create and save a new empty crypto store
  KeyStore keystore = cryptIO.createEmptyKeyStore( cryptoStore.storeType().get() );
  cryptIO.writeKeyStore( keystore, password, cryptoStore.managedFile() );
  return cryptoStore;
}
origin: org.codeartisans.qipki/qipki-ca

@Override
public SubCA createSubCA( CA parentCA,
             String name, Integer validityDays, DistinguishedName distinguishedName,
             KeyPairSpecValue keySpec, CryptoStore cryptoStore,
             String... crlDistPoints )
{
  try {
    // Sub CA
    KeyPair keyPair = asymGenerator.generateKeyPair( new AsymetricGeneratorParameters( keySpec.algorithm().get(), keySpec.length().get() ) );
    PKCS10CertificationRequest pkcs10 = x509Generator.generatePKCS10( distinguishedName, keyPair );
    List<X509ExtensionHolder> extensions = generateCAExtensions( pkcs10.getPublicKey(), parentCA.certificate().getPublicKey() );
    X509Certificate cert = x509Generator.generateX509Certificate( parentCA.privateKey(),
                                   parentCA.distinguishedName(),
                                   BigInteger.probablePrime( 120, new SecureRandom() ),
                                   distinguishedName,
                                   pkcs10.getPublicKey(),
                                   Duration.standardDays( validityDays ),
                                   extensions );
    EntityBuilder<SubCA> caBuilder = uowf.currentUnitOfWork().newEntityBuilder( SubCA.class );
    SubCA ca = caBuilder.instance();
    createCa( ca, name, cryptoStore, keyPair, cert );
    ca.issuer().set( parentCA );
    return caBuilder.newInstance();
  } catch ( GeneralSecurityException ex ) {
    throw new QiPkiFailure( "Unable to create self signed keypair plus certificate", ex );
  }
}
origin: org.codeartisans.qipki/qipki-ca

X509Profile profile = builder.instance();
profile.name().set( name );
profile.validityDays().set( validityDays );
org.qi4j.api.entityEntityBuilderinstance

Javadoc

Get a representation of the state for the new Composite. It is possible to access and update properties and associations, even immutable ones since the builder represents the initial state.

Popular methods of EntityBuilder

  • newInstance
    Create a new Entity instance.

Popular in Java

  • Parsing JSON documents to java classes using gson
  • getApplicationContext (Context)
  • getResourceAsStream (ClassLoader)
    Returns a stream for the resource with the specified name. See #getResource(String) for a descriptio
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • Arrays (java.util)
    This class contains various methods for manipulating arrays (such as sorting and searching). This cl
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • ServletException (javax.servlet)
    Defines a general exception a servlet can throw when it encounters difficulty.
  • JTextField (javax.swing)
  • Table (org.hibernate.mapping)
    A relational table
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now