Class ProjectFileUtil
java.lang.Object
java.nio.file.spi.FileTypeDetector
com.inductiveautomation.ignition.common.project.ProjectFileUtil
A utility class for inspecting, identifying and loading Projects from Files or streams.
 
Provides utilities for both legacy XML exported projects, as well as 8.0 disk-based project zip exports.
 Also registers with the ServiceLoader to act as a FileTypeDetector. See the docs on
 probeContentType(java.nio.file.Path)
- 
Field SummaryFields
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic voidexportToZip(ProjectManifest manifest, List<ProjectResource> resources, OutputStream destination) static ProjectImportfromInputStream(InputStream s, String projectNameOverwrite) static Optional<ProjectImport>fromProjectFile(File projectFile) static Optional<ProjectImport>fromProjectFile(File projectFile, String projectNameOverride) static ProjectImportimportFromXml(File projectFile, String newProjectName) Creates a RuntimeProject from a legacy (Ignition 7.9 and older) xml-based project exportstatic ProjectImportimportFromXml(InputStream is, String newProjectName) static ProjectImportimportFromZip(File projectFile, String projectNameOverwrite) static ProjectImportimportFromZip(InputStream zipStream, String projectName) static booleanstatic booleanisXmlProjectFile(File file) Detect if a file appears to be an xml based project exportstatic booleanisZipProjectFile(File file) Detect if a file appears to be a zip based (8.0+) project export fileprobeContentType(Path path) This class is registered with the ServiceLoader to provide itself as a FileTypeDetector, which makes it possible to use Files.probeContentType(someFilePath) and then compare the result to see if it matches the staticXML_FILE_TYPEorZIP_FILE_TYPE, the latter being the format for project exports in 8.0 and higher.static ProjectResource
- 
Field Details- 
XML_FILE_TYPE- See Also:
 
- 
ZIP_FILE_TYPE- See Also:
 
 
- 
- 
Constructor Details- 
ProjectFileUtilpublic ProjectFileUtil()
 
- 
- 
Method Details- 
exportToZippublic static void exportToZip(ProjectManifest manifest, List<ProjectResource> resources, OutputStream destination) throws IOException - Throws:
- IOException
 
- 
probeContentTypeThis class is registered with the ServiceLoader to provide itself as a FileTypeDetector, which makes it possible to use Files.probeContentType(someFilePath) and then compare the result to see if it matches the staticXML_FILE_TYPEorZIP_FILE_TYPE, the latter being the format for project exports in 8.0 and higher.- Specified by:
- probeContentTypein class- FileTypeDetector
- Parameters:
- path- path to a file possibly being an Ignition project export in either zip or .proj xml format.
- Returns:
- the discovered file type, or null if no match was found
- Throws:
- IOException- on failure to read the path as a buffered input stream
 
- 
isXmlProjectFileDetect if a file appears to be an xml based project export- Parameters:
- file- a file to detect
- Returns:
- true if the file is an xml based project export
- Throws:
- IOException- on failure to read file
 
- 
isZipProjectFileDetect if a file appears to be a zip based (8.0+) project export file- Parameters:
- file- to detect
- Returns:
- true if the file is believed to be a zip based export
- Throws:
- IOException- on failure to read file
 
- 
importFromXmlpublic static ProjectImport importFromXml(@Nonnull File projectFile, String newProjectName) throws IOException, SAXException, ProjectInvalidException Creates a RuntimeProject from a legacy (Ignition 7.9 and older) xml-based project export- Parameters:
- projectFile- file to import from
- newProjectName- if non-null or empty string, will create the new project with the given name, building the resources with the appropriate project/resource paths.
- Throws:
- IOException
- SAXException
- ProjectInvalidException
 
- 
importFromXmlpublic static ProjectImport importFromXml(@Nonnull InputStream is, String newProjectName) throws IOException, SAXException - Throws:
- IOException
- SAXException
 
- 
isSingleton
- 
sanitizeSingletons
- 
fromProjectFilepublic static Optional<ProjectImport> fromProjectFile(File projectFile) throws IOException, SAXException, ProjectInvalidException 
- 
fromProjectFilepublic static Optional<ProjectImport> fromProjectFile(File projectFile, String projectNameOverride) throws IOException, SAXException, ProjectInvalidException - Parameters:
- projectFile- the exported project file
- projectNameOverride- if the resources in the incoming project should be loaded with a different project name than exists in the file, pass the desired name in as this arg
- Returns:
- optional containing a runtime project on success, or empty if parsing or creation of the project failed.
- Throws:
- IOException- on failure to read the file
- SAXException- on failure to read/parse xml
- ProjectInvalidException
 
- 
importFromZippublic static ProjectImport importFromZip(@Nonnull File projectFile, String projectNameOverwrite) throws ProjectInvalidException, IOException - Throws:
- ProjectInvalidException
- IOException
 
- 
fromInputStreampublic static ProjectImport fromInputStream(InputStream s, String projectNameOverwrite) throws IOException, ProjectInvalidException, SAXException 
- 
importFromZippublic static ProjectImport importFromZip(@Nonnull InputStream zipStream, String projectName) throws ProjectInvalidException, IOException - Throws:
- ProjectInvalidException
- IOException
 
 
-