Java Code Examples for com.thoughtworks.xstream.XStream

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project Baseform-Epanet-Java-Library, under directory /src/org/addition/epanet/network/io/output/.

Source file: XMLComposer.java

  23 
vote

@Override public void composer(Network net,File f) throws ENException {
  XStream xStream=XMLParser.X_STREAM;
  try {
    OutputStream os=!gzip ? new FileOutputStream(f) : new GZIPOutputStream(new FileOutputStream(f));
    Writer w=new OutputStreamWriter(os,"UTF-8");
    xStream.toXML(net,w);
    w.close();
    os.close();
  }
 catch (  IOException e) {
    e.printStackTrace();
    throw new ENException(308);
  }
}
 

Example 2

From project codjo-data-process, under directory /codjo-data-process-common/src/main/java/net/codjo/dataprocess/common/codec/.

Source file: ExecutionListModelCodec.java

  23 
vote

public String encode(ExecutionListModel executionListModel){
  XStream xStream=new XStream(new DomDriver("ISO-8859-1"));
  xStream.registerConverter(new ExecutionListModelConverter());
  xStream.alias("executionList",ExecutionListModel.class);
  return HEADER + xStream.toXML(executionListModel);
}
 

Example 3

From project com.cedarsoft.serialization, under directory /samples/evolution/src/test/java/com/cedarsoft/sample/fixed/xstream/.

Source file: XStreamDemo.java

  23 
vote

@Test public void testSerialization() throws IOException, SAXException {
  XStream xStream=new XStream();
  xStream.alias("car",Car.class);
  xStream.alias("extra",Extra.class);
  xStream.alias("money",Money.class);
  String xml=xStream.toXML(createSampleCar());
  AssertUtils.assertXMLEquals(getClass().getResource("car.xml"),xml);
}
 

Example 4

From project common_1, under directory /src/test/java/org/powertac/common/.

Source file: BalancingTransactionTests.java

  22 
vote

@Test public void xmlSerializationTest(){
  BalancingTransaction bt=new BalancingTransaction(broker,baseTime,42.1,3.22);
  XStream xstream=new XStream();
  xstream.processAnnotations(BalancingTransaction.class);
  StringWriter serialized=new StringWriter();
  serialized.write(xstream.toXML(bt));
  BalancingTransaction xbt=(BalancingTransaction)xstream.fromXML(serialized.toString());
  assertNotNull("deserialized something",xbt);
  assertEquals("correct time",baseTime.getMillis(),xbt.getPostedTime().getMillis());
  assertEquals("correct qty",42.1,xbt.getKWh(),1e-6);
  assertEquals("correct charge",3.22,xbt.getCharge(),1e-6);
}
 

Example 5

From project core_5, under directory /exo.core.component.organization.api/src/main/java/org/exoplatform/services/organization/impl/.

Source file: UserProfileData.java

  22 
vote

public org.exoplatform.services.organization.UserProfile getUserProfile(){
  final XStream xstream=getXStream();
  UserProfileImpl up=SecurityHelper.doPrivilegedAction(new PrivilegedAction<UserProfileImpl>(){
    public UserProfileImpl run(){
      return (UserProfileImpl)xstream.fromXML(profile);
    }
  }
);
  return up;
}
 

Example 6

From project D2-Java-Persistence, under directory /src/main/java/org/d2/plugins/localfile/.

Source file: LocalFileStorage.java

  22 
vote

public void saveSequences(Sequences sequences){
  try {
    XStream xs=new XStream();
    String xml=xs.toXML(sequences);
    String fileName=dirStr + "/sequences.txt";
    PrintStream out=new PrintStream(new FileOutputStream(fileName));
    out.println(xml);
    out.println();
    out.close();
  }
 catch (  FileNotFoundException e) {
    throw Util.wrap(e);
  }
}
 

Example 7

From project data-access, under directory /src/org/pentaho/platform/dataaccess/client/.

Source file: ConnectionServiceClient.java

  22 
vote

public Document serializeDatabaseConnection(DatabaseConnection databaseConnection){
  XStream xstream=new XStream(new DomDriver());
  xstream.alias("databaseConnection",DatabaseConnection.class);
  xstream.alias("accessType",DatabaseAccessType.class);
  String xml=xstream.toXML(databaseConnection);
  System.out.println(xml);
  return null;
}
 

Example 8

From project drools-mas, under directory /drools-mas-util/src/test/java/org/drools/mas/.

Source file: TestACLMessage.java

  22 
vote

@Test @Ignore public void testSerializeDeserializeArray(){
  XStream json=new XStream(new JettisonMappedXmlDriver());
  Object[] test=new Object[]{new String("aaa"),new Integer(233),new String("bbb"),new String("aaa")};
  String js=json.toXML(test);
  Object o=json.fromXML(js);
  Object[] rec=(Object[])o;
  assertEquals("aaa",rec[0]);
  assertEquals(new Integer(233),rec[1]);
  assertEquals("bbb",rec[2]);
  assertEquals("aaa",rec[3]);
}
 

Example 9

From project drools-planner, under directory /drools-planner-benchmark/src/main/java/org/drools/planner/benchmark/core/.

Source file: SolverBenchmark.java

  22 
vote

public String getSolverConfigAsHtmlEscapedXml(){
  XStream xStream=XmlSolverFactory.buildXstream();
  xStream.setMode(XStream.NO_REFERENCES);
  String xml=xStream.toXML(solverConfig);
  return StringEscapeUtils.escapeHtml(xml);
}
 

Example 10

From project droolsjbpm-integration, under directory /drools-pipeline/src/main/java/org/drools/runtime/pipeline/impl/.

Source file: XStreamToXmlGridTransformer.java

  22 
vote

public Object transform(PipelineContext context,Object object){
  XStream xstream=(XStream)context.getProperties().get("xstream-instance");
  xstream.setClassLoader(context.getClassLoader());
  Object result=null;
  try {
    result=xstream.toXML(object);
  }
 catch (  Exception e) {
    handleException(this,object,e);
  }
  return result;
}
 

Example 11

From project fuzzydb-samples, under directory /sample-webapp/src/main/java/org/fuzzydb/samples/mvc/.

Source file: AbstractDataController.java

  22 
vote

@Transactional(readOnly=true) @RequestMapping(value="/dump",method=RequestMethod.GET) public void dump(OutputStream response) throws IOException {
  Iterable<ENTITY> items=getRepo().findAll();
  XStream xs=new XStream();
  for (  ENTITY item : items) {
    xs.toXML(item,response);
  }
}
 

Example 12

From project git-plugin, under directory /src/test/java/hudson/plugins/git/converter/.

Source file: ObjectIdConverterTest.java

  22 
vote

@Test public void testMarshall() throws Exception {
  XStream XSTREAM=initXStream();
  XSTREAM.registerConverter(new ObjectIdConverter());
  Object item=getSourceConfigFile(XSTREAM).read();
  getTargetConfigFile(XSTREAM).write(item);
  getTargetConfigFile(XSTREAM).read();
}
 

Example 13

From project iSpace, under directory /base/ktree/src/test/java/com/villemos/ispace/ktree/.

Source file: MetadataTest.java

  22 
vote

public void testConvert(){
  String testString="<response><fields>" + "							<item>" + "								<name>Document Author</name>"+ "								<value>Boris Kartascheff</value>"+ "							</item>"+ "							<item>"+ "								<name>Reference ID</name>"+ "								<value>OSMV-OPMT-LOGI-RP-11-1402</value>"+ "							</item>"+ "						</fields></response>";
  MetadataItem metadata=new MetadataItem();
  XStream xstream=new XStream();
  xstream.processAnnotations(MetadataField.class);
  xstream.processAnnotations(MetadataItem.class);
  xstream.fromXML(testString,metadata);
  System.out.println(metadata);
}
 

Example 14

From project jabox, under directory /jabox-persistence/src/main/java/org/apache/wicket/persistence/provider/.

Source file: ConfigXstreamDao.java

  22 
vote

public static void persist(DefaultConfiguration config){
  XStream xstream=getXStream();
  String xml=xstream.toXML(config);
  try {
    File dir=Environment.getBaseDirFile();
    File file=new File(dir,"config.xml");
    FileWriter writer=new FileWriter(file);
    writer.write(xml);
    writer.close();
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
}
 

Example 15

From project jmeter-amf, under directory /src/protocol/amf/org/apache/jmeter/protocol/amf/util/.

Source file: AmfXmlConverterTest.java

  22 
vote

@SuppressWarnings("unchecked") public static void testASObjectConverter(){
  ASObject asObj=new ASObject();
  Object[] objArr={"thing","other thing"};
  asObj.setType("com.test.RequestVO");
  asObj.put("clientId","abcd");
  asObj.put("args",objArr);
  XStream xs=AmfXmlConverter.getXStream();
  String xml=xs.toXML(asObj);
  System.out.println("Result: \n" + xml);
  ASObject newASObj=(ASObject)xs.fromXML(xml);
  System.out.print("Rebuilt: \nType: " + newASObj.getType() + "\n"+ newASObj.toString());
}
 

Example 16

From project maven3-support, under directory /maven3-model/src/test/java/org/hudsonci/maven/model/.

Source file: ThrowableDTOHelperTest.java

  22 
vote

@Test public void testThrowable() throws Exception {
  Throwable source=new Throwable("hello");
  ThrowableDTO throwable1=ThrowableDTOHelper.convert(source);
  assertEquals(Throwable.class.getName(),throwable1.getType());
  assertEquals(source.getMessage(),throwable1.getMessage());
  XStream xs=new XStream();
  xs.autodetectAnnotations(true);
  String xml=xs.toXML(throwable1);
  System.out.println("XML:\n" + xml);
  ThrowableDTO throwable2=(ThrowableDTO)xs.fromXML(xml);
  assertEquals(Throwable.class.getName(),throwable2.getType());
  assertEquals(source.getMessage(),throwable2.getMessage());
}
 

Example 17

From project restfulie-java, under directory /client/src/main/java/br/com/caelum/restfulie/mediatype/.

Source file: XmlMediaType.java

  22 
vote

public <T>T unmarshal(String content,RestClient client){
  XStream xstream=getXstream(client);
  xstream.registerConverter(new DefaultLinkConverter(client));
  xstream.registerConverter(new DefaultUrlConverter(client));
  return (T)xstream.fromXML(content);
}
 

Example 18

From project serfj, under directory /src/main/java/net/sf/serfj/serializers/.

Source file: JsonSerializer.java

  22 
vote

/** 
 * Serializes an object to Json.
 */
public String serialize(Object object){
  if (LOGGER.isDebugEnabled()) {
    LOGGER.debug("Serializing object to Json");
  }
  XStream xstream=new XStream(new JettisonMappedXmlDriver());
  String json=xstream.toXML(object);
  if (LOGGER.isDebugEnabled()) {
    LOGGER.debug("Object serialized well");
  }
  return json;
}
 

Example 19

From project server-main, under directory /src/test/java/org/powertac/server/.

Source file: ServerMessageReceiverTests.java

  22 
vote

private String baToXml(BrokerAuthentication ba){
  XStream xstream=new XStream();
  xstream.processAnnotations(BrokerAuthentication.class);
  StringWriter serialized=new StringWriter();
  serialized.write(xstream.toXML(ba));
  return serialized.toString();
}
 

Example 20

From project servicemix-utils, under directory /src/main/java/org/apache/servicemix/expression/.

Source file: JAXPXPathXStreamExpression.java

  22 
vote

private XStream createXStream(){
  XStream answer=new XStream();
  try {
    answer.alias("invoke",Class.forName("org.logicblaze.lingo.LingoInvocation"));
  }
 catch (  ClassNotFoundException e) {
  }
  return answer;
}
 

Example 21

From project simplerialize, under directory /comparison/src/test/java/se/hitta/simplerialize/comparison/xstream/.

Source file: XStreamTest.java

  22 
vote

@Override public void serializeJsonTo(final Writer writer) throws Exception {
  final XStream xstream=new XStream(new JsonHierarchicalStreamDriver());
  xstream.setMode(XStream.NO_REFERENCES);
  xstream.alias("root",SampleObject.class);
  xstream.toXML(createRoot(),writer);
}
 

Example 22

From project skalli, under directory /org.eclipse.skalli.api/src/main/java/org/eclipse/skalli/services/configuration/rest/.

Source file: ConfigResourceBase.java

  22 
vote

protected XStream getXStream(){
  XStream xstream=new XStream();
  xstream.setClassLoader(this.getClass().getClassLoader());
  xstream.processAnnotations(getConfigClass());
  for (  Class<?> additionalClass : getAdditionalConfigClasses()) {
    xstream.processAnnotations(additionalClass);
  }
  for (  Converter converter : getAdditionalConverters()) {
    xstream.registerConverter(converter);
  }
  return xstream;
}
 

Example 23

From project tapestry-tldgen, under directory /src/main/java/fr/exanpe/tapestry/tldgen/javadoc/reader/impl/.

Source file: XStreamComponentsInfoBuilder.java

  22 
vote

public ComponentsInfoBean readXMLOutput(Reader reader){
  XStream xstream=new XStream(new DomDriver());
  xstream.processAnnotations(ComponentsInfoBean.class);
  xstream.processAnnotations(ComponentBean.class);
  xstream.processAnnotations(ParameterBean.class);
  ComponentsInfoBean bean=(ComponentsInfoBean)xstream.fromXML(reader);
  bean.createFastAccess();
  return bean;
}
 

Example 24

From project activiti-webapp-rest-generic, under directory /activiti-webapp-rest/src/main/java/org/activiti/rest/api/cycle/.

Source file: Test.java

  21 
vote

/** 
 * @param args
 */
public static void main(String[] args){
  XStream xStream=new XStream(new JettisonMappedXmlDriver());
  xStream.setMode(XStream.NO_REFERENCES);
  List<ArtifactLinkDto> artifactLinkDtos=new ArrayList<ArtifactLinkDto>();
  for (int i=0; i < 10; i++) {
    ArtifactLinkDto dto=new ArtifactLinkDto();
    dto.setContentType("word");
    dto.setLinkType("linkType");
    dto.setPreviewUrl("http://www.showhttprequest.com/?previewUrl=ture&artifact=" + i);
    dto.setTargetElementId("targetElementId");
    dto.setTargetId("targetId");
    dto.setTargetRevision("targetRevision");
    dto.setTargetUrl("http://www.showhttprequest.com/?targetUrl=true&artifact=" + i);
    dto.setLabel("Artifact Link No " + i);
    dto.setDescription("This is a description for " + dto.getLabel());
    artifactLinkDtos.add(dto);
  }
  String json=xStream.toXML(artifactLinkDtos);
  System.out.println("Items (JSON):");
  System.out.println("-------------");
  System.out.println(json);
  List<ArtifactLinkDto> deSerializedArtifactLinkDtos=(ArrayList<ArtifactLinkDto>)xStream.fromXML(json);
  System.out.println();
  System.out.println("Items (toString):");
  System.out.println("-----------------");
  for (  ArtifactLinkDto item : deSerializedArtifactLinkDtos) {
    System.out.println(item);
  }
}
 

Example 25

From project Axon-trader, under directory /web-ui/src/main/java/org/axonframework/samples/trader/webui/rest/.

Source file: RestController.java

  21 
vote

@SuppressWarnings("SpringJavaAutowiringInspection") @Autowired public RestController(CommandBus commandBus,PortfolioQueryRepository portfolioQueryRepository,OrderBookQueryRepository orderBookQueryRepository){
  this.portfolioQueryRepository=portfolioQueryRepository;
  this.orderBookQueryRepository=orderBookQueryRepository;
  this.xStream=new XStream();
  this.commandBus=commandBus;
}
 

Example 26

From project BreizhCamp-android, under directory /src/org/breizhjug/breizhcamp/util/.

Source file: XmlLoader.java

  21 
vote

protected Event getEvent(){
  Event event=null;
  try {
    XStream xStream=new XStream();
    xStream.setMode(XStream.ID_REFERENCES);
    xStream.alias("event",Event.class);
    xStream.alias("timeSlot",TimeSlot.class);
    xStream.alias("session",Session.class);
    xStream.alias("speaker",Speaker.class);
    xStream.alias("room",Room.class);
    xStream.alias("subject",Subject.class);
    event=(Event)xStream.fromXML(getEventInputStream());
  }
 catch (  Exception ex) {
    Log.e("BreizhCamp",ex.getMessage());
  }
  return event;
}
 

Example 27

From project Catroid-maven-playground, under directory /src/main/java/at/tugraz/ist/catroid/io/.

Source file: StorageHandler.java

  21 
vote

private StorageHandler() throws IOException {
  xstream=new XStream(new PureJavaReflectionProvider(new FieldDictionary(new CatroidFieldKeySorter())));
  xstream.processAnnotations(Project.class);
  xstream.aliasPackage("Bricks","at.tugraz.ist.catroid.content.bricks");
  xstream.aliasPackage("Common","at.tugraz.ist.catroid.common");
  xstream.aliasPackage("Content","at.tugraz.ist.catroid.content");
  if (!Utils.hasSdCard()) {
    throw new IOException("Could not read external storage");
  }
  createCatroidRoot();
}
 

Example 28

From project ceres, under directory /ceres-binding/src/main/java/com/bc/ceres/binding/dom/.

Source file: XStreamDomConverter.java

  21 
vote

public XStream getXStream(){
  if (xStream == null) {
    xStream=new XStream();
    configureXStream(xStream);
  }
  return xStream;
}
 

Example 29

From project cloudbees-api-client, under directory /cloudbees-api-client/src/main/java/com/cloudbees/upload/.

Source file: ArchiveUtils.java

  21 
vote

public static File createDeltaWarFile(Map<String,Long> existingArchiveCheckSums,File warFile,String tmp) throws IOException {
  Map<String,Integer> deltas=getDeltas(warFile.getAbsolutePath(),existingArchiveCheckSums);
  String tmpDir=makeTmpDir(warFile,tmp);
  ZipFile zipFile=new ZipFile(warFile.getAbsolutePath());
  Enumeration<? extends ZipEntry> e=zipFile.entries();
  while (e.hasMoreElements()) {
    ZipEntry entry=e.nextElement();
    Integer delta=deltas.get(entry.getName());
    if (delta != null && delta.intValue() != ArchiveUtils.ENTRY_DELETED) {
      unArchiveZipEntry(tmpDir,zipFile,entry);
    }
  }
  File metaInfDir=new File(tmpDir + META_INF);
  metaInfDir.mkdirs();
  File deltaFile=new File(metaInfDir,DELTA_FILE);
  XStream xstream=new XStream();
  FileOutputStream fos=new FileOutputStream(deltaFile);
  xstream.toXML(deltas,fos);
  fos.close();
  String deltaDir=warFile.getParent() == null ? "." : warFile.getParent();
  String deltaArchiveFile=deltaDir + "/DELTA-" + warFile.getName();
  archiveDirectory(tmpDir,deltaArchiveFile);
  deleteAll(new File(tmpDir));
  return new File(deltaArchiveFile);
}
 

Example 30

From project CMake-runner-plugin, under directory /regex-parser/src/jetbrains.buildServer.cmakerunner/regexparser/.

Source file: RegexParser.java

  21 
vote

@Nullable public static RegexParser deserialize(@NotNull final String xml){
  final XStreamHolder holder=createXStreamHolder();
  if (xml.length() > 0) {
    final XStream xStream=holder.getXStream(RegexParser.class.getClassLoader());
    try {
      return (RegexParser)xStream.fromXML(xml);
    }
  finally {
      holder.releaseXStream(xStream);
    }
  }
 else {
    return null;
  }
}
 

Example 31

From project eucalyptus, under directory /clc/modules/core/src/edu/ucsb/eucalyptus/cloud/.

Source file: Configuration.java

  21 
vote

private static XStream getXStream(){
  if (xstream == null) {
    xstream=new XStream();
    xstream.processAnnotations(Configuration.class);
  }
  return xstream;
}
 

Example 32

From project gerrit-trigger-plugin, under directory /gerrithudsontrigger/src/test/java/com/sonyericsson/hudson/plugins/gerrit/trigger/hudsontrigger/data/.

Source file: TriggerContextConverterTest.java

  21 
vote

/** 
 * Tests  {@link TriggerContextConverter#marshal(Object,com.thoughtworks.xstream.io.HierarchicalStreamWriter,com.thoughtworks.xstream.converters.MarshallingContext)}. With an empty list of "others".
 * @throws Exception if so.
 */
@Test public void testMarshalNoOthers() throws Exception {
  TriggeredItemEntity entity=new TriggeredItemEntity(100,"projectX");
  PatchsetCreated event=Setup.createPatchsetCreated();
  TriggerContext context=new TriggerContext(event);
  context.setThisBuild(entity);
  context.setOthers(new LinkedList<TriggeredItemEntity>());
  TestMarshalClass t=new TestMarshalClass(context,"Bobby",new TestMarshalClass(context,"SomeoneElse"));
  XStream xStream=new XStream2();
  xStream.registerConverter(new TriggerContextConverter());
  String xml=xStream.toXML(t);
  TestMarshalClass readT=(TestMarshalClass)xStream.fromXML(xml);
  assertNotNull(readT.getEntity());
  assertNotNull(readT.getEntity().getEvent());
  assertNotNull(readT.getEntity().getThisBuild());
  assertThat("Event is not a ChangeBasedEvent",readT.getEntity().getEvent(),instanceOf(ChangeBasedEvent.class));
  ChangeBasedEvent changeBasedEvent=(ChangeBasedEvent)readT.getEntity().getEvent();
  assertEquals("project",changeBasedEvent.getChange().getProject());
  assertEquals(100,readT.getEntity().getThisBuild().getBuildNumber().intValue());
  assertEquals("projectX",readT.getEntity().getThisBuild().getProjectId());
  assertSame(readT.getEntity(),readT.getTestClass().getEntity());
}
 

Example 33

From project jqplot4java, under directory /src/main/java/br/com/digilabs/jqplot/.

Source file: JqPlotUtils.java

  21 
vote

/** 
 * Retorna o um json a partir de uma configura??o jqplot
 * @param jqPlot
 * @return 
 */
public static String jqPlotToJson(ChartConfiguration<?> jqPlot){
  XStream xstream=new XStream(new JsonHierarchicalStreamDriver(){
    @Override public HierarchicalStreamWriter createWriter(    Writer writer){
      return new JqPlotJsonMapHierarchicalWriter(writer,JsonWriter.DROP_ROOT_MODE){
        @Override public void addAttribute(        String name,        String value){
          if (!name.contains("class")) {
            super.addAttribute(name,value);
          }
        }
      }
;
    }
  }
){
  }
;
  EnumConverter converter=new EnumConverter(){
    @Override public void marshal(    Object source,    HierarchicalStreamWriter writer,    MarshallingContext context){
      if (source instanceof JqPlotResources) {
        JqPlotResources plugin=(JqPlotResources)source;
        writer.setValue(plugin.getClassName());
      }
 else {
        super.marshal(source,writer,context);
      }
    }
  }
;
  converter.canConvert(JqPlotResources.class);
  xstream.registerConverter(converter);
  return xstream.toXML(jqPlot);
}
 

Example 34

From project knime-scripting, under directory /scriptingcore/src/de/mpicbg/tds/knime/knutils/scripting/.

Source file: ScriptingNodeDialog.java

  21 
vote

public static ScriptTemplate deserializeTemplate(String serializedTemplate){
  if (serializedTemplate == null || StringUtils.isBlank(serializedTemplate)) {
    return null;
  }
  return (ScriptTemplate)new XStream(new DomDriver()).fromXML(serializedTemplate);
}
 

Example 35

From project maple-ide, under directory /build/windows/launcher/launch4j/src/net/sf/launch4j/config/.

Source file: ConfigPersister.java

  21 
vote

private ConfigPersister(){
  _xstream=new XStream(new DomDriver());
  _xstream.alias("launch4jConfig",Config.class);
  _xstream.alias("classPath",ClassPath.class);
  _xstream.alias("jre",Jre.class);
  _xstream.alias("splash",Splash.class);
  _xstream.alias("versionInfo",VersionInfo.class);
  _xstream.addImplicitCollection(Config.class,"headerObjects","obj",String.class);
  _xstream.addImplicitCollection(Config.class,"libs","lib",String.class);
  _xstream.addImplicitCollection(Config.class,"variables","var",String.class);
  _xstream.addImplicitCollection(ClassPath.class,"paths","cp",String.class);
  _xstream.addImplicitCollection(Jre.class,"options","opt",String.class);
}
 

Example 36

From project OpenReports, under directory /src/org/efs/openreports/actions/admin/.

Source file: DataExportAction.java

  21 
vote

public String execute(){
  try {
    if (!submitOk) {
      reports=reportProvider.getReports();
      return SUCCESS;
    }
    XStream xStream=new XStream();
    xStream.omitField(BasicDataSource.class,"logWriter");
    xStream.omitField(Report.class,"id");
    xStream.omitField(ReportAlert.class,"id");
    xStream.omitField(ReportChart.class,"id");
    xStream.omitField(ReportParameter.class,"id");
    xStream.omitField(ReportExportOption.class,"id");
    List<Report> selectedReports=new ArrayList<Report>();
    for (int i=0; i < reportIds.length; i++) {
      Report report=reportProvider.getReport(new Integer(reportIds[i]));
      selectedReports.add(report);
    }
    HttpServletResponse response=ServletActionContext.getResponse();
    response.setHeader("Content-disposition","inline; filename=or-report-export.xml");
    response.setContentType("application/xml");
    ServletOutputStream outputStream=response.getOutputStream();
    xStream.toXML(selectedReports,outputStream);
    outputStream.flush();
    outputStream.close();
    return NONE;
  }
 catch (  Exception e) {
    addActionError(e.toString());
    return INPUT;
  }
}
 

Example 37

From project platform_1, under directory /component/organization/src/main/java/org/exoplatform/platform/organization/injector/.

Source file: DataInjectorService.java

  21 
vote

public void writeProfiles(ZipOutputStream zos) throws Exception {
  RequestLifeCycle.begin(PortalContainer.getInstance());
  try {
    ListAccess<User> usersListAccess=organizationService.getUserHandler().findAllUsers();
    XStream xstream_=new XStream(new XppDriver());
    int i=0;
    while (i <= usersListAccess.getSize()) {
      int length=i + SerializationUtils.MAX_USERS_IN_FILE_PARAM_NAME <= usersListAccess.getSize() ? SerializationUtils.MAX_USERS_IN_FILE_PARAM_NAME : usersListAccess.getSize() - i;
      User[] users=usersListAccess.load(i,length);
      for (      User user : users) {
        UserProfile userProfile=organizationService.getUserProfileHandler().findUserProfileByName(user.getUserName());
        if ((userProfile != null) && (userProfile.getUserInfoMap() != null) && !userProfile.getUserInfoMap().isEmpty()) {
          xstream_.alias("user-profile",userProfile.getClass());
          String xml=xstream_.toXML(userProfile);
          zos.putNextEntry(new ZipEntry(SerializationUtils.PROFILES_FOLDER_NAME + userProfile.getUserName() + SerializationUtils.PROFILE_FILE_SUFFIX));
          zos.write(xml.getBytes());
          zos.closeEntry();
          if (LOG.isDebugEnabled()) {
            LOG.debug("Adding entry for userProfile: " + userProfile.getUserName());
          }
        }
      }
      i+=SerializationUtils.MAX_USERS_IN_FILE_PARAM_NAME;
    }
  }
  finally {
    RequestLifeCycle.end();
  }
}
 

Example 38

From project RomRaider, under directory /3rdparty/launch4j/src/net/sf/launch4j/config/.

Source file: ConfigPersister.java

  21 
vote

private ConfigPersister(){
  _xstream=new XStream(new DomDriver());
  _xstream.alias("launch4jConfig",Config.class);
  _xstream.alias("classPath",ClassPath.class);
  _xstream.alias("jre",Jre.class);
  _xstream.alias("splash",Splash.class);
  _xstream.alias("versionInfo",VersionInfo.class);
  _xstream.addImplicitCollection(Config.class,"headerObjects","obj",String.class);
  _xstream.addImplicitCollection(Config.class,"libs","lib",String.class);
  _xstream.addImplicitCollection(Config.class,"variables","var",String.class);
  _xstream.addImplicitCollection(ClassPath.class,"paths","cp",String.class);
  _xstream.addImplicitCollection(Jre.class,"options","opt",String.class);
}
 

Example 39

From project rpiplanner, under directory /src/rpiplanner/.

Source file: XML.java

  21 
vote

private static XStream getDatabaseReader(){
  if (databaseReader == null) {
    databaseReader=new XStream();
    initializeXStream(databaseReader);
  }
  return databaseReader;
}
 

Example 40

From project sandbox, under directory /xeclipse/org.xwiki.eclipse.core/src/main/java/org/xwiki/eclipse/core/utils/.

Source file: CoreUtils.java

  21 
vote

/** 
 * Write an XML serialization of the given object to a file. Overwrites the previous file content is the file already exists.
 * @param file The file where the serialization should be written to.
 * @param data
 * @return
 * @throws CoreException
 */
public static IFile writeDataToXML(IFile file,Object data) throws CoreException {
  XStream xstream=getXStream();
  if (file.getParent() instanceof IFolder) {
    IFolder parentFolder=(IFolder)file.getParent();
    createFolder(parentFolder);
  }
  InputStream is=new ByteArrayInputStream(xstream.toXML(data).getBytes());
  if (!file.exists()) {
    file.create(is,true,null);
  }
 else {
    file.setContents(is,true,false,null);
  }
  try {
    is.close();
  }
 catch (  IOException e) {
  }
  return file;
}
 

Example 41

From project SPREAD, under directory /release/tools/launch4j/src/net/sf/launch4j/config/.

Source file: ConfigPersister.java

  21 
vote

private ConfigPersister(){
  _xstream=new XStream(new DomDriver());
  _xstream.alias("launch4jConfig",Config.class);
  _xstream.alias("classPath",ClassPath.class);
  _xstream.alias("jre",Jre.class);
  _xstream.alias("splash",Splash.class);
  _xstream.alias("versionInfo",VersionInfo.class);
  _xstream.addImplicitCollection(Config.class,"headerObjects","obj",String.class);
  _xstream.addImplicitCollection(Config.class,"libs","lib",String.class);
  _xstream.addImplicitCollection(Config.class,"variables","var",String.class);
  _xstream.addImplicitCollection(ClassPath.class,"paths","cp",String.class);
  _xstream.addImplicitCollection(Jre.class,"options","opt",String.class);
}
 

Example 42

From project spring-me, under directory /spring-me-samples/spring-me-sample-cmdline/src/main/java/me/springframework/sample/cmdline/.

Source file: MoviePrettyPrinter.java

  21 
vote

private void printOutput(MovieListRenderer renderer){
  XStream xstream=new XStream();
  xstream.processAnnotations(new Class[]{XStreamMovies.class,XStream.class});
  XStreamMovies movies=new XStreamMovies();
  InputStream in=null;
  try {
    if (inputFile != null) {
      in=new FileInputStream(inputFile);
    }
 else {
      in=System.in;
    }
    xstream.fromXML(in,movies);
    renderer.print(movies.getMovies(),System.out);
  }
 catch (  FileNotFoundException e) {
    System.out.println("Failed to read input file.");
  }
 finally {
    IOUtils.closeQuietly(in);
  }
}
 

Example 43

From project SWE12-Drone, under directory /catroid/src/at/tugraz/ist/catroid/io/.

Source file: StorageHandler.java

  21 
vote

private StorageHandler() throws IOException {
  xstream=new XStream(new PureJavaReflectionProvider(new FieldDictionary(new CatroidFieldKeySorter())));
  xstream.processAnnotations(Project.class);
  xstream.aliasPackage("Bricks","at.tugraz.ist.catroid.content.bricks");
  xstream.aliasPackage("Common","at.tugraz.ist.catroid.common");
  xstream.aliasPackage("Content","at.tugraz.ist.catroid.content");
  if (!Utils.hasSdCard()) {
    throw new IOException("Could not read external storage");
  }
  createCatroidRoot();
}
 

Example 44

From project Switji, under directory /src/main/java/org/jinglenodes/session/persistence/.

Source file: PersistentCallSessionMapper.java

  21 
vote

public PersistentCallSessionMapper(){
  super();
  xStream=new XStream(new DomDriver());
  xStream.processAnnotations(CallSession.class);
  xStream.omitField(Message.class,"sendTo");
  xStream.omitField(Message.class,"arrivedAt");
  xStream.omitField(Message.class,"participants");
}
 

Example 45

From project iee, under directory /org.eclipse.iee.editor/src/org/eclipse/iee/editor/core/storage/.

Source file: FileStorage.java

  20 
vote

public FileStorage(String directoryPath){
  fXstream=new XStream(new DomDriver());
  fXstream.setMode(XStream.ID_REFERENCES);
  fXstream.autodetectAnnotations(true);
  fDirectoryPath=directoryPath;
  File storageDirectory=new File(fDirectoryPath);
  if (!storageDirectory.exists()) {
    if (!storageDirectory.mkdirs()) {
      return;
    }
  }
  if (storageDirectory.exists() && storageDirectory.isDirectory()) {
    loadAllFiles(storageDirectory);
  }
}
 

Example 46

From project jetty-session-redis, under directory /src/main/java/com/ovea/jetty/session/serializer/.

Source file: XStreamSerializer.java

  20 
vote

@Override public void start(){
  xStream=new XStream(new AbstractXmlDriver(new XmlFriendlyReplacer()){
    @Override public HierarchicalStreamReader createReader(    Reader in){
      return new XppReader(in,xmlFriendlyReplacer());
    }
    @Override public HierarchicalStreamReader createReader(    InputStream in){
      try {
        return createReader(new XmlHeaderAwareReader(in));
      }
 catch (      UnsupportedEncodingException e) {
        throw new StreamException(e);
      }
catch (      IOException e) {
        throw new StreamException(e);
      }
    }
    @Override public HierarchicalStreamWriter createWriter(    Writer out){
      return new CompactWriter(out,xmlFriendlyReplacer());
    }
    @Override public HierarchicalStreamWriter createWriter(    OutputStream out){
      return createWriter(new OutputStreamWriter(out));
    }
  }
);
  super.start();
}
 

Example 47

From project labeled-test-groups-publisher-plugin, under directory /src/test/java/hudson/plugins/labeledandgroupedtests/.

Source file: AntiDestructionTest.java

  20 
vote

public void testSavingJUnitConfiguration() throws Exception {
  JUnitResultArchiver archiver=new JUnitResultArchiver(JUNIT_MASK);
  String archiverAsString=Items.XSTREAM.toXML(archiver);
  System.out.println("We converted it: " + archiverAsString);
  assertTrue(archiverAsString.contains("hudson.tasks.junit.JUnitResultArchiver"));
  assertTrue(archiverAsString.contains("<testResults>" + JUNIT_MASK + "</testResults>"));
  assertTrue(archiverAsString.contains("<testDataPublishers/>"));
  Object reloaded=new XStream().fromXML(archiverAsString);
  assertTrue("got a JUnitResultArchiver back",reloaded instanceof JUnitResultArchiver);
  JUnitResultArchiver reloadedArchiver=(JUnitResultArchiver)reloaded;
  assertEquals(JUNIT_MASK,reloadedArchiver.getTestResults());
  boolean emptyTDPs=false;
  DescribableList testDataPublishers=reloadedArchiver.getTestDataPublishers();
  try {
    if (testDataPublishers == null) {
      emptyTDPs=true;
    }
 else     if (testDataPublishers.size() == 0) {
      emptyTDPs=true;
    }
  }
 catch (  NullPointerException e) {
    emptyTDPs=true;
  }
  assertTrue("we should not have any TestDataPublishers in the reloaded thing",emptyTDPs);
}
 

Example 48

From project riot, under directory /content/src/org/riotfamily/components/xstream/.

Source file: XStreamMarshaller.java

  20 
vote

public void afterPropertiesSet() throws Exception {
  if (driver == null) {
    driver=new DomDriver("UTF-8");
  }
  xstream=new XStream(driver){
    @Override protected MapperWrapper wrapMapper(    MapperWrapper next){
      return new HibernateProxyMapper(next);
    }
  }
;
  xstream.alias("component",Component.class);
  xstream.alias("component-list",ComponentList.class);
  xstream.alias("content-map",ContentMapImpl.class);
  xstream.alias("virtual-page",VirtualPage.class);
  Mapper mapper=xstream.getMapper();
  xstream.registerConverter(new HibernateEntityConverter(mapper,applicationContext),1);
  xstream.registerConverter(new ComponentListConverter(mapper),1);
  xstream.registerConverter(new ComponentConverter(mapper),2);
  xstream.registerConverter(new ContentMapConverter(mapper),1);
  xstream.registerConverter(new VirtualPageConverter(),1);
  xstream.setMarshallingStrategy(new NullSafeXPathMarshallingStrategy());
}
 

Example 49

From project security_1, under directory /security-rest/security-rest-api/src/test/java/org/sonatype/security/rest/users/.

Source file: UserLocatorComponentListTest.java

  20 
vote

public void testGet() throws Exception {
  PlexusResource resource=this.lookup(PlexusResource.class,"UserLocatorComponentListPlexusResource");
  Object result=resource.get(null,null,null,null);
  assertThat(result,instanceOf(PlexusComponentListResourceResponse.class));
  PlexusComponentListResourceResponse response=(PlexusComponentListResourceResponse)result;
  assertThat("Result: " + new XStream().toXML(response),response.getData().size(),equalTo(5));
  Map<String,String> data=new HashMap<String,String>();
  for (  PlexusComponentListResource item : response.getData()) {
    data.put(item.getRoleHint(),item.getDescription());
  }
  assertThat(data.keySet(),containsInAnyOrder("default","allConfigured","MockUserManagerA","MockUserManagerB","Mock"));
  assertThat(data.get("default"),equalTo("Default"));
  assertThat(data.get("allConfigured"),equalTo("All Configured Users"));
  assertThat(data.get("MockUserManagerA"),equalTo("MockUserManagerA"));
}
 

Example 50

From project janbanery, under directory /janbanery-core/src/main/java/pl/project13/janbanery/config/xstream/.

Source file: RssConverter.java

  19 
vote

public RssConverter(XStream xStream){
  this.xStream=xStream;
  xStream.alias("rss",RssResource.Rss.class);
  xStream.alias("item",RssResource.Item.class);
  xStream.addImplicitCollection(RssResource.Channel.class,"items");
  xStream.omitField(RssResource.Channel.class,"pubDate");
  xStream.omitField(RssResource.Channel.class,"guid");
  xStream.useAttributeFor("version",RssResource.Version.class);
  xStream.registerConverter(new VersionConverter());
  xStream.registerConverter(new GuidConverter());
  xStream.registerConverter(new DateTimeConverter());
}
 

Example 51

From project shiningpanda-plugin, under directory /src/main/java/jenkins/plugins/shiningpanda/utils/.

Source file: DescriptorUtil.java

  19 
vote

/** 
 * Load the configuration by looking first for the nominal file, and then by looking for the provided IDs.
 * @param xs The XML stream
 * @param descriptor The descriptor
 * @param ids The addition IDs
 */
public synchronized static void load(XStream xs,Descriptor<?> descriptor,String... ids){
  XmlFile file=getConfigFile(xs,descriptor);
  if (file.exists()) {
    load(descriptor,file);
    return;
  }
  for (  String id : ids) {
    XmlFile aliasFile=getConfigFile(xs,id);
    if (aliasFile.exists()) {
      load(descriptor,aliasFile);
      return;
    }
  }
}
 

Example 52

From project staccatissimo, under directory /staccatissimo-io/src/test/java/net/sf/staccatocommons/io/preferences/.

Source file: CharSerializationObjectPreferencesUnitTest.java

  19 
vote

/** 
 */
@Before public void setup(){
  setImposteriser(ClassImposteriser.INSTANCE);
  preferences=mock(Preferences.class);
  manager=new XStreamXmlSerializationManager(new XStream());
  objectPreferences=new CharSerializationObjectPreferences(preferences,manager);
}