/*
(non-Javadoc)
@see org.apereo.portal.io.xml.IDataImporterExporter#exportData(java.lang.String)
774902
@Override
    public ExternalPortletType exportData(String id) {
        IPortletType portletType = this.portletTypeRegistry.getPortletType(Integer.parseInt(id));
        if (null == portletType) {
            return null;
        }

        return convert(portletType);
    }
900196
@Override
    protected Element exportDataElement(String userName) {
        final Integer userId = this.userIdentityStore.getPortalUserId(userName);
        if (userId == null) {
            this.logger.warn("No user " + userName + " found, no layout will be exported");
            return null;
        }

        // Setup empty IPerson used to interact with the layout store
        final PersonImpl person = new PersonImpl();
        person.setUserName(userName);
        person.setID(userId);
        person.setSecurityContext(new BrokenSecurityContext());

        try {
            this.userLayoutStore.setProfileImportExportCache(layoutCache);
            this.userLayoutStore.setLayoutImportExportCache(profileCache);

            final IUserProfile userProfile =
                    userLayoutStore.getUserProfileByFname(
                            person, UserProfile.DEFAULT_PROFILE_FNAME);
            final Element layoutElement = userLayoutStore.exportLayout(person, userProfile);

            return layoutElement;
        } finally {
            this.userLayoutStore.setProfileImportExportCache(null);
            this.userLayoutStore.setLayoutImportExportCache(null);
        }
    }
198621
@Override
    public final void exportTo(final File target, final boolean overwrite) throws ArchiveExportException,
        FileExistsException {
        // Get stream and perform precondition checks
        final OutputStream out = this.getOutputStreamToFile(target, overwrite);

        try {
            // Write out
            this.exportTo(out);
        } finally {
            // Close
            try {
                out.close();
            } catch (final IOException ioe) {
                // Just log
                log.warning("Could not close " + out + ": " + ioe);
            }
        }
    }
567535
public void writeData(String data) {
        _buffer.append("<![CDATA[");
        _buffer.append( data);
        _buffer.append( "]]>");
    }
524770
public void export() throws IOException {
		final byte[] imageData = getImageData();
		if (imageData != null) {
			final File file = ImageFileChooser.chooseImage(this, false, getFileName());
			if (file != null) {
				try (OutputStream fileOutputStream = new BufferedOutputStream(
						new FileOutputStream(file))) {
					fileOutputStream.write(imageData);
				}
			}
		}
	}
738611
protected void initDatabaseExportObject() {

        Object o;

        if (CmsStringUtil.isEmpty(getParamAction())) {
            o = new CmsExportParameters();
        } else {
            // this is not the initial call, get the job object from session
            o = getDialogObject();
        }

        if (!(o instanceof CmsExportParameters)) {
            // create a new export parameters object
            m_exportParams = new CmsExportParameters();
        } else {
            // reuse export parameters object stored in session
            m_exportParams = (CmsExportParameters)o;
        }

        if (CmsStringUtil.isEmpty(getParamAction()) && (m_exportParams.getResources().size() < 1)) {
            // on initial call, at least on resource input field has to be present
            List initialPaths = new ArrayList(1);
            initialPaths.add("/");
            m_exportParams.setResources(initialPaths);
        }
    }
24462
@Override
    public ExternalEventAggregationConfiguration exportData(String id) {
        final ExternalEventAggregationConfiguration externalData =
                new ExternalEventAggregationConfiguration();

        // Copy interval configs
        final List<ExternalAggregatedIntervalConfig> aggregatedIntervalConfigs =
                externalData.getAggregatedIntervalConfigs();
        for (final AggregatedIntervalConfig aggregatedIntervalConfig :
                this.aggregationManagementDao.getAggregatedIntervalConfigs()) {
            final ExternalAggregatedIntervalConfig externalIntervalConfig =
                    new ExternalAggregatedIntervalConfig();
            externalIntervalConfig.setAggregatorType(
                    aggregatedIntervalConfig.getAggregatorType().getName());

            final List<ExternalAggregationInterval> extIncludes =
                    externalIntervalConfig.getIncludes();
            for (final AggregationInterval interval : aggregatedIntervalConfig.getIncluded()) {
                extIncludes.add(convert(interval));
            }
            Collections.sort(extIncludes, EnumNameComparator.INSTANCE);

            final List<ExternalAggregationInterval> extExcludes =
                    externalIntervalConfig.getExcludes();
            for (final AggregationInterval interval : aggregatedIntervalConfig.getExcluded()) {
                extExcludes.add(convert(interval));
            }
            Collections.sort(extExcludes, EnumNameComparator.INSTANCE);

            aggregatedIntervalConfigs.add(externalIntervalConfig);
        }
        Collections.sort(
                aggregatedIntervalConfigs, ExternalAggregatedDimensionConfigComparator.INSTANCE);

        // Copy group configs
        final List<ExternalAggregatedGroupConfig> aggregatedGroupConfigs =
                externalData.getAggregatedGroupConfigs();
        for (final AggregatedGroupConfig aggregatedGroupConfig :
                this.aggregationManagementDao.getAggregatedGroupConfigs()) {
            final ExternalAggregatedGroupConfig externalGroupConfig =
                    new ExternalAggregatedGroupConfig();
            externalGroupConfig.setAggregatorType(
                    aggregatedGroupConfig.getAggregatorType().getName());

            final List<ExternalAggregatedGroupMapping> extIncludes =
                    externalGroupConfig.getIncludes();
            for (final AggregatedGroupMapping Group : aggregatedGroupConfig.getIncluded()) {
                extIncludes.add(convert(Group));
            }
            Collections.sort(extIncludes, ExternalAggregatedGroupMappingComparator.INSTANCE);

            final List<ExternalAggregatedGroupMapping> extExcludes =
                    externalGroupConfig.getExcludes();
            for (final AggregatedGroupMapping Group : aggregatedGroupConfig.getExcluded()) {
                extExcludes.add(convert(Group));
            }
            Collections.sort(extExcludes, ExternalAggregatedGroupMappingComparator.INSTANCE);

            aggregatedGroupConfigs.add(externalGroupConfig);
        }
        Collections.sort(
                aggregatedGroupConfigs, ExternalAggregatedDimensionConfigComparator.INSTANCE);

        // Copy term details
        final List<ExternalTermDetail> externalTermDetails = externalData.getTermDetails();
        for (final AcademicTermDetail academicTermDetail :
                this.aggregationManagementDao.getAcademicTermDetails()) {
            final ExternalTermDetail externalTermDetail = new ExternalTermDetail();
            externalTermDetail.setName(academicTermDetail.getTermName());
            externalTermDetail.setStart(academicTermDetail.getStart().toGregorianCalendar());
            externalTermDetail.setEnd(academicTermDetail.getEnd().toGregorianCalendar());
            externalTermDetails.add(externalTermDetail);
        }
        Collections.sort(externalTermDetails, ExternalTermDetailComparator.INSTANCE);

        // Copy quarter details
        final List<ExternalQuarterDetail> quarterDetails = externalData.getQuarterDetails();
        for (final QuarterDetail quarterDetail :
                this.aggregationManagementDao.getQuartersDetails()) {
            final ExternalQuarterDetail externalQuarterDetail = new ExternalQuarterDetail();
            externalQuarterDetail.setId(quarterDetail.getQuarterId());
            externalQuarterDetail.setStart(quarterDetail.getStart().toString());
            externalQuarterDetail.setEnd(quarterDetail.getEnd().toString());
            quarterDetails.add(externalQuarterDetail);
        }
        Collections.sort(quarterDetails, ExternalQuarterDetailComparator.INSTANCE);

        return externalData;
    }
1025652
public static Xml exports(Map<String, PathData> pathData)
    {
        Check.notNull(pathData);

        final Xml node = new Xml(NODE_PATHFINDABLE);
        for (final PathData data : pathData.values())
        {
            node.add(exportPathData(data));
        }

        return node;
    }
899820
@Override
    @Transactional
    public void importData(ExternalPermissionOwner externalPermissionOwner) {
        final String name = externalPermissionOwner.getName();
        final String fname = externalPermissionOwner.getFname();
        final IPermissionOwner permissionOwner =
                this.permissionOwnerDao.getOrCreatePermissionOwner(name, fname);

        final String desc = externalPermissionOwner.getDesc();
        permissionOwner.setDescription(desc);

        for (final ExternalActivity externalActivity : externalPermissionOwner.getActivities()) {
            final String activityName = externalActivity.getName();
            final String activityFname = externalActivity.getFname();
            final String targetProvider = externalActivity.getTargetProvider();

            final IPermissionActivity permissionActivity =
                    this.permissionOwnerDao.getOrCreatePermissionActivity(
                            permissionOwner, activityName, activityFname, targetProvider);

            final String activityDesc = externalActivity.getDesc();
            permissionActivity.setDescription(activityDesc);
        }

        this.permissionOwnerDao.saveOwner(permissionOwner);
    }
42382
public static void exportCSVLocal(File outputFile, String delimiter, JavaRDD<List<Writable>> data, int rngSeed)
                    throws Exception {
        exportCSVLocal(outputFile, delimiter, null, data, rngSeed);
    }
1061220
public void exportDataSetExcel(final DataSetLookup request,
                                   final DataSetExportReadyCallback listener) throws Exception {

        if (dataSetLookupServices != null) {
            // Look always into the client data set manager.
            if (clientDataSetManager.getDataSet(request.getDataSetUUID()) != null) {
                DataSet dataSet = clientDataSetManager.lookupDataSet(request);
                try {
                    dataSetExportServices.call(
                            new RemoteCallback<Path>() {
                                public void callback(Path excelFilePath) {
                                    listener.exportReady(excelFilePath);
                                }
                            }).exportDataSetExcel(dataSet);
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
            }
            // Data set not found on client.
            else {
                // If the data set is not in client, then look up remotely (only if the remote access is available).
                try {
                    dataSetExportServices.call(
                            new RemoteCallback<Path>() {
                                public void callback(Path excelFilePath) {
                                    listener.exportReady(excelFilePath);
                                }
                            }
                            ,
                            new ErrorCallback<Message>() {
                                public boolean error(Message message,
                                                     Throwable throwable) {
                                    listener.onError(new ClientRuntimeError(throwable));
                                    return true;
                                }
                            }).exportDataSetExcel(request);
                } catch (Exception e) {
                    listener.onError(new ClientRuntimeError(e));
                }
            }
        } else {
            listener.onError(new ClientRuntimeError(CommonConstants.INSTANCE.exc_no_client_side_data_export()));
        }
    }
1307011
public static void export(OutputStream os, List<JobDef> jobDefList, DbConn cnx) throws JqmXmlException
    {
        // Argument tests
        if (os == null)
        {
            throw new IllegalArgumentException("output stream cannot be null");
        }
        if (jobDefList == null || jobDefList.isEmpty())
        {
            throw new IllegalArgumentException("job def list cannot be null or empty");
        }
        if (cnx == null)
        {
            throw new IllegalArgumentException("database connection cannot be null");
        }

        Collections.sort(jobDefList, new Comparator<JobDef>()
        {
            @Override
            public int compare(JobDef o1, JobDef o2)
            {
                return o1.getJarPath().compareTo(o2.getJarPath());
            }
        });

        // Create XML document
        Element root = new Element("jqm");
        Document document = new Document(root);

        Element jobDefinitions = null;
        String currentJarPath = null;
        Set<Cl> cls = new HashSet<>();

        for (JobDef j : jobDefList)
        {
            if (currentJarPath == null || !j.getJarPath().equals(currentJarPath))
            {
                currentJarPath = j.getJarPath();
                Element jar = new Element("jar");
                addTextElementToParentElement(jar, "path", currentJarPath);
                addTextElementToParentElement(jar, "pathType", j.getPathType().toString());
                jobDefinitions = new Element("jobdefinitions");
                jar.addContent(jobDefinitions);
                root.addContent(jar);
            }
            Element jobDefinition = getJobDefinitionElement(j, cnx);
            jobDefinitions.addContent(jobDefinition);

            if (j.getClassLoader(cnx) != null)
            {
                cls.add(j.getClassLoader());
            }
        }

        for (Cl cl : cls)
        {
            root.addContent(getClElement(cl));
        }

        // Done: output XML to stream.
        try
        {
            XMLOutputter out = new XMLOutputter(Format.getPrettyFormat());
            out.output(document, os);
        }
        catch (java.io.IOException e)
        {
            throw new JqmXmlException("Could not output XML to stream", e);
        }
    }
564186
public boolean export() throws QueryException, NoDataFoundException {

		start = true;
		
        testForData();        
        
		if (needsFirstCrossing() && !(this instanceof FirstCrossingExporter)) {			
			FirstCrossingExporter fe = new FirstCrossingExporter(bean);
			fe.export();
			// get template values from FirstCrossing
			templatesValues = fe.getTemplatesValues();
			groupTemplateKeys = fe.getGroupTemplateKeys();			
		} 

        initExport();

        printHeaderBand();
        if (!printContentBands()) {
            return false;
        }
        printFooterBand();

        finishExport();
        
        if ((bean.getResult() != null) && (!(this instanceof FirstCrossingExporter)) )  {
        	bean.getResult().close();
        }       
        
        if (this instanceof FirstCrossingExporter) {
        	// after FirstCrossing go to the beginning of the result set
        	try {
				bean.getResult().getResultSet().beforeFirst();
			} catch (SQLException ex) {
				LOG.error(ex.getMessage(), ex);
			}
        }               

        return true;
    }
715924
@Override
   public final DATATYPE getData() {
      return (data != null) ? data : convert(getValue(DATA, String.class));
   }
264030
@Deprecated
    public void importData(CmsObject cms, String importFile, String importPath, I_CmsReport report)
    throws CmsXmlException, CmsImportExportException, CmsRoleViolationException, CmsException {

        CmsImportParameters parameters = new CmsImportParameters(importFile, importPath, true);
        setImportParameters(parameters);

        importData(cms, report);
    }
480240
@Override
    public InputStream exportAsInputStream() {
        // Create export delegate
        final AbstractExporterDelegate<InputStream> exportDelegate = new ZipExporterDelegate(this.getArchive());

        // Export and get result
        return exportDelegate.export();
    }
760096
private void exportToCsv(File exportFile) {
        FileWriter fileWriter = null;
        exportStatus=true;
        try {
            fileWriter = new FileWriter(exportFile);
            CSVWriter writer = new CSVWriter(fileWriter);
            List<Marker> markers = datastore.getBookmarksAsMarkers(getmMapView());
            String[] headers = new String[] {"Latitude","Longitude","Description","Title"};
            writer.writeNext(headers);
            for (Marker m: markers) {
                String[] items = new String[4];
                items[0] = m.getPosition().getLatitude()+"";
                items[1] = m.getPosition().getLongitude()+"";
                items[2] = m.getSubDescription();
                items[3] = m.getTitle();
                writer.writeNext(items);
            }
        }catch (Exception ex) {
            exportStatus=false;
            ex.printStackTrace();
        } finally {
            if (fileWriter!=null)
                try {
                    fileWriter.close();
                }catch (Exception ex) {}
        }
        final Activity act = getActivity();
        if (act!=null) {
            act.runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    if (exportStatus) {
                        Toast.makeText(act, "Export Complete", Toast.LENGTH_LONG).show();
                    } else
                        Toast.makeText(act, "Export Failed", Toast.LENGTH_LONG).show();
                }
            });
        }
    }