plugins/org.symbian.tools.tmw.previewer/src/org/symbian/tools/tmw/previewer/http/handlers/WorkspaceResourceProvider.java
author Eugene Ostroukhov <eugeneo@symbian.org>
Tue, 31 Aug 2010 11:58:53 -0700
changeset 479 518afa7c6d2f
parent 470 d4809db37847
permissions -rw-r--r--
Minor refactoring to make API more clear
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
470
d4809db37847 Changed repository layout and renamed project files. This revision is untested and may not run.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     1
/**
d4809db37847 Changed repository layout and renamed project files. This revision is untested and may not run.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     2
 * Copyright (c) 2010 Symbian Foundation and/or its subsidiary(-ies).
d4809db37847 Changed repository layout and renamed project files. This revision is untested and may not run.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     3
 * All rights reserved.
d4809db37847 Changed repository layout and renamed project files. This revision is untested and may not run.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     4
 * This component and the accompanying materials are made available
d4809db37847 Changed repository layout and renamed project files. This revision is untested and may not run.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     5
 * under the terms of the License "Eclipse Public License v1.0"
d4809db37847 Changed repository layout and renamed project files. This revision is untested and may not run.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     6
 * which accompanies this distribution, and is available
d4809db37847 Changed repository layout and renamed project files. This revision is untested and may not run.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     7
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
d4809db37847 Changed repository layout and renamed project files. This revision is untested and may not run.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     8
 *
d4809db37847 Changed repository layout and renamed project files. This revision is untested and may not run.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
     9
 * Initial Contributors:
d4809db37847 Changed repository layout and renamed project files. This revision is untested and may not run.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    10
 * Symbian Foundation - initial contribution.
d4809db37847 Changed repository layout and renamed project files. This revision is untested and may not run.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    11
 * Contributors:
d4809db37847 Changed repository layout and renamed project files. This revision is untested and may not run.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    12
 * Description:
d4809db37847 Changed repository layout and renamed project files. This revision is untested and may not run.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    13
 * Overview:
d4809db37847 Changed repository layout and renamed project files. This revision is untested and may not run.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    14
 * Details:
d4809db37847 Changed repository layout and renamed project files. This revision is untested and may not run.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    15
 * Platforms/Drives/Compatibility:
d4809db37847 Changed repository layout and renamed project files. This revision is untested and may not run.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    16
 * Assumptions/Requirement/Pre-requisites:
d4809db37847 Changed repository layout and renamed project files. This revision is untested and may not run.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    17
 * Failures and causes:
d4809db37847 Changed repository layout and renamed project files. This revision is untested and may not run.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    18
 */
d4809db37847 Changed repository layout and renamed project files. This revision is untested and may not run.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    19
package org.symbian.tools.tmw.previewer.http.handlers;
d4809db37847 Changed repository layout and renamed project files. This revision is untested and may not run.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    20
d4809db37847 Changed repository layout and renamed project files. This revision is untested and may not run.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    21
import java.io.IOException;
d4809db37847 Changed repository layout and renamed project files. This revision is untested and may not run.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    22
import java.io.InputStream;
d4809db37847 Changed repository layout and renamed project files. This revision is untested and may not run.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    23
import java.util.Map;
d4809db37847 Changed repository layout and renamed project files. This revision is untested and may not run.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    24
d4809db37847 Changed repository layout and renamed project files. This revision is untested and may not run.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    25
import org.eclipse.core.resources.IProject;
d4809db37847 Changed repository layout and renamed project files. This revision is untested and may not run.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    26
import org.eclipse.core.runtime.CoreException;
d4809db37847 Changed repository layout and renamed project files. This revision is untested and may not run.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    27
import org.eclipse.core.runtime.IPath;
d4809db37847 Changed repository layout and renamed project files. This revision is untested and may not run.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    28
import org.json.simple.JSONObject;
479
518afa7c6d2f Minor refactoring to make API more clear
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 470
diff changeset
    29
import org.symbian.tools.tmw.core.TMWCore;
518afa7c6d2f Minor refactoring to make API more clear
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 470
diff changeset
    30
import org.symbian.tools.tmw.core.projects.ITMWProject;
518afa7c6d2f Minor refactoring to make API more clear
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 470
diff changeset
    31
import org.symbian.tools.tmw.core.runtimes.IMobileWebRuntime;
470
d4809db37847 Changed repository layout and renamed project files. This revision is untested and may not run.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    32
d4809db37847 Changed repository layout and renamed project files. This revision is untested and may not run.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    33
public class WorkspaceResourceProvider implements IResourceProvider {
d4809db37847 Changed repository layout and renamed project files. This revision is untested and may not run.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    34
    public String[] getPaths() {
d4809db37847 Changed repository layout and renamed project files. This revision is untested and may not run.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    35
        return null;
d4809db37847 Changed repository layout and renamed project files. This revision is untested and may not run.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    36
    }
d4809db37847 Changed repository layout and renamed project files. This revision is untested and may not run.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    37
d4809db37847 Changed repository layout and renamed project files. This revision is untested and may not run.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    38
    public InputStream getResourceStream(IProject project, IPath resource, Map<String, String[]> parameters,
d4809db37847 Changed repository layout and renamed project files. This revision is untested and may not run.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    39
            String sessionId) throws CoreException {
479
518afa7c6d2f Minor refactoring to make API more clear
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 470
diff changeset
    40
        final ITMWProject p = TMWCore.create(project);
518afa7c6d2f Minor refactoring to make API more clear
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 470
diff changeset
    41
        if (p != null) {
518afa7c6d2f Minor refactoring to make API more clear
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 470
diff changeset
    42
            final IMobileWebRuntime targetRuntime = p.getTargetRuntime();
518afa7c6d2f Minor refactoring to make API more clear
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 470
diff changeset
    43
            if (targetRuntime != null) {
518afa7c6d2f Minor refactoring to make API more clear
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 470
diff changeset
    44
                return targetRuntime.getLayoutProvider().getResourceFromPath(project, resource);
518afa7c6d2f Minor refactoring to make API more clear
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 470
diff changeset
    45
            }
518afa7c6d2f Minor refactoring to make API more clear
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 470
diff changeset
    46
        }
518afa7c6d2f Minor refactoring to make API more clear
Eugene Ostroukhov <eugeneo@symbian.org>
parents: 470
diff changeset
    47
        return null;
470
d4809db37847 Changed repository layout and renamed project files. This revision is untested and may not run.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    48
    }
d4809db37847 Changed repository layout and renamed project files. This revision is untested and may not run.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    49
d4809db37847 Changed repository layout and renamed project files. This revision is untested and may not run.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    50
    public void post(IProject project, IPath resource, Map<String, String[]> parameterMap, JSONObject object,
d4809db37847 Changed repository layout and renamed project files. This revision is untested and may not run.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    51
            String sessionId) throws IOException, CoreException {
d4809db37847 Changed repository layout and renamed project files. This revision is untested and may not run.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    52
        // Do nothing
d4809db37847 Changed repository layout and renamed project files. This revision is untested and may not run.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    53
    }
d4809db37847 Changed repository layout and renamed project files. This revision is untested and may not run.
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
diff changeset
    54
}