當前位置: 首頁>>代碼示例>>Java>>正文


Java XStream.addPermission方法代碼示例

本文整理匯總了Java中com.thoughtworks.xstream.XStream.addPermission方法的典型用法代碼示例。如果您正苦於以下問題:Java XStream.addPermission方法的具體用法?Java XStream.addPermission怎麽用?Java XStream.addPermission使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.thoughtworks.xstream.XStream的用法示例。


在下文中一共展示了XStream.addPermission方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: parse

import com.thoughtworks.xstream.XStream; //導入方法依賴的package包/類
@Override
public Suite parse(InputStream suiteInputStream) throws Exception
{
    XStream xStream = new XStream(new StaxDriver());
    xStream.addPermission(NoTypePermission.NONE);
    xStream.allowTypesByWildcard(new String[]{
            "com.surenpi.autotest.suite.runner.**"
    });

    xStream.aliasSystemAttribute(null, "class");

    xStream.alias("suite", Suite.class);
    xStream.aliasField("pageConfig", Suite.class, "xmlConfPath");
    xStream.useAttributeFor(Suite.class, "xmlConfPath");
    xStream.aliasField("pages", Suite.class, "pageList");
    xStream.useAttributeFor(Suite.class, "pagePackage");
    xStream.useAttributeFor(Suite.class, "rows");
    xStream.useAttributeFor(Suite.class, "afterSleep");

    xStream.alias("page", SuitePage.class);
    xStream.aliasField("class", SuitePage.class, "pageCls");
    xStream.useAttributeFor(SuitePage.class, "pageCls");
    xStream.aliasField("actions", SuitePage.class, "actionList");
    xStream.useAttributeFor(SuitePage.class, "repeat");

    xStream.alias("action", SuiteAction.class);
    xStream.useAttributeFor(SuiteAction.class, "field");
    xStream.useAttributeFor(SuiteAction.class, "name");

    Object obj = xStream.fromXML(suiteInputStream);

    return (Suite) obj;
}
 
開發者ID:LinuxSuRen,項目名稱:phoenix.webui.suite.runner,代碼行數:34,代碼來源:XStreamSuiteParser.java

示例2: getInstance

import com.thoughtworks.xstream.XStream; //導入方法依賴的package包/類
public static XStream getInstance() {
  XStream xstream = new XStream(new XppDriver() {

    @Override
    public HierarchicalStreamWriter createWriter(Writer out) {
      return new PrettyPrintWriter(out, getNameCoder()) {
        protected String PREFIX_CDATA = "<![CDATA[";
        protected String SUFFIX_CDATA = "]]>";
        protected String PREFIX_MEDIA_ID = "<MediaId>";
        protected String SUFFIX_MEDIA_ID = "</MediaId>";

        @Override
        protected void writeText(QuickWriter writer, String text) {
          if (text.startsWith(this.PREFIX_CDATA) && text.endsWith(this.SUFFIX_CDATA)) {
            writer.write(text);
          } else if (text.startsWith(this.PREFIX_MEDIA_ID) && text.endsWith(this.SUFFIX_MEDIA_ID)) {
            writer.write(text);
          } else {
            super.writeText(writer, text);
          }

        }

        @Override
        public String encodeNode(String name) {
          return name;//防止將_轉換成__
        }
      };
    }
  });
  xstream.ignoreUnknownElements();
  xstream.setMode(XStream.NO_REFERENCES);
  xstream.addPermission(NullPermission.NULL);
  xstream.addPermission(PrimitiveTypePermission.PRIMITIVES);
  return xstream;
}
 
開發者ID:11590692,項目名稱:Wechat-Group,代碼行數:37,代碼來源:XStreamInitializer.java

示例3: initXStream

import com.thoughtworks.xstream.XStream; //導入方法依賴的package包/類
protected void initXStream() {

        _xStream = new XStream(null, new XppDriver(), new ClassLoaderReference(
                XStreamConfiguratorRegistryUtil.getConfiguratorsClassLoader(XStream.class.getClassLoader())));

        _xStream.omitField(HashMap.class, "cache_bitmask");

        Set<XStreamConfigurator> xStreamConfigurators = XStreamConfiguratorRegistryUtil.getXStreamConfigurators();

        if (SetUtil.isEmpty(xStreamConfigurators)) {
            return;
        }

        List<String> allowedTypeNames = new ArrayList<>();

        for (XStreamConfigurator xStreamConfigurator : xStreamConfigurators) {
            List<XStreamAlias> xStreamAliases = xStreamConfigurator.getXStreamAliases();

            if (ListUtil.isNotEmpty(xStreamAliases)) {
                for (XStreamAlias xStreamAlias : xStreamAliases) {
                    _xStream.alias(xStreamAlias.getName(), xStreamAlias.getClazz());
                }
            }

            List<XStreamConverter> xStreamConverters = xStreamConfigurator.getXStreamConverters();

            if (ListUtil.isNotEmpty(xStreamConverters)) {
                for (XStreamConverter xStreamConverter : xStreamConverters) {
                    _xStream.registerConverter(new ConverterAdapter(xStreamConverter), XStream.PRIORITY_VERY_HIGH);
                }
            }

            List<XStreamType> xStreamTypes = xStreamConfigurator.getAllowedXStreamTypes();

            if (ListUtil.isNotEmpty(xStreamTypes)) {
                for (XStreamType xStreamType : xStreamTypes) {
                    allowedTypeNames.add(xStreamType.getTypeExpression());
                }
            }
        }

        // For default permissions, first wipe than add default

        _xStream.addPermission(NoTypePermission.NONE);

        // Add permissions

        _xStream.addPermission(PrimitiveTypePermission.PRIMITIVES);
        _xStream.addPermission(XStreamStagedModelTypeHierarchyPermission.STAGED_MODELS);

        _xStream.allowTypes(_XSTREAM_DEFAULT_ALLOWED_TYPES);

        _xStream.allowTypeHierarchy(List.class);
        _xStream.allowTypeHierarchy(Map.class);
        _xStream.allowTypeHierarchy(Timestamp.class);
        _xStream.allowTypeHierarchy(Set.class);

        _xStream.allowTypes(allowedTypeNames.toArray(new String[0]));

        _xStream.allowTypesByWildcard(new String[] { "com.thoughtworks.xstream.mapper.DynamicProxyMapper*" });
    }
 
開發者ID:inofix,項目名稱:ch-inofix-timetracker,代碼行數:62,代碼來源:BaseExportImportController.java

示例4: importWizard

import com.thoughtworks.xstream.XStream; //導入方法依賴的package包/類
/**
    * Imports the wizard model from an xml file and replaces the current model
    * First, saves the configurations, then performs the import using xstream
    *
    * @param mapping
    * @param form
    * @param request
    * @param response
    * @return
    */
   @SuppressWarnings("unchecked")
   public ActionForward importWizard(ActionMapping mapping, ActionForm form, HttpServletRequest request,
    HttpServletResponse response) {
QaAdminForm adminForm = (QaAdminForm) form;

if (qaService == null) {
    qaService = QaServiceProxy.getQaService(this.getServlet().getServletContext());
}

// First save the config items
QaConfigItem enableQaWizard = qaService.getConfigItem(QaConfigItem.KEY_ENABLE_QAWIZARD);

if (adminForm.getQaWizardEnabled() != null && adminForm.getQaWizardEnabled()) {
    enableQaWizard.setConfigValue(QaAdminForm.TRUE);

    // get the wizard content and save
    if (adminForm.getSerialiseXML() != null && !adminForm.getSerialiseXML().trim().equals("")) {
	updateWizardFromXML(adminForm.getSerialiseXML().trim());
    }

    // remove any wizard items that were removed
    removeWizardItems(adminForm.getDeleteCategoriesCSV(), adminForm.getDeleteSkillsCSV(),
	    adminForm.getDeleteQuestionsCSV());
} else {
    enableQaWizard.setConfigValue(QaAdminForm.FALSE);
}
qaService.saveOrUpdateConfigItem(enableQaWizard);

// Now perform the import
try {
    String xml = new String(adminForm.getImportFile().getFileData());
    XStream conversionXml = new XStream(new SunUnsafeReflectionProvider());
    conversionXml.addPermission(AnyTypePermission.ANY);
    SortedSet<QaWizardCategory> exportCategories = (SortedSet<QaWizardCategory>) conversionXml.fromXML(xml);

    qaService.deleteAllWizardCategories();
    qaService.saveOrUpdateQaWizardCategories(exportCategories);
} catch (Exception e) {
    logger.error("Failed to import wizard model", e);
    request.setAttribute("error", true);
    request.setAttribute("errorKey", "wizard.import.error");
    request.setAttribute(ATTR_CATEGORIES, getQaWizardCategories());
    return mapping.findForward("config");
}

request.setAttribute(ATTR_CATEGORIES, getQaWizardCategories());
request.setAttribute("savedSuccess", true);
return mapping.findForward("config");

   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:61,代碼來源:QaAdminAction.java

示例5: exportNode

import com.thoughtworks.xstream.XStream; //導入方法依賴的package包/類
/**
    * The proper method for exporting nodes.
    *
    * @param nodeUid
    * @return
    * @throws ZipFileUtilException
    * @throws FileUtilException
    * @throws IOException
    * @throws RepositoryCheckedException
    * @throws ExportToolContentException
    */
   private String exportNode(Long nodeUid) throws ZipFileUtilException, FileUtilException, IOException,
    RepositoryCheckedException, ExportToolContentException {
if (nodeUid != null) {

    String rootDir = FileUtil.createTempDirectory(PedagogicalPlannerAction.EXPORT_NODE_FOLDER_SUFFIX);
    String contentDir = FileUtil.getFullPath(rootDir, PedagogicalPlannerAction.DIR_CONTENT);
    FileUtil.createDirectory(contentDir);

    String nodeFileName = FileUtil.getFullPath(contentDir, PedagogicalPlannerAction.NODE_FILE_NAME);
    Writer nodeFile = new OutputStreamWriter(new FileOutputStream(nodeFileName),
	    PedagogicalPlannerAction.ENCODING_UTF_8);

    PedagogicalPlannerSequenceNode node = getPedagogicalPlannerDAO().getByUid(nodeUid);
    // exporting XML
    XStream designXml = new XStream(new SunUnsafeReflectionProvider());
    designXml.addPermission(AnyTypePermission.ANY);
    // do not serialize node's owner
    designXml.omitField(PedagogicalPlannerSequenceNode.class, "user");
    designXml.toXML(node, nodeFile);
    nodeFile.close();

    PedagogicalPlannerAction.log.debug("Node xml export success");

    // Copy templates' ZIP files from repository
    File templateDir = new File(contentDir, PedagogicalPlannerAction.DIR_TEMPLATES);
    exportSubnodeTemplates(node, templateDir);

    // create zip file for fckeditor unique content folder
    String targetZipFileName = PedagogicalPlannerAction.EXPORT_NODE_CONTENT_ZIP_PREFIX
	    + node.getContentFolderId() + PedagogicalPlannerAction.FILE_EXTENSION_ZIP;
    String secureDir = Configuration.get(ConfigurationKeys.LAMS_EAR_DIR) + File.separator
	    + FileUtil.LAMS_WWW_DIR + File.separator + FileUtil.LAMS_WWW_SECURE_DIR;
    String nodeContentDir = FileUtil.getFullPath(secureDir, node.getContentFolderId());

    if (!FileUtil.isEmptyDirectory(nodeContentDir, true)) {
	PedagogicalPlannerAction.log
		.debug("Create export node content target zip file. File name is " + targetZipFileName);
	ZipFileUtil.createZipFile(targetZipFileName, nodeContentDir, contentDir);
    } else {
	PedagogicalPlannerAction.log.debug("No such directory (or empty directory): " + nodeContentDir);
    }

    // zip file name with full path
    targetZipFileName = PedagogicalPlannerAction.EXPORT_NODE_ZIP_PREFIX + node.getTitle()
	    + PedagogicalPlannerAction.FILE_EXTENSION_ZIP;
    ;
    PedagogicalPlannerAction.log
	    .debug("Create export node content zip file. File name is " + targetZipFileName);
    // create zip file and return zip full file name
    return ZipFileUtil.createZipFile(targetZipFileName, contentDir, rootDir);
}
return null;
   }
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:65,代碼來源:PedagogicalPlannerAction.java


注:本文中的com.thoughtworks.xstream.XStream.addPermission方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。