/** * Write an LDAP record into LDIF file as LDAPContent data. * * <p>You are not allowed to mix request data and content data</p> * * @param entry LDAPEntry object * * @param controls Controls that were returned with this entry * * @throws IOException if an I/O error occurs. * * @see com.novell.ldap.LDAPEntry */ public void writeEntry(LDAPEntry entry, LDAPControl[] controls) throws IOException { requestFile = Boolean.FALSE; // This is a content file writeAddRequest(entry, controls); bufWriter.newLine(); return; }
/** * Writes an exception as a comment in LDIF. * @param e Exception to be written. */ public void writeError(Exception e) throws IOException { this.writeComments(e.toString()); }
/** * Used to generate LDIF change/delete record lines. * * <p>Turn entry DN, controls * and change type into LDIF change/delete record fields and then turn * record fields into LDIF moddn record lines</p> * * @param dn String object representing entry DN * @param ctrls LDAPControl array object * * @see LDAPControl */ private void writeDeleteRequest( String dn, LDAPControl[] ctrls ) throws IOException { // write dn line(s) writeDN(dn); // write control line(s) if ( ctrls != null ) { writeControls( ctrls ); } // write change type writeLine("changetype: delete"); return; }
writeDN(dn); writeControls( ctrls ); writeLine("changetype: modify"); writeLine("add: "+ attrName); break; case LDAPModification.DELETE: writeLine("delete: "+ attrName); break; case LDAPModification.REPLACE: writeLine("replace: "+ attrName); break; default: writeAttribute(attrName, attrValue[j]); writeLine("-");
requestFile = Boolean.FALSE; if( isRequest()) { throw new RuntimeException("Attempting to write content " + " in a request stream"); if( ! isRequest()) { throw new RuntimeException("Attempting to write request " + " in a content stream"); writeAddRequest(sreq.getEntry(), controls); break; case LDAPMessage.ADD_REQUEST: writeAddRequest(areq.getEntry(), controls); break; case LDAPMessage.DEL_REQUEST: writeDeleteRequest( dreq.getDN(), controls ); break; case LDAPMessage.MODIFY_RDN_REQUEST: writeModifyDNRequest( rreq.getDN(), rreq.getNewRDN(), rreq.getDeleteOldRDN(), writeModifyRequest( mreq.getDN(), mreq.getModifications(), controls ); break;
OutputStreamWriter osw = new OutputStreamWriter(out, "UTF-8"); bufWriter = new BufferedWriter( osw ); writeComments("This LDIF file was generated by the LDIF APIs. " + "of Novell's Java LDAP SDK"); writeVersionLine(); return;
/** * Write attribute name and value into outputStream. * * <p>Check if attribute value contains NON-SAFE-INIT-CHAR or * NON-SAFE-CHAR. if it does, it needs to be base64 encoded and then * write it out</p> */ private void writeAttribute(String attrName, byte[] attrVal) throws IOException { if (attrVal != null) { writeLine( (Base64.isLDIFSafe(attrVal) && isPrintable(attrVal))? attrName + ": " + new String(attrVal, "UTF-8"): attrName + ":: " + Base64.encode(attrVal) ); } return; }
/** * Write an LDAP record into LDIF file as LDAPContent data. * * <p>You are not allowed to mix request data and content data</p> * * @param entry LDAPEntry object * * @throws IOException if an I/O error occurs. * * @see com.novell.ldap.LDAPEntry */ public void writeEntry(LDAPEntry entry) throws IOException { writeEntry(entry, new LDAPControl[]{}); return; }
/** * Write the version line of LDIF file into the OutputStream. * * <p>Two extra lines will be written to separate version line * with the rest of lines in LDIF file</p> * * @throws IOException if an I/O error occurs. */ private void writeVersionLine () throws IOException { // LDIF file is currently using 'version 1' String versionLine = new String("version: " + getVersion()); bufWriter.write( versionLine, 0, versionLine.length()); // write an empty line to separate the version line // with the rest of the contents in LDIF file bufWriter.newLine(); bufWriter.newLine(); return; }
writeDN(entry.getDN()); if (isRequest()) { writeControls( ctrls ); writeLine("changetype: add"); writeAttribute(attrName, values[i]);
writeDN(dn); writeControls( ctrls ); writeLine("changetype: moddn"); writeLine( Base64.isLDIFSafe(newRDN)? "newrdn: " + newRDN: "newrdn:: " + Base64.encode(newRDN)); writeLine("deleteoldrdn:" + deleteOldRDN); writeLine( Base64.isLDIFSafe(newSuperior)? "newsuperior: " + newSuperior: "newsuperior:: " + Base64.encode(newSuperior));