Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

remove redundant code

  • Loading branch information...
commit d15a602fed8e9eaea7732a4f4df2b0cd26fa9c2b 1 parent 948c0e1
Peter Wu authored
Showing with 0 additions and 6,481 deletions.
  1. +0 −241 packager/TumblerLauncher/TumblerLauncher.cpp
  2. +0 −209 packager/net/rim/tumbler/CmdLineHandler.java
  3. +0 −153 packager/net/rim/tumbler/WidgetArchive.java
  4. +0 −250 packager/net/rim/tumbler/WidgetPackager.java
  5. +0 −745 packager/net/rim/tumbler/config/FeatureManager.java
  6. +0 −57 packager/net/rim/tumbler/config/WidgetAccess.java
  7. +0 −525 packager/net/rim/tumbler/config/WidgetConfig.java
  8. +0 −64 packager/net/rim/tumbler/config/WidgetFeature.java
  9. +0 −44 packager/net/rim/tumbler/exception/CommandLineException.java
  10. +0 −44 packager/net/rim/tumbler/exception/PackageException.java
  11. +0 −45 packager/net/rim/tumbler/exception/SessionException.java
  12. +0 −39 packager/net/rim/tumbler/exception/ValidationException.java
  13. +0 −108 packager/net/rim/tumbler/file/ExtensionDependencyManager.java
  14. +0 −598 packager/net/rim/tumbler/file/FileManager.java
  15. +0 −349 packager/net/rim/tumbler/file/Library.java
  16. +0 −112 packager/net/rim/tumbler/file/TemplateFile.java
  17. +0 −90 packager/net/rim/tumbler/file/TemplateWrapper.java
  18. +0 −25 packager/net/rim/tumbler/log/LogType.java
  19. +0 −69 packager/net/rim/tumbler/log/Logger.java
  20. +0 −81 packager/net/rim/tumbler/log/resources/MessageBundle_en_CA.properties
  21. +0 −688 packager/net/rim/tumbler/rapc/Rapc.java
  22. +0 −20 packager/net/rim/tumbler/serialize/WidgetConfigSerializer.java
  23. +0 −297 packager/net/rim/tumbler/serialize/WidgetConfig_v1Serializer.java
  24. +0 −284 packager/net/rim/tumbler/session/BBWPProperties.java
  25. +0 −233 packager/net/rim/tumbler/session/SessionManager.java
  26. +0 −733 packager/net/rim/tumbler/xml/ConfigXMLParser.java
  27. +0 −355 packager/net/rim/tumbler/xml/LibraryXMLParser.java
  28. +0 −23 packager/net/rim/tumbler/xml/XMLParser.java
241 packager/TumblerLauncher/TumblerLauncher.cpp
View
@@ -1,241 +0,0 @@
-/*
-* Copyright 2010-2011 Research In Motion Limited.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#include <stdio.h>
-#include <stdlib.h>
-#include <tchar.h>
-#include <malloc.h>
-#include <process.h>
-#include <msxml.h>
-
-
-// Macro that calls a COM method returning HRESULT value.
-#define CHK_HR(stmt) do { hr=(stmt); if (FAILED(hr)) goto CleanUp; } while(0)
-
-// Macro to verify memory allcation.
-#define CHK_ALLOC(p) do { if (!(p)) { hr = E_OUTOFMEMORY; goto CleanUp; } } while(0)
-
-// Macro that releases a COM object if not NULL.
-#define SAFE_RELEASE(p) do { if ((p)) { (p)->Release(); (p) = NULL; } } while(0)
-
-// A counter to track the errors when dealing with bbwp.properties
-int errors = 0;
-
-
-// Helper function to create a VT_BSTR variant from a null terminated string.
-HRESULT VariantFromString(PCWSTR wszValue, VARIANT &Variant)
-{
- HRESULT hr = S_OK;
- BSTR bstr = SysAllocString(wszValue);
- CHK_ALLOC(bstr);
-
- V_VT(&Variant) = VT_BSTR;
- V_BSTR(&Variant) = bstr;
-
-CleanUp:
- return hr;
-}
-
-// Helper function to create a DOM instance.
-HRESULT CreateAndInitDOM(IXMLDOMDocument **ppDoc)
-{
- HRESULT hr = CoCreateInstance(__uuidof(DOMDocument), NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(ppDoc));
- if (SUCCEEDED(hr))
- {
- // these methods should not fail so don't inspect result
- (*ppDoc)->put_async(VARIANT_FALSE);
- (*ppDoc)->put_validateOnParse(VARIANT_FALSE);
- (*ppDoc)->put_resolveExternals(VARIANT_FALSE);
- }
- return hr;
-}
-
-// Helper function to display parse error.
-// It returns error code of the parse error.
-HRESULT ReportParseError(IXMLDOMDocument *pDoc, char *szDesc)
-{
- HRESULT hr = S_OK;
- HRESULT hrRet = E_FAIL; // Default error code if failed to get from parse error.
- IXMLDOMParseError *pXMLErr = NULL;
- BSTR bstrReason = NULL;
-
- CHK_HR(pDoc->get_parseError(&pXMLErr));
- CHK_HR(pXMLErr->get_errorCode(&hrRet));
- CHK_HR(pXMLErr->get_reason(&bstrReason));
- printf("%-12s\t%s\n", "[ERROR]", szDesc);
- errors++;
-
-CleanUp:
- SAFE_RELEASE(pXMLErr);
- SysFreeString(bstrReason);
- return hrRet;
-}
-
-BSTR getJavaHome(WCHAR wsBBWPExe[])
-{
- HRESULT hr = S_OK;
- IXMLDOMDocument *pXMLDom = NULL;
- IXMLDOMParseError *pXMLErr = NULL;
- IXMLDOMNode *pNode = NULL;
-
- BSTR bstrJavaHome = NULL;
- BSTR bstrNodeName = NULL;
- BSTR bstrNodeValue = NULL;
- WCHAR wsBBWPProperties[MAX_PATH];
-
- BSTR bstrXML = NULL;
- BSTR bstrErr = NULL;
- VARIANT_BOOL varStatus;
- VARIANT varFileName;
- VariantInit(&varFileName);
-
- CHK_HR(CreateAndInitDOM(&pXMLDom));
-
- // XML file name to load
-
- wcscpy_s(wsBBWPProperties, MAX_PATH, wsBBWPExe);
- wcscat_s(wsBBWPProperties, MAX_PATH, L"bin\\bbwp.properties");
-
- CHK_HR(VariantFromString(wsBBWPProperties, varFileName));
- CHK_HR(pXMLDom->load(varFileName, &varStatus));
- if (varStatus != VARIANT_TRUE)
- {
- // Failed to load xml, get last parsing error
- CHK_HR(pXMLDom->get_parseError(&pXMLErr));
- CHK_HR(pXMLErr->get_reason(&bstrErr));
- printf("%-12s\t%s\n", "[ERROR]", "Failed to load DOM from bbwp.properties");
- errors++;
- }
-
- bstrJavaHome = SysAllocString(L"//wcp/java");
- CHK_ALLOC(bstrJavaHome);
- CHK_HR(pXMLDom->selectSingleNode(bstrJavaHome, &pNode));
-
- if (pNode)
- {
- CHK_HR(pNode->get_text(&bstrNodeValue));
- SysFreeString(bstrNodeValue);
- SAFE_RELEASE(pNode);
- }
- else
- {
- CHK_HR(ReportParseError(pXMLDom, "Error while locating <java> in the bbwp.properties."));
- }
-
-CleanUp:
- SAFE_RELEASE(pXMLDom);
- SAFE_RELEASE(pXMLErr);
- SysFreeString(bstrXML);
- SysFreeString(bstrErr);
- SysFreeString(bstrJavaHome);
- SysFreeString(bstrNodeName);
- SysFreeString(bstrNodeValue);
- VariantClear(&varFileName);
-
- return bstrNodeValue;
-}
-
-
-void _tmain(int argc, _TCHAR* argv[])
-{
- int i;
- WCHAR wsBBWPExe[MAX_PATH];
- WCHAR wsJavaExe[MAX_PATH];
- WCHAR wsJavaExeParams[4096];
-
- BSTR bstrJavaHome = NULL;
- STARTUPINFO si;
- PROCESS_INFORMATION pi;
-
- // initialize
- ZeroMemory( &si, sizeof(si) );
- si.cb = sizeof(si);
- ZeroMemory( &pi, sizeof(pi) );
-
- if (SearchPath(NULL,
- L"bbwp.exe",
- NULL,
- MAX_PATH,
- wsBBWPExe,
- NULL)) {
- wcsncpy_s(wsBBWPExe, wsBBWPExe, wcslen(wsBBWPExe) - wcslen(L"bbwp.exe"));
- } else {
- printf("%-12s\t%s\n", "[ERROR]", "Failed to locate bbwp.exe.");
- exit(1);
- }
-
- HRESULT hr = CoInitialize(NULL);
- if(SUCCEEDED(hr))
- {
- bstrJavaHome = getJavaHome(wsBBWPExe);
- if (bstrJavaHome && SysStringLen(bstrJavaHome) > 0)
- {
- wcscpy_s(wsJavaExe, MAX_PATH, bstrJavaHome);
- wcscat_s(wsJavaExe, MAX_PATH, L"\\bin\\java.exe");
- }
- else
- {
- SearchPath(NULL,
- L"java.exe",
- NULL,
- MAX_PATH,
- wsJavaExe,
- NULL);
-
- }
-
- SysFreeString(bstrJavaHome);
- CoUninitialize();
- }
-
- if (errors > 0 ) exit(1);
-
- wcscpy_s(wsJavaExeParams, 4096, L" -jar \"");
- wcscat_s(wsJavaExeParams, 4096, wsBBWPExe);
- wcscat_s(wsJavaExeParams, 4096, L"bin\\bbwp.jar\"");
-
- for (i = 1; i <= argc; i++) {
- if (argv[i] != NULL) {
- wcscat_s(wsJavaExeParams, 4096, L" \"");
- wcscat_s(wsJavaExeParams, 4096, argv[i]);
- wcscat_s(wsJavaExeParams, 4096, L"\"");
- }
- }
-
- // Start the child process.
- if( !CreateProcess(
- wsJavaExe, // No module name (use command line)
- wsJavaExeParams, // Command line
- NULL, // Process handle not inheritable
- NULL, // Thread handle not inheritable
- FALSE, // Set handle inheritance to FALSE
- 0, // No creation flags
- NULL, // Use parent's environment block
- NULL, // Use parent's starting directory
- &si, // Pointer to STARTUPINFO structure
- &pi ) // Pointer to PROCESS_INFORMATION structure
- )
- {
- printf("%-12s\t%s\n", "[ERROR]", "Failed to run launch java.exe.");
- return;
- }
-
- // Wait until child process exits.
- WaitForSingleObject( pi.hProcess, INFINITE );
-
- // Close process and thread handles.
- CloseHandle( pi.hProcess );
- CloseHandle( pi.hThread );
-}
209 packager/net/rim/tumbler/CmdLineHandler.java
View
@@ -1,209 +0,0 @@
-/*
-* Copyright 2010-2011 Research In Motion Limited.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package net.rim.tumbler;
-
-import java.io.File;
-import java.util.Date;
-import java.util.Random;
-import java.util.regex.Pattern;
-
-import net.rim.tumbler.exception.CommandLineException;
-import net.rim.tumbler.exception.PackageException;
-import net.rim.tumbler.log.LogType;
-import net.rim.tumbler.log.Logger;
-import net.rim.tumbler.session.SessionManager;
-
-public class CmdLineHandler {
- private static final String FILE_SEP = System.getProperty("file.separator");
- private static final String OPTION_SOURCEDIR = "/s";
- private static final String OPTION_PASSWORD = "/g";
- private static final String OPTION_OUTPUTDIR = "/o";
- private static final String OPTION_VERBOSE = "/v";
- private static final String OPTION_HELP = "/h";
- private static final String OPTION_DEBUG = "/d";
-
- private boolean _requireSigned;
- private String _password;
- private String _outputDir;
- private boolean _requireSource;
- private String _sourceDir;
- private boolean _debugMode;
- private boolean _isVerbose;
- private String _widgetArchive;
- private String _archiveName;
-
- public boolean parse (String[] inputParams) throws PackageException, CommandLineException {
- // Validate at least one parameter.
- if (inputParams.length < 1) {
- throw new CommandLineException("EXCEPTION_INVALID_COMMAND_LINE");
- }
-
- // Get first param - exception case: /h
- String input1 = inputParams[0].toLowerCase().trim();
- if (input1.equals(OPTION_HELP)) {
- Logger.logMessage(LogType.NONE, "BBWP_USAGE", WidgetPackager.getVersion());
- return false;
- }
-
- // Check archive format
- if (!input1.endsWith(".zip")) {
- throw new CommandLineException("EXCEPTION_INVALID_COMMAND_LINE");
- }
-
- // Parse the command line
- _widgetArchive = getAbsolutePath(input1);
- _archiveName = parseWidgetName(_widgetArchive);
-
- Pattern patternWidgetName = Pattern.compile("[a-zA-Z][a-zA-Z0-9]*");
- if (!patternWidgetName.matcher(_archiveName).matches()) {
- throw new PackageException("EXCEPTION_INVALID_ARCHIVE_NAME");
- }
-
- // Parse options
- try {
- parseOptionParameters(inputParams);
- } catch (Exception e) {
- throw new CommandLineException("EXCEPTION_INVALID_COMMAND_LINE");
- }
- return true;
- }
-
- public SessionManager createSession() throws Exception {
- // Parse location of packager
- String bbwpInstallFolder;
- String installPath = getAbsolutePath(SessionManager.BBWP_JAR_PATH);
- File p = new File(installPath);
- if (p.isDirectory()) {
- if (installPath.lastIndexOf(FILE_SEP) == installPath.length() - 1) {
- bbwpInstallFolder = installPath;
- } else {
- bbwpInstallFolder = installPath + FILE_SEP;
- }
- } else {
- installPath = installPath.substring(0, installPath
- .lastIndexOf(FILE_SEP))
- + FILE_SEP;
- bbwpInstallFolder = installPath;
- }
-
- SessionManager.createInstance(
- _archiveName,
- _widgetArchive,
- bbwpInstallFolder,
- _outputDir,
- _requireSigned,
- _password,
- _requireSource,
- _sourceDir,
- _debugMode,
- _isVerbose);
- return SessionManager.getInstance();
- }
-
- private String parseWidgetName(String archivePath) {
- String name = archivePath.substring(
- archivePath.lastIndexOf(FILE_SEP) + 1, archivePath.lastIndexOf("."));
- return name;
- }
-
- private String getAbsolutePath(String filePath) {
- try {
- return (new File(filePath)).getCanonicalFile().getAbsolutePath();
- } catch (Exception e) {
- return (new File(filePath)).getAbsolutePath();
- }
- }
-
- private void parseOptionParameters(String[] params) throws Exception {
- _requireSigned = false;
- _password = "";
- _outputDir = "";
- _requireSource = false;
- _sourceDir = "";
-
- int index = 1;
- while (index < params.length) {
- String param = params[index];
-
- if (param.equals(OPTION_HELP)) {
- throw new Exception();
- } else if (param.equals(OPTION_DEBUG)) {
- _debugMode = true;
- index++;
- } else if (param.equals(OPTION_VERBOSE)) {
- _isVerbose = true;
- index++;
- } else if (param.equals(OPTION_PASSWORD)) {
- _requireSigned = true;
- if (params.length > index + 1) {
- String followingParameter = params[index + 1];
- if (followingParameter.charAt(0) != '/') {
- _password = followingParameter;
- index++;
- }
- }
- index++;
- } else if (param.equals(OPTION_OUTPUTDIR)) {
- if (params.length > index + 1) {
- _outputDir = params[index + 1];
- _outputDir = getAbsolutePath(_outputDir);
- index += 2;
- } else {
- throw new Exception();
- }
- } else if (param.equals(OPTION_SOURCEDIR)) {
- _requireSource = true;
- if (params.length > index + 1) {
- String followingParameter = params[index + 1];
- if (followingParameter.charAt(0) != '/') {
- _sourceDir = followingParameter;
- _sourceDir = getAbsolutePath(_sourceDir);
- index++;
- }
- }
- index++;
- } else {
- throw new Exception();
- }
- }
-
- // Populate correct source directory
- if (!_requireSource) {
- _sourceDir = System.getProperty("java.io.tmpdir") + "widgetGen."
- + new Random().nextInt(2147483647) + new Date().getTime()
- + ".tmp";
- } else {
- if (_sourceDir.length() != 0) {
- _sourceDir = _sourceDir + FILE_SEP + "src";
- } else {
- if (_outputDir.length() != 0) {
- _sourceDir = _outputDir + FILE_SEP + "src";
- } else {
- _sourceDir = _widgetArchive.substring(0, _widgetArchive
- .lastIndexOf(FILE_SEP) + 1)
- + "src";
- }
- }
- }
-
- // Populate correct output directory
- if (_outputDir.length() == 0) {
- _outputDir = _widgetArchive.substring(0, _widgetArchive
- .lastIndexOf(FILE_SEP) + 1)
- + "bin";
- }
- }
-}
153 packager/net/rim/tumbler/WidgetArchive.java
View
@@ -1,153 +0,0 @@
-/*
-* Copyright 2010-2011 Research In Motion Limited.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package net.rim.tumbler;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.regex.Pattern;
-import java.util.zip.Adler32;
-import java.util.zip.CheckedInputStream;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipInputStream;
-
-import net.rim.tumbler.exception.PackageException;
-import net.rim.tumbler.exception.ValidationException;
-import net.rim.tumbler.log.LogType;
-import net.rim.tumbler.log.Logger;
-
-public class WidgetArchive {
- private static final String[] RESERVED_DIRS = new String[] { "src", "bin" };
-
- private String _archiveFile;
- private byte[] _configXML;
- private String _indexFile;
- private String _iconFile;
-
- public WidgetArchive(String widgetArchive) {
- _archiveFile = widgetArchive;
- _configXML = new byte[0];
- _indexFile = null;
- _iconFile = null;
- }
-
- public void validate() throws ValidationException, PackageException {
- File f = new File(_archiveFile);
- try {
- FileInputStream fis = new FileInputStream(f);
- CheckedInputStream checksum = new CheckedInputStream(fis, new Adler32());
- ZipInputStream zis = new ZipInputStream(new BufferedInputStream(
- checksum));
-
- // Parse each zip file
- ZipEntry entry;
- while ((entry = zis.getNextEntry()) != null) {
- String entryName = entry.getName().replace('\\', '/');
- if (entryName.equals("index.htm")) {
- _indexFile = "index.htm";
- }
- else if (_indexFile == null && entryName.equals("index.html")) {
- _indexFile = "index.html";
- }
- else if (entryName.equals("config.xml")) {
- _configXML = getBytes(zis);
- }
- else if (entryName.equals("icon.svg")) {
- _iconFile = "icon.svg";
- }
- else if ((_iconFile == null || _iconFile.equals("icon.gif")) && entryName.equals("icon.png")) {
- _iconFile = "icon.png";
-
- }
- else if (_iconFile == null && entryName.equals("icon.gif")) {
- _iconFile = "icon.gif";
- }
- else if (entry.isDirectory()) {
- // Check for reservedDirs
- for (String reserved : RESERVED_DIRS) {
- // The dir entry name has a trailing / like "dir/"
- if (entryName.equals(reserved + "/")) {
- throw new ValidationException("EXCEPTION_ARCHIVE_RESERVED_DIR");
- }
- }
- }
- // Validate the resource name
- Pattern patternEntryName = Pattern.compile("[a-zA-Z-_0-9][a-zA-Z-_0-9\\.]*");;
- String entity;
- String fullEntryName = entryName;
- boolean noMoreEntity = false;
-
- while (!noMoreEntity) {
- if (entryName.charAt(entryName.length() - 1) == '/') {
- entryName = entryName.substring(0, entryName.length() - 1); // Remove the ending '/'
- }
-
- if (entryName.lastIndexOf('/') >= 0) {
- entity = entryName.substring(entryName.lastIndexOf('/') + 1);
- entryName = entryName.substring(0, entryName.lastIndexOf('/'));
- } else {
- entity = entryName;
- noMoreEntity = true;
- }
-
- if (!patternEntryName.matcher(entity).matches()) {
- throw new ValidationException("EXCEPTION_INVALID_RESOURCE_NAME", fullEntryName);
- }
- }
- }
-
- if (_configXML.length == 0) {
- throw new PackageException("EXCEPTION_CONFIGXML_MISSING");
- }
- }
- catch (FileNotFoundException fnfe) {
- // Already validated for existence of archive file - never get here
- Logger.logMessage(LogType.FATAL, "EXCEPTION_WIDGET_ARCHIVE_NOT_FOUND");
- }
- catch (IOException ioe) {
- throw new PackageException("EXCEPTION_ARCHIVE_IO", ioe);
- }
- }
-
- public byte[] getConfigXML() {
- return _configXML;
- }
-
- public String getIndexFile() {
- return _indexFile;
- }
-
- public String getIconFile() {
- return _iconFile;
- }
-
- private byte[] getBytes(ZipInputStream zis) throws IOException {
- int size;
- byte[] buffer = new byte[4096];
- ByteArrayOutputStream os = new ByteArrayOutputStream();
- BufferedOutputStream bos = new BufferedOutputStream(os, buffer.length);
- while ((size = zis.read(buffer, 0, buffer.length)) != -1) {
- bos.write(buffer, 0, size);
- }
- bos.flush();
- bos.close();
- return os.toString().trim().getBytes();
- }
-}
250 packager/net/rim/tumbler/WidgetPackager.java
View
@@ -1,250 +0,0 @@
-/*
-* Copyright 2010-2011 Research In Motion Limited.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package net.rim.tumbler;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-
-import net.rim.tumbler.config.WidgetConfig;
-import net.rim.tumbler.exception.CommandLineException;
-import net.rim.tumbler.exception.PackageException;
-import net.rim.tumbler.exception.ValidationException;
-import net.rim.tumbler.file.FileManager;
-import net.rim.tumbler.log.LogType;
-import net.rim.tumbler.log.Logger;
-import net.rim.tumbler.rapc.Rapc;
-import net.rim.tumbler.serialize.WidgetConfigSerializer;
-import net.rim.tumbler.serialize.WidgetConfig_v1Serializer;
-import net.rim.tumbler.session.BBWPProperties;
-import net.rim.tumbler.session.SessionManager;
-import net.rim.tumbler.xml.ConfigXMLParser;
-import net.rim.tumbler.xml.XMLParser;
-
-public class WidgetPackager {
-
- public static final String[] STANDARD_OUTPUTS = new String[] { ".cod",
- ".alx", ".cso", ".csl" };
- public static final String[] OTA_OUTPUTS = new String[] { ".cod", ".jad" };
-
- // TODO: retrieve from logger
- public static final String BLACKBERRY_WIDGET_PORTAL_URL = "http://www.blackberry.com/developers/webworkssdk/";
- public static final String PROPERTIES_FILE = "bbwp.properties";
- public static final String SIGNATURE_KEY_FILE = "sigtool.csk";
-
- private static final String AUTOGEN_FILE = "blackberry/web/widget/autogen/WidgetConfigAutoGen.java";
-
- private static final int NO_ERROR_RETURN_CODE = 0;
- private static final int PACKAGE_ERROR_RCODE = 1;
- private static final int VALIDATION_ERROR_RCODE = 2;
- private static final int RUNTIME_ERROR_RCODE = 3;
- private static final int UNEXPECTED_ERROR_RCODE = 4;
- private static final int COMMAND_LINE_EXCEPTION = 5;
-
- public static void main(String[] args) {
- WidgetPackager wp = new WidgetPackager();
- int returnCode = wp.go(args);
- System.exit(returnCode);
- }
-
- public int go(String[] args) {
- Logger.logMessage(LogType.INFO, "PROGRESS_CMDLINE_OPTIONS");
- int returnCode = NO_ERROR_RETURN_CODE;
-
- try {
- CmdLineHandler cmd = new CmdLineHandler();
- if (!cmd.parse(args)) {
- // nothing to package
- return NO_ERROR_RETURN_CODE;
- }
-
- // create SessionManager
- SessionManager sessionManager = cmd.createSession();
-
- // create bbwp.properties
- Logger.logMessage(LogType.INFO, "PROGRESS_SESSION_BBWP_PROPERTIES");
- String propertiesFile = sessionManager.getBBWPJarFolder()
- + WidgetPackager.PROPERTIES_FILE;
- BBWPProperties bbwpProperties = new BBWPProperties(propertiesFile,
- sessionManager.getSessionHome());
-
- // validate BlackBerry WebWorks application archive
- Logger.logMessage(LogType.INFO,
- "PROGRESS_VALIDATING_WIDGET_ARCHIVE");
- WidgetArchive wa = new WidgetArchive(sessionManager
- .getWidgetArchive());
- wa.validate();
-
- // parse/validate config.xml
- Logger.logMessage(LogType.INFO, "PROGRESS_SESSION_CONFIGXML");
- XMLParser xmlparser = new ConfigXMLParser();
- WidgetConfig config = xmlparser.parseXML(wa); // raw data, without \
-
-
- // create/clean outputs/source
- // Logger.printInfoMessage("BlackBerry WebWorks application packaging starts...");
- FileManager fileManager = new FileManager(bbwpProperties, config.getAccessTable());
- Logger.logMessage(LogType.INFO, "PROGRESS_FILE_POPULATING_SOURCE");
- fileManager.prepare();
-
- // Set 3rd party extension classes
- config.setExtensionClasses(fileManager.getExtensionClasses());
-
- // create autogen file
- WidgetConfigSerializer wcs = new WidgetConfig_v1Serializer(config);
- byte[] autogenFile = wcs.serialize();
- fileManager.writeToSource(autogenFile, AUTOGEN_FILE);
-
- // create jdw/jdp files
- fileManager.generateProjectFiles(sessionManager.getSourceFolder(),
- sessionManager.getArchiveName(), config.getName(), config
- .getVersion(), config.getAuthor(),config.getContent(),config.getBackgroundSource(),config.isStartupEnabled(), config
- .getIconSrc(), config.getHoverIconSrc(),
- fileManager.getFiles(), bbwpProperties.getImports());
-
- // run rapc
- Logger.logMessage(LogType.INFO, "PROGRESS_COMPILING");
- Rapc rapc = new Rapc(bbwpProperties, config, fileManager.getCompiledJARDependencies());
- if (!rapc.run(fileManager.getFiles())) {
- throw new PackageException("EXCEPTION_RAPC");
- }
-
- // generate ALX
- generateAlxFile(config);
-
- // Sign the cod if required
- if (sessionManager.requireSigning()) {
- Logger.logMessage(LogType.INFO, "PROGRESS_SIGNING");
- signCod(sessionManager);
- Logger.logMessage(LogType.INFO, "PROGRESS_SIGNING_COMPLETE");
- }
-
- // clean/prep output folders
- fileManager.cleanOutput();
-
- // copy output files
- Logger.logMessage(LogType.INFO, "PROGRESS_GEN_OUTPUT");
- fileManager.copyOutputsFromSource();
-
- // clean source (if necessary)
- if (!sessionManager.requireSource()) {
- fileManager.cleanSource();
- }
-
- Logger.logMessage(LogType.INFO, "PROGRESS_COMPLETE");
- } catch (CommandLineException cle) {
- Logger.logMessage(LogType.ERROR, cle.getMessage(), cle.getInfo());
- Logger.logMessage(LogType.NONE, "BBWP_USAGE", getVersion());
- returnCode = COMMAND_LINE_EXCEPTION;
- } catch (PackageException pe) {
- Logger.logMessage(LogType.ERROR, pe.getMessage(), pe.getInfo());
- returnCode = PACKAGE_ERROR_RCODE;
- } catch (ValidationException ve) {
- Logger.logMessage(LogType.ERROR, ve.getMessage(), ve.getInfo());
- returnCode = VALIDATION_ERROR_RCODE;
- } catch (RuntimeException re) {
- Logger.logMessage(LogType.FATAL, re);
- returnCode = RUNTIME_ERROR_RCODE;
- } catch (Exception e) {
- Logger.logMessage(LogType.ERROR, e);
- returnCode = UNEXPECTED_ERROR_RCODE;
- }
-
- return returnCode;
- }
-
- public static Object[] getVersion() {
- return new Object[] { new WidgetPackager().getClass().getPackage().getImplementationVersion() };
- }
-
- private static void signCod(SessionManager sessionManager) throws Exception {
- Process signingProcess;
- long lastModified = 0;
- String codFullname = sessionManager.getSourceFolder()
- + System.getProperty("file.separator")
- + sessionManager.getArchiveName() + ".cod";
-
- try {
- lastModified = (new File(codFullname)).lastModified();
- String password = sessionManager.getPassword();
- File cwd = new File(sessionManager.getBBWPJarFolder());
- String cmdline = "java -jar SignatureTool.jar -a -c "
- + (password.length() == 0 ? "" : "-p " + password + " ")
- + "\"" + sessionManager.getSourceFolder()
- + System.getProperty("file.separator")
- + sessionManager.getArchiveName() + ".cod" + "\"";
- signingProcess = Runtime.getRuntime().exec(cmdline, null, cwd);
- } catch (IOException ex) {
- throw ex;
- }
-
- try {
- int signingResult = signingProcess.waitFor();
-
- // Check whether signing is successful
- if (signingResult != 0) {
- throw new PackageException("EXCEPTION_SIGNING_FAILED");
- }
-
- long newModified = (new File(codFullname)).lastModified();
- if (newModified == lastModified) {
- throw new PackageException("EXCEPTION_SIGNING_FAILED");
- }
- } catch (InterruptedException e) {
- throw e;
- }
- }
-
- // Generate a .alx file
- private static void generateAlxFile(WidgetConfig widgetConfig)
- throws IOException {
- String EOL = System.getProperty("line.separator");
- String fileName = SessionManager.getInstance().getSourceFolder()
- + System.getProperty("file.separator")
- + SessionManager.getInstance().getArchiveName() + ".alx";
- BufferedWriter writer = new BufferedWriter(new FileWriter(fileName));
- writer.write("<loader version=\"1.0\" >" + EOL);
- writer.write("<application id=\""
- + SessionManager.getInstance().getArchiveName() + "\">" + EOL);
- writer.write("<name>" + widgetConfig.getName() + "</name>" + EOL);
- if (widgetConfig.getDescription() != null) {
- writer.write("<description>" + widgetConfig.getDescription()
- + "</description>" + EOL);
- }
- writer.write("<version>" + widgetConfig.getVersion() + "</version>"
- + EOL);
- if (widgetConfig.getAuthor() != null) {
- writer.write("<vendor>" + widgetConfig.getAuthor() + "</vendor>"
- + EOL);
- }
- if (widgetConfig.getCopyright() != null) {
- writer.write("<copyright>" + widgetConfig.getCopyright()
- + "</copyright>" + EOL);
- }
- writer.write("<fileset Java=\"1.45\">" + EOL);
- writer.write("<directory>");
- writer.write("</directory>" + EOL);
- writer.write("<files>");
- writer.write(SessionManager.getInstance().getArchiveName() + ".cod");
- writer.write("</files>" + EOL);
- writer.write("</fileset>" + EOL);
- writer.write("</application>" + EOL);
- writer.write("</loader>" + EOL);
- writer.close();
- }
-
-}
745 packager/net/rim/tumbler/config/FeatureManager.java
View
@@ -1,745 +0,0 @@
-/*
-* Copyright 2010-2011 Research In Motion Limited.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package net.rim.tumbler.config;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.HashSet;
-import java.util.Hashtable;
-import java.util.Set;
-import java.util.Vector;
-import java.util.Map.Entry;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
-
-import net.rim.tumbler.exception.PackageException;
-import net.rim.tumbler.file.ExtensionDependencyManager;
-import net.rim.tumbler.file.FileManager;
-import net.rim.tumbler.file.Library;
-import net.rim.tumbler.file.Library.Configuration;
-import net.rim.tumbler.file.Library.Extension;
-import net.rim.tumbler.file.Library.Jar;
-import net.rim.tumbler.file.Library.Platform;
-import net.rim.tumbler.file.Library.Src;
-import net.rim.tumbler.file.Library.Target;
-import net.rim.tumbler.log.LogType;
-import net.rim.tumbler.log.Logger;
-import net.rim.tumbler.session.BBWPProperties;
-import net.rim.tumbler.session.SessionManager;
-import net.rim.tumbler.xml.LibraryXMLParser;
-
-public class FeatureManager {
- // TODO Hardcode platform="JAVA"
- private String _platform = "JAVA";
- // TODO Hardcode target="default" until target becomes one of the command
- // line params in bbwp.exe
- private String _targetVersion = "default";
- private HashSet< String > _requiredFeatures;
- // {featureId, paths & root library.xml info}
- private Hashtable< String, ExtensionInfo > _repositoryFeatures;
- // {extensionId, paths & root library.xml info}
- private Hashtable< String, ExtensionInfo > _extensionLookupTable;
- private HashSet< String > _resolvedPaths;
- // By default, "ext" under Tumbler's home, configurable in bbwp.properties
- private String _repositoryDir;
- // Common folder contains shared common APIs, folder under _repositoryDir
- // for storing common API
- private String _commonAPIDir = "common";
- private HashSet< String > _extensionClasses;
- // List of compiled JARs that the extensions might depend on
- private HashSet< String > _compiledJARDependencies;
-
- private HashSet< String > _curPaths = new HashSet< String >();
- private HashSet< String > _commonAPIPaths = new HashSet< String >();
- private File _temporaryDirectory;
- // TODO Hardcode features that are not found in extension repository,
- // temporary workaround until widgetcache extension is moved out of
- // framework
- private static HashSet< String > FRAMEWORK_FEATURES = new HashSet< String >();
-
- private static final String TEMPORARY_DIRECTORY = "~temporaryextensionsource";
- private static final String EXTENSION_DIRECTORY = "extension";
- private static final String LIBRARY_XML = "library.xml";
-
- /**
- * Stores the extension's library.xml information and the paths to source
- * code in repository.
- */
- public static class ExtensionInfo {
- private Library _lib;
- private HashSet<String> _repPaths;
- private HashSet<String> _jarPaths;
-
- public ExtensionInfo(Library lib, HashSet<String> repPaths) {
- _lib = lib;
- _repPaths = repPaths;
- }
-
- public Library getLibrary() {
- return _lib;
- }
-
- /**
- * @return the extension id found in library.xml, or null if it is not
- * defined
- */
- public String getExtensionId() {
- if (_lib != null && _lib.getExtension() != null) {
- return _lib.getExtension().getId();
- }
-
- return null;
- }
-
- public HashSet<String> getRepositoryPaths() {
- return _repPaths;
- }
-
- public HashSet<String> getCompiledJARPaths() {
- return _jarPaths;
- }
-
- public void addCompiledJARPath(String path) {
- if (_jarPaths == null) {
- _jarPaths = new HashSet<String>();
- }
-
- _jarPaths.add(path);
- }
-
- @Override
- public String toString() {
- StringBuffer buf = new StringBuffer();
- buf.append("{lib: ");
- buf.append(_lib);
- buf.append(", paths: ");
- buf.append(_repPaths);
- buf.append("}");
- return buf.toString();
- }
- }
-
- public FeatureManager(BBWPProperties bbwpProperties,
- Hashtable<WidgetAccess, Vector<WidgetFeature>> accessTable) {
- _repositoryFeatures = new Hashtable<String, ExtensionInfo>();
- _extensionLookupTable = new Hashtable<String, ExtensionInfo>();
- _resolvedPaths = new HashSet<String>();
- _repositoryDir = bbwpProperties.getRepositoryDir();
- _requiredFeatures = getRequiredFeatures(accessTable);
- _extensionClasses = new HashSet<String>();
- _compiledJARDependencies = new HashSet<String>();
-
- // TODO temp workaround, treat widgetcache features as exceptions
- // will not throw error when the code fails to find them in extension
- // repository
- if (FRAMEWORK_FEATURES.isEmpty()) {
- FRAMEWORK_FEATURES.add("blackberry.widgetcache");
- FRAMEWORK_FEATURES.add("blackberry.widgetcache.CacheInformation");
- }
- }
-
- private static HashSet<String> getRequiredFeatures(
- Hashtable<WidgetAccess, Vector<WidgetFeature>> accessTable) {
- Set<WidgetAccess> keys = accessTable.keySet();
- HashSet<String> requiredFeatures = new HashSet<String>();
-
- for (Object accessKey : keys) {
- Vector<WidgetFeature> features = (Vector<WidgetFeature>) accessTable
- .get(accessKey);
-
- for (Object featureObject : features) {
- WidgetFeature feature = (WidgetFeature) featureObject;
- requiredFeatures.add(feature.getID());
- }
- }
-
- return requiredFeatures;
- }
-
- /**
- * Given a WebWorks application archive, look at the features specified in
- * the white list and figure out all the extensions that need to be built.
- *
- * @param widgetArchive
- * WebWorks application archive
- * @param extJars
- * zip entries of JAR files found in the archive's "ext" folder
- * @return a set of file paths of the source code of all extensions that
- * need to be built
- * @throws Exception
- * if problems encountered while resolving extension
- * dependencies
- */
- public HashSet<String> resolveFeatures(ZipFile widgetArchive,
- HashSet<ZipEntry> extJars) throws Exception {
- // step 1: resolve features from widget archive ext folder
- // if JAR files contribute to features from core API, JAR wins
- if (extJars != null && !extJars.isEmpty()) {
- resolveFeaturesFromExtJars(widgetArchive, extJars);
- }
-
- // step 2: resolve features from repository folder
- resolveFeaturesFromRepository();
-
- // step 3: copy common API files to extension folder for code to compile
- copyCommonAPI();
-
- return _resolvedPaths;
- }
-
- public HashSet<String> getExtensionClasses() {
- return _extensionClasses;
- }
-
- /**
- * @return folders that need to be copied for common APIs
- */
- public HashSet<String> getCommonAPIPaths() {
- return _commonAPIPaths;
- }
-
- /**
- * @return
- */
- public HashSet<String> getCompiledJARDependencies() {
- return _compiledJARDependencies;
- }
-
- /**
- * Check JARs in widget archive's ext folder <br>
- * If required features are found in JARs, extract them to source folder <br>
- * Add paths in HashSet when done
- */
- private void resolveFeaturesFromExtJars(ZipFile widgetArchive,
- HashSet<ZipEntry> extJars) {
- if (_temporaryDirectory != null) {
- if (_temporaryDirectory.delete() == false) {
- Logger.logMessage(LogType.WARNING, "EXCEPTION_DELETING_DIRECTORY",
- _temporaryDirectory.toString());
- }
- }
- _temporaryDirectory = new File(getTempExtensionPath());
-
- for (ZipEntry jarFile : extJars) {
- try {
- // uncompress the jar into folders
- File sourceExtension = unzipJarToTempDir(widgetArchive, jarFile);
-
- if (sourceExtension == null) {
- Logger.logMessage(LogType.WARNING,
- "EXCEPTION_FAILING_DECOMPRESS_JAR", jarFile.getName());
- return;
- }
-
- // parse features offered from ext JARs
- Hashtable<String, ExtensionInfo> eligibleFeatures = getEligibleFeatures(sourceExtension);
-
- // if any eligible ids exists, move the content of the temp dir
- // into a permanent location
- finalizeEligibleIDs(eligibleFeatures);
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- File[] tempExten = _temporaryDirectory.listFiles();
-
- for (File f : tempExten) {
- FileManager.deleteDirectory(f);
- }
- }
- }
-
- FileManager.deleteDirectory(_temporaryDirectory);
- }
-
- /*
- * Takes the jar, uncompress it to temp folder, then return its handle in
- * the temp folder
- */
- private File unzipJarToTempDir(ZipFile widgetArchive, ZipEntry jarFile)
- throws IOException {
-
- String extensionName = getExtensionName(jarFile.getName());
- File sourceExtensionJar = null;
- ZipFile zipFile = null;
- try {
- // first copy the zip entry into the extension folder and identify
- // it as a jar
- sourceExtensionJar = FileManager.copyZipEntry(widgetArchive,
- jarFile, getExtensionPath() + extensionName + ".jar");
-
- zipFile = new ZipFile(sourceExtensionJar);
- Enumeration<?> enu = zipFile.entries();
-
- // go through the jar, copy each entry into the temporary folder
- while (enu.hasMoreElements()) {
- ZipEntry zipEntry = (ZipEntry) enu.nextElement();
-
- if (zipEntry.isDirectory()) {
- continue;
- }
-
- FileManager.copyZipEntry(zipFile, zipEntry,
- getTempExtensionPath() + extensionName + File.separator);
- }
- } finally {
- if (zipFile != null) {
- zipFile.close();
- }
-
- if (sourceExtensionJar != null) {
- if (sourceExtensionJar.delete() == false) {
- Logger.logMessage(LogType.WARNING,
- "EXCEPTION_DELETING_FILE", sourceExtensionJar.toString());
- }
- }
- }
-
- File[] fileList = _temporaryDirectory.listFiles();
- for (File f : fileList) {
- if (extensionName.equals(f.getName())) {
- return f;
- }
- }
-
- return null;
- }
-
- private static String getExtensionName(String extensionName) {
- if (extensionName == null) {
- return null;
- }
- int fileTypePosition = extensionName.lastIndexOf(".jar");
- // the zip entry might look like "ext/xxx.jar" or "ext\xxx.jar"
- // if checking index of "/" gives -1, should check the index of "\"
- int fileSepPosition = extensionName.lastIndexOf("/");
-
- if (fileSepPosition < 0) {
- fileSepPosition = extensionName.lastIndexOf("\\");
- }
-
- if (fileTypePosition < 0) {
- fileTypePosition = extensionName.length();
- }
- return extensionName.substring(fileSepPosition + 1, fileTypePosition);
- }
-
- private Hashtable<String, ExtensionInfo> getEligibleFeatures(
- File sourceExtension) {
- Hashtable<String, ExtensionInfo> eligibleFeatures = new Hashtable<String, ExtensionInfo>();
-
- File[] files = sourceExtension.listFiles();
- Hashtable<String, ExtensionInfo> availableFeatures = null;
-
- // library.xml should at top level
- for (File f : files) {
- if (f.getName().equalsIgnoreCase(LIBRARY_XML)) {
- try {
- availableFeatures = parseFeaturesInLibraryXML(f, true);
- } catch (Exception e) {
- return eligibleFeatures;
- }
-
- if (availableFeatures != null) {
- for (Entry<String, ExtensionInfo> entry : availableFeatures
- .entrySet()) {
- eligibleFeatures.put(entry.getKey(), entry.getValue());
- }
- }
- }
- }
-
- return eligibleFeatures;
- }
-
- @SuppressWarnings("unchecked")
- private void finalizeEligibleIDs(Hashtable<String, ExtensionInfo> eligibleFeatures) {
- for (Entry<String, ExtensionInfo> entry : eligibleFeatures.entrySet()) {
- String key = entry.getKey();
- ExtensionInfo value = entry.getValue();
- if (_requiredFeatures.contains(key)) {
- copyExtensionPathsToSourceDir(value.getRepositoryPaths());
- _resolvedPaths.addAll((HashSet<String>) _curPaths.clone());
- _extensionClasses.add(value.getLibrary().getEntryClass());
-
- // remove features from the list, so that even if the feature is
- // available in repository, the repository version will not be used
- _requiredFeatures.remove(key);
- }
- }
- }
-
- /**
- * Resolve features from extension repository
- */
- @SuppressWarnings("unchecked")
- private void resolveFeaturesFromRepository() throws Exception {
- parseRepository();
-
- HashSet<String> extensions = new HashSet<String>();
-
- // derive extensions to be built based on features on white list
- for (String featureId : _requiredFeatures) {
- ExtensionInfo info = _repositoryFeatures.get(featureId);
-
- if (info != null) {
- String extensionId = info.getExtensionId();
-
- // unable to build app that uses feature from an extension that
- // does not have an id
- // because it is not possible to resolve dependencies
- if (extensionId != null && !extensionId.isEmpty()) {
- extensions.add(extensionId);
-
- // if the extension has any JAR dependencies, add it to the
- // list so that it gets added to rapc classpath
- if (info.getCompiledJARPaths() != null) {
- for (String jarPath : info.getCompiledJARPaths()) {
- File jarFile = new File(jarPath);
- _compiledJARDependencies.add(jarFile
- .getAbsolutePath());
- }
- }
- } else {
- throw new PackageException(
- "EXCEPTION_NEED_FEATURE_FROM_UNIDENTIFIED_EXTENSION", featureId);
- }
- } else {
- // TODO temp workaround to not throw error when widgetcache
- // features cannot be found in repository
- if (!FRAMEWORK_FEATURES.contains(featureId)) {
- throw new PackageException("EXCEPTION_FEATURE_NOT_FOUND",
- featureId);
- }
- }
- }
-
- // find all extensions that need to be built with dependencies taken
- // into account
- ExtensionDependencyManager edm = new ExtensionDependencyManager(
- _extensionLookupTable);
- extensions = edm.resolveExtensions(extensions);
-
- for (String extensionId : extensions) {
- HashSet<String> repPaths = _extensionLookupTable.get(extensionId)
- .getRepositoryPaths();
- copyExtensionPathsToSourceDir(repPaths);
- _resolvedPaths.addAll((HashSet<String>) _curPaths.clone());
-
- // extension can be found in lookup table for sure, otherwise
- // exception would have been thrown in ExtensionDependencyManager.resolve
- Library lib = _extensionLookupTable.get(extensionId).getLibrary();
- _extensionClasses.add(lib.getEntryClass());
- }
- }
-
- @SuppressWarnings("unchecked")
- private void copyCommonAPI() {
- File dir = new File(_repositoryDir + File.separator + _commonAPIDir);
- File[] files = dir.listFiles();
-
- for (File f : files) {
- if (f.exists()) {
- try {
- File destFile = new File(getExtensionPath() + f.getName());
- _curPaths.clear();
- copyFiles(f, destFile);
- _commonAPIPaths
- .addAll((HashSet<String>) _curPaths.clone());
- } catch (IOException e) {
- Logger.logMessage(LogType.ERROR, "EXCEPTION_IO_COPY_FILES",
- new String[] {f.getAbsolutePath(), e.getMessage()});
- }
- }
- }
- }
-
- /**
- * For each folder in the extension repository, look for its library.xml and
- * parse it to resolve source file paths
- */
- private void parseRepository() {
- File dir = new File(_repositoryDir);
-
- if (dir.exists() && dir.isDirectory()) {
- File[] files = dir.listFiles();
-
- for (File f : files) {
- if (f.isDirectory()) {
- File[] extFiles = f.listFiles();
-
- for (File g : extFiles) {
- try {
- if (g.getName().equalsIgnoreCase(LIBRARY_XML)) {
- Hashtable<String, ExtensionInfo> features = parseFeaturesInLibraryXML(
- g, false);
- if (features != null) {
- _repositoryFeatures.putAll(features);
- }
- }
- } catch (Exception e) {
- // TODO handle error
- }
- }
- }
- }
- }
- }
-
- /**
- * Given a library file, find the configuration element that matches the
- * current platform and target
- *
- * @param lib
- * @return the configuration that matches the current platform and target
- */
- private Configuration getTargetConfiguration(Library lib) {
- String matchedConfigName = null;
-
- // check whether platform and target match what we support
- ArrayList<Platform> platforms = lib.getPlatforms();
- if (platforms != null) {
- for (Platform p : platforms) {
- if (p.getValue().equals(_platform)) {
- ArrayList<Target> targets = p.getTargets();
-
- if (targets != null) {
- for (Target t : targets) {
- if (t.getVersion().equals(_targetVersion)) {
- matchedConfigName = t.getConfigName();
- }
- }
- }
- }
- }
- }
-
- // make sure the config is defined
- if (matchedConfigName != null) {
- ArrayList<Configuration> configurations = lib.getConfigurations();
-
- for (Configuration config : configurations) {
- if (config.getName().equals(matchedConfigName)) {
- return config;
- }
- }
- }
-
- return null;
- }
-
- /**
- * Helper method for parsing out library.xml into an object
- *
- * @param libraryXML
- * @throws Exception
- */
- private static Library parseLibraryXML(File libraryXML) throws Exception {
- LibraryXMLParser parser = new LibraryXMLParser();
- return parser.parseXML(libraryXML.getAbsolutePath());
- }
-
- /**
- * Parse a given a library.xml to find out the features it offers and store
- * the proper set of source file paths for the current platform and target
- *
- * @param libraryXML
- * library.xml file, cannot be null
- * @param allowBackwardCompatibility
- * true if it's parsing library.xml from an extension JAR
- * @return hashtable that contains feature id's and the paths for the source
- * files, or null if (1) library.xml is malformed, (2) if
- * allowBackwardCompatibility is false, and <target>,
- * <configuration>, <platform> or <src> is not specified correctly
- * @throws Exception
- */
- private Hashtable<String, ExtensionInfo> parseFeaturesInLibraryXML(
- File libraryXML, boolean allowBackwardCompatibility) throws Exception {
- Library lib = parseLibraryXML(libraryXML);
-
- if (lib == null) {
- return null;
- }
-
- ArrayList<WidgetFeature> features = lib.getFeatures();
- HashSet<String> paths = new HashSet<String>();
- Hashtable<String, ExtensionInfo> availableFeatures = new Hashtable<String, ExtensionInfo>();
-
- if (allowBackwardCompatibility) {
- // have to work for library.xml that doesn't contain configuration and platform elements
- File[] files = _temporaryDirectory.listFiles();
-
- for (File f : files) {
- paths.add(f.getAbsolutePath());
- }
- } else {
- ExtensionInfo info = new ExtensionInfo(lib, paths);
- boolean extensionIdFound = false;
-
- if (lib.getExtension() != null) {
- Extension extension = lib.getExtension();
- String id = extension.getId();
-
- if (id != null && !id.isEmpty()) {
- if (_extensionLookupTable.contains(id)) {
- // more than one library.xml contain the same extension id
- Logger.logMessage(LogType.WARNING,
- "VALIDATION_EXTENSION_DEFINED_MORE_THAN_ONCE",
- new String[] { id });
- }
-
- _extensionLookupTable.put(id, info);
- extensionIdFound = true;
- }
- }
-
- if (!extensionIdFound) {
- // not considered an error, this extension might not be used
- // by the app being compiled
- Logger.logMessage(LogType.WARNING,
- "VALIDATION_LIBRARYXML_EXTENSION_ID_NOT_DEFINED",
- new String[] { libraryXML.getAbsolutePath() });
- }
-
- Configuration config = getTargetConfiguration(lib);
-
- if (config == null) {
- Logger.logMessage(LogType.WARNING, "VALIDATION_LIBRARYXML_NO_CONFIG",
- new String[] { libraryXML.getAbsolutePath() });
- return null;
- }
-
- ArrayList<Src> src = config.getSrc();
-
- if (src == null || src.isEmpty()) {
- Logger.logMessage(LogType.WARNING, "VALIDATION_LIBRARYXML_NO_SRC",
- new String[] { libraryXML.getAbsolutePath() });
- return null;
- }
-
- File extensionDir = libraryXML.getParentFile();
-
- for (Src s : src) {
- String path = s.getPath();
- paths.add(extensionDir.getAbsolutePath() + File.separator
- + path);
- }
- }
-
- ExtensionInfo info = new ExtensionInfo(lib, paths);
-
- for (WidgetFeature feature : features) {
- availableFeatures.put(feature.getID(), info);
- }
-
- if (lib.getCompiledJARDependencies() != null) {
- for (Jar j : lib.getCompiledJARDependencies()) {
- String path = j.getPath();
- File temp = new File(path);
-
- if (temp.isAbsolute()) {
- info.addCompiledJARPath(path);
- } else {
- info.addCompiledJARPath(libraryXML.getParentFile()
- .getAbsolutePath()
- + File.separator + path);
- }
- }
- }
-
- return availableFeatures;
- }
-
- private static String getExtensionPath() {
- return SessionManager.getInstance().getSourceFolder() + File.separator
- + EXTENSION_DIRECTORY + File.separator;
- }
-
- private static String getTempExtensionPath() {
- return SessionManager.getInstance().getSourceFolder()
- + TEMPORARY_DIRECTORY + File.separator;
- }
-
- private void copyExtensionPathsToSourceDir(HashSet<String> paths) {
- _curPaths.clear();
-
- for (String path : paths) {
- File file = new File(path);
-
- if (file.exists()) {
- try {
- copyFiles(file, new File(getExtensionPath()
- + file.getName()));
- } catch (IOException e) {
- Logger.logMessage(LogType.ERROR, "EXCEPTION_IO_COPY_FILES",
- new String[] {file.getAbsolutePath(), e.getMessage()});
- }
- }
- }
- }
-
- /**
- * This method copies file recursively from src to dest
- */
- private void copyFiles(File src, File dest) throws IOException {
- // Check to ensure that the source is valid
- if (!src.exists()) {
- throw new IOException("copyFiles: Cannot find source: "
- + src.getAbsolutePath() + ".");
- } else if (!src.canRead()) {
- // check to ensure we have rights to the source
- throw new IOException("copyFiles: No right to read source: "
- + src.getAbsolutePath() + ".");
- }
-
- // is this a directory copy?
- if (src.isDirectory()) {
- if (!dest.exists()) { // does the destination already exist?
- // if not we need to make it exist if possible (note this is
- // mkdirs not mkdir)
- if (!dest.mkdirs()) {
- throw new IOException(
- "copyFiles: Could not create direcotry: "
- + dest.getAbsolutePath() + ".");
- }
- }
-
- String list[] = src.list();
- // copy all the files in the list.
- for (String path : list) {
- File dest1 = new File(dest, path);
- File src1 = new File(src, path);
- copyFiles(src1, dest1);
- }
- } else {
- // This was not a directory, just copy the file
- try {
- // open the files for input and output
- FileManager.copyFile(src, dest);
- _curPaths.add(dest.getAbsolutePath());
- } catch (IOException e) { // Error copying file
- IOException wrapper = new IOException(
- "copyFiles: Unable to copy file: "
- + src.getAbsolutePath() + " to "
- + dest.getAbsolutePath() + ".");
- wrapper.initCause(e);
- wrapper.setStackTrace(e.getStackTrace());
- throw wrapper;
- }
- }
- }
-}
57 packager/net/rim/tumbler/config/WidgetAccess.java
View
@@ -1,57 +0,0 @@
-/*
-* Copyright 2010-2011 Research In Motion Limited.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package net.rim.tumbler.config;
-
-import java.net.URI;
-
-import net.rim.tumbler.exception.ValidationException;
-import net.rim.tumbler.session.SessionManager;
-
-public class WidgetAccess {
- private URI _uri;
- private boolean _allowSubDomain;
-
- public WidgetAccess(String uri, boolean allowSubDomain) throws Exception {
- try {
- _uri = URI.create(uri);
- // Check for a protocol
- if (!(_uri.toString().equals("WidgetConfig.WIDGET_LOCAL_DOMAIN")) &&
- (_uri.getScheme() == null || _uri.getScheme().length() == 0)) {
- throw new ValidationException (
- "EXCEPTION_ACCESSURI_NO_PROTOCOL", uri.toString());
- }
- _allowSubDomain = allowSubDomain;
-
- String host = _uri.getHost();
- if (host != null
- && SessionManager.getInstance().getTLD().indexOf(
- "$$" + host.toLowerCase().trim() + "$$") != -1 && _allowSubDomain) {
- // Throw exception - exit compilation
- throw new ValidationException( "EXCEPTION_CONFIGXML_TLD", uri );
- }
- } catch (IllegalArgumentException e) {
- throw new ValidationException("EXCEPTION_ACCESSURI_BADURI", uri.toString());
- }
- }
-
- public URI getURI() {
- return _uri;
- }
-
- public boolean allowSubDomain() {
- return _allowSubDomain;
- }
-}
525 packager/net/rim/tumbler/config/WidgetConfig.java
View
@@ -1,525 +0,0 @@
-/*
-* Copyright 2010-2011 Research In Motion Limited.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package net.rim.tumbler.config;
-
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.Map;
-import java.util.Vector;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import net.rim.tumbler.exception.ValidationException;
-import net.rim.tumbler.log.LogType;
-import net.rim.tumbler.log.Logger;
-import net.rim.tumbler.session.SessionManager;
-
-public class WidgetConfig {
- private String _content;
- private String _author;
- private String _authorEmail;
- private String _authorURL;
- private String _name;
- private String _version;
-
- private String _loadingScreenColour;
- private String _backgroundImage;
- private String _foregroundImage;
- private boolean _firstPageLoad;
- private boolean _remotePageLoad;
- private boolean _localPageLoad;
- private String _transitionType;
- private int _transitionDuration;
- private String _transitionDirection;
-
- private String _copyright;
- private String _description;
- private Vector<String> _hoverIconSrc;
- private Vector<String> _iconSrc;
- private String _id;
- private Map<String, String> _customHeaders;
- private String _backButton;
- private boolean _navigationMode;
- private String _contentType;
- private String _contentCharSet;
- private String _license;
- private String _licenseURL;
- private int _transportTimeout;
- private String[] _transportOrder;
- private boolean _multiAccess;
- private String _configXML;
- private Hashtable<WidgetAccess, Vector<WidgetFeature>> _accessTable;
- private Vector<String> _extensionClasses;
-
- // Cache fields
- private Boolean _cacheEnabled;
- private Boolean _aggressivelyCaching;
- private Integer _aggressiveCacheAge;
- private Integer _maxCacheable;
- private Integer _maxCacheSize; // Total cache size
-
- //Auto-Startup Fields
- private boolean _runOnStartup;
- private boolean _allowInvokeParams;
- private String _backgroundSource;
- private String _foregroundSource;
-
- // Debug issue
- private boolean _debugEnabled=false;
-
- public WidgetConfig() {
-
- // Set defaults
- _accessTable = new Hashtable<WidgetAccess, Vector<WidgetFeature>>();
- _hoverIconSrc = new Vector<String>();
- _customHeaders = new HashMap<String, String>();
- _iconSrc = new Vector<String>();
- _configXML = "config.xml";
- _transportTimeout = -1;
-
- _backgroundImage = null;
- _foregroundImage = null;
- _firstPageLoad = false;
- _remotePageLoad = false;
- _localPageLoad = false;
- _transitionType = null;
- _transitionDuration = -1;
- _transitionDirection = null;
-
- _cacheEnabled = null;
- _aggressivelyCaching = null;
- _aggressiveCacheAge= null;
- _maxCacheable = null;
- _maxCacheSize = null;
-
- _runOnStartup=false;
- _allowInvokeParams=false;
- _backgroundSource=null;
- _foregroundSource=null;
-
- _debugEnabled = SessionManager.getInstance().debugMode();
- }
-
- public void validate() {
- if (_version == null || _version.length() == 0) {
- Logger.logMessage(LogType.WARNING,
- "VALIDATION_CONFIGXML_MISSING_VERSION");
- _version = "1.0.0.0";
- }
- }
-
- public String getContent() {
- return _content;
- }
-
- public String getAuthor() {
- return _author;
- }
-
- public String getName() {
- return _name;
- }
-
- public String getVersion() {
- return _version;
- }
-
- public String getLoadingScreenColour() {
- return _loadingScreenColour;
- }
-
- public String getCopyright() {
- return _copyright;
- }
-
- public String getDescription() {
- return _description;
- }
-
- public Vector<String> getHoverIconSrc() {
- return _hoverIconSrc;
- }
-
- public Vector<String> getIconSrc() {
- return _iconSrc;
- }
-
- public void setContent(String content) {
- _content = content;
- }
-
- public void setAuthor(String author) {
- _author = author;
- }
-
- public void setName(String name) throws ValidationException {
- if (name == null || name.length() == 0) {
- throw new ValidationException(
- "EXCEPTION_CONFIGXML_MISSING_WIDGET_NAME");
- }
- _name = name;
- }
-
- public void setVersion(String version) throws ValidationException {
- if (SessionManager.getInstance().isVerbose()) {
- Logger.logMessage(LogType.INFO,
- "PROGRESS_VALIDATING_CONFIG_XML_WIDGET_VERSION");
- }
- // version variable should look like one of the options:
- // version="a.b"
- // version="a.b.c"
- // version="a.b.c.d"
- String regex = "\\d{1,3}\\.\\d{1,3}(\\.\\d{1,3}){0,2}$";
-
- Pattern pattern = Pattern.compile(regex);
- Matcher matcher = pattern.matcher(version);
-
- if (!matcher.matches()) {
- throw new ValidationException("EXCEPTION_CONFIGXML_INVALID_VERSION");
- }
- _version = version;
- }
-
- public void setLoadingScreenColour(String screenColour)
- throws ValidationException {
-
- if (screenColour != null) {
- if (SessionManager.getInstance().isVerbose()) {
- Logger.logMessage(LogType.INFO,
- "PROGRESS_VALIDATING_CONFIG_XML_LOADINGSCREEN_COLOR");
- }
- // Color variable should look like: #000000
- String regex = "^#[A-Fa-f0-9]{6}$";
- Pattern pattern = Pattern.compile(regex);
- Matcher matcher = pattern.matcher(screenColour);
- if (!matcher.matches()) {
- throw new ValidationException(
- "EXCEPTION_CONFIGXML_LOADINGSCREEN_COLOUR");
- }
- }
-
- _loadingScreenColour = screenColour;
- }
-
- public String getBackgroundImage() {
- return _backgroundImage;
- }
-
- public void setBackgroundImage(String src) {
- _backgroundImage = src;
- }
-
- public String getForegroundImage() {
- return _foregroundImage;
- }
-
- public void setForegroundImage(String src) {
- _foregroundImage = src;
- }
-
- public boolean getFirstPageLoad() {
- return _firstPageLoad;
- }
-
- public void setFirstPageLoad(boolean value) {
- _firstPageLoad = value;
- }
-
- public boolean getRemotePageLoad() {
- return _remotePageLoad;
- }
-
- public void setRemotePageLoad(boolean value) {
- _remotePageLoad = value;
- }
-
- public boolean getLocalPageLoad() {
- return _localPageLoad;
- }
-
- public void setLocalPageLoad(boolean value) {
- _localPageLoad = value;
- }
-
- public String getTransitionType() {
- return _transitionType;
- }
-
- public void setTransitionType(String value) {
- _transitionType = value;
- }
-
- public int getTransitionDuration() {
- return _transitionDuration;
- }
-
- public void setTransitionDuration(int value) {
- _transitionDuration = value;
- }
-
- public String getTransitionDirection() {
- return _transitionDirection;
- }
-
- public void setTransitionDirection(String value) {
- _transitionDirection = value;
- }
-
- public void setCopyright(String copyright) {
- _copyright = copyright;
- }
-
- public void setDescription(String description) {
- _description = description;
- }
-
- public void addHoverIcon(String icon) {
- _hoverIconSrc.add(icon);
- }
-
- public void addIcon(String icon) {
- _iconSrc.add(icon);
- }
-
- public String getID() {
- return _id;
- }
-
- public void setID(String id) {
- _id = id;
- }
-
- public Map<String, String> getCustomHeaders() {
- return _customHeaders;
- }
-
- public void addHeader(String key, String value) {
- _customHeaders.put(key, value);
- }
-
- public String getBackButtonBehaviour() {
- return _backButton;
- }
-
- public void setBackButtonBehaviour(String value) {
- _backButton = value;
- }
-
- public boolean getNavigationMode() {
- return _navigationMode;
- }
-
- public void setNavigationMode(boolean value) {
- _navigationMode = value;
- }
-
- public String getContentType() {
- return _contentType;
- }
-
- public String getContentCharSet() {
- return _contentCharSet;
- }
-
- public void setContentType(String type) {
- _contentType = type;
- }
-
- public void setContentCharSet(String charSet) {
- _contentCharSet = charSet;
- }
-
- public String getLicense() {
- return _license;
- }
-
- public String getLicenseURL() {
- return _licenseURL;
- }
-
- public void setLicense(String license) {
- _license = license;
- }
-
- public void setLicenseURL(String licenseurl) {
- _licenseURL = licenseurl;
- }
-
- public void setAuthorURL(String authorURL) {
- _authorURL = authorURL;
- }
-
- public String getAuthorURL() {
- return _authorURL;
- }
-
- public void setAuthorEmail(String authorEmail) {
- _authorEmail = authorEmail;
- }
-
- public String getAuthorEmail() {
- return _authorEmail;
- }
-
- public void setTransportTimeout(int transportTimeout) {
- _transportTimeout = transportTimeout;
- }
-
- public int getTransportTimeout() {
- return _transportTimeout;
- }
-
- public void setTransportOrder(String[] transportOrder) {
- _transportOrder = transportOrder;
- }
-
- public String[] getTransportOrder() {
- return _transportOrder;
- }
-
- public boolean allowMultiAccess() {
- return _multiAccess;
- }
-
- public void setMultiAccess(boolean multiAccess) {
- _multiAccess = multiAccess;
- }
-
- public String getConfigXML() {
- return _configXML;
- }
-
- public void setConfigXML(String configXML) {
- _configXML = configXML;
- }
-
- public Hashtable<WidgetAccess, Vector<WidgetFeature>> getAccessTable() {
- return _accessTable;
- }
-
- public void setAccessTable(
- Hashtable<WidgetAccess, Vector<WidgetFeature>> table) {
- _accessTable = table;
- }
-
- public void setExtensionClasses(Vector<String> classes) {
- _extensionClasses = classes;
- }
-
- public Vector<String> getExtensionClasses() {
- return _extensionClasses;
- }
-
- // Cache field functions
-
- public Boolean isCacheEnabled() {
- return _cacheEnabled;
- }
-
- public void setCacheEnabled(boolean inputValue) {
- _cacheEnabled = inputValue;
- }
-
- public Boolean isAggressiveCacheEnabled() {
- return _aggressivelyCaching;
- }
-
- private void setAggressiveCache(boolean inputValue) {
- _aggressivelyCaching = inputValue;
- }
-
- public Integer getAggressiveCacheAge() {
- return _aggressiveCacheAge;
- }
-
- public void setAggressiveCacheAge(int inputValue) {
- // Enable aggressive cache flag if the value is above 0
- if (inputValue > 0){
- setAggressiveCache(true);
- } else if (inputValue == -1) {
- setAggressiveCache(false);
- }
-
- // Max value is 30 days
- if(inputValue <= 2592000){
- _aggressiveCacheAge = inputValue;
- }
- }
-
- public Integer getMaxCacheSize() {
- return _maxCacheSize;
- }
-
- public void setMaxCacheSize(int inputValue) {
- // Min value of 0, max value of 2048 KB
- final int kb_2048 = 2048 * 1024;
- if (inputValue >= 0 && inputValue <= (kb_2048)){
- _maxCacheSize = inputValue;
- } else if (inputValue > kb_2048) {
- _maxCacheSize = kb_2048;
- }
- }
-
- public Integer getMaxCacheItemSize() {
- return _maxCacheable;
- }
-
- public void setMaxCacheItemSize(int inputValue) {
- // -1 is a valid value
- if (inputValue >= -1){
- _maxCacheable = inputValue;
- }
- }
-
- //Auto-Startup Accessors and Mutators
-
- public Boolean isStartupEnabled() {
- return _runOnStartup;
- }
-
- public void setStartup(Boolean runOnStartup) {
- _runOnStartup = runOnStartup;
- }
-
- public String getBackgroundSource() {
- return _backgroundSource;
- }
-
- public String getForegroundSource() {
- return _foregroundSource;
- }
-
- public void setForegroundSource(String foregroundSource) {
- _foregroundSource = foregroundSource;
- }
-
- public void setBackgroundSource(String backgroundSource) {
- _backgroundSource = backgroundSource;
- }
-
- public Boolean allowInvokeParams() {
- return _allowInvokeParams;
- }
-
- public void setAllowInvokeParams(Boolean allowInvokeParams) {
- _allowInvokeParams = allowInvokeParams;
- }
-
- public boolean isDebugEnabled() {
- return _debugEnabled;
- }
-
-}
64 packager/net/rim/tumbler/config/WidgetFeature.java
View
@@ -1,64 +0,0 @@
-/*
-* Copyright 2010-2011 Research In Motion Limited.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package net.rim.tumbler.config;
-
-import java.util.Arrays;
-
-public class WidgetFeature {
- private String _id;
- private boolean _isRequired;
- private String _version;
- private WidgetFeature[] _dependentFeatures;
-
- public WidgetFeature(String id, boolean isRequired, String version,
- WidgetFeature[] dependentFeatures) {
- _id = id;
- _isRequired = isRequired;
- _version = version;
- _dependentFeatures = dependentFeatures;
- }
-
- public String getID() {
- return _id;
- }
-
- public boolean isRequired() {
- return _isRequired;
- }
-
- public String getVersion() {
- return _version;
- }
-
- public WidgetFeature[] getDependentFeatures() {
- return _dependentFeatures;
- }
-
- @Override
- public String toString() {
- StringBuffer buf = new StringBuffer();
- buf.append("Feature{id: ");
- buf.append(_id);
- buf.append(", required: ");
- buf.append(_isRequired);
- buf.append(", version: ");
- buf.append(_version);
- buf.append(", dependentFeatures: ");
- buf.append(Arrays.toString(_dependentFeatures));
- buf.append("}");
- return buf.toString();
- }
-}
44 packager/net/rim/tumbler/exception/CommandLineException.java
View
@@ -1,44 +0,0 @@
-/*
-* Copyright 2010-2011 Research In Motion Limited.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package net.rim.tumbler.exception;
-
-public class CommandLineException extends RuntimeException {
-
- private static final long serialVersionUID = 1L;
- private String _info;
-
- public CommandLineException(String id) {
- super(id);
- }
-
- public CommandLineException(String id, String info) {
- super(id);
- _info = info;
- }
-
- public CommandLineException(String id, Exception causedBy) {
- super(id, causedBy);
- }
-
- public CommandLineException(Exception causedBy, String info) {
- super(causedBy);
- _info = info;
- }
-
- public String getInfo() {
- return _info;
- }
-}
44 packager/net/rim/tumbler/exception/PackageException.java
View
@@ -1,44 +0,0 @@
-/*
-* Copyright 2010-2011 Research In Motion Limited.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package net.rim.tumbler.exception;
-
-public class PackageException extends Exception {
-
- private static final long serialVersionUID = 1L;
- private String _info;
-
- public PackageException(String id) {
- super(id);
- }
-
- public PackageException(String id, String info) {
- super(id);
- _info = info;
- }
-
- public PackageException(String id, Exception causedBy) {
- super(id, causedBy);
- }
-
- public PackageException(Exception causedBy, String info) {
- super(causedBy);
- _info = info;
- }
-
- public String getInfo() {
- return _info;
- }
-}
45 packager/net/rim/tumbler/exception/SessionException.java
View
@@ -1,45 +0,0 @@
-/*
-* Copyright 2010-2011 Research In Motion Limited.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package net.rim.tumbler.exception;
-
-public class SessionException extends RuntimeException {
-
- private static final long serialVersionUID = 1L;
- private String _info;
-
- public SessionException(String id) {
- super(id);
- }
-
- public SessionException(String id, String info) {
- super(id);
- _info = info;
- }
-
- public SessionException(String id, Exception causedBy) {
- super(id, causedBy);
- }
-
- public SessionException(Exception causedBy, String info) {
- super(causedBy);
- _info = info;
- }
-
- public String getInfo() {
- return _info;
- }
-
-}
39 packager/net/rim/tumbler/exception/ValidationException.java
View
@@ -1,39 +0,0 @@
-/*
-* Copyright 2010-2011 Research In Motion Limited.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package net.rim.tumbler.exception;
-
-public class ValidationException extends Exception {
-
- private static final long serialVersionUID = 1L;
- private String _info;
-
- public ValidationException(String id) {
- super(id);
- }
-
- public ValidationException(String id, String info) {
- super(id);
- _info = info;
- }
-
- public ValidationException(String id, Exception causedBy) {
- super(id, causedBy);
- }
-
- public String getInfo() {
- return _info;
- }
-}
108 packager/net/rim/tumbler/file/ExtensionDependencyManager.java
View
@@ -1,108 +0,0 @@
-/*
-* Copyright 2010-2011 Research In Motion Limited.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package net.rim.tumbler.file;
-
-import java.util.ArrayDeque;
-import java.util.ArrayList;
-import java.util.Deque;
-import java.util.HashSet;
-import java.util.Hashtable;
-
-import net.rim.tumbler.config.FeatureManager.ExtensionInfo;
-import net.rim.tumbler.exception.PackageException;
-import net.rim.tumbler.file.Library.Extension;
-import net.rim.tumbler.log.LogType;
-import net.rim.tumbler.log.Logger;
-
-
-/**
- * Logic for resolving dependencies for extensions
- */
-public class ExtensionDependencyManager {
- private Hashtable<String, ExtensionInfo> _extensionLookupTable;
-
- private Deque<String> _inProgressStack;
- private HashSet<String> _resolvedDependencies;
-
- /**
- * Constructor
- *
- * @param extensionLookupTable
- * map with extension library info and paths indexed by extension
- * id, cannot be null
- */
- public ExtensionDependencyManager(
- Hashtable<String, ExtensionInfo> extensionLookupTable) {
- _extensionLookupTable = extensionLookupTable;
- _inProgressStack = new ArrayDeque<String>();
- _resolvedDependencies = new HashSet<String>();
- }
-
- private void resolve(HashSet<String> extensions) throws Exception {
- for (String extId : extensions) {
- Library info = null;
-
- if (_extensionLookupTable.get(extId) != null) {
- info = _extensionLookupTable.get(extId).getLibrary();
- }
-
- if (info != null) {
- _inProgressStack.push(extId);
- _resolvedDependencies.add(extId);
-
- ArrayList<Extension> dependencies = info.getDependencies();
-
- if (dependencies != null && !dependencies.isEmpty()) {
- HashSet<String> deps = new HashSet<String>();
-
- for (Extension e : dependencies) {
- if (!_inProgressStack.contains(e.getId())) {
- deps.add(e.getId());
- } else {
- throw new PackageException("EXCEPTION_CIRCULAR_DEPENDENCY", e.getId());
- }
- }
-
- resolve(deps);
- }
-
- _inProgressStack.pop();
- } else {
- throw new PackageException("EXCEPTION_EXTENSION_NOT_FOUND", extId);
- }
- }
- }
-
- /**
- * Resolve dependencies recursively<br>
- * Base case: extension does not have any dependencies<br>
- * <br>
- *
- * Push an extension on the stack at the start of the resolve process. The
- * extension is popped off the stack when all its dependencies have been
- * resolved.
- *
- * @param extensions
- * @throws Exception
- * when a circular dependency is detected, or if an extension
- * listed as a dependency cannot be found in the lookup table
- */
- public HashSet<String> resolveExtensions(HashSet<String> extensions)
- throws Exception {
- resolve(extensions);
- return _resolvedDependencies;
- }
-}
598 packager/net/rim/tumbler/file/FileManager.java
View
@@ -1,598 +0,0 @@
-/*
-* Copyright 2010-2011 Research In Motion Limited.
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-package net.rim.tumbler.file;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.channels.FileChannel;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.HashSet;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Vector;
-import java.util.zip.Adler32;
-import java.util.zip.CheckedInputStream;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
-import java.util.zip.ZipInputStream;
-
-import net.rim.tumbler.WidgetPackager;
-import net.rim.tumbler.config.FeatureManager;
-import net.rim.tumbler.config.WidgetAccess;
-import net.rim.tumbler.config.WidgetFeature;
-import net.rim.tumbler.exception.PackageException;
-import net.rim.tumbler.log.LogType;
-import net.rim.tumbler.log.Logger;
-import net.rim.tumbler.session.BBWPProperties;
-import net.rim.tumbler.session.SessionManager;