import java.io.Serializable;
+import javax.portlet.PortletContext;
+import javax.servlet.ServletContext;
+
/**
* Provide deployment specific settings that are required outside terminal
* specific code.
* @return the class loader to use, or <code>null</code>
*/
public ClassLoader getClassLoader();
+
+ /**
+ * Returns the MIME type of the specified file, or null if the MIME type is
+ * not known. The MIME type is determined by the configuration of the
+ * container, and may be specified in a deployment descriptor. Common MIME
+ * types are "text/html" and "image/gif".
+ *
+ * @param resourceName
+ * a String specifying the name of a file
+ * @return a String specifying the file's MIME type
+ *
+ * @see ServletContext#getMimeType(String)
+ * @see PortletContext#getMimeType(String)
+ */
+ public String getMimeType(String resourceName);
}
}
uidlUri = themeUri + uidlUri.substring(7);
}
+
+ if (uidlUri.startsWith(CONNECTOR_PROTOCOL_PREFIX)) {
+ // getAppUri *should* always end with /
+ // substring *should* always start with / (connector:///foo.bar
+ // without connector://)
+ uidlUri = "app://" + CONNECTOR_RESOURCE_PREFIX
+ + uidlUri.substring(CONNECTOR_PROTOCOL_PREFIX.length());
+ // Let translation of app:// urls take care of the rest
+ }
if (uidlUri.startsWith("app://")) {
String relativeUrl = uidlUri.substring(6);
if (getConfiguration().usePortletURLs()) {
} else {
uidlUri = getAppUri() + relativeUrl;
}
- } else if (uidlUri.startsWith(CONNECTOR_PROTOCOL_PREFIX)) {
- // getAppUri *should* always end with /
- // substring *should* always start with / (connector:///foo.bar
- // without connector://)
- uidlUri = getAppUri() + CONNECTOR_RESOURCE_PREFIX
- + uidlUri.substring(CONNECTOR_PROTOCOL_PREFIX.length());
}
return uidlUri;
}
// #8574)
return null;
}
+
+ @Override
+ public String getMimeType(String resourceName) {
+ return getPortletContext().getMimeType(resourceName);
+ }
};
@Override
}
protected enum RequestType {
- FILE_UPLOAD, UIDL, RENDER, STATIC_FILE, APPLICATION_RESOURCE, DUMMY, EVENT, ACTION, UNKNOWN, BROWSER_DETAILS;
+ FILE_UPLOAD, UIDL, RENDER, STATIC_FILE, APPLICATION_RESOURCE, DUMMY, EVENT, ACTION, UNKNOWN, BROWSER_DETAILS, CONNECTOR_RESOURCE;
}
protected RequestType getRequestType(WrappedPortletRequest wrappedRequest) {
return RequestType.BROWSER_DETAILS;
} else if (ServletPortletHelper.isFileUploadRequest(wrappedRequest)) {
return RequestType.FILE_UPLOAD;
+ } else if (ServletPortletHelper
+ .isConnectorResourceRequest(wrappedRequest)) {
+ return RequestType.CONNECTOR_RESOURCE;
} else if (ServletPortletHelper
.isApplicationResourceRequest(wrappedRequest)) {
return RequestType.APPLICATION_RESOURCE;
PortletCommunicationManager applicationManager = applicationContext
.getApplicationManager(application);
+ if (requestType == RequestType.CONNECTOR_RESOURCE) {
+ applicationManager.serveConnectorResource(wrappedRequest,
+ wrappedResponse);
+ return;
+ }
+
/* Update browser information from request */
applicationContext.getBrowser().updateRequestDetails(
wrappedRequest);
throw new RuntimeException(e);
}
}
+
+ @Override
+ public String getMimeType(String resourceName) {
+ return getServletContext().getMimeType(resourceName);
+ }
};
/**
.getApplicationManager(application, this);
if (requestType == RequestType.CONNECTOR_RESOURCE) {
- String pathInfo = getRequestPathInfo(request);
- // + 2 to also remove beginning and ending slashes
- String resourceName = pathInfo
- .substring(ApplicationConnection.CONNECTOR_RESOURCE_PREFIX
- .length() + 2);
-
- final String mimetype = getServletContext().getMimeType(
- resourceName);
-
- applicationManager.serveConnectorResource(resourceName,
- request, response, mimetype);
+ applicationManager.serveConnectorResource(request, response);
return;
}
* including a {@link JavaScript} or {@link StyleSheet} annotation on a
* Connector class.
*
- * @param resourceName
* @param request
* @param response
- * @param mimetype
+ *
* @throws IOException
*/
- public void serveConnectorResource(String resourceName,
- WrappedRequest request, WrappedResponse response, String mimetype)
- throws IOException {
+ public void serveConnectorResource(WrappedRequest request,
+ WrappedResponse response) throws IOException {
+
+ String pathInfo = request.getRequestPathInfo();
+ // + 2 to also remove beginning and ending slashes
+ String resourceName = pathInfo
+ .substring(ApplicationConnection.CONNECTOR_RESOURCE_PREFIX
+ .length() + 2);
+
+ final String mimetype = response.getDeploymentConfiguration()
+ .getMimeType(resourceName);
+
// Security check: avoid accidentally serving from the root of the
// classpath instead of relative to the context class
if (resourceName.startsWith("/")) {
import javax.portlet.WindowState;
import com.vaadin.Application;
+import com.vaadin.annotations.StyleSheet;
import com.vaadin.terminal.ExternalResource;
import com.vaadin.terminal.gwt.client.ui.label.ContentMode;
import com.vaadin.terminal.gwt.server.PortletApplicationContext2;
*/
public class JSR286PortletApplication extends Application.LegacyApplication {
- LegacyWindow main = new LegacyWindow();
+ @StyleSheet("PortletConnectorResource.css")
+ public final class LegacyWindowWithStylesheet extends LegacyWindow {
+
+ }
+
+ LegacyWindow main = new LegacyWindowWithStylesheet();
TextField tf = new TextField("Some value");
Label userInfo = new Label();
Link portletEdit = new Link();
Embedded specialNameResourceTest = new Embedded(
"Test ApplicationResources with special names",
new SpecialNameResource(this));
+ specialNameResourceTest.addStyleName("hugeBorder");
main.addComponent(specialNameResourceTest);
userInfo.setCaption("User info");
--- /dev/null
+.hugeBorder {
+ border: 10px solid green;
+}
\ No newline at end of file