Package com.dotmarketing.util.json

Examples of com.dotmarketing.util.json.JSONObject


    URL publishUrl = new URL( completeURL );
    String response = IOUtils.toString( publishUrl.openStream(), "UTF-8" );
    /*
     * Validations
     */
    JSONObject jsonResponse = new JSONObject( response );
    assertEquals( jsonResponse.getInt( "errors" ), 0 );
    assertEquals( jsonResponse.getInt( "total" ), 1 );
    assertNotNull( jsonResponse.get( "bundleId" ) );

    /*
     * Now that we have a bundle id
     */
    String bundleId = jsonResponse.getString( "bundleId" );
    /*
     * First we need to verify if this bundle is in the queue job
     */
    List<PublishQueueElement> foundBundles = publisherAPI.getQueueElementsByBundleId( bundleId );
    assertNotNull( foundBundles );
View Full Code Here


    URL publishUrl = new URL( completeURL );
    String response = IOUtils.toString( publishUrl.openStream(), "UTF-8" );
    /*
     * Validations
     */
    JSONObject jsonResponse = new JSONObject( response );
    assertEquals( jsonResponse.getInt( "errors" ), 0 );
    assertEquals( jsonResponse.getInt( "total" ), 1 );
    assertNotNull( jsonResponse.get( "bundleId" ) );

    /*
     * Now that we have a bundle id
     */
    String bundleId = jsonResponse.getString( "bundleId" );
    /*
     * First we need to verify if this bundle is in the queue job
     */
    List<PublishQueueElement> foundBundles = publisherAPI.getQueueElementsByBundleId( bundleId );
    assertNotNull( foundBundles );
View Full Code Here

      filesInputStream = new URL(autoUpdaterFilesQuery).openStream();
      versionsInputStream = new URL(autoUpdaterVersionsQuery).openStream();
      BufferedReader filesReader = new BufferedReader(new InputStreamReader(filesInputStream, Charset.forName("UTF-8")));
      BufferedReader versionsReader = new BufferedReader(new InputStreamReader(versionsInputStream, Charset.forName("UTF-8")));
      String filesText = UtilMethods.getStringFromReader(filesReader);
      JSONObject filesJSON  = new JSONObject(filesText);
      String versionsText = UtilMethods.getStringFromReader(versionsReader);
      JSONObject versionsJSON  = new JSONObject(versionsText);
      JSONArray majorArr = versionsJSON.getJSONArray("contentlets");
      JSONArray minorArr = filesJSON.getJSONArray("contentlets");
     
      if(minorArr.size()>0){
        String versionsFilesQuery = "http://dotcms.com/JSONContent/?type=json&q="+
        URLEncoder.encode("+Parent_Versions-Child_Files:"+minorArr.getJSONObject(0).getString("identifier")+" +deleted:false +live:true","UTF-8")+
        "&limit=1&orderBy=AutoupdaterFiles.releasedDate%20desc";
        versionsFilesQueryIs = new URL(versionsFilesQuery).openStream();
        BufferedReader versionsFilesReader = new BufferedReader(new InputStreamReader(versionsFilesQueryIs, Charset.forName("UTF-8")));
        String versionsFilesText = UtilMethods.getStringFromReader(versionsFilesReader);
        JSONObject versionsFilesJSON  = new JSONObject(versionsFilesText);
        JSONArray versionsFilesArr = versionsFilesJSON.getJSONArray("contentlets");
        if(versionsFilesArr.size()>0){
          if(versionsFilesQueryIs!=null){
            versionsFilesQueryIs.close();
          }
          versionsFilesQuery = "http://dotcms.com/JSONContent/?type=json&q="+
          URLEncoder.encode("+Parent_Versions-Child_Files:"+versionsFilesArr.getJSONObject(0).getString("identifier")+" -AutoupdaterFiles.minor:autoupdater_* +AutoupdaterFiles.released:true +deleted:false +working:true", "UTF-8")+
          "&limit=1&orderBy=AutoupdaterFiles.releasedDate%20desc";
          versionsFilesQueryIs = new URL(versionsFilesQuery).openStream();
          versionsFilesReader = new BufferedReader(new InputStreamReader(versionsFilesQueryIs, Charset.forName("UTF-8")));
          versionsFilesText = UtilMethods.getStringFromReader(versionsFilesReader);
          versionsFilesJSON  = new JSONObject(versionsFilesText);
          versionsFilesArr = versionsFilesJSON.getJSONArray("contentlets");
          minor = versionsFilesArr.getJSONObject(0).getString("minor");
        }


      }
      if(majorArr.size()>0){
        for(int i=0;i<majorArr.size();i++){
          if(versionsFilesQueryIs!=null){
            versionsFilesQueryIs.close();
          }
          major = majorArr.getJSONObject(i).getString("major");
          String majorIdentifier = majorArr.getJSONObject(i).getString("identifier");
          String versionsFilesQuery = "http://dotcms.com/JSONContent/?type=json&q="+
          URLEncoder.encode("+Parent_Versions-Child_Files:"+majorIdentifier+" +AutoupdaterFiles.released:true -AutoupdaterFiles.minor:autoupdater_* +deleted:false +live:true","UTF-8")+
          "&limit=1&orderBy=AutoupdaterFiles.releasedDate%20desc";
          versionsFilesQueryIs = new URL(versionsFilesQuery).openStream();
          BufferedReader versionsFilesReader = new BufferedReader(new InputStreamReader(versionsFilesQueryIs, Charset.forName("UTF-8")));
          String versionsFilesText = UtilMethods.getStringFromReader(versionsFilesReader);
          JSONObject versionsFilesJSON  = new JSONObject(versionsFilesText);
          JSONArray versionsFilesArr = versionsFilesJSON.getJSONArray("contentlets");
          if(versionsFilesArr.size()>0){
            break;
          }else{
            major = "";
          }
View Full Code Here

      for ( WorkflowAction action : wfActions ) {
        boolean hasPushPublishActionlet = false;
                if ( action.requiresCheckout() )
                    continue;

                JSONObject wfActionMap = new JSONObject();
                try {
          wfActionMap.put( "name", action.getName() );
                  wfActionMap.put( "id", action.getId() );
                  wfActionMap.put( "icon", action.getIcon() );
                  wfActionMap.put( "assignable", action.isAssignable() );
                  wfActionMap.put( "commentable", action.isCommentable() || UtilMethods.isSet( action.getCondition() ) );
                  wfActionMap.put( "requiresCheckout", action.requiresCheckout() );

                  List<WorkflowActionClass> actionlets = APILocator.getWorkflowAPI().findActionClasses(action);
                  for(WorkflowActionClass actionlet : actionlets){
                    if(actionlet.getActionlet() != null
                        && actionlet.getActionlet().getClass().getCanonicalName().equals(PushPublishActionlet.class.getCanonicalName())){
                      hasPushPublishActionlet = true;
                    }
                  }
                  wfActionMap.put( "hasPushPublishActionlet", hasPushPublishActionlet );
                  try {
            wfActionMap.put( "wfActionNameStr", LanguageUtil.get( currentUser, action.getName() ) );
          } catch (LanguageException e) {
            Logger.error( this, "Could not load language key : " + action.getName() );
          }
                  wfActionMapList.add( wfActionMap );
View Full Code Here

            //Update the company
            CompanyManagerUtil.updateCompany( currentCompany );

            //And prepare the response
            JSONObject jsonResponse = new JSONObject();
            jsonResponse.put( "success", true );
            jsonResponse.put( "message", LanguageUtil.get( initData.getUser().getLocale(), "you-have-successfully-updated-the-company-profile" ) );
            responseMessage.append( jsonResponse.toString() );
        } catch ( Exception e ) {
            Logger.error( this.getClass(), "Error saving basic information for current company.", e );

            if ( e.getMessage() != null ) {
                responseMessage.append( e.getMessage() );
View Full Code Here

            //Updating the locale info
            CompanyManagerUtil.updateUsers( languageId, timeZoneId, null, false, false, null );
            TimeZone.setDefault( TimeZone.getTimeZone( timeZoneId ) );

            //And prepare the response
            JSONObject jsonResponse = new JSONObject();
            jsonResponse.put( "success", true );
            jsonResponse.put( "message", LanguageUtil.get( initData.getUser().getLocale(), "you-have-successfully-updated-the-company-profile" ) );
            responseMessage.append( jsonResponse.toString() );
        } catch ( Exception e ) {
            Logger.error( this.getClass(), "Error saving basic information for current company.", e );

            if ( e.getMessage() != null ) {
                responseMessage.append( e.getMessage() );
View Full Code Here

            //Update the company
            CompanyManagerUtil.updateCompany( currentCompany );

            //And prepare the response
            JSONObject jsonResponse = new JSONObject();
            jsonResponse.put( "success", true );
            jsonResponse.put( "message", LanguageUtil.get( initData.getUser().getLocale(), "you-have-successfully-updated-the-company-profile" ) );
            responseMessage.append( jsonResponse.toString() );
        } catch ( Exception e ) {
            Logger.error( this.getClass(), "Error saving basic information for current company.", e );

            if ( e.getMessage() != null ) {
                responseMessage.append( e.getMessage() );
View Full Code Here

                    }
                }
            }

            //And prepare the response
            JSONObject jsonResponse = new JSONObject();
            jsonResponse.put( "success", true );
            jsonResponse.put( "message", LanguageUtil.get( initData.getUser().getLocale(), "publisher_Environment_deleted" ) );
            responseMessage.append( jsonResponse.toString() );
        } catch ( Exception e ) {
            Logger.error( this.getClass(), "Error deleting Environment: " + environment, e );

            if ( e.getMessage() != null ) {
                responseMessage.append( e.getMessage() );
View Full Code Here

                }
            }


            //And prepare the response
            JSONObject jsonResponse = new JSONObject();
            jsonResponse.put( "success", true );
            jsonResponse.put( "message", LanguageUtil.get( initData.getUser().getLocale(), "publisher_End-Point_deleted" ) );
            responseMessage.append( jsonResponse.toString() );
        } catch ( Exception e ) {
            Logger.error( this.getClass(), "Error deleting End Point: " + endPoint, e );

            if ( e.getMessage() != null ) {
                responseMessage.append( e.getMessage() );
View Full Code Here

        InitDataObject initData = init( params, true, request, false, "9" );
        ResourceResponse responseResource = new ResourceResponse( initData.getParamsMap() );
        View view = ((DotGuavaCacheAdministratorImpl)CacheLocator.getCacheAdministrator().getImplementationObject()).getView();
        JChannel channel = ((DotGuavaCacheAdministratorImpl)CacheLocator.getCacheAdministrator().getImplementationObject()).getChannel();
        JSONObject jsonClusterStatusObject = new JSONObject();

        if(view!=null) {
          List<Address> members = view.getMembers();
          jsonClusterStatusObject.put( "clusterName", channel.getClusterName());
          jsonClusterStatusObject.put( "open", channel.isOpen());
          jsonClusterStatusObject.put( "numberOfNodes", members.size());
          jsonClusterStatusObject.put( "address", channel.getAddressAsString());
          jsonClusterStatusObject.put( "receivedBytes", channel.getReceivedBytes());
          jsonClusterStatusObject.put( "receivedMessages", channel.getReceivedMessages());
          jsonClusterStatusObject.put( "sentBytes", channel.getSentBytes());
          jsonClusterStatusObject.put( "sentMessages", channel.getSentMessages());
        }


        return responseResource.response( jsonClusterStatusObject.toString() );

    }
View Full Code Here

TOP

Related Classes of com.dotmarketing.util.json.JSONObject

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.