当前位置: 首页>>代码示例>>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;未经允许,请勿转载。