Package com.thoughtworks.xstream

Examples of com.thoughtworks.xstream.XStream


   
  /**
   * @see org.olat.core.commons.modules.glossary.morphService.FlexionServiceClient#getFlexions(java.lang.String, java.lang.String)
   */
  public ArrayList<String> getFlexions(String partOfSpeech, String word) {
    XStream xstream = XStreamHelper.createXStreamInstance();
    File replyFile = new File(PATH_TO_MS_REPLY_XML);
    xstream.alias("msreply",FlexionReply.class);
    xstream.alias("wordform", String.class);
    Object msReply = XStreamHelper.readObject(xstream,replyFile);
    FlexionReply flexionReply = (FlexionReply) msReply;
    ArrayList<String> stemWithWordforms = flexionReply.getStem();
    return stemWithWordforms;
  }
View Full Code Here


   * @param glossaryFile
   * @param glossaryItemArr
   */
  private void saveToFile(VFSLeaf glossaryFile, ArrayList<GlossaryItem> glossaryItemArr) {
    // cdata-tags should be used instead of strings, overwrite writer.
    XStream xstream = new XStream(new XppDriver() {
      public HierarchicalStreamWriter createWriter(Writer out) {
        return new PrettyPrintWriter(out) {
          protected void writeText(QuickWriter writer, String text) {
            if (text.contains("<")||text.contains(">")||text.contains("&")){
              writer.write("<![CDATA[");
              writer.write(text);
              writer.write("]]>");
            } else {
              writer.write(text);
            }
          }
        };
      }
    });

    xstream.alias(XML_GLOSSARY_ITEM_NAME, GlossaryItem.class);
    glossaryItemArr = removeEmptyGlossaryItems(glossaryItemArr);
    XStreamHelper.writeObject(xstream, glossaryFile, glossaryItemArr);
  }
View Full Code Here

   */
  @SuppressWarnings("unchecked")
  private ArrayList<GlossaryItem> loadGlossaryItemListFromFile(VFSLeaf glossaryFile) {
    ArrayList<GlossaryItem> glossaryItemList = new ArrayList<GlossaryItem>();
    if (glossaryFile == null) { return new ArrayList<GlossaryItem>(); }
    XStream xstream = XStreamHelper.createXStreamInstance();
    xstream.alias(XML_GLOSSARY_ITEM_NAME, GlossaryItem.class);
    Object glossObj = XStreamHelper.readObject(xstream, glossaryFile.getInputStream());
    if (glossObj instanceof ArrayList) {
      ArrayList<GlossaryItem> glossItemsFromFile = (ArrayList<GlossaryItem>) glossObj;
      glossaryItemList.addAll(glossItemsFromFile);
    } else {
View Full Code Here

    deleteChecklistKeyConf(course.getCourseEnvironment().getCoursePropertyManager());
  }
 
  @Override
  public void exportNode(File exportDirectory, ICourse course) {
    XStream xstream = new XStream();
    ChecklistManager cm = ChecklistManager.getInstance();
    Checklist checklist = loadOrCreateChecklist(course.getCourseEnvironment().getCoursePropertyManager());
    Checklist copy = cm.copyChecklistInRAM(checklist);
    String exportContent = xstream.toXML(copy);
    ExportUtil.writeContentToFile(getExportFilename(), exportContent, exportDirectory, WebappHelper.getDefaultCharset());
  }
View Full Code Here

    String importContent = FileUtils.load(importFile, WebappHelper.getDefaultCharset());
    if(importContent == null || importContent.isEmpty()) {
      return null;
    }
   
    XStream xstream = new XStream();
    Checklist checklist = (Checklist) xstream.fromXML(importContent);
    if(checklist != null) {
      checklist = ChecklistManager.getInstance().copyChecklist(checklist);
      setChecklistKey(cpm, checklist.getKey());
    }
   
View Full Code Here

    return null;
  }
 
  @Override
  public void archiveNodeData(Locale locale, ICourse course, File exportDirectory, String charset) {
    XStream xstream = new XStream();
    Checklist checklist = loadOrCreateChecklist(course.getCourseEnvironment().getCoursePropertyManager());
    String exportContent = xstream.toXML(checklist);
    String exportFilename = ExportUtil.createFileNameWithTimeStamp("checklist_"+this.getIdent(), "xml");
    ExportUtil.writeContentToFile(exportFilename, exportContent, exportDirectory, WebappHelper.getDefaultCharset());
  }
View Full Code Here

  private static Identity findIdentInChangingEmailWorkflow(String login){
    RegistrationManager rm = RegistrationManager.getInstance();
    List<TemporaryKey> tk = rm.loadTemporaryKeyByAction(RegistrationManager.EMAIL_CHANGE);
    if (tk != null) {
      for (TemporaryKey temporaryKey : tk) {
        XStream xml = new XStream();
        HashMap<String, String> mails = (HashMap<String, String>) xml.fromXML(temporaryKey.getEmailAddress());
        if (login.equals(mails.get("changedEMail"))) {
          return ManagerFactory.getManager().findIdentityByName(mails.get("currentEMail"));
        }
      }
    }
View Full Code Here

      if (userPropertyHandler.getName().equals("email")) {
        RegistrationManager rm = RegistrationManager.getInstance();
        String key = this.identity.getUser().getProperty("emchangeKey", null);
        TemporaryKeyImpl tempKey = rm.loadTemporaryKeyByRegistrationKey(key);
        if (tempKey != null) {
          XStream xml = new XStream();
          HashMap<String, String> mails = (HashMap<String, String>) xml.fromXML(tempKey.getEmailAddress());
          formItem.setExampleKey("email.change.form.info", new String[] {mails.get("changedEMail")});
        }
      }
    }
   
View Full Code Here

    // load or create temporary key
    HashMap<String, String> mailMap = new HashMap<String, String>();
    mailMap.put("currentEMail", currentEmail);
    mailMap.put("changedEMail", changedEmail);
   
    XStream xml = new XStream();
    String serMailMap = xml.toXML(mailMap);
   
    TemporaryKey tk = loadCleanTemporaryKey(serMailMap);       
    if (tk == null) {
      tk = rm.createTemporaryKeyByEmail(serMailMap, ip, RegistrationManager.EMAIL_CHANGE);
    } else {
View Full Code Here

   * @return
   */
  private TemporaryKey loadCleanTemporaryKey(String serMailMap) {
    TemporaryKey tk = rm.loadTemporaryKeyByEmail(serMailMap);
    if (tk == null) {
      XStream xml = new XStream();
      HashMap<String, String> mails = (HashMap<String, String>) xml.fromXML(serMailMap);
      String currentEMail = mails.get("currentEMail");
      List<TemporaryKey> tks = rm.loadTemporaryKeyByAction(RegistrationManager.EMAIL_CHANGE);
      if (tks != null) {
        synchronized (tks) {
          tks = rm.loadTemporaryKeyByAction(RegistrationManager.EMAIL_CHANGE);
          int countCurrentEMail = 0;
          for (TemporaryKey temporaryKey : tks) {
            HashMap<String, String> tkMails = (HashMap<String, String>) xml.fromXML(temporaryKey.getEmailAddress());
            if (tkMails.get("currentEMail").equals(currentEMail)) {
              if (countCurrentEMail > 0) {
                // clean
                rm.deleteTemporaryKeyWithId(temporaryKey.getRegistrationKey());
              } else {
View Full Code Here

TOP

Related Classes of com.thoughtworks.xstream.XStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.