Example usage for org.apache.http.entity.mime MultipartEntity addPart

List of usage examples for org.apache.http.entity.mime MultipartEntity addPart

Introduction

In this page you can find the example usage for org.apache.http.entity.mime MultipartEntity addPart.

Prototype

public void addPart(final String name, final ContentBody contentBody) 

Source Link

Usage

From source file:bluej.collect.DataCollectorImpl.java

public static void fixtureToObjectBench(Package pkg, File sourceFile, List<NamedTyped> objects) {
    MultipartEntity mpe = new MultipartEntity();

    mpe.addPart("event[source_file_name]",
            CollectUtility.toBodyLocal(new ProjectDetails(pkg.getProject()), sourceFile));
    for (NamedTyped obj : objects) {
        mpe.addPart("event[bench_objects][][name]", CollectUtility.toBody(obj.getName()));
        mpe.addPart("event[bench_objects][][class_name]", CollectUtility.toBody(obj.getType()));
    }/*from  w  w w.j  ava2 s. c  o  m*/

    submitEvent(pkg.getProject(), pkg, EventName.FIXTURE_TO_BENCH, new PlainEvent(mpe));
}

From source file:bluej.collect.DataCollectorImpl.java

public static void ConvertStrideToJava(Package pkg, File sourceFile) {
    final ProjectDetails projDetails = new ProjectDetails(pkg.getProject());
    MultipartEntity mpe = new MultipartEntity();
    mpe.addPart("source_histories[][source_history_type]", CollectUtility.toBody("stride_converted_to_java"));
    mpe.addPart("source_histories[][name]", CollectUtility.toBodyLocal(projDetails, sourceFile));
    submitEvent(pkg.getProject(), pkg, EventName.CONVERT_TO_JAVA, new PlainEvent(mpe) {

        @Override/*w  w  w  .j a  v a2 s  .c om*/
        public MultipartEntity makeData(int sequenceNum, Map<FileKey, List<String>> fileVersions) {
            return super.makeData(sequenceNum, fileVersions);
        }

    });
}

From source file:bluej.collect.DataCollectorImpl.java

public static void inspectorHide(Project project, Inspector inspector) {
    if (!false) {
        MultipartEntity mpe = new MultipartEntity();
        mpe.addPart("event[inspect][unique]", CollectUtility.toBody(inspector.getUniqueId()));
        if (inspector instanceof ClassInspector || inspector instanceof ObjectInspector) {
            submitEvent(project, inspectorPackages.get(inspector), EventName.INSPECTOR_HIDE,
                    new PlainEvent(mpe));
        }/*from w ww  .  ja v  a2s  .  com*/
    }
}

From source file:bluej.collect.DataCollectorImpl.java

public static void assertTestMethod(Package pkg, int testIdentifier, int invocationIdentifier, String assertion,
        String param1, String param2) {
    MultipartEntity mpe = new MultipartEntity();

    mpe.addPart("event[assert][test_identifier]", CollectUtility.toBody(testIdentifier));
    mpe.addPart("event[assert][invoke_identifier]", CollectUtility.toBody(invocationIdentifier));
    mpe.addPart("event[assert][assertion]", CollectUtility.toBody(assertion));
    mpe.addPart("event[assert][param1]", CollectUtility.toBody(param1));
    mpe.addPart("event[assert][param2]", CollectUtility.toBody(param2));

    submitEvent(pkg.getProject(), pkg, EventName.ASSERTION, new PlainEvent(mpe));

}

From source file:bluej.collect.DataCollectorImpl.java

public static void invokeCompileError(Package pkg, String code, String compilationError) {
    if (!false) {
        MultipartEntity mpe = new MultipartEntity();

        mpe.addPart("event[invoke][code]", CollectUtility.toBody(code));
        mpe.addPart("event[invoke][result]", CollectUtility.toBody("compile_error"));
        mpe.addPart("event[invoke][compile_error]", CollectUtility.toBody(compilationError));
        submitEvent(pkg.getProject(), pkg, EventName.INVOKE_METHOD, new PlainEvent(mpe));
    }// w w  w . j  a  va  2  s  .c om
}

From source file:bluej.collect.DataCollectorImpl.java

public static void removeClass(Package pkg, final File sourceFile) {
    final ProjectDetails projDetails = new ProjectDetails(pkg.getProject());
    MultipartEntity mpe = new MultipartEntity();
    mpe.addPart("source_histories[][source_history_type]", CollectUtility.toBody("file_delete"));
    mpe.addPart("source_histories[][name]", CollectUtility.toBodyLocal(projDetails, sourceFile));
    submitEvent(pkg.getProject(), pkg, EventName.DELETE, new PlainEvent(mpe) {

        @Override/*from   ww w.  ja v  a2s. com*/
        public MultipartEntity makeData(int sequenceNum, Map<FileKey, List<String>> fileVersions) {
            // We should remove the old source from the fileVersions hash:
            fileVersions.remove(new FileKey(projDetails, CollectUtility.toPath(projDetails, sourceFile)));
            return super.makeData(sequenceNum, fileVersions);
        }

    });
}

From source file:bluej.collect.DataCollectorImpl.java

public static void bluejOpened(String osVersion, String javaVersion, String bluejVersion,
        String interfaceLanguage, List<ExtensionWrapper> extensions) {
    if (Config.isGreenfoot())
        return; //Don't even look for UUID
    DataSubmitter.initSequence();//from  ww w .  j a va  2s. com

    MultipartEntity mpe = new MultipartEntity();

    mpe.addPart("installation[operating_system]", CollectUtility.toBody(osVersion));
    mpe.addPart("installation[java_version]", CollectUtility.toBody(javaVersion));
    mpe.addPart("installation[bluej_version]", CollectUtility.toBody(bluejVersion));
    mpe.addPart("installation[interface_language]", CollectUtility.toBody(interfaceLanguage));

    addExtensions(mpe, extensions);

    submitEvent(null, null, EventName.BLUEJ_START, new PlainEvent(mpe));
}

From source file:bluej.collect.DataCollectorImpl.java

public static void invokeMethodException(Package pkg, String code, ExceptionDescription ed) {
    if (!false) {
        MultipartEntity mpe = new MultipartEntity();

        mpe.addPart("event[invoke][code]", CollectUtility.toBody(code));
        mpe.addPart("event[invoke][result]", CollectUtility.toBody("exception"));
        mpe.addPart("event[invoke][exception_class]", CollectUtility.toBody(ed.getClassName()));
        mpe.addPart("event[invoke][exception_message]", CollectUtility.toBody(ed.getText()));
        DataCollectorImpl.addStackTrace(mpe, "event[invoke][exception_stack]",
                ed.getStack().toArray(new SourceLocation[0]));
        submitEvent(pkg.getProject(), pkg, EventName.INVOKE_METHOD, new PlainEvent(mpe));
    }/*from   w w  w  .j a  v  a2 s  . c o m*/
}

From source file:bluej.collect.DataCollectorImpl.java

public static void inspectorObjectShow(Package pkg, Inspector inspector, String benchName, String className,
        String displayName) {//from www. java2 s  .co  m
    if (!false) {
        MultipartEntity mpe = new MultipartEntity();
        mpe.addPart("event[inspect][unique]", CollectUtility.toBody(inspector.getUniqueId()));
        mpe.addPart("event[inspect][display_name]", CollectUtility.toBody(displayName));
        mpe.addPart("event[inspect][class_name]", CollectUtility.toBody(className));
        if (benchName != null) {
            mpe.addPart("event[inspect][bench_object_name]", CollectUtility.toBody(benchName));
        }
        inspectorPackages.put(inspector, pkg);
        submitEvent(pkg.getProject(), pkg, EventName.INSPECTOR_SHOW, new PlainEvent(mpe));
    }
}

From source file:bluej.collect.DataCollectorImpl.java

public static void renamedClass(Package pkg, final File oldSourceFile, final File newSourceFile) {
    final ProjectDetails projDetails = new ProjectDetails(pkg.getProject());
    MultipartEntity mpe = new MultipartEntity();
    mpe.addPart("source_histories[][source_history_type]", CollectUtility.toBody("rename"));
    mpe.addPart("source_histories[][content]", CollectUtility.toBodyLocal(projDetails, oldSourceFile));
    mpe.addPart("source_histories[][name]", CollectUtility.toBodyLocal(projDetails, newSourceFile));
    submitEvent(pkg.getProject(), pkg, EventName.RENAME, new PlainEvent(mpe) {

        @Override//from   w w  w. java2s  . c o  m
        public MultipartEntity makeData(int sequenceNum, Map<FileKey, List<String>> fileVersions) {
            // We need to change the fileVersions hash to move the content across from the old file
            // to the new file:
            FileKey oldKey = new FileKey(projDetails, CollectUtility.toPath(projDetails, oldSourceFile));
            FileKey newKey = new FileKey(projDetails, CollectUtility.toPath(projDetails, newSourceFile));
            fileVersions.put(newKey, fileVersions.get(oldKey));
            fileVersions.remove(oldKey);
            return super.makeData(sequenceNum, fileVersions);
        }

    });
}