org.apache.accumulo.core.security.ColumnVisibility

Here are the examples of the java api class org.apache.accumulo.core.security.ColumnVisibility taken from open source projects.

1. AccumuloUtils#storeMetadataIntoTable()

Project: mrgeo
File: AccumuloUtils.java
// end buildMetadataFromTable
/**
	 * Store image metadata into a table.
	 * 
	 * @param table - the table to use.
	 * @param metadata - the metadata object to store.
	 * @param conn - the accumulo connector to use.
	 * @param cv - the ColumnVisibility to use.
	 * @return - true if successful in storing the data.
	 */
@Deprecated
public static boolean storeMetadataIntoTable(String table, MrsPyramidMetadata metadata, Connector conn, String cv) {
    ColumnVisibility cViz = null;
    if (cv == null) {
        cViz = new ColumnVisibility();
    } else {
        cViz = new ColumnVisibility(cv);
    }
    return storeMetadataIntoTable(table, metadata, conn, cViz);
}

2. JoinSelectStatsUtil#createMutation()

Project: incubator-rya
File: JoinSelectStatsUtil.java
public static Mutation createMutation(TripleRow tripleRow) {
    Mutation mutation = new Mutation(new Text(tripleRow.getRow()));
    byte[] columnVisibility = tripleRow.getColumnVisibility();
    ColumnVisibility cv = columnVisibility == null ? EMPTY_CV : new ColumnVisibility(columnVisibility);
    Long timestamp = tripleRow.getTimestamp();
    boolean hasts = timestamp != null;
    timestamp = timestamp == null ? 0l : timestamp;
    byte[] value = tripleRow.getValue();
    Value v = value == null ? EMPTY_VALUE : new Value(value);
    byte[] columnQualifier = tripleRow.getColumnQualifier();
    Text cqText = columnQualifier == null ? EMPTY_TEXT : new Text(columnQualifier);
    byte[] columnFamily = tripleRow.getColumnFamily();
    Text cfText = columnFamily == null ? EMPTY_TEXT : new Text(columnFamily);
    if (hasts) {
        mutation.put(cfText, cqText, cv, timestamp, v);
    } else {
        mutation.put(cfText, cqText, cv, v);
    }
    return mutation;
}

3. EntityCentricIndex#createMutation()

Project: incubator-rya
File: EntityCentricIndex.java
private static Mutation createMutation(TripleRow tripleRow) {
    Mutation mutation = new Mutation(new Text(tripleRow.getRow()));
    byte[] columnVisibility = tripleRow.getColumnVisibility();
    ColumnVisibility cv = columnVisibility == null ? EMPTY_CV : new ColumnVisibility(columnVisibility);
    Long timestamp = tripleRow.getTimestamp();
    byte[] value = tripleRow.getValue();
    Value v = value == null ? EMPTY_VALUE : new Value(value);
    byte[] columnQualifier = tripleRow.getColumnQualifier();
    Text cqText = columnQualifier == null ? EMPTY_TEXT : new Text(columnQualifier);
    byte[] columnFamily = tripleRow.getColumnFamily();
    Text cfText = columnFamily == null ? EMPTY_TEXT : new Text(columnFamily);
    mutation.put(cfText, cqText, cv, timestamp, v);
    return mutation;
}

4. EntityCentricIndex#deleteMutation()

Project: incubator-rya
File: EntityCentricIndex.java
protected Mutation deleteMutation(TripleRow tripleRow) {
    Mutation m = new Mutation(new Text(tripleRow.getRow()));
    byte[] columnFamily = tripleRow.getColumnFamily();
    Text cfText = columnFamily == null ? EMPTY_TEXT : new Text(columnFamily);
    byte[] columnQualifier = tripleRow.getColumnQualifier();
    Text cqText = columnQualifier == null ? EMPTY_TEXT : new Text(columnQualifier);
    byte[] columnVisibility = tripleRow.getColumnVisibility();
    ColumnVisibility cv = columnVisibility == null ? EMPTY_CV : new ColumnVisibility(columnVisibility);
    m.putDelete(cfText, cqText, cv, tripleRow.getTimestamp());
    return m;
}

5. RyaTableMutationsFactory#createMutation()

Project: incubator-rya
File: RyaTableMutationsFactory.java
protected Mutation createMutation(TripleRow tripleRow) {
    Mutation mutation = new Mutation(new Text(tripleRow.getRow()));
    byte[] columnVisibility = tripleRow.getColumnVisibility();
    ColumnVisibility cv = columnVisibility == null ? EMPTY_CV : new ColumnVisibility(columnVisibility);
    Long timestamp = tripleRow.getTimestamp();
    byte[] value = tripleRow.getValue();
    Value v = value == null ? EMPTY_VALUE : new Value(value);
    byte[] columnQualifier = tripleRow.getColumnQualifier();
    Text cqText = columnQualifier == null ? EMPTY_TEXT : new Text(columnQualifier);
    byte[] columnFamily = tripleRow.getColumnFamily();
    Text cfText = columnFamily == null ? EMPTY_TEXT : new Text(columnFamily);
    mutation.put(cfText, cqText, cv, timestamp, v);
    return mutation;
}

6. Flutation#put()

Project: incubator-fluo
File: Flutation.java
public static void put(Environment env, Mutation m, Column col, long ts, byte[] val) {
    ColumnVisibility cv;
    if (env != null) {
        cv = env.getSharedResources().getVisCache().getCV(col.getVisibility());
    } else if (col.getVisibility().length() == 0) {
        cv = VisibilityCache.EMPTY_VIS;
    } else {
        cv = new ColumnVisibility(ByteUtil.toText(col.getVisibility()));
    }
    m.put(ByteUtil.toText(col.getFamily()), ByteUtil.toText(col.getQualifier()), cv, ts, new Value(val));
}

7. AccumuloSecondaryIndexDataStore#buildMutation()

Project: geowave
File: AccumuloSecondaryIndexDataStore.java
private Mutation buildMutation(final byte[] secondaryIndexRowId, final byte[] secondaryIndexId, final byte[] attributeName, final byte[] attributeValue, final byte[] visibility, final byte[] primaryIndexId, final byte[] primaryIndexRowId) {
    final Mutation m = new Mutation(secondaryIndexRowId);
    final ColumnVisibility columnVisibility = new ColumnVisibility(visibility);
    m.put(secondaryIndexId, attributeName, columnVisibility, attributeValue);
    m.put(secondaryIndexId, primaryIndexId, columnVisibility, primaryIndexRowId);
    return m;
}

8. OSMMapperBase#setup()

Project: geowave
File: OSMMapperBase.java
@Override
public void setup(Context context) throws IOException, InterruptedException {
    String tn = context.getConfiguration().get("tableName");
    if (tn != null && !tn.isEmpty()) {
        _tableName.set(tn);
    }
    String visibility = context.getConfiguration().get("osmVisibility");
    if (visibility == null) {
        visibility = "";
    }
    _visibility = new ColumnVisibility(visibility.getBytes(Constants.CHARSET));
}

9. ToStringMutationTransformer#getMutations()

Project: sqoop
File: ToStringMutationTransformer.java
/**
   * Return the serialized bytes for a field name, using
   * the cache if it's already in there.
   */
@Override
public Iterable<Mutation> getMutations(Map<String, Object> fields) throws IOException {
    String rowKeyCol = getRowKeyColumn();
    String colFamily = getColumnFamily();
    Object rowKey = fields.get(rowKeyCol);
    String vis = getVisibility();
    if (null == rowKey) {
        // If the row-key column is null, we don't insert this row.
        LOG.warn("Could not insert row with null value for row-key column: " + rowKeyCol);
        return null;
    }
    ColumnVisibility colVis = null;
    if (null != vis && vis.length() > 0) {
        colVis = new ColumnVisibility(vis);
    }
    Mutation mut = new Mutation(rowKey.toString());
    for (Map.Entry<String, Object> fieldEntry : fields.entrySet()) {
        String colName = fieldEntry.getKey();
        if (!colName.equals(rowKeyCol)) {
            // This is a regular field, not the row key.
            // Add it if it's not null.
            Object val = fieldEntry.getValue();
            if (null != val) {
                if (null == colVis) {
                    mut.put(new Text(colFamily), new Text(colName), new Value(val.toString().getBytes("UTF8")));
                } else {
                    mut.put(new Text(colFamily), new Text(colName), colVis, new Value(val.toString().getBytes("UTF8")));
                }
            }
        }
    }
    return Collections.singletonList(mut);
}

10. AccumuloUtils#storeMetadataIntoTable()

Project: mrgeo
File: AccumuloUtils.java
// end storeMetadataIntoTable
/**
	 * This is a method for storing a MrsImagePyramidMetadata object into an Accumulo Table
	 * 
	 * The metadata object is base64 encoded to store all items.
	 * 
	 * The individual items of the object are also stored.
	 *   all - base64 - base64 encoded object
	 *   zoomLevel - max zoom level - max zoom level
	 *   bounds - max zoom level - geo spatial bounds seperated by commas
	 *   tileBounds - zoom level - tile bounds separated by commas
	 *   pixelBounds - zoom level - pixel bounds of original image
	 *   bands - bands of original image - bands of original image
	 *   classification - classification value - classification value
	 *   defaultValues - max zoom level - double array separated by commas
	 *   imageString - max zoom level - the string pointing to the image
	 *   tileSize - max zoom level - the size of the tile
	 *   //stats - zoom level - stats values separated by commas
	 *   
	 * 
	 * @param table - table to be used for the storage of the information
	 * @param metadata - the MrsImagePyramidMetadata object to be stored
	 * @param conn - the Accumulo connector to use
	 */
public static boolean storeMetadataIntoTable(String table, MrsPyramidMetadata metadata, Connector conn, ColumnVisibility cViz) {
    ColumnVisibility columnVis;
    if (cViz != null) {
        columnVis = cViz;
    } else {
        columnVis = new ColumnVisibility();
    }
    int zoomLevel = metadata.getMaxZoomLevel();
    try {
        BatchWriter bw = conn.createBatchWriter(table, 1000, Long.MAX_VALUE, 1);
        //ColumnVisibility cv = new ColumnVisibility();
        // store all metadata base 64 encoded
        Mutation ma = new Mutation(MrGeoAccumuloConstants.MRGEO_ACC_METADATA);
        ma.put("all", "base64", columnVis, new Value(Base64Utils.encodeObject(metadata).getBytes()));
        bw.addMutation(ma);
        // store the zoom level
        Mutation mz = new Mutation(MrGeoAccumuloConstants.MRGEO_ACC_METADATA);
        mz.put("zoomLevel", "" + zoomLevel, columnVis, new Value(("" + zoomLevel).getBytes()));
        bw.addMutation(mz);
        // store the geospatial bounds
        Mutation mb = new Mutation(MrGeoAccumuloConstants.MRGEO_ACC_METADATA);
        mb.put("bounds", "" + zoomLevel, columnVis, new Value(metadata.getBounds().toCommaString().getBytes()));
        bw.addMutation(mb);
        // store the tile bounds for the best zoom level
        Mutation mtb = new Mutation(MrGeoAccumuloConstants.MRGEO_ACC_METADATA);
        mtb.put("tileBounds", "" + zoomLevel, columnVis, new Value(metadata.getTileBounds(zoomLevel).toDelimitedString().getBytes()));
        bw.addMutation(mtb);
        // store the pixel bounds of the image
        Mutation mpb = new Mutation(MrGeoAccumuloConstants.MRGEO_ACC_METADATA);
        mpb.put("pixelBounds", "" + zoomLevel, columnVis, new Value(metadata.getPixelBounds(zoomLevel).toDelimitedString().getBytes()));
        bw.addMutation(mpb);
        // store the bands of the original object
        int bands = metadata.getBands();
        Mutation mband = new Mutation(MrGeoAccumuloConstants.MRGEO_ACC_METADATA);
        mband.put("bands", "" + zoomLevel, columnVis, new Value(Integer.toString(bands).getBytes()));
        bw.addMutation(mband);
        // store the classification
        Classification cl = metadata.getClassification();
        Mutation mclass = new Mutation(MrGeoAccumuloConstants.MRGEO_ACC_METADATA);
        mclass.put("classification", "" + zoomLevel, columnVis, new Value(cl.toString().getBytes()));
        bw.addMutation(mclass);
        double[] dVals = metadata.getDefaultValues();
        StringBuffer sb = new StringBuffer();
        for (int x = 0; x < dVals.length; x++) {
            sb.append(dVals[x]);
            if (x < dVals.length - 1) {
                sb.append(",");
            }
        }
        Mutation mdVals = new Mutation(MrGeoAccumuloConstants.MRGEO_ACC_METADATA);
        mdVals.put("defaultValues", "" + zoomLevel, columnVis, new Value(sb.toString().getBytes()));
        bw.addMutation(mdVals);
        String imgStr = metadata.getName(zoomLevel);
        Mutation mimg = new Mutation(MrGeoAccumuloConstants.MRGEO_ACC_METADATA);
        mimg.put("imageString", "" + zoomLevel, columnVis, new Value(imgStr.getBytes()));
        bw.addMutation(mimg);
        int tsize = metadata.getTilesize();
        Mutation mts = new Mutation(MrGeoAccumuloConstants.MRGEO_ACC_METADATA);
        mts.put("tileSize", "" + zoomLevel, columnVis, new Value(Integer.toString(tsize).getBytes()));
        bw.addMutation(mts);
        String name = metadata.getPyramid();
        Mutation mname = new Mutation(MrGeoAccumuloConstants.MRGEO_ACC_METADATA);
        mname.put("name", "" + zoomLevel, columnVis, new Value(name.getBytes()));
        bw.addMutation(mname);
        //ImageStats[] sts = metadata.getStats();
        bw.flush();
        bw.close();
    } catch (IOException ioe) {
        return false;
    } catch (MutationsRejectedException mre) {
        return false;
    } catch (TableNotFoundException tnfe) {
        return false;
    }
    return true;
}

11. AccumuloMrsPyramidMetadataWriter#write()

Project: mrgeo
File: AccumuloMrsPyramidMetadataWriter.java
// end write
/**
   * 
   * need to know the type of table/image this is
   * if it is a standalone - then there is one table
   * if not - we write to a table that has a bunch of data in it
   * 
   * 
   * 
   * 
   * 
   */
@Override
public void write(MrsPyramidMetadata metadata) throws IOException {
    Properties mrgeoAccProps = AccumuloConnector.getAccumuloProperties();
    String pl = metadata.getProtectionLevel();
    if (conn == null) {
        try {
            conn = AccumuloConnector.getConnector();
        } catch (DataProviderException dpe) {
            dpe.printStackTrace();
            throw new RuntimeException("No connection to Accumulo!");
        }
    }
    /*
     *  need to know the type of table/image this is
     *  
     *  if it is a standalone - then there is one table
     *  
     *  if not - we write to a table that has a bunch of data in it
     *  
     */
    String table = provider.getResourceName();
    if (table == null || table.length() == 0) {
        throw new RuntimeException("Can not load metadata, resource name is empty!");
    }
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    String metadataStr = null;
    try {
        metadata.save(baos);
        metadataStr = baos.toString();
        baos.close();
    } catch (IOException ioe) {
        throw new RuntimeException(ioe.getMessage());
    }
    /**
     * TODO: when the protection levels are in the metadata
     * class then pull them out and put them in the visualization
     * fields.
     */
    ColumnVisibility cv;
    if (pl == null) {
        if (mrgeoAccProps.getProperty(MrGeoAccumuloConstants.MRGEO_ACC_KEY_VIZ) == null) {
            cv = new ColumnVisibility();
        } else {
            cv = new ColumnVisibility(mrgeoAccProps.getProperty(MrGeoAccumuloConstants.MRGEO_ACC_KEY_VIZ));
        }
    } else {
        cv = new ColumnVisibility(pl);
    }
    log.debug("Writing metadata for table " + metadata.getPyramid() + " with ColumnVisibility = " + cv.toString());
    // this is the name of the image
    //    String pyramid = metadata.getPyramid();
    Mutation m = new Mutation(MrGeoAccumuloConstants.MRGEO_ACC_METADATA);
    m.put(MrGeoAccumuloConstants.MRGEO_ACC_METADATA, MrGeoAccumuloConstants.MRGEO_ACC_CQALL, cv, new Value(metadataStr.getBytes()));
    BatchWriter bw = null;
    try {
        bw = conn.createBatchWriter(table, 10000000L, 1000, 2);
        bw.addMutation(m);
        bw.flush();
        bw.close();
    } catch (TableNotFoundException tnfe) {
    } catch (MutationsRejectedException mre) {
    }
    provider.getMetadataReader(null).reload();
}

12. Notification#put()

Project: incubator-fluo
File: Notification.java
public static void put(Environment env, Mutation m, Column col, long ts) {
    ColumnVisibility cv = env.getSharedResources().getVisCache().getCV(col);
    m.put(ColumnConstants.NOTIFY_CF.toArray(), encodeCol(col), cv, encodeTs(ts, false), TransactionImpl.EMPTY);
}

13. Notification#newDelete()

Project: incubator-fluo
File: Notification.java
public Flutation newDelete(Environment env, long ts) {
    Flutation m = new Flutation(env, getRow());
    ColumnVisibility cv = env.getSharedResources().getVisCache().getCV(getColumn());
    m.put(ColumnConstants.NOTIFY_CF.toArray(), encodeCol(getColumn()), cv, encodeTs(ts, true), TransactionImpl.EMPTY);
    return m;
}