Package javax.activation

Examples of javax.activation.DataSource


               
                // retrieve config
                taskStatus = _taskStatusMap.get(CONFIGURATION_TASK);
                _config = null;
                try {
                    DataSource source = _server.getServices().getWGAConfiguration(_server.getSession());
                    _config = WGAConfiguration.read(source.getInputStream());
                    taskStatus.setSeverity(TaskStatus.OK);
                    taskStatus.setMessage("OK");
                    //taskStatus.setSeverityLabel("retrieved");
                    _multiTaskStatusControl.update(taskStatus);                   
                }
View Full Code Here


                                IPath remotePathObj = resource.getLocation();
                                int count = remotePathObj.matchingFirstSegments(_runtime.getDesignRoot().getLocation());
                                remotePathObj = remotePathObj.removeFirstSegments(count);
                                String remotePath = remotePathObj.toString();
                                if (resource.getType() == IResource.FILE) {
                                    DataSource content = new FileDataSource(((IFile) resource).getLocation().toFile());
                                    try {
                                        _remoteServer.getServices().updateFSDesignResource(_remoteServer.getSession(), remotePath, content, resource.getLocalTimeStamp());
                                    }
                                    catch (WGAServiceException e) {
                                        throw new CoreException(new Status(IStatus.ERROR, WGADesignerPlugin.PLUGIN_ID, "Creating design file failed.", e));
                                    }
                                }
                                else if (resource.getType() == IResource.FOLDER) {
                                    try {
                                        _remoteServer.getServices().mkFSDesignDir(_remoteServer.getSession(), remotePath);
                                    }
                                    catch (WGAServiceException e) {
                                        throw new CoreException(new Status(IStatus.ERROR, WGADesignerPlugin.PLUGIN_ID, "Creating design folder failed.", e));
                                    }
                                }
                                return true;
                            }
                        });
                        monitor.worked(1);

                        monitor.setTaskName("configuring content store");
                        WGAConfiguration localConfig = _runtime.retrieveWGAConfig(false);
                        ContentStore cs = localConfig.getContentStore(_webApplication);
                        cs.getDatabaseOptions().put(CS_PATH_OPTION_NAME, _remoteDatabaseName);
                        cs.setDbServer(_remoteDatabaseServer.getUid());
                        cs.setImplClassName(_remoteDatabaseServer.getCreateableContentStoreImplemenations().get(0));
                        String remoteDomainUID = null;
                        if (cs.getDomain().equals("default")) {
                            remoteDomainUID = "default";
                        } else {
                            String localDomainName = localConfig.getDomain(cs.getDomain()).getName();
                            remoteDomainUID = getDomainUID(_remoteWGAConfiguration, localDomainName);
                        }
                        cs.setDomain(remoteDomainUID);                       
                        _remoteWGAConfiguration.add(cs);
                        monitor.worked(1);

                        monitor.setTaskName("updating remote server configuration");
                        ByteArrayOutputStream out = new ByteArrayOutputStream();
                        WGAConfiguration.write(_remoteWGAConfiguration, out);
                        DataSource configDataSource = new ByteArrayDataSource(out.toByteArray(), "WGAConfiguration", "text/xml");
                        _remoteServer.getServices().updateWGAConfiguration(_remoteServer.getSession(), configDataSource);
                        monitor.worked(1);

                        monitor.setTaskName("waiting for remote content store to get available");
                        List<String> dbkeys = new ArrayList<String>();
                        long startTime = System.currentTimeMillis();
                        while (!dbkeys.contains(_webApplication)) {
                            if ((System.currentTimeMillis() - startTime) > 1000 * 60) {
                                throw new TimeoutException("Timeout waiting for remote content store.");
                            }
                            Thread.sleep(2000);
                            dbkeys = _remoteServer.getServices().getConnectedContentDatabases(_remoteServer.getSession());
                        }
                        monitor.worked(1);

                        if (isCopyContent()) {
                            // create local database dump
                            monitor.setTaskName("creating content store dump");
                            WGARemoteServer server = new WGARemoteServer("local", _runtime.getRootURL(), "unused", "unused");
                            server.connectToServer(5*1000, 0);

                            DataSource csDump = server.getServices().createContentStoreDump(server.getSession(), _webApplication, isIncludeACL(), true);
                            monitor.worked(1);

                            // import dump on remote db
                            monitor.setTaskName("importing content store dump in remote database");
                            _remoteServer.getServices().importContentStoreDump(_remoteServer.getSession(), csDump, _webApplication, isIncludeACL(), true);
View Full Code Here

      dispatch.getRequestContext().put(MessageContext.HTTP_REQUEST_METHOD, method);
      if (payload != null && !"POST".equalsIgnoreCase(method)) { //$NON-NLS-1$
        throw new WebServiceException(WSExecutionFactory.UTIL.getString("http_usage_error")); //$NON-NLS-1$
      }

      DataSource ds = null;
      if (payload instanceof String) {
        ds = new InputStreamFactory.ClobInputStreamFactory(new SerialClob(((String)payload).toCharArray()));
      } else if (payload instanceof SQLXML) {
        ds = new InputStreamFactory.SQLXMLInputStreamFactory((SQLXML)payload);
      } else if (payload instanceof Clob) {
View Full Code Here

        MimeMultipart content = new MimeMultipart("related");

        //Create attachments
        DataSource[] attachments = mailMessage.getAttachments();
        for (int i = 0; i < attachments.length; i++) {
            DataSource attachment = attachments[i];
            MimeBodyPart attachmentPart = createAttachmentPart(attachment);
            content.addBodyPart(attachmentPart);
        }
       
        //Create message body
View Full Code Here

  public IStorage getStorage(IProgressMonitor monitor) {
    if (_server != null) {
      try {
        monitor.beginTask("Retrieving content of design resource '" + _state.getPath() + "'.", 1);
        _server.connectToServer();
        DataSource source = _server.getServices().retrieveFSDesignResourceContent(_server.getSession(), _state);
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        WGUtils.inToOut(source.getInputStream(), out, 1024);
        monitor.worked(1);
        return new WGAFSDesignResourceStorage(_state, out.toByteArray());
      } catch (Exception e) {
        monitor.setCanceled(true);
        return null;
View Full Code Here

  public byte[] asBytes() {
    if (_server != null) {
      try {
        _server.connectToServer();
        DataSource source = _server.getServices().retrieveFSDesignResourceContent(_server.getSession(), _state);
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        WGUtils.inToOut(source.getInputStream(), out, 1024);
        return out.toByteArray();
      } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
View Full Code Here

                  monitor.setTaskName("adding '" + remotePath + "'.");
                } else {
                  monitor.setTaskName("updating '" + remotePath + "'.");
                }
                if (resource.getType() == IResource.FILE) {
                  DataSource content = new FileDataSource(((IFile)resource).getLocation().toFile());
                  wgaSyncInfo.getServer().getServices().updateFSDesignResource(session, remotePath, content, resource.getLocalTimeStamp());
                  committedResources.add(resource);
                } else if (resource.getType() == IResource.FOLDER) {
                  wgaSyncInfo.getServer().getServices().mkFSDesignDir(session, remotePath);
                  committedResources.add(resource);
                }             
              }
            }
           
          } catch (Exception e) {
            throw new InvocationTargetException(e);
          }       
        } else if (info instanceof WGAPluginResourceSyncInfo) {
            try {
                WGAPluginResourceSyncInfo wgaSyncInfo = (WGAPluginResourceSyncInfo) info;
                if ((wgaSyncInfo.getKind() & SyncInfo.CONFLICTING) != SyncInfo.CONFLICTING) {
                    int change = SyncInfo.getChange(wgaSyncInfo.getKind());
                            if (change == SyncInfo.DELETION) {
                                WGARemoteServer remote = wgaSyncInfo.getServer();
                                remote.getServices().deactivatePlugin(remote.getSession(), ((WGAPluginResourceVariant)wgaSyncInfo.getRemote()).getPluginInfo());    
                                committedResources.add(wgaSyncInfo.getLocal());
                            } else if (change == SyncInfo.ADDITION) {
                                WGARemoteServer local = wgaSyncInfo.getRuntime().createRemoteServer();
                                local.connectToServer();
                                DataSource plugin = local.getServices().downloadPlugin(local.getSession(), wgaSyncInfo.getLocalPluginInfo());
                                WGARemoteServer remote = wgaSyncInfo.getServer();
                                remote.getServices().installPlugins(remote.getSession(), Collections.singletonList(plugin));
                                remote.getServices().activatePlugin(remote.getSession(), wgaSyncInfo.getLocalPluginInfo());
                                committedResources.add(wgaSyncInfo.getLocal());
                            }
View Full Code Here

  }

  public void sendLoginLink(String email, String loginLink) {


    DataSource htmlDataSource = getHtmlDataSource(loginLink);
    DataSource textDataSource = getTextDataSource(loginLink);

    Transport transport;
    try {
      transport = session.getTransport();
      transport.connect();
View Full Code Here

  /**
   * @param loginLink
   * @return
   */
  private static DataSource getTextDataSource(final String loginLink) {
    return new DataSource() {

      public String getContentType() {
        return "text/plain; charset=UTF-8";
      }

View Full Code Here

  /**
   * @param loginLink
   * @return
   */
  private static DataSource getHtmlDataSource(final String loginLink) {
    return new DataSource() {

      public String getContentType() {
        return "text/html";
      }

View Full Code Here

TOP

Related Classes of javax.activation.DataSource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.