Example usage for org.apache.solr.common.util Base64 base64ToByteArray

List of usage examples for org.apache.solr.common.util Base64 base64ToByteArray

Introduction

In this page you can find the example usage for org.apache.solr.common.util Base64 base64ToByteArray.

Prototype

public static byte[] base64ToByteArray(String s) 

Source Link

Usage

From source file:fi.vm.sade.organisaatio.service.converter.OrganisaatioRDTOToOrganisaatioConverter.java

License:EUPL

private BinaryData decodeFromUUENCODED(String kuva) {
    if (kuva == null || kuva.isEmpty()) {
        return null;
    }//from  w ww.  j av a 2  s . co  m
    BinaryData bd = new BinaryData();
    bd.setData(Base64.base64ToByteArray(kuva));
    return bd;
}

From source file:net.semanticmetadata.lire.solr.BinaryDocValuesField.java

License:Open Source License

@Override
public IndexableField createField(SchemaField field, Object val, float boost) {
    if (val == null)
        return null;
    if (!field.stored()) {
        return null;
    }//from  w w  w. jav a  2s.  com
    byte[] buf = null;
    int offset = 0, len = 0;
    if (val instanceof byte[]) {
        buf = (byte[]) val;
        len = buf.length;
    } else if (val instanceof ByteBuffer && ((ByteBuffer) val).hasArray()) {
        ByteBuffer byteBuf = (ByteBuffer) val;
        buf = byteBuf.array();
        offset = byteBuf.position();
        len = byteBuf.limit() - byteBuf.position();
    } else {
        String strVal = val.toString();
        //the string has to be a base64 encoded string
        buf = Base64.base64ToByteArray(strVal);
        offset = 0;
        len = buf.length;
    }

    Field f = new org.apache.lucene.document.BinaryDocValuesField(field.getName(),
            new BytesRef(buf, offset, len));
    //        Field f = new org.apache.lucene.document.StoredField(field.getName(), buf, offset, len);
    f.setBoost(boost);
    return f;
}

From source file:org.socialhistoryservices.api.oai.Utils.java

License:Open Source License

public static ResumptionToken parseResumptionToken(String token) throws Exception {

    if (token == null)
        return null;
    final byte[] bytes = Base64.base64ToByteArray(token);
    String pt = new String(bytes, "utf-8");
    final String separator = (String) Utils.getParam("separator", ",");
    final String[] split = pt.split(separator, 6);
    ResumptionToken re = new ResumptionToken();
    // Parameters are in fixed order: "from", "until","set","metadataPrefix","cursor"
    re.setVerb(VerbType.fromValue(split[0]));
    if (!split[1].isEmpty())
        re.setFrom(split[1]);//from www  .  ja  v a2s  . c om
    if (!split[2].isEmpty())
        re.setUntil(split[2]);
    if (!split[3].isEmpty())
        re.setSet(split[3]);
    if (!split[4].isEmpty())
        re.setMetadataPrefix(split[4]);
    int cursor = (split[5].isEmpty()) ? 0 : Integer.parseInt(split[5]);
    re.setCursor(cursor);
    re.setResumptionToken(token);
    return re;
}