Package com.maverick.util

Examples of com.maverick.util.ByteArrayWriter


                  filteredResources.add(resource);
              }
          }
         
          // Send the list of resource IDs and names back to the agent
          ByteArrayWriter response = new ByteArrayWriter();
          response.writeInt(filteredResources.size());
          for (Resource resource : filteredResources) {
            response.writeInt(resource.getResourceId());
            response.writeString(resource.getResourceDisplayName());
          }
          request.setRequestData(response.toByteArray());
          return true;
        }
      } catch (Exception e) {
        log.error("Failed to get resources.", e);
      }
View Full Code Here


        }
        return sent;
    }
   
    private boolean send(Message message, Recipient recipient, SessionInfo info) throws IOException {
        ByteArrayWriter msg = new ByteArrayWriter();
        msg.writeString(message.getSubject());
        msg.writeInt(0);
        msg.writeString(message.getContent());

        DefaultAgentManager agentManager = DefaultAgentManager.getInstance();
        if (agentManager.hasActiveAgent(info) && info.getUser().getPrincipalName().equals(recipient.getRecipientAlias())) {
            try {
                Request request = new Request("agentMessage", msg.toByteArray());
                AgentTunnel tunnel = agentManager.getAgentBySession(info);
                if (tunnel != null) {
                    tunnel.sendRequest(request, false, 0);
                    return true;
                }
View Full Code Here

   *         launched
   * @throws Exception
   */
  public Request launchApplication(LaunchSession launchSession) throws Exception {
    ApplicationShortcut shortcut = (ApplicationShortcut) launchSession.getResource();
    ByteArrayWriter msg = new ByteArrayWriter();
   
    // If this is a service side application launcher then launch now and inform the agent not to go any further
    ExtensionDescriptor descriptor = ExtensionStore.getInstance().getExtensionDescriptor(shortcut.getApplication());
    if(((ApplicationLauncherType)descriptor.getExtensionType()).isServerSide()) {
      msg.writeBoolean(true);


      // Do the launch
      try {
        if(descriptor.getApplicationBundle().getStatus() != ExtensionBundleStatus.ACTIVATED) {
          throw new Exception("Extension bundle " + descriptor.getApplicationBundle().getId() +" is not activated, cannot launch applicaiton.");
        }
       
        ((ApplicationLauncherType) descriptor.getExtensionType()).launch(new HashMap<String, String>(),
          descriptor,
          shortcut,
          null,
          launchSession,
          null,
          null);

        CoreServlet.getServlet().fireCoreEvent(new ResourceAccessEvent(this,
                ApplicationShortcutEventConstants.APPLICATION_SHORTCUT_LAUNCHED,
                launchSession.getResource(),
                launchSession.getPolicy(),
                launchSession.getSession(),
                CoreEvent.STATE_SUCCESSFUL).addAttribute(CoreAttributeConstants.EVENT_ATTR_APPLICATION_NAME,
          descriptor.getName()).addAttribute(CoreAttributeConstants.EVENT_ATTR_APPLICATION_ID, descriptor.getId()));

      } catch (Exception ex) {
        CoreServlet.getServlet().fireCoreEvent(new ResourceAccessEvent(this,
            ApplicationShortcutEventConstants.APPLICATION_SHORTCUT_LAUNCHED,
                launchSession.getSession(),
                ex).addAttribute(CoreAttributeConstants.EVENT_ATTR_APPLICATION_NAME, descriptor.getName())
                .addAttribute(CoreAttributeConstants.EVENT_ATTR_APPLICATION_ID, descriptor.getId()));
        throw ex;

      }
    }
    else {   
      msg.writeBoolean(false);
      msg.writeString(shortcut.getApplication());
      msg.writeInt(shortcut.getResourceId());
      msg.writeString(launchSession.getId());
      msg.writeString(ExtensionParser.processApplicationParameters(launchSession,
        new Properties(),
        shortcut.getParameters(),
        shortcut.getApplication()));
    }
   
    return new Request("launchApplication", msg.toByteArray());
  }
View Full Code Here

     */
    public synchronized boolean processRequest(Request request,
        MultiplexedConnection connection) {
      try {
        notifyAll();
        ByteArrayWriter baw = new ByteArrayWriter();
        try {
          baw.writeString(VersionInfo.getVersion().toString());
          request.setRequestData(baw.toByteArray());
          return true;
        } catch (IOException e) {
          log.error("Failed to send back server version.");
          return false;
        }
View Full Code Here

      try {
        ByteArrayReader reader = new ByteArrayReader(request.getRequestData());
       
        int type = (int)reader.readInt();
        String name = reader.readString();
        ByteArrayWriter baw = new ByteArrayWriter();
       
        switch(type) {
          case PROFILE:
          {
            baw.writeString(Property.getProperty(new ProfilePropertyKey(name, tunnel.getSession())));
            break;
          }
          case SYSTEM:
          {
            baw.writeString(Property.getProperty(new SystemConfigKey(name)));           
            break;
          }
          case REALM:
          {
            baw.writeString(Property.getProperty(new RealmKey(name, tunnel.getSession().getRealmId())));
          }
          default:
          {
            log.error("Agent requested invalid property type!");
            return false;
          }
        }
       
       
        request.setRequestData(baw.toByteArray());
        return true;
     
      } catch(Exception ex) {
        log.error(ex);
        return false;
View Full Code Here

        DefaultAgentManager.getInstance().getAgentBroadcastExecutor().execute(new Runnable() {
          public void run() {           
            Collection<AgentTunnel> agents = DefaultAgentManager.getInstance().getAgents();
            synchronized(agents) {
              for(AgentTunnel agent : agents) {
                ByteArrayWriter baw = new ByteArrayWriter();
                try {
                  baw.writeInt(resourceType.getResourceTypeId());
                  synchronized(agent) {
                    agent.sendRequest(new Request(AgentTunnel.UPDATE_RESOURCES_REQUEST, baw.toByteArray()), false);
                  }
                }
                catch(IOException ioe) {
                  log.warn("Failed to send resource update request to agent " + agent.getId() + ".", ioe);
                }
View Full Code Here

TOP

Related Classes of com.maverick.util.ByteArrayWriter

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.