Package org.exoplatform.ws.frameworks.json.value

Examples of org.exoplatform.ws.frameworks.json.value.JsonValue


         ArrayList<Object> sourceCollection = new ArrayList<Object>(jsonArray.size());
         Iterator<JsonValue> values = jsonArray.getElements();
         while (values.hasNext())
         {
            JsonValue v = values.next();
            if (!JsonUtils.isKnownType(actualType))
            {
               sourceCollection.add(createObject(actualType, v));
            }
            else
View Full Code Here


         HashMap<String, Object> sourceMap = new HashMap<String, Object>(jsonObject.size());
         Iterator<String> keys = jsonObject.getKeys();
         while (keys.hasNext())
         {
            String k = keys.next();
            JsonValue v = jsonObject.getElement(k);
            if (!JsonUtils.isKnownType(valueActualType))
            {
               sourceMap.put(k, createObject(valueActualType, v));
            }
            else
View Full Code Here

            // 3 is length of prefix 'set'
            String key = methodName.substring(3);
            // first letter to lower case
            key = (key.length() > 1) ? Character.toLowerCase(key.charAt(0)) + key.substring(1) : key.toLowerCase();

            JsonValue childJsonValue = jsonValue.getElement(key);
            if (childJsonValue == null)
            {
               continue;
            }
            // if one of known primitive type or array of primitive type
            try
            {

               if (JsonUtils.isKnownType(methodParameterClass))
               {
                  method.invoke(object, new Object[]{createObjectKnownTypes(methodParameterClass, childJsonValue)});
               }
               else
               {
                  Types parameterType = JsonUtils.getType(methodParameterClass);
                  // other type Collection, Map or Object[].
                  if (parameterType != null)
                  {
                     if (parameterType == Types.ENUM)
                     {
                        Class c = methodParameterClass;
                        Enum<?> en = Enum.valueOf(c, childJsonValue.getStringValue());
                        method.invoke(object, new Object[]{en});
                     }
                     else if (parameterType == Types.ARRAY_OBJECT)
                     {
                        Object array = createArray(methodParameterClass, childJsonValue);
View Full Code Here

      {
         String stringRepositoryEntry = null;
         try
         {
            JsonGeneratorImpl generatorImpl = new JsonGeneratorImpl();
            JsonValue json = generatorImpl.createJsonObject(rEntry);
            stringRepositoryEntry = json.toString();
         }
         catch (JsonException e)
         {
            throw new RepositoryCreationException("Can not serialize repository entry: " + e.getMessage(), e);
         }
View Full Code Here

   {
      JsonHandler jsonHandler = new JsonDefaultHandler();
      JsonParser jsonParser = new JsonParserImpl();
      InputStream inputStream = new ByteArrayInputStream(data);
      jsonParser.parse(inputStream, jsonHandler);
      JsonValue jsonValue = jsonHandler.getJsonObject();

      return new BeanBuilder().createObject(cl, jsonValue);
   }
View Full Code Here

                           + "/" + repositoryName + "/" + workspaceName;

         BackupConfigBean bean = new BackupConfigBean(BackupManager.FULL_BACKUP_ONLY, backupDir);

         JsonGeneratorImpl generatorImpl = new JsonGeneratorImpl();
         JsonValue json;
         try
         {
            json = generatorImpl.createJsonObject(bean);
         }
         catch (JsonException e)
         {
            throw new BackupExecuteException("Can not get json from  : " + bean.getClass().toString(), e);
         }

         BackupAgentResponse response = transport.executePOST(sURL, json.toString());

         if (response.getStatus() == Response.Status.OK.getStatusCode())
         {
            return "\nSuccessful : \n" + "\tstatus code = " + response.getStatus() + "\n";
         }
         else
         {
            return failureProcessing(response);
         }
      }
      else
      {
         String sURL =
                  path + HTTPBackupAgent.Constants.BASE_URL
                           + HTTPBackupAgent.Constants.OperationType.START_BACKUP_REPOSITORY + "/" + repositoryName;

         BackupConfigBean bean = new BackupConfigBean(BackupManager.FULL_BACKUP_ONLY, backupDir);

         JsonGeneratorImpl generatorImpl = new JsonGeneratorImpl();
         JsonValue json;
         try
         {
            json = generatorImpl.createJsonObject(bean);
         }
         catch (JsonException e)
         {
            throw new BackupExecuteException("Can not get json from  : " + bean.getClass().toString(), e);
         }

         BackupAgentResponse response = transport.executePOST(sURL, json.toString());

         if (response.getStatus() == Response.Status.OK.getStatusCode())
         {
            return "\nSuccessful : \n" + "\tstatus code = " + response.getStatus() + "\n";
         }
View Full Code Here

                           + "/" + repositoryName + "/" + workspaceName;

         BackupConfigBean bean = new BackupConfigBean(BackupManager.FULL_AND_INCREMENTAL, backupDir, incr);

         JsonGeneratorImpl generatorImpl = new JsonGeneratorImpl();
         JsonValue json;
         try
         {
            json = generatorImpl.createJsonObject(bean);
         }
         catch (JsonException e)
         {
            throw new BackupExecuteException("Can not get json from  : " + bean.getClass().toString(), e);
         }

         BackupAgentResponse response = transport.executePOST(sURL, json.toString());

         if (response.getStatus() == Response.Status.OK.getStatusCode())
         {
            return "\nSuccessful : \n" + "\tstatus code = " + response.getStatus() + "\n";
         }
         else
         {
            return failureProcessing(response);
         }
      }
      else
      {
         String sURL =
                  path + HTTPBackupAgent.Constants.BASE_URL
                           + HTTPBackupAgent.Constants.OperationType.START_BACKUP_REPOSITORY + "/" + repositoryName;

         BackupConfigBean bean = new BackupConfigBean(BackupManager.FULL_AND_INCREMENTAL, backupDir, incr);

         JsonGeneratorImpl generatorImpl = new JsonGeneratorImpl();
         JsonValue json;
         try
         {
            json = generatorImpl.createJsonObject(bean);
         }
         catch (JsonException e)
         {
            throw new BackupExecuteException("Can not get json from  : " + bean.getClass().toString(), e);
         }

         BackupAgentResponse response = transport.executePOST(sURL, json.toString());

         if (response.getStatus() == Response.Status.OK.getStatusCode())
         {
            return "\nSuccessful : \n" + "\tstatus code = " + response.getStatus() + "\n";
         }
View Full Code Here

               throw new BackupExecuteException("Can not get WorkspaceEntry for workspace '" + workspaceName
                        + "' from config.", e);
            }

            JsonGeneratorImpl generatorImpl = new JsonGeneratorImpl();
            JsonValue json;

            try
            {
               json = generatorImpl.createJsonObject(wEntry);
            }
            catch (JsonException e)
            {
               throw new BackupExecuteException("Can not get json from  : " + wEntry.getClass().toString(), e);
            }

            response = transport.executePOST(sURL, json.toString());
         }
      }
      else if (repositoryName != null)
      {
         if (config != null)
         {
            if (backupId != null)
            {
               sURL =
                        path + HTTPBackupAgent.Constants.BASE_URL
                                 + HTTPBackupAgent.Constants.OperationType.RESTORE_REPOSITORY + "/" + backupId + "/"
                                 + removeExists;
            }
            else if (backupSetPath != null)
            {
               sURL =
                        path + HTTPBackupAgent.Constants.BASE_URL
                                 + HTTPBackupAgent.Constants.OperationType.RESTORE_REPOSITORY_BACKUP_SET + "/"
                                 + removeExists + "?backup-set-path=" + backupSetPathEncoded;
            }
  
            RepositoryEntry wEntry = null;
            try
            {
               wEntry = getRepositoryEntry(config, repositoryName);
            }
            catch (Throwable e) //NOSONAR
            {
               throw new BackupExecuteException("Can not get RepositoryEntry for repository '" + repositoryName
                        + "' from config.", e);
            }
  
            JsonGeneratorImpl generatorImpl = new JsonGeneratorImpl();
            JsonValue json;
  
            try
            {
               json = generatorImpl.createJsonObject(wEntry);
            }
            catch (JsonException e)
            {
               throw new BackupExecuteException("Can not get json from  : " + wEntry.getClass().toString(), e);
            }
  
            response = transport.executePOST(sURL, json.toString());
         }
      }
      else
      {
         if (backupId != null)
View Full Code Here

   {
      JsonHandler jsonHandler = new JsonDefaultHandler();
      JsonParser jsonParser = new JsonParserImpl();
      InputStream inputStream = new ByteArrayInputStream(data);
      jsonParser.parse(inputStream, jsonHandler);
      JsonValue jsonValue = jsonHandler.getJsonObject();

      return new BeanBuilder().createObject(cl, jsonValue);
   }
View Full Code Here

      {
         String stringRepositoryEntry = null;
         try
         {
            JsonGeneratorImpl generatorImpl = new JsonGeneratorImpl();
            JsonValue json = generatorImpl.createJsonObject(rEntry);
            stringRepositoryEntry = json.toString();
         }
         catch (JsonException e)
         {
            throw new RepositoryCreationException("Can not serialize repository entry: " + e.getMessage(), e);
         }
View Full Code Here

TOP

Related Classes of org.exoplatform.ws.frameworks.json.value.JsonValue

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.