本文整理汇总了Java中de.schlichtherle.truezip.file.TFile类的典型用法代码示例。如果您正苦于以下问题:Java TFile类的具体用法?Java TFile怎么用?Java TFile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TFile类属于de.schlichtherle.truezip.file包,在下文中一共展示了TFile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkCompatibleVersion
import de.schlichtherle.truezip.file.TFile; //导入依赖的package包/类
@Override
public void checkCompatibleVersion(TFile war, ModuleDetails installingModuleDetails)
{
//Version check
TFile propsFile = new TFile(war+VERSION_PROPERTIES);
if (propsFile != null && propsFile.exists())
{
log.info("INFO: Checking the war version using "+VERSION_PROPERTIES);
Properties warVers = loadProperties(propsFile);
VersionNumber warVersion = new VersionNumber(warVers.getProperty("version.major")+"."+warVers.getProperty("version.minor")+"."+warVers.getProperty("version.revision"));
checkVersions(warVersion, installingModuleDetails);
}
else
{
log.info("INFO: Checking the war version using the manifest.");
checkCompatibleVersionUsingManifest(war,installingModuleDetails);
}
}
示例2: checkCompatibleEditionUsingManifest
import de.schlichtherle.truezip.file.TFile; //导入依赖的package包/类
/**
* Checks to see if the module that is being installed is compatible with the war, (using the entry in the manifest).
* This is more accurate and works for both alfresco.war and share.war, however
* valid manifest entries weren't added until 3.4.11, 4.1.1 and Community 4.2
* @param war TFile
* @param installingModuleDetails ModuleDetails
*/
public void checkCompatibleEditionUsingManifest(TFile war, ModuleDetails installingModuleDetails)
{
List<String> installableEditions = installingModuleDetails.getEditions();
if (installableEditions != null && installableEditions.size() > 0) {
String warEdition = findManifestArtibute(war, MANIFEST_IMPLEMENTATION_TITLE);
if (warEdition != null && warEdition.length() > 0)
{
warEdition = warEdition.toLowerCase();
for (String edition : installableEditions)
{
if (warEdition.endsWith(edition.toLowerCase()))
{
return; //successful match.
}
}
throw new ModuleManagementToolException("The module ("+installingModuleDetails.getTitle()
+") can only be installed in one of the following editions"+installableEditions);
} else {
log.info("WARNING: No edition information detected in war, edition validation is disabled, continuing anyway. Is this war prior to 3.4.11, 4.1.1 and Community 4.2 ?");
}
}
}
示例3: checkModuleDependencies
import de.schlichtherle.truezip.file.TFile; //导入依赖的package包/类
@Override
public void checkModuleDependencies(TFile war, ModuleDetails installingModuleDetails)
{
// Check that the target war has the necessary dependencies for this install
List<ModuleDependency> installingModuleDependencies = installingModuleDetails.getDependencies();
List<ModuleDependency> missingDependencies = new ArrayList<ModuleDependency>(0);
for (ModuleDependency dependency : installingModuleDependencies)
{
String dependencyId = dependency.getDependencyId();
ModuleDetails dependencyModuleDetails = getModuleDetails(war, dependencyId);
// Check the dependency. The API specifies that a null returns false, so no null check is required
if (!dependency.isValidDependency(dependencyModuleDetails))
{
missingDependencies.add(dependency);
continue;
}
}
if (missingDependencies.size() > 0)
{
throw new ModuleManagementToolException("The following modules must first be installed: " + missingDependencies);
}
}
示例4: getModuleDetailsOrAlias
import de.schlichtherle.truezip.file.TFile; //导入依赖的package包/类
@Override
public ModuleDetails getModuleDetailsOrAlias(TFile war, ModuleDetails installingModuleDetails)
{
ModuleDetails installedModuleDetails = getModuleDetails(war, installingModuleDetails.getId());
if (installedModuleDetails == null)
{
// It might be there as one of the aliases
List<String> installingAliases = installingModuleDetails.getAliases();
for (String installingAlias : installingAliases)
{
ModuleDetails installedAliasModuleDetails = getModuleDetails(war, installingAlias);
if (installedAliasModuleDetails == null)
{
// There is nothing by that alias
continue;
}
// We found an alias and will treat it as the same module
installedModuleDetails = installedAliasModuleDetails;
//outputMessage("Module '" + installingAlias + "' is installed and is an alias of '" + installingModuleDetails + "'", false);
break;
}
}
return installedModuleDetails;
}
示例5: extractToDir
import de.schlichtherle.truezip.file.TFile; //导入依赖的package包/类
private String extractToDir(String extension, String location)
{
File tmpDir = TempFileProvider.getTempDir();
try {
TFile zipFile = new TFile(this.getClass().getClassLoader().getResource(location).getPath());
TFile outDir = new TFile(tmpDir.getAbsolutePath()+"/moduleManagementToolTestDir"+System.currentTimeMillis());
outDir.mkdir();
zipFile.cp_rp(outDir);
TVFS.umount(zipFile);
return outDir.getPath();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
示例6: checkContentsOfFile
import de.schlichtherle.truezip.file.TFile; //导入依赖的package包/类
private void checkContentsOfFile(String location, String expectedContents)
throws IOException
{
File file = new TFile(location);
assertTrue(file.exists());
BufferedReader reader = null;
try
{
reader = new BufferedReader(new InputStreamReader(new TFileInputStream(file)));
String line = reader.readLine();
assertNotNull(line);
assertEquals(expectedContents, line.trim());
}
finally
{
if (reader != null)
{
try { reader.close(); } catch (Throwable e ) {}
}
}
}
示例7: testfindManifest
import de.schlichtherle.truezip.file.TFile; //导入依赖的package包/类
@Test
public void testfindManifest() throws Exception {
//Now check the compatible versions using the manifest
TFile theWar = getFile(".war", "module/share-3.4.11.war");
Manifest manifest = this.findManifest(theWar);
assertNotNull(manifest);
assertEquals("Alfresco Share Enterprise", manifest.getMainAttributes().getValue(MANIFEST_IMPLEMENTATION_TITLE));
assertEquals("3.4.11", manifest.getMainAttributes().getValue(MANIFEST_SPECIFICATION_VERSION));
theWar = getFile(".war", "module/alfresco-4.2.a.war");
manifest = this.findManifest(theWar);
assertNotNull(manifest);
assertEquals("Alfresco Repository Community", manifest.getMainAttributes().getValue(MANIFEST_IMPLEMENTATION_TITLE));
assertEquals("4.2.a", manifest.getMainAttributes().getValue(MANIFEST_SPECIFICATION_VERSION));
}
示例8: testListModules
import de.schlichtherle.truezip.file.TFile; //导入依赖的package包/类
@Test
public void testListModules() throws Exception
{
TFile theWar = getFile(".war", "module/test.war");
List<ModuleDetails> details = this.listModules(theWar);
assertNotNull(details);
assertEquals(details.size(), 0);
theWar = getFile(".war", "module/share-4.2.a.war");
details = this.listModules(theWar);
assertNotNull(details);
assertEquals(details.size(), 1);
ModuleDetails aModule = details.get(0);
assertEquals("alfresco-mm-share", aModule.getId());
assertEquals("0.1.5.6", aModule.getModuleVersionNumber().toString());
assertEquals(ModuleInstallState.INSTALLED, aModule.getInstallState());
}
示例9: testIsShareWar
import de.schlichtherle.truezip.file.TFile; //导入依赖的package包/类
/**
* Tests to see if the war is a share war.
*/
@Test
public void testIsShareWar()
{
TFile theWar = getFile(".war", "module/test.war"); //Version 4.1.0
assertFalse(this.isShareWar(theWar));
theWar = getFile(".war", "module/empty.war");
assertFalse(this.isShareWar(theWar));
theWar = getFile(".war", "module/alfresco-4.2.a.war");
assertFalse(this.isShareWar(theWar));
theWar = getFile(".war", "module/share-4.2.a.war");
assertTrue(this.isShareWar(theWar));
}
示例10: getFile
import de.schlichtherle.truezip.file.TFile; //导入依赖的package包/类
private TFile getFile(String extension, String location)
{
File file = TempFileProvider.createTempFile("moduleManagementToolTest-", extension);
InputStream is = this.getClass().getClassLoader().getResourceAsStream(location);
assertNotNull(is);
OutputStream os;
try
{
os = new FileOutputStream(file);
FileCopyUtils.copy(is, os);
}
catch (IOException error)
{
error.printStackTrace();
}
return new TFile(file);
}
示例11: removeVersionFromFileNames
import de.schlichtherle.truezip.file.TFile; //导入依赖的package包/类
private void removeVersionFromFileNames(String ouptutDirectory, File ear) throws IOException, JDOMException {
for (Dependency dependency : this.getJarDependencies()) {
Pattern p = Pattern.compile("(.*)-" + dependency.getVersion() + JAR_EXTENSION);
String includeOrigin = getJarName(dependency, false);
String includeDestination;
Matcher m = p.matcher(includeOrigin);
if (m.matches()) {
includeDestination = m.group(1)+JAR_EXTENSION;
truezip.moveFile(new TFile(ouptutDirectory + File.separator + includeOrigin), new TFile(ouptutDirectory + File.separator + includeDestination));
updateAlias(includeOrigin, includeDestination, ear);
}
}
truezip.sync();
}
示例12: updateAlias
import de.schlichtherle.truezip.file.TFile; //导入依赖的package包/类
private void updateAlias(String includeOrigin, String includeDestination, File ear) throws JDOMException, IOException, JDOMException {
TFile xmlTIBCO = new TFile(ear.getAbsolutePath() + File.separator + "TIBCO.xml");
String tempPath = ear.getParentFile().getAbsolutePath() + File.separator + "TIBCO.xml";
TFile xmlTIBCOTemp = new TFile(tempPath);
truezip.copyFile(xmlTIBCO, xmlTIBCOTemp);
File xmlTIBCOFile = new File(tempPath);
SAXBuilder sxb = new SAXBuilder();
Document document = sxb.build(xmlTIBCOFile);
XPath xpa = XPath.newInstance("//dd:NameValuePairs/dd:NameValuePair[starts-with(dd:name, 'tibco.alias') and dd:value='" + includeOrigin + "']/dd:value");
xpa.addNamespace("dd", "http://www.tibco.com/xmlns/dd");
Element singleNode = (Element) xpa.selectSingleNode(document);
if (singleNode != null) {
singleNode.setText(includeDestination);
XMLOutputter xmlOutput = new XMLOutputter();
xmlOutput.setFormat(Format.getPrettyFormat().setIndent(" "));
xmlOutput.output(document, new FileWriter(xmlTIBCOFile));
truezip.copyFile(xmlTIBCOTemp, xmlTIBCO);
}
updateAliasInPARs(includeOrigin, includeDestination, ear);
}
示例13: updateAliasInPARs
import de.schlichtherle.truezip.file.TFile; //导入依赖的package包/类
private void updateAliasInPARs(String includeOrigin, String includeDestination, File ear) throws IOException, JDOMException {
TrueZipFileSet pars = new TrueZipFileSet();
pars.setDirectory(ear.getAbsolutePath());
pars.addInclude("*.par");
List<TFile> parsXML = truezip.list(pars);
for (TFile parXML : parsXML) {
TFile xmlTIBCO = new TFile(parXML, "TIBCO.xml");
String tempPath = ear.getParentFile().getAbsolutePath() + File.separator + "TIBCO.xml";
TFile xmlTIBCOTemp = new TFile(tempPath);
truezip.copyFile(xmlTIBCO, xmlTIBCOTemp);
File xmlTIBCOFile = new File(tempPath);
SAXBuilder sxb = new SAXBuilder();
Document document = sxb.build(xmlTIBCOFile);
XPath xpa = XPath.newInstance("//dd:NameValuePairs/dd:NameValuePair[dd:name='EXTERNAL_JAR_DEPENDENCY']/dd:value");
xpa.addNamespace("dd", "http://www.tibco.com/xmlns/dd");
Element singleNode = (Element) xpa.selectSingleNode(document);
if (singleNode != null) {
String value = singleNode.getText().replace(includeOrigin, includeDestination);
singleNode.setText(value);
XMLOutputter xmlOutput = new XMLOutputter();
xmlOutput.setFormat(Format.getPrettyFormat().setIndent(" "));
xmlOutput.output(document, new FileWriter(xmlTIBCOFile));
truezip.copyFile(xmlTIBCOTemp, xmlTIBCO);
}
}
}
示例14: perform
import de.schlichtherle.truezip.file.TFile; //导入依赖的package包/类
@Override
public void perform() throws ServiceException, SecurityServiceException {
LOGGER.info("Performing MigrationTest upgrade");
try {
entityManagerUtils.openEntityManager();
importDataService.importDirectory(new TFile( // May be inside a Jar
BasicApplicationCorePackage.class.getResource("/init").toURI()
));
hibernateSearchService.reindexAll();
LOGGER.info("Initialization complete");
} catch (Throwable e) { // NOSONAR We just want to log the Exception/Error, no error handling here.
LOGGER.error("Error during initialization", e);
throw new IllegalStateException(e);
}
}
示例15: main
import de.schlichtherle.truezip.file.TFile; //导入依赖的package包/类
public static void main(String[] args) throws ServiceException, SecurityServiceException, IOException {
ConfigurableApplicationContext context = null;
try {
context = new AnnotationConfigApplicationContext(BasicApplicationInitConfig.class);
SpringContextWrapper contextWrapper = context.getBean("springContextWrapper", SpringContextWrapper.class);
contextWrapper.openEntityManager();
contextWrapper.importDirectory(new TFile( // May be inside a Jar
BasicApplicationInitFromExcelMain.class.getResource("/init").toURI()
));
contextWrapper.reindexAll();
LOGGER.info("Initialization complete");
} catch (Throwable e) { // NOSONAR We just want to log the Exception/Error, no error handling here.
LOGGER.error("Error during initialization", e);
throw new IllegalStateException(e);
} finally {
if (context != null) {
context.close();
}
}
}