repo_name stringlengths 7 104 | file_path stringlengths 13 198 | context stringlengths 67 7.15k | import_statement stringlengths 16 4.43k | code stringlengths 40 6.98k | prompt stringlengths 227 8.27k | next_line stringlengths 8 795 |
|---|---|---|---|---|---|---|
OfficeDev/Property-Inspection-Code-Sample | AndroidRepairApp/app/src/main/java/com/canviz/repairapp/SigninActivity.java | // Path: AndroidRepairApp/app/src/main/java/com/canviz/repairapp/utility/AuthenticationHelper.java
// public class AuthenticationHelper {
//
// private static Activity mActivity;
// public static AuthenticationContext mAADAuthContext = null;
//
// final static String TAG = "AuthenticationHelper";
//
// public static void initialize(Activity activity) throws NoSuchPaddingException, NoSuchAlgorithmException {
// mActivity = activity;
// mAADAuthContext = new AuthenticationContext(
// mActivity.getApplicationContext(),
// Constants.AAD_AUTHORITY,
// false);
// }
//
// public static AuthenticationContext getAuthenticationContext() {
// return mAADAuthContext;
// }
//
// public static void acquireToken(String serverUrl, AuthenticationCallback<AuthenticationResult> callback) {
// getAuthenticationContext().acquireToken(
// mActivity,
// serverUrl,
// Constants.AAD_CLIENT_ID,
// Constants.AAD_REDIRECT_URL,
// PromptBehavior.Auto,
// callback);
// }
//
// public static void acquireTokenSilent(String resource, String userId,AuthenticationCallback<AuthenticationResult> callback){
// getAuthenticationContext().acquireTokenSilent(
// resource,
// Constants.AAD_CLIENT_ID,
// userId,
// callback);
// }
//
// public static SettableFuture<String> acquireToken(String resource){
// final SettableFuture<String> future = SettableFuture.create();
// try {
// getAuthenticationContext().acquireToken(
// mActivity,
// resource,
// Constants.AAD_CLIENT_ID,
// Constants.AAD_REDIRECT_URL,
// PromptBehavior.Auto,
// new AuthenticationCallback<AuthenticationResult>() {
// @Override
// public void onSuccess(AuthenticationResult authenticationResult) {
// future.set(authenticationResult.getAccessToken());
// }
//
// @Override
// public void onError(Exception e) {
// future.setException(e);
// }
// });
// } catch (Throwable t) {
// future.setException(t);
// }
//
// return future;
// }
//
// public static ListClient getSharePointListClient(String accessToken) {
// OAuthCredentials credentials = new OAuthCredentials(accessToken);
// return new ListClient(Constants.SHAREPOINT_URL, Constants.SHAREPOINT_SITE_PATH, credentials);
// }
//
// private static DependencyResolver getDependencyResolver(final String token) {
// DefaultDependencyResolver dependencyResolver = new DefaultDependencyResolver(token);
// dependencyResolver.getLogger().setEnabled(true);
// dependencyResolver.getLogger().setLogLevel(LogLevel.VERBOSE);
// return dependencyResolver;
// }
//
// public static IGraphServiceClient getGraphServiceClient(Application app, String token){
// return new GraphServiceClient
// .Builder()
// .fromConfig(DefaultClientConfig.createWithAuthenticationProvider(new GraphAuthenticationProvider(app, token)))
// .buildClient();
// }
//
// public static SettableFuture<String> getGraphAccessToken(){
// final SettableFuture<String> future = SettableFuture.create();
// try {
// getAuthenticationContext().acquireToken(
// mActivity,
// Constants.GRAPH_RESOURCE_ID,
// Constants.AAD_CLIENT_ID,
// Constants.AAD_REDIRECT_URL,
// PromptBehavior.Auto,
// new AuthenticationCallback<AuthenticationResult>() {
// @Override
// public void onSuccess(AuthenticationResult authenticationResult) {
// future.set(authenticationResult.getAccessToken());
// }
//
// @Override
// public void onError(Exception e) {
// future.setException(e);
// }
// });
// } catch (Throwable t) {
// future.setException(t);
// }
// return future;
// }
// }
| import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import java.security.NoSuchAlgorithmException;
import javax.crypto.NoSuchPaddingException;
import com.canviz.repairapp.utility.AuthenticationHelper;
import com.canviz.repairapp.utility.Helper;
import com.microsoft.aad.adal.AuthenticationCallback;
import com.microsoft.aad.adal.AuthenticationContext;
import com.microsoft.aad.adal.AuthenticationResult;
import com.microsoft.aad.adal.PromptBehavior;
import com.microsoft.services.sharepoint.ListClient; | package com.canviz.repairapp;
public class SigninActivity extends Activity {
private App mApp;
private Button signInBtn;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_signin);
mApp = (App) getApplication();
setIncidentId();
try { | // Path: AndroidRepairApp/app/src/main/java/com/canviz/repairapp/utility/AuthenticationHelper.java
// public class AuthenticationHelper {
//
// private static Activity mActivity;
// public static AuthenticationContext mAADAuthContext = null;
//
// final static String TAG = "AuthenticationHelper";
//
// public static void initialize(Activity activity) throws NoSuchPaddingException, NoSuchAlgorithmException {
// mActivity = activity;
// mAADAuthContext = new AuthenticationContext(
// mActivity.getApplicationContext(),
// Constants.AAD_AUTHORITY,
// false);
// }
//
// public static AuthenticationContext getAuthenticationContext() {
// return mAADAuthContext;
// }
//
// public static void acquireToken(String serverUrl, AuthenticationCallback<AuthenticationResult> callback) {
// getAuthenticationContext().acquireToken(
// mActivity,
// serverUrl,
// Constants.AAD_CLIENT_ID,
// Constants.AAD_REDIRECT_URL,
// PromptBehavior.Auto,
// callback);
// }
//
// public static void acquireTokenSilent(String resource, String userId,AuthenticationCallback<AuthenticationResult> callback){
// getAuthenticationContext().acquireTokenSilent(
// resource,
// Constants.AAD_CLIENT_ID,
// userId,
// callback);
// }
//
// public static SettableFuture<String> acquireToken(String resource){
// final SettableFuture<String> future = SettableFuture.create();
// try {
// getAuthenticationContext().acquireToken(
// mActivity,
// resource,
// Constants.AAD_CLIENT_ID,
// Constants.AAD_REDIRECT_URL,
// PromptBehavior.Auto,
// new AuthenticationCallback<AuthenticationResult>() {
// @Override
// public void onSuccess(AuthenticationResult authenticationResult) {
// future.set(authenticationResult.getAccessToken());
// }
//
// @Override
// public void onError(Exception e) {
// future.setException(e);
// }
// });
// } catch (Throwable t) {
// future.setException(t);
// }
//
// return future;
// }
//
// public static ListClient getSharePointListClient(String accessToken) {
// OAuthCredentials credentials = new OAuthCredentials(accessToken);
// return new ListClient(Constants.SHAREPOINT_URL, Constants.SHAREPOINT_SITE_PATH, credentials);
// }
//
// private static DependencyResolver getDependencyResolver(final String token) {
// DefaultDependencyResolver dependencyResolver = new DefaultDependencyResolver(token);
// dependencyResolver.getLogger().setEnabled(true);
// dependencyResolver.getLogger().setLogLevel(LogLevel.VERBOSE);
// return dependencyResolver;
// }
//
// public static IGraphServiceClient getGraphServiceClient(Application app, String token){
// return new GraphServiceClient
// .Builder()
// .fromConfig(DefaultClientConfig.createWithAuthenticationProvider(new GraphAuthenticationProvider(app, token)))
// .buildClient();
// }
//
// public static SettableFuture<String> getGraphAccessToken(){
// final SettableFuture<String> future = SettableFuture.create();
// try {
// getAuthenticationContext().acquireToken(
// mActivity,
// Constants.GRAPH_RESOURCE_ID,
// Constants.AAD_CLIENT_ID,
// Constants.AAD_REDIRECT_URL,
// PromptBehavior.Auto,
// new AuthenticationCallback<AuthenticationResult>() {
// @Override
// public void onSuccess(AuthenticationResult authenticationResult) {
// future.set(authenticationResult.getAccessToken());
// }
//
// @Override
// public void onError(Exception e) {
// future.setException(e);
// }
// });
// } catch (Throwable t) {
// future.setException(t);
// }
// return future;
// }
// }
// Path: AndroidRepairApp/app/src/main/java/com/canviz/repairapp/SigninActivity.java
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Intent;
import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import java.security.NoSuchAlgorithmException;
import javax.crypto.NoSuchPaddingException;
import com.canviz.repairapp.utility.AuthenticationHelper;
import com.canviz.repairapp.utility.Helper;
import com.microsoft.aad.adal.AuthenticationCallback;
import com.microsoft.aad.adal.AuthenticationContext;
import com.microsoft.aad.adal.AuthenticationResult;
import com.microsoft.aad.adal.PromptBehavior;
import com.microsoft.services.sharepoint.ListClient;
package com.canviz.repairapp;
public class SigninActivity extends Activity {
private App mApp;
private Button signInBtn;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_signin);
mApp = (App) getApplication();
setIncidentId();
try { | AuthenticationHelper.initialize(this); |
OfficeDev/Property-Inspection-Code-Sample | AndroidRepairApp/app/src/main/java/com/canviz/repairapp/utility/AuthenticationHelper.java | // Path: AndroidRepairApp/app/src/main/java/com/canviz/repairapp/Constants.java
// public final class Constants {;
//
// public static final String AAD_CLIENT_ID = "YOUR CLIENT ID";
// public static final String AAD_REDIRECT_URL = "http://PropertyManagementRepairApp";
// public static final String AAD_AUTHORITY = "https://login.microsoftonline.com/common";
//
// public static final String GRAPH_RESOURCE_ID = "https://graph.microsoft.com/";
// public static final String GRAPH_RESOURCE_URL = "https://graph.microsoft.com/v1.0/";
// public static final String GRAPH_BETA_RESOURCE_URL = "https://graph.microsoft.com/beta/";
//
// public static final String SHAREPOINT_URL = "https://TENANCY.sharepoint.com";
// public static final String SHAREPOINT_SITE_PATH = "/sites/SuiteLevelAppDemo";
// public static final String SHAREPOINT_RESOURCE_ID = SHAREPOINT_URL;
//
// public static final String OUTLOOK_RESOURCE_ID = "https://outlook.office365.com/";
// public static final String ONENOTE_RESOURCE_ID = "https://onenote.com/";
// public static final String ONENOTE_NAME = "Contoso Property Management";
// public static final String VIDEO_RESOURCE_URL = SHAREPOINT_URL + "/portals/hub";
// public static final String VIDEO_CHANNEL_NAME = "Incidents";
//
// public static final String DISPATCHEREMAIL = "katiej@TENANCY.onmicrosoft.com";
//
// public static final String LIST_NAME_INCIDENTS = "Incidents";
// public static final String LIST_NAME_INSPECTIONS = "Inspections";
// public static final String LIST_NAME_INCIDENTWORKFLOWTASKS = "Incident Workflow Tasks";
// public static final String LIST_NAME_PROPERTYPHOTOS = "Property Photos";
// public static final String LIST_NAME_ROOMINSPECTIONPHOTOS = "Room Inspection Photos";
// public static final String LIST_NAME_REPAIRPHOTOS = "Repair Photos";
// public static final String LOCALIMAGE_SAVEPATH="/mnt/sdcard/repair/images/";
//
// public static final int SUCCESS = 0x111;
// public static final int FAILED = 0x112;
// }
| import android.app.Activity;
import android.app.Application;
import android.util.Log;
import com.canviz.repairapp.Constants;
import com.google.common.util.concurrent.SettableFuture;
import com.microsoft.aad.adal.AuthenticationCallback;
import com.microsoft.aad.adal.AuthenticationContext;
import com.microsoft.aad.adal.AuthenticationResult;
import com.microsoft.aad.adal.PromptBehavior;
import com.microsoft.graph.authentication.IAuthenticationProvider;
import com.microsoft.graph.core.DefaultClientConfig;
import com.microsoft.graph.core.IClientConfig;
import com.microsoft.graph.authentication.IAuthenticationAdapter;
import com.microsoft.graph.authentication.MSAAuthAndroidAdapter;
import com.microsoft.graph.extensions.GraphServiceClient;
import com.microsoft.graph.extensions.IGraphServiceClient;
import com.microsoft.services.onenote.fetchers.OneNoteApiClient;
import com.microsoft.services.orc.resolvers.DefaultDependencyResolver;
import com.microsoft.services.orc.core.DependencyResolver;
import com.microsoft.services.orc.log.LogLevel;
import com.microsoft.services.sharepoint.ListClient;
import com.microsoft.services.sharepoint.http.OAuthCredentials;
import java.security.NoSuchAlgorithmException;
import javax.crypto.NoSuchPaddingException; | package com.canviz.repairapp.utility;
/**
* Created by Tyler on 5/13/15.
*/
public class AuthenticationHelper {
private static Activity mActivity;
public static AuthenticationContext mAADAuthContext = null;
final static String TAG = "AuthenticationHelper";
public static void initialize(Activity activity) throws NoSuchPaddingException, NoSuchAlgorithmException {
mActivity = activity;
mAADAuthContext = new AuthenticationContext(
mActivity.getApplicationContext(), | // Path: AndroidRepairApp/app/src/main/java/com/canviz/repairapp/Constants.java
// public final class Constants {;
//
// public static final String AAD_CLIENT_ID = "YOUR CLIENT ID";
// public static final String AAD_REDIRECT_URL = "http://PropertyManagementRepairApp";
// public static final String AAD_AUTHORITY = "https://login.microsoftonline.com/common";
//
// public static final String GRAPH_RESOURCE_ID = "https://graph.microsoft.com/";
// public static final String GRAPH_RESOURCE_URL = "https://graph.microsoft.com/v1.0/";
// public static final String GRAPH_BETA_RESOURCE_URL = "https://graph.microsoft.com/beta/";
//
// public static final String SHAREPOINT_URL = "https://TENANCY.sharepoint.com";
// public static final String SHAREPOINT_SITE_PATH = "/sites/SuiteLevelAppDemo";
// public static final String SHAREPOINT_RESOURCE_ID = SHAREPOINT_URL;
//
// public static final String OUTLOOK_RESOURCE_ID = "https://outlook.office365.com/";
// public static final String ONENOTE_RESOURCE_ID = "https://onenote.com/";
// public static final String ONENOTE_NAME = "Contoso Property Management";
// public static final String VIDEO_RESOURCE_URL = SHAREPOINT_URL + "/portals/hub";
// public static final String VIDEO_CHANNEL_NAME = "Incidents";
//
// public static final String DISPATCHEREMAIL = "katiej@TENANCY.onmicrosoft.com";
//
// public static final String LIST_NAME_INCIDENTS = "Incidents";
// public static final String LIST_NAME_INSPECTIONS = "Inspections";
// public static final String LIST_NAME_INCIDENTWORKFLOWTASKS = "Incident Workflow Tasks";
// public static final String LIST_NAME_PROPERTYPHOTOS = "Property Photos";
// public static final String LIST_NAME_ROOMINSPECTIONPHOTOS = "Room Inspection Photos";
// public static final String LIST_NAME_REPAIRPHOTOS = "Repair Photos";
// public static final String LOCALIMAGE_SAVEPATH="/mnt/sdcard/repair/images/";
//
// public static final int SUCCESS = 0x111;
// public static final int FAILED = 0x112;
// }
// Path: AndroidRepairApp/app/src/main/java/com/canviz/repairapp/utility/AuthenticationHelper.java
import android.app.Activity;
import android.app.Application;
import android.util.Log;
import com.canviz.repairapp.Constants;
import com.google.common.util.concurrent.SettableFuture;
import com.microsoft.aad.adal.AuthenticationCallback;
import com.microsoft.aad.adal.AuthenticationContext;
import com.microsoft.aad.adal.AuthenticationResult;
import com.microsoft.aad.adal.PromptBehavior;
import com.microsoft.graph.authentication.IAuthenticationProvider;
import com.microsoft.graph.core.DefaultClientConfig;
import com.microsoft.graph.core.IClientConfig;
import com.microsoft.graph.authentication.IAuthenticationAdapter;
import com.microsoft.graph.authentication.MSAAuthAndroidAdapter;
import com.microsoft.graph.extensions.GraphServiceClient;
import com.microsoft.graph.extensions.IGraphServiceClient;
import com.microsoft.services.onenote.fetchers.OneNoteApiClient;
import com.microsoft.services.orc.resolvers.DefaultDependencyResolver;
import com.microsoft.services.orc.core.DependencyResolver;
import com.microsoft.services.orc.log.LogLevel;
import com.microsoft.services.sharepoint.ListClient;
import com.microsoft.services.sharepoint.http.OAuthCredentials;
import java.security.NoSuchAlgorithmException;
import javax.crypto.NoSuchPaddingException;
package com.canviz.repairapp.utility;
/**
* Created by Tyler on 5/13/15.
*/
public class AuthenticationHelper {
private static Activity mActivity;
public static AuthenticationContext mAADAuthContext = null;
final static String TAG = "AuthenticationHelper";
public static void initialize(Activity activity) throws NoSuchPaddingException, NoSuchAlgorithmException {
mActivity = activity;
mAADAuthContext = new AuthenticationContext(
mActivity.getApplicationContext(), | Constants.AAD_AUTHORITY, |
OfficeDev/Property-Inspection-Code-Sample | AndroidRepairApp/app/src/main/java/com/canviz/repairapp/data/IncidentModel.java | // Path: AndroidRepairApp/app/src/main/java/com/canviz/repairapp/utility/SPListItemWrapper.java
// public class SPListItemWrapper {
// private SimpleDateFormat mZuluFormat;
// private SPListItem mInner;
//
// public SPListItemWrapper(SPListItem inner) {
// mInner = inner;
// }
//
// public SPListItem getInner() {
// return mInner;
// }
//
// private DateFormat getZuluFormat() {
// if (mZuluFormat == null) {
// //Format used by SharePoint for encoding datetimes
// mZuluFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
// mZuluFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
// }
// return mZuluFormat;
// }
//
// public Date getDate(String fieldName) {
// try {
// Object data = mInner.getData(fieldName);
// if (data == null || !(data instanceof String)) {
// return null;
// }
// return getZuluFormat().parse((String) data);
// }
// catch (Exception ex) {
// return null;
// }
// }
//
// public void setDate(String fieldName, Date value) {
// if (value == null) {
// mInner.setData(fieldName, null);
// }
// mInner.setData(fieldName, getZuluFormat().format(value));
// }
//
// public int getInt(String fieldName) {
// try {
// return (Integer) mInner.getData(fieldName);
// }
// catch (Exception ex) {
// return 0;
// }
// }
//
// public void setInt(String fieldName, int value) {
// mInner.setData(fieldName, value);
// }
//
// public String getString(String fieldName) {
// try {
// return (String) mInner.getData(fieldName);
// }
// catch (Exception ex) {
// return null;
// }
// }
//
// public void setString(String fieldName, String value) {
// mInner.setData(fieldName, value);
// }
//
// public JSONObject getObject(String fieldName) {
// try {
// return (JSONObject) mInner.getData(fieldName);
// }
// catch (Exception ex) {
// return null;
// }
// }
//
// public void setObject(String fieldName, JSONObject value) {
// mInner.setData(fieldName, value);
// }
// }
| import android.graphics.Bitmap;
import com.canviz.repairapp.utility.SPListItemWrapper;
import com.microsoft.services.sharepoint.SPListItem;
import org.json.JSONObject; | package com.canviz.repairapp.data;
public class IncidentModel {
public static final String[] SELECT = {
"ID","Title","sl_inspectorIncidentComments",
"sl_dispatcherComments","sl_repairComments","sl_status",
"sl_type","sl_date","sl_repairCompleted","sl_propertyIDId","sl_inspectionIDId","sl_roomIDId","sl_taskId",
"sl_inspectionID/ID",
"sl_inspectionID/sl_datetime",
"sl_inspectionID/sl_finalized",
"sl_propertyID/ID",
"sl_propertyID/Title",
"sl_propertyID/sl_emailaddress",
"sl_propertyID/sl_owner",
"sl_propertyID/sl_address1",
"sl_propertyID/sl_address2",
"sl_propertyID/sl_city",
"sl_propertyID/sl_state",
"sl_propertyID/sl_postalCode",
"sl_propertyID/sl_group",
"sl_roomID/ID",
"sl_roomID/Title",
};
public static final String[] EXPAND = {
"sl_inspectionID","sl_propertyID","sl_roomID"
};
| // Path: AndroidRepairApp/app/src/main/java/com/canviz/repairapp/utility/SPListItemWrapper.java
// public class SPListItemWrapper {
// private SimpleDateFormat mZuluFormat;
// private SPListItem mInner;
//
// public SPListItemWrapper(SPListItem inner) {
// mInner = inner;
// }
//
// public SPListItem getInner() {
// return mInner;
// }
//
// private DateFormat getZuluFormat() {
// if (mZuluFormat == null) {
// //Format used by SharePoint for encoding datetimes
// mZuluFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
// mZuluFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
// }
// return mZuluFormat;
// }
//
// public Date getDate(String fieldName) {
// try {
// Object data = mInner.getData(fieldName);
// if (data == null || !(data instanceof String)) {
// return null;
// }
// return getZuluFormat().parse((String) data);
// }
// catch (Exception ex) {
// return null;
// }
// }
//
// public void setDate(String fieldName, Date value) {
// if (value == null) {
// mInner.setData(fieldName, null);
// }
// mInner.setData(fieldName, getZuluFormat().format(value));
// }
//
// public int getInt(String fieldName) {
// try {
// return (Integer) mInner.getData(fieldName);
// }
// catch (Exception ex) {
// return 0;
// }
// }
//
// public void setInt(String fieldName, int value) {
// mInner.setData(fieldName, value);
// }
//
// public String getString(String fieldName) {
// try {
// return (String) mInner.getData(fieldName);
// }
// catch (Exception ex) {
// return null;
// }
// }
//
// public void setString(String fieldName, String value) {
// mInner.setData(fieldName, value);
// }
//
// public JSONObject getObject(String fieldName) {
// try {
// return (JSONObject) mInner.getData(fieldName);
// }
// catch (Exception ex) {
// return null;
// }
// }
//
// public void setObject(String fieldName, JSONObject value) {
// mInner.setData(fieldName, value);
// }
// }
// Path: AndroidRepairApp/app/src/main/java/com/canviz/repairapp/data/IncidentModel.java
import android.graphics.Bitmap;
import com.canviz.repairapp.utility.SPListItemWrapper;
import com.microsoft.services.sharepoint.SPListItem;
import org.json.JSONObject;
package com.canviz.repairapp.data;
public class IncidentModel {
public static final String[] SELECT = {
"ID","Title","sl_inspectorIncidentComments",
"sl_dispatcherComments","sl_repairComments","sl_status",
"sl_type","sl_date","sl_repairCompleted","sl_propertyIDId","sl_inspectionIDId","sl_roomIDId","sl_taskId",
"sl_inspectionID/ID",
"sl_inspectionID/sl_datetime",
"sl_inspectionID/sl_finalized",
"sl_propertyID/ID",
"sl_propertyID/Title",
"sl_propertyID/sl_emailaddress",
"sl_propertyID/sl_owner",
"sl_propertyID/sl_address1",
"sl_propertyID/sl_address2",
"sl_propertyID/sl_city",
"sl_propertyID/sl_state",
"sl_propertyID/sl_postalCode",
"sl_propertyID/sl_group",
"sl_roomID/ID",
"sl_roomID/Title",
};
public static final String[] EXPAND = {
"sl_inspectionID","sl_propertyID","sl_roomID"
};
| private final SPListItemWrapper mData; |
OfficeDev/Property-Inspection-Code-Sample | AndroidRepairApp/app/src/main/java/com/canviz/repairapp/utility/AsyncBitmapLoader.java | // Path: AndroidRepairApp/app/src/main/java/com/canviz/repairapp/Constants.java
// public final class Constants {;
//
// public static final String AAD_CLIENT_ID = "YOUR CLIENT ID";
// public static final String AAD_REDIRECT_URL = "http://PropertyManagementRepairApp";
// public static final String AAD_AUTHORITY = "https://login.microsoftonline.com/common";
//
// public static final String GRAPH_RESOURCE_ID = "https://graph.microsoft.com/";
// public static final String GRAPH_RESOURCE_URL = "https://graph.microsoft.com/v1.0/";
// public static final String GRAPH_BETA_RESOURCE_URL = "https://graph.microsoft.com/beta/";
//
// public static final String SHAREPOINT_URL = "https://TENANCY.sharepoint.com";
// public static final String SHAREPOINT_SITE_PATH = "/sites/SuiteLevelAppDemo";
// public static final String SHAREPOINT_RESOURCE_ID = SHAREPOINT_URL;
//
// public static final String OUTLOOK_RESOURCE_ID = "https://outlook.office365.com/";
// public static final String ONENOTE_RESOURCE_ID = "https://onenote.com/";
// public static final String ONENOTE_NAME = "Contoso Property Management";
// public static final String VIDEO_RESOURCE_URL = SHAREPOINT_URL + "/portals/hub";
// public static final String VIDEO_CHANNEL_NAME = "Incidents";
//
// public static final String DISPATCHEREMAIL = "katiej@TENANCY.onmicrosoft.com";
//
// public static final String LIST_NAME_INCIDENTS = "Incidents";
// public static final String LIST_NAME_INSPECTIONS = "Inspections";
// public static final String LIST_NAME_INCIDENTWORKFLOWTASKS = "Incident Workflow Tasks";
// public static final String LIST_NAME_PROPERTYPHOTOS = "Property Photos";
// public static final String LIST_NAME_ROOMINSPECTIONPHOTOS = "Room Inspection Photos";
// public static final String LIST_NAME_REPAIRPHOTOS = "Repair Photos";
// public static final String LOCALIMAGE_SAVEPATH="/mnt/sdcard/repair/images/";
//
// public static final int SUCCESS = 0x111;
// public static final int FAILED = 0x112;
// }
| import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.ref.SoftReference;
import java.net.URL;
import java.util.HashMap;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.widget.ImageView;
import com.canviz.repairapp.Constants; | package com.canviz.repairapp.utility;
public class AsyncBitmapLoader {
private static final String TAG="AsyncBitmapLoader";
private static HashMap<String, SoftReference<Bitmap>> imageCache = new HashMap<String, SoftReference<Bitmap>>();
public static void saveBitmapToCache(String imageURL,Bitmap bitmap){
try {
if(imageCache.containsKey(imageURL)) {
return;
}
else
{
imageCache.put(imageURL, new SoftReference<Bitmap>(bitmap));
}
| // Path: AndroidRepairApp/app/src/main/java/com/canviz/repairapp/Constants.java
// public final class Constants {;
//
// public static final String AAD_CLIENT_ID = "YOUR CLIENT ID";
// public static final String AAD_REDIRECT_URL = "http://PropertyManagementRepairApp";
// public static final String AAD_AUTHORITY = "https://login.microsoftonline.com/common";
//
// public static final String GRAPH_RESOURCE_ID = "https://graph.microsoft.com/";
// public static final String GRAPH_RESOURCE_URL = "https://graph.microsoft.com/v1.0/";
// public static final String GRAPH_BETA_RESOURCE_URL = "https://graph.microsoft.com/beta/";
//
// public static final String SHAREPOINT_URL = "https://TENANCY.sharepoint.com";
// public static final String SHAREPOINT_SITE_PATH = "/sites/SuiteLevelAppDemo";
// public static final String SHAREPOINT_RESOURCE_ID = SHAREPOINT_URL;
//
// public static final String OUTLOOK_RESOURCE_ID = "https://outlook.office365.com/";
// public static final String ONENOTE_RESOURCE_ID = "https://onenote.com/";
// public static final String ONENOTE_NAME = "Contoso Property Management";
// public static final String VIDEO_RESOURCE_URL = SHAREPOINT_URL + "/portals/hub";
// public static final String VIDEO_CHANNEL_NAME = "Incidents";
//
// public static final String DISPATCHEREMAIL = "katiej@TENANCY.onmicrosoft.com";
//
// public static final String LIST_NAME_INCIDENTS = "Incidents";
// public static final String LIST_NAME_INSPECTIONS = "Inspections";
// public static final String LIST_NAME_INCIDENTWORKFLOWTASKS = "Incident Workflow Tasks";
// public static final String LIST_NAME_PROPERTYPHOTOS = "Property Photos";
// public static final String LIST_NAME_ROOMINSPECTIONPHOTOS = "Room Inspection Photos";
// public static final String LIST_NAME_REPAIRPHOTOS = "Repair Photos";
// public static final String LOCALIMAGE_SAVEPATH="/mnt/sdcard/repair/images/";
//
// public static final int SUCCESS = 0x111;
// public static final int FAILED = 0x112;
// }
// Path: AndroidRepairApp/app/src/main/java/com/canviz/repairapp/utility/AsyncBitmapLoader.java
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.ref.SoftReference;
import java.net.URL;
import java.util.HashMap;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.widget.ImageView;
import com.canviz.repairapp.Constants;
package com.canviz.repairapp.utility;
public class AsyncBitmapLoader {
private static final String TAG="AsyncBitmapLoader";
private static HashMap<String, SoftReference<Bitmap>> imageCache = new HashMap<String, SoftReference<Bitmap>>();
public static void saveBitmapToCache(String imageURL,Bitmap bitmap){
try {
if(imageCache.containsKey(imageURL)) {
return;
}
else
{
imageCache.put(imageURL, new SoftReference<Bitmap>(bitmap));
}
| File dir = new File(Constants.LOCALIMAGE_SAVEPATH); |
OfficeDev/Property-Inspection-Code-Sample | AndroidRepairApp/app/src/main/java/com/canviz/repairapp/utility/EmailHelper.java | // Path: AndroidRepairApp/app/src/main/java/com/canviz/repairapp/Constants.java
// public final class Constants {;
//
// public static final String AAD_CLIENT_ID = "YOUR CLIENT ID";
// public static final String AAD_REDIRECT_URL = "http://PropertyManagementRepairApp";
// public static final String AAD_AUTHORITY = "https://login.microsoftonline.com/common";
//
// public static final String GRAPH_RESOURCE_ID = "https://graph.microsoft.com/";
// public static final String GRAPH_RESOURCE_URL = "https://graph.microsoft.com/v1.0/";
// public static final String GRAPH_BETA_RESOURCE_URL = "https://graph.microsoft.com/beta/";
//
// public static final String SHAREPOINT_URL = "https://TENANCY.sharepoint.com";
// public static final String SHAREPOINT_SITE_PATH = "/sites/SuiteLevelAppDemo";
// public static final String SHAREPOINT_RESOURCE_ID = SHAREPOINT_URL;
//
// public static final String OUTLOOK_RESOURCE_ID = "https://outlook.office365.com/";
// public static final String ONENOTE_RESOURCE_ID = "https://onenote.com/";
// public static final String ONENOTE_NAME = "Contoso Property Management";
// public static final String VIDEO_RESOURCE_URL = SHAREPOINT_URL + "/portals/hub";
// public static final String VIDEO_CHANNEL_NAME = "Incidents";
//
// public static final String DISPATCHEREMAIL = "katiej@TENANCY.onmicrosoft.com";
//
// public static final String LIST_NAME_INCIDENTS = "Incidents";
// public static final String LIST_NAME_INSPECTIONS = "Inspections";
// public static final String LIST_NAME_INCIDENTWORKFLOWTASKS = "Incident Workflow Tasks";
// public static final String LIST_NAME_PROPERTYPHOTOS = "Property Photos";
// public static final String LIST_NAME_ROOMINSPECTIONPHOTOS = "Room Inspection Photos";
// public static final String LIST_NAME_REPAIRPHOTOS = "Repair Photos";
// public static final String LOCALIMAGE_SAVEPATH="/mnt/sdcard/repair/images/";
//
// public static final int SUCCESS = 0x111;
// public static final int FAILED = 0x112;
// }
| import com.canviz.repairapp.Constants;
import com.microsoft.aad.adal.AuthenticationContext;
import com.microsoft.aad.adal.AuthenticationResult;
import com.microsoft.services.odata.impl.GsonSerializer;
import com.microsoft.services.odata.interfaces.JsonSerializer;
import java.io.BufferedOutputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL; | package com.canviz.repairapp.utility;
/**
* Created by Tyler on 5/19/15.
*/
public class EmailHelper {
public static void sendMail(String userId, com.microsoft.graph.extensions.Message message, Boolean saveToSentItems) throws Exception {
JsonSerializer serializer = new GsonSerializer();
java.util.Map<String, String> map = new java.util.HashMap<String, String>();
map.put("Message", serializer.serialize(message));
map.put("SaveToSentItems", serializer.serialize(saveToSentItems));
String content = serializer.jsonObjectFromJsonMap(map); | // Path: AndroidRepairApp/app/src/main/java/com/canviz/repairapp/Constants.java
// public final class Constants {;
//
// public static final String AAD_CLIENT_ID = "YOUR CLIENT ID";
// public static final String AAD_REDIRECT_URL = "http://PropertyManagementRepairApp";
// public static final String AAD_AUTHORITY = "https://login.microsoftonline.com/common";
//
// public static final String GRAPH_RESOURCE_ID = "https://graph.microsoft.com/";
// public static final String GRAPH_RESOURCE_URL = "https://graph.microsoft.com/v1.0/";
// public static final String GRAPH_BETA_RESOURCE_URL = "https://graph.microsoft.com/beta/";
//
// public static final String SHAREPOINT_URL = "https://TENANCY.sharepoint.com";
// public static final String SHAREPOINT_SITE_PATH = "/sites/SuiteLevelAppDemo";
// public static final String SHAREPOINT_RESOURCE_ID = SHAREPOINT_URL;
//
// public static final String OUTLOOK_RESOURCE_ID = "https://outlook.office365.com/";
// public static final String ONENOTE_RESOURCE_ID = "https://onenote.com/";
// public static final String ONENOTE_NAME = "Contoso Property Management";
// public static final String VIDEO_RESOURCE_URL = SHAREPOINT_URL + "/portals/hub";
// public static final String VIDEO_CHANNEL_NAME = "Incidents";
//
// public static final String DISPATCHEREMAIL = "katiej@TENANCY.onmicrosoft.com";
//
// public static final String LIST_NAME_INCIDENTS = "Incidents";
// public static final String LIST_NAME_INSPECTIONS = "Inspections";
// public static final String LIST_NAME_INCIDENTWORKFLOWTASKS = "Incident Workflow Tasks";
// public static final String LIST_NAME_PROPERTYPHOTOS = "Property Photos";
// public static final String LIST_NAME_ROOMINSPECTIONPHOTOS = "Room Inspection Photos";
// public static final String LIST_NAME_REPAIRPHOTOS = "Repair Photos";
// public static final String LOCALIMAGE_SAVEPATH="/mnt/sdcard/repair/images/";
//
// public static final int SUCCESS = 0x111;
// public static final int FAILED = 0x112;
// }
// Path: AndroidRepairApp/app/src/main/java/com/canviz/repairapp/utility/EmailHelper.java
import com.canviz.repairapp.Constants;
import com.microsoft.aad.adal.AuthenticationContext;
import com.microsoft.aad.adal.AuthenticationResult;
import com.microsoft.services.odata.impl.GsonSerializer;
import com.microsoft.services.odata.interfaces.JsonSerializer;
import java.io.BufferedOutputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
package com.canviz.repairapp.utility;
/**
* Created by Tyler on 5/19/15.
*/
public class EmailHelper {
public static void sendMail(String userId, com.microsoft.graph.extensions.Message message, Boolean saveToSentItems) throws Exception {
JsonSerializer serializer = new GsonSerializer();
java.util.Map<String, String> map = new java.util.HashMap<String, String>();
map.put("Message", serializer.serialize(message));
map.put("SaveToSentItems", serializer.serialize(saveToSentItems));
String content = serializer.jsonObjectFromJsonMap(map); | byte[] data = content.getBytes(com.microsoft.services.odata.Constants.UTF8); |
OfficeDev/Property-Inspection-Code-Sample | AndroidRepairApp/app/src/main/java/com/canviz/repairapp/utility/FileHelper.java | // Path: AndroidRepairApp/app/src/main/java/com/canviz/repairapp/Constants.java
// public final class Constants {;
//
// public static final String AAD_CLIENT_ID = "YOUR CLIENT ID";
// public static final String AAD_REDIRECT_URL = "http://PropertyManagementRepairApp";
// public static final String AAD_AUTHORITY = "https://login.microsoftonline.com/common";
//
// public static final String GRAPH_RESOURCE_ID = "https://graph.microsoft.com/";
// public static final String GRAPH_RESOURCE_URL = "https://graph.microsoft.com/v1.0/";
// public static final String GRAPH_BETA_RESOURCE_URL = "https://graph.microsoft.com/beta/";
//
// public static final String SHAREPOINT_URL = "https://TENANCY.sharepoint.com";
// public static final String SHAREPOINT_SITE_PATH = "/sites/SuiteLevelAppDemo";
// public static final String SHAREPOINT_RESOURCE_ID = SHAREPOINT_URL;
//
// public static final String OUTLOOK_RESOURCE_ID = "https://outlook.office365.com/";
// public static final String ONENOTE_RESOURCE_ID = "https://onenote.com/";
// public static final String ONENOTE_NAME = "Contoso Property Management";
// public static final String VIDEO_RESOURCE_URL = SHAREPOINT_URL + "/portals/hub";
// public static final String VIDEO_CHANNEL_NAME = "Incidents";
//
// public static final String DISPATCHEREMAIL = "katiej@TENANCY.onmicrosoft.com";
//
// public static final String LIST_NAME_INCIDENTS = "Incidents";
// public static final String LIST_NAME_INSPECTIONS = "Inspections";
// public static final String LIST_NAME_INCIDENTWORKFLOWTASKS = "Incident Workflow Tasks";
// public static final String LIST_NAME_PROPERTYPHOTOS = "Property Photos";
// public static final String LIST_NAME_ROOMINSPECTIONPHOTOS = "Room Inspection Photos";
// public static final String LIST_NAME_REPAIRPHOTOS = "Repair Photos";
// public static final String LOCALIMAGE_SAVEPATH="/mnt/sdcard/repair/images/";
//
// public static final int SUCCESS = 0x111;
// public static final int FAILED = 0x112;
// }
//
// Path: AndroidRepairApp/app/src/main/java/com/canviz/repairapp/data/GroupVideoModel.java
// public class GroupVideoModel {
// private String Title;
// private String Url;
// private String ImageUrl;
// private Bitmap Image;
// private Boolean IsChanged;
//
// public String getTitle() {
// return Title;
// }
//
// public void setTitle(String title) {
// Title = title;
// }
//
// public String getUrl() {
// return Url;
// }
//
// public void setUrl(String url) {
// Url = url;
// }
//
// public Bitmap getImage() {
// return Image;
// }
//
// public void setImage(Bitmap image) {
// Image = image;
// }
//
// public Boolean getIsChanged() {
// return IsChanged;
// }
//
// public void setIsChanged(Boolean isChanged) {
// IsChanged = isChanged;
// }
//
// public String getImageUrl() {
// return ImageUrl;
// }
//
// public void setImageUrl(String imageUrl) {
// ImageUrl = imageUrl;
// }
// }
| import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import com.canviz.repairapp.Constants;
import com.canviz.repairapp.data.GroupVideoModel;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import android.util.Base64; | package com.canviz.repairapp.utility;
public class FileHelper {
private final static String TAG = "FileHelper";
public static String getFileServerRelativeUrlUrl(String token,String listName, int itemId) throws IOException, JSONException {
String listNamePart = String.format("/_api/web/lists/GetByTitle('%s')/Items(%s)/File?$select=ServerRelativeUrl", listName,itemId); | // Path: AndroidRepairApp/app/src/main/java/com/canviz/repairapp/Constants.java
// public final class Constants {;
//
// public static final String AAD_CLIENT_ID = "YOUR CLIENT ID";
// public static final String AAD_REDIRECT_URL = "http://PropertyManagementRepairApp";
// public static final String AAD_AUTHORITY = "https://login.microsoftonline.com/common";
//
// public static final String GRAPH_RESOURCE_ID = "https://graph.microsoft.com/";
// public static final String GRAPH_RESOURCE_URL = "https://graph.microsoft.com/v1.0/";
// public static final String GRAPH_BETA_RESOURCE_URL = "https://graph.microsoft.com/beta/";
//
// public static final String SHAREPOINT_URL = "https://TENANCY.sharepoint.com";
// public static final String SHAREPOINT_SITE_PATH = "/sites/SuiteLevelAppDemo";
// public static final String SHAREPOINT_RESOURCE_ID = SHAREPOINT_URL;
//
// public static final String OUTLOOK_RESOURCE_ID = "https://outlook.office365.com/";
// public static final String ONENOTE_RESOURCE_ID = "https://onenote.com/";
// public static final String ONENOTE_NAME = "Contoso Property Management";
// public static final String VIDEO_RESOURCE_URL = SHAREPOINT_URL + "/portals/hub";
// public static final String VIDEO_CHANNEL_NAME = "Incidents";
//
// public static final String DISPATCHEREMAIL = "katiej@TENANCY.onmicrosoft.com";
//
// public static final String LIST_NAME_INCIDENTS = "Incidents";
// public static final String LIST_NAME_INSPECTIONS = "Inspections";
// public static final String LIST_NAME_INCIDENTWORKFLOWTASKS = "Incident Workflow Tasks";
// public static final String LIST_NAME_PROPERTYPHOTOS = "Property Photos";
// public static final String LIST_NAME_ROOMINSPECTIONPHOTOS = "Room Inspection Photos";
// public static final String LIST_NAME_REPAIRPHOTOS = "Repair Photos";
// public static final String LOCALIMAGE_SAVEPATH="/mnt/sdcard/repair/images/";
//
// public static final int SUCCESS = 0x111;
// public static final int FAILED = 0x112;
// }
//
// Path: AndroidRepairApp/app/src/main/java/com/canviz/repairapp/data/GroupVideoModel.java
// public class GroupVideoModel {
// private String Title;
// private String Url;
// private String ImageUrl;
// private Bitmap Image;
// private Boolean IsChanged;
//
// public String getTitle() {
// return Title;
// }
//
// public void setTitle(String title) {
// Title = title;
// }
//
// public String getUrl() {
// return Url;
// }
//
// public void setUrl(String url) {
// Url = url;
// }
//
// public Bitmap getImage() {
// return Image;
// }
//
// public void setImage(Bitmap image) {
// Image = image;
// }
//
// public Boolean getIsChanged() {
// return IsChanged;
// }
//
// public void setIsChanged(Boolean isChanged) {
// IsChanged = isChanged;
// }
//
// public String getImageUrl() {
// return ImageUrl;
// }
//
// public void setImageUrl(String imageUrl) {
// ImageUrl = imageUrl;
// }
// }
// Path: AndroidRepairApp/app/src/main/java/com/canviz/repairapp/utility/FileHelper.java
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import com.canviz.repairapp.Constants;
import com.canviz.repairapp.data.GroupVideoModel;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import android.util.Base64;
package com.canviz.repairapp.utility;
public class FileHelper {
private final static String TAG = "FileHelper";
public static String getFileServerRelativeUrlUrl(String token,String listName, int itemId) throws IOException, JSONException {
String listNamePart = String.format("/_api/web/lists/GetByTitle('%s')/Items(%s)/File?$select=ServerRelativeUrl", listName,itemId); | String getFileUrl = Constants.SHAREPOINT_URL + Constants.SHAREPOINT_SITE_PATH + listNamePart; |
OfficeDev/Property-Inspection-Code-Sample | AndroidRepairApp/app/src/main/java/com/canviz/repairapp/utility/FileHelper.java | // Path: AndroidRepairApp/app/src/main/java/com/canviz/repairapp/Constants.java
// public final class Constants {;
//
// public static final String AAD_CLIENT_ID = "YOUR CLIENT ID";
// public static final String AAD_REDIRECT_URL = "http://PropertyManagementRepairApp";
// public static final String AAD_AUTHORITY = "https://login.microsoftonline.com/common";
//
// public static final String GRAPH_RESOURCE_ID = "https://graph.microsoft.com/";
// public static final String GRAPH_RESOURCE_URL = "https://graph.microsoft.com/v1.0/";
// public static final String GRAPH_BETA_RESOURCE_URL = "https://graph.microsoft.com/beta/";
//
// public static final String SHAREPOINT_URL = "https://TENANCY.sharepoint.com";
// public static final String SHAREPOINT_SITE_PATH = "/sites/SuiteLevelAppDemo";
// public static final String SHAREPOINT_RESOURCE_ID = SHAREPOINT_URL;
//
// public static final String OUTLOOK_RESOURCE_ID = "https://outlook.office365.com/";
// public static final String ONENOTE_RESOURCE_ID = "https://onenote.com/";
// public static final String ONENOTE_NAME = "Contoso Property Management";
// public static final String VIDEO_RESOURCE_URL = SHAREPOINT_URL + "/portals/hub";
// public static final String VIDEO_CHANNEL_NAME = "Incidents";
//
// public static final String DISPATCHEREMAIL = "katiej@TENANCY.onmicrosoft.com";
//
// public static final String LIST_NAME_INCIDENTS = "Incidents";
// public static final String LIST_NAME_INSPECTIONS = "Inspections";
// public static final String LIST_NAME_INCIDENTWORKFLOWTASKS = "Incident Workflow Tasks";
// public static final String LIST_NAME_PROPERTYPHOTOS = "Property Photos";
// public static final String LIST_NAME_ROOMINSPECTIONPHOTOS = "Room Inspection Photos";
// public static final String LIST_NAME_REPAIRPHOTOS = "Repair Photos";
// public static final String LOCALIMAGE_SAVEPATH="/mnt/sdcard/repair/images/";
//
// public static final int SUCCESS = 0x111;
// public static final int FAILED = 0x112;
// }
//
// Path: AndroidRepairApp/app/src/main/java/com/canviz/repairapp/data/GroupVideoModel.java
// public class GroupVideoModel {
// private String Title;
// private String Url;
// private String ImageUrl;
// private Bitmap Image;
// private Boolean IsChanged;
//
// public String getTitle() {
// return Title;
// }
//
// public void setTitle(String title) {
// Title = title;
// }
//
// public String getUrl() {
// return Url;
// }
//
// public void setUrl(String url) {
// Url = url;
// }
//
// public Bitmap getImage() {
// return Image;
// }
//
// public void setImage(Bitmap image) {
// Image = image;
// }
//
// public Boolean getIsChanged() {
// return IsChanged;
// }
//
// public void setIsChanged(Boolean isChanged) {
// IsChanged = isChanged;
// }
//
// public String getImageUrl() {
// return ImageUrl;
// }
//
// public void setImageUrl(String imageUrl) {
// ImageUrl = imageUrl;
// }
// }
| import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import com.canviz.repairapp.Constants;
import com.canviz.repairapp.data.GroupVideoModel;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import android.util.Base64; | int id = (new JSONObject(jsonObject.getString("d"))).getInt("Id");
if(id > 0){
return id;
}
}
return 0;
}
public static String getChannelUrl(String token) throws IOException, JSONException {
String url = Constants.VIDEO_RESOURCE_URL + "/_api/VideoService/Channels?$filter=Title%20eq%20%27" + Constants.VIDEO_CHANNEL_NAME + "%27";
String channelUrl = null;
OkHttpClient okHttpClient = new OkHttpClient();
Request request = new Request.Builder()
.url(url)
.addHeader("Authorization ", "Bearer " + token)
.addHeader("accept", "application/json;odata=verbose")
.get()
.build();
Response response = okHttpClient.newCall(request).execute();
if(response.code() == 200){
JSONObject jsonObject = new JSONObject(response.body().string());
JSONArray jsonArray = jsonObject.getJSONObject("d").getJSONArray("results");
channelUrl = jsonArray.getJSONObject(0).getJSONObject("__metadata").getString("id");
}
return channelUrl;
}
| // Path: AndroidRepairApp/app/src/main/java/com/canviz/repairapp/Constants.java
// public final class Constants {;
//
// public static final String AAD_CLIENT_ID = "YOUR CLIENT ID";
// public static final String AAD_REDIRECT_URL = "http://PropertyManagementRepairApp";
// public static final String AAD_AUTHORITY = "https://login.microsoftonline.com/common";
//
// public static final String GRAPH_RESOURCE_ID = "https://graph.microsoft.com/";
// public static final String GRAPH_RESOURCE_URL = "https://graph.microsoft.com/v1.0/";
// public static final String GRAPH_BETA_RESOURCE_URL = "https://graph.microsoft.com/beta/";
//
// public static final String SHAREPOINT_URL = "https://TENANCY.sharepoint.com";
// public static final String SHAREPOINT_SITE_PATH = "/sites/SuiteLevelAppDemo";
// public static final String SHAREPOINT_RESOURCE_ID = SHAREPOINT_URL;
//
// public static final String OUTLOOK_RESOURCE_ID = "https://outlook.office365.com/";
// public static final String ONENOTE_RESOURCE_ID = "https://onenote.com/";
// public static final String ONENOTE_NAME = "Contoso Property Management";
// public static final String VIDEO_RESOURCE_URL = SHAREPOINT_URL + "/portals/hub";
// public static final String VIDEO_CHANNEL_NAME = "Incidents";
//
// public static final String DISPATCHEREMAIL = "katiej@TENANCY.onmicrosoft.com";
//
// public static final String LIST_NAME_INCIDENTS = "Incidents";
// public static final String LIST_NAME_INSPECTIONS = "Inspections";
// public static final String LIST_NAME_INCIDENTWORKFLOWTASKS = "Incident Workflow Tasks";
// public static final String LIST_NAME_PROPERTYPHOTOS = "Property Photos";
// public static final String LIST_NAME_ROOMINSPECTIONPHOTOS = "Room Inspection Photos";
// public static final String LIST_NAME_REPAIRPHOTOS = "Repair Photos";
// public static final String LOCALIMAGE_SAVEPATH="/mnt/sdcard/repair/images/";
//
// public static final int SUCCESS = 0x111;
// public static final int FAILED = 0x112;
// }
//
// Path: AndroidRepairApp/app/src/main/java/com/canviz/repairapp/data/GroupVideoModel.java
// public class GroupVideoModel {
// private String Title;
// private String Url;
// private String ImageUrl;
// private Bitmap Image;
// private Boolean IsChanged;
//
// public String getTitle() {
// return Title;
// }
//
// public void setTitle(String title) {
// Title = title;
// }
//
// public String getUrl() {
// return Url;
// }
//
// public void setUrl(String url) {
// Url = url;
// }
//
// public Bitmap getImage() {
// return Image;
// }
//
// public void setImage(Bitmap image) {
// Image = image;
// }
//
// public Boolean getIsChanged() {
// return IsChanged;
// }
//
// public void setIsChanged(Boolean isChanged) {
// IsChanged = isChanged;
// }
//
// public String getImageUrl() {
// return ImageUrl;
// }
//
// public void setImageUrl(String imageUrl) {
// ImageUrl = imageUrl;
// }
// }
// Path: AndroidRepairApp/app/src/main/java/com/canviz/repairapp/utility/FileHelper.java
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import com.canviz.repairapp.Constants;
import com.canviz.repairapp.data.GroupVideoModel;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import android.util.Base64;
int id = (new JSONObject(jsonObject.getString("d"))).getInt("Id");
if(id > 0){
return id;
}
}
return 0;
}
public static String getChannelUrl(String token) throws IOException, JSONException {
String url = Constants.VIDEO_RESOURCE_URL + "/_api/VideoService/Channels?$filter=Title%20eq%20%27" + Constants.VIDEO_CHANNEL_NAME + "%27";
String channelUrl = null;
OkHttpClient okHttpClient = new OkHttpClient();
Request request = new Request.Builder()
.url(url)
.addHeader("Authorization ", "Bearer " + token)
.addHeader("accept", "application/json;odata=verbose")
.get()
.build();
Response response = okHttpClient.newCall(request).execute();
if(response.code() == 200){
JSONObject jsonObject = new JSONObject(response.body().string());
JSONArray jsonArray = jsonObject.getJSONObject("d").getJSONArray("results");
channelUrl = jsonArray.getJSONObject(0).getJSONObject("__metadata").getString("id");
}
return channelUrl;
}
| public static List<GroupVideoModel> getChannelVideos(String token,int incidentId) throws IOException, JSONException { |
OfficeDev/Property-Inspection-Code-Sample | AndroidRepairApp/app/src/main/java/com/canviz/repairapp/data/InspectionInspectorModel.java | // Path: AndroidRepairApp/app/src/main/java/com/canviz/repairapp/utility/SPListItemWrapper.java
// public class SPListItemWrapper {
// private SimpleDateFormat mZuluFormat;
// private SPListItem mInner;
//
// public SPListItemWrapper(SPListItem inner) {
// mInner = inner;
// }
//
// public SPListItem getInner() {
// return mInner;
// }
//
// private DateFormat getZuluFormat() {
// if (mZuluFormat == null) {
// //Format used by SharePoint for encoding datetimes
// mZuluFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
// mZuluFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
// }
// return mZuluFormat;
// }
//
// public Date getDate(String fieldName) {
// try {
// Object data = mInner.getData(fieldName);
// if (data == null || !(data instanceof String)) {
// return null;
// }
// return getZuluFormat().parse((String) data);
// }
// catch (Exception ex) {
// return null;
// }
// }
//
// public void setDate(String fieldName, Date value) {
// if (value == null) {
// mInner.setData(fieldName, null);
// }
// mInner.setData(fieldName, getZuluFormat().format(value));
// }
//
// public int getInt(String fieldName) {
// try {
// return (Integer) mInner.getData(fieldName);
// }
// catch (Exception ex) {
// return 0;
// }
// }
//
// public void setInt(String fieldName, int value) {
// mInner.setData(fieldName, value);
// }
//
// public String getString(String fieldName) {
// try {
// return (String) mInner.getData(fieldName);
// }
// catch (Exception ex) {
// return null;
// }
// }
//
// public void setString(String fieldName, String value) {
// mInner.setData(fieldName, value);
// }
//
// public JSONObject getObject(String fieldName) {
// try {
// return (JSONObject) mInner.getData(fieldName);
// }
// catch (Exception ex) {
// return null;
// }
// }
//
// public void setObject(String fieldName, JSONObject value) {
// mInner.setData(fieldName, value);
// }
// }
| import com.canviz.repairapp.utility.SPListItemWrapper;
import com.microsoft.services.sharepoint.SPListItem;
import org.json.JSONObject; | package com.canviz.repairapp.data;
public class InspectionInspectorModel {
public static final String[] SELECT = {
"Id","sl_datetime","sl_finalized",
"sl_inspector",
"sl_emailaddress"
};
public static final String[] EXPAND = {
};
| // Path: AndroidRepairApp/app/src/main/java/com/canviz/repairapp/utility/SPListItemWrapper.java
// public class SPListItemWrapper {
// private SimpleDateFormat mZuluFormat;
// private SPListItem mInner;
//
// public SPListItemWrapper(SPListItem inner) {
// mInner = inner;
// }
//
// public SPListItem getInner() {
// return mInner;
// }
//
// private DateFormat getZuluFormat() {
// if (mZuluFormat == null) {
// //Format used by SharePoint for encoding datetimes
// mZuluFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
// mZuluFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
// }
// return mZuluFormat;
// }
//
// public Date getDate(String fieldName) {
// try {
// Object data = mInner.getData(fieldName);
// if (data == null || !(data instanceof String)) {
// return null;
// }
// return getZuluFormat().parse((String) data);
// }
// catch (Exception ex) {
// return null;
// }
// }
//
// public void setDate(String fieldName, Date value) {
// if (value == null) {
// mInner.setData(fieldName, null);
// }
// mInner.setData(fieldName, getZuluFormat().format(value));
// }
//
// public int getInt(String fieldName) {
// try {
// return (Integer) mInner.getData(fieldName);
// }
// catch (Exception ex) {
// return 0;
// }
// }
//
// public void setInt(String fieldName, int value) {
// mInner.setData(fieldName, value);
// }
//
// public String getString(String fieldName) {
// try {
// return (String) mInner.getData(fieldName);
// }
// catch (Exception ex) {
// return null;
// }
// }
//
// public void setString(String fieldName, String value) {
// mInner.setData(fieldName, value);
// }
//
// public JSONObject getObject(String fieldName) {
// try {
// return (JSONObject) mInner.getData(fieldName);
// }
// catch (Exception ex) {
// return null;
// }
// }
//
// public void setObject(String fieldName, JSONObject value) {
// mInner.setData(fieldName, value);
// }
// }
// Path: AndroidRepairApp/app/src/main/java/com/canviz/repairapp/data/InspectionInspectorModel.java
import com.canviz.repairapp.utility.SPListItemWrapper;
import com.microsoft.services.sharepoint.SPListItem;
import org.json.JSONObject;
package com.canviz.repairapp.data;
public class InspectionInspectorModel {
public static final String[] SELECT = {
"Id","sl_datetime","sl_finalized",
"sl_inspector",
"sl_emailaddress"
};
public static final String[] EXPAND = {
};
| private final SPListItemWrapper mData; |
OfficeDev/Property-Inspection-Code-Sample | AndroidRepairApp/app/src/main/java/com/canviz/repairapp/data/IncidentWorkflowTaskModel.java | // Path: AndroidRepairApp/app/src/main/java/com/canviz/repairapp/utility/SPListItemWrapper.java
// public class SPListItemWrapper {
// private SimpleDateFormat mZuluFormat;
// private SPListItem mInner;
//
// public SPListItemWrapper(SPListItem inner) {
// mInner = inner;
// }
//
// public SPListItem getInner() {
// return mInner;
// }
//
// private DateFormat getZuluFormat() {
// if (mZuluFormat == null) {
// //Format used by SharePoint for encoding datetimes
// mZuluFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
// mZuluFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
// }
// return mZuluFormat;
// }
//
// public Date getDate(String fieldName) {
// try {
// Object data = mInner.getData(fieldName);
// if (data == null || !(data instanceof String)) {
// return null;
// }
// return getZuluFormat().parse((String) data);
// }
// catch (Exception ex) {
// return null;
// }
// }
//
// public void setDate(String fieldName, Date value) {
// if (value == null) {
// mInner.setData(fieldName, null);
// }
// mInner.setData(fieldName, getZuluFormat().format(value));
// }
//
// public int getInt(String fieldName) {
// try {
// return (Integer) mInner.getData(fieldName);
// }
// catch (Exception ex) {
// return 0;
// }
// }
//
// public void setInt(String fieldName, int value) {
// mInner.setData(fieldName, value);
// }
//
// public String getString(String fieldName) {
// try {
// return (String) mInner.getData(fieldName);
// }
// catch (Exception ex) {
// return null;
// }
// }
//
// public void setString(String fieldName, String value) {
// mInner.setData(fieldName, value);
// }
//
// public JSONObject getObject(String fieldName) {
// try {
// return (JSONObject) mInner.getData(fieldName);
// }
// catch (Exception ex) {
// return null;
// }
// }
//
// public void setObject(String fieldName, JSONObject value) {
// mInner.setData(fieldName, value);
// }
// }
| import com.canviz.repairapp.utility.SPListItemWrapper;
import com.microsoft.services.sharepoint.SPListItem; | package com.canviz.repairapp.data;
public class IncidentWorkflowTaskModel {
public static final String[] SELECT = {
"Id","PercentComplete","Status"
};
public static final String[] EXPAND = {
};
| // Path: AndroidRepairApp/app/src/main/java/com/canviz/repairapp/utility/SPListItemWrapper.java
// public class SPListItemWrapper {
// private SimpleDateFormat mZuluFormat;
// private SPListItem mInner;
//
// public SPListItemWrapper(SPListItem inner) {
// mInner = inner;
// }
//
// public SPListItem getInner() {
// return mInner;
// }
//
// private DateFormat getZuluFormat() {
// if (mZuluFormat == null) {
// //Format used by SharePoint for encoding datetimes
// mZuluFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
// mZuluFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
// }
// return mZuluFormat;
// }
//
// public Date getDate(String fieldName) {
// try {
// Object data = mInner.getData(fieldName);
// if (data == null || !(data instanceof String)) {
// return null;
// }
// return getZuluFormat().parse((String) data);
// }
// catch (Exception ex) {
// return null;
// }
// }
//
// public void setDate(String fieldName, Date value) {
// if (value == null) {
// mInner.setData(fieldName, null);
// }
// mInner.setData(fieldName, getZuluFormat().format(value));
// }
//
// public int getInt(String fieldName) {
// try {
// return (Integer) mInner.getData(fieldName);
// }
// catch (Exception ex) {
// return 0;
// }
// }
//
// public void setInt(String fieldName, int value) {
// mInner.setData(fieldName, value);
// }
//
// public String getString(String fieldName) {
// try {
// return (String) mInner.getData(fieldName);
// }
// catch (Exception ex) {
// return null;
// }
// }
//
// public void setString(String fieldName, String value) {
// mInner.setData(fieldName, value);
// }
//
// public JSONObject getObject(String fieldName) {
// try {
// return (JSONObject) mInner.getData(fieldName);
// }
// catch (Exception ex) {
// return null;
// }
// }
//
// public void setObject(String fieldName, JSONObject value) {
// mInner.setData(fieldName, value);
// }
// }
// Path: AndroidRepairApp/app/src/main/java/com/canviz/repairapp/data/IncidentWorkflowTaskModel.java
import com.canviz.repairapp.utility.SPListItemWrapper;
import com.microsoft.services.sharepoint.SPListItem;
package com.canviz.repairapp.data;
public class IncidentWorkflowTaskModel {
public static final String[] SELECT = {
"Id","PercentComplete","Status"
};
public static final String[] EXPAND = {
};
| private final SPListItemWrapper mData; |
NightKosh/Gravestone-mod-Graves | src/main/java/nightkosh/gravestone/core/event/EventHandlerNetwork.java | // Path: src/main/java/nightkosh/gravestone/core/MobHandler.java
// public class MobHandler {
// public static final String MOBS_SPAWN_TIME_FILE_NAME = "mobsSpawnTime.gs";
// public static final String MOBS_SPAWN_TIME_BACKUP_FILE_NAME = "mobsSpawnTimeBackup.gs";
//
// private static HashMap<String, Long> mobsSpawnTime = new HashMap<>();
//
// public static void clearMobsSpawnTime(Entity entity) {
// mobsSpawnTime.remove(entity.getUniqueID().toString());
// saveMobsSpawnTime(entity.getEntityWorld());
// }
//
// public static long getAndRemoveSpawnTime(Entity entity) {
// if (mobsSpawnTime.containsKey(entity.getUniqueID().toString())) {
// long time = mobsSpawnTime.get(entity.getUniqueID().toString());
// clearMobsSpawnTime(entity);
// return time;
// } else {
// return entity.getEntityWorld().getWorldTime();
// }
// }
//
// public static long getMobSpawnTime(Entity entity) {
// if (!mobsSpawnTime.containsKey(entity.getUniqueID().toString())) {
// mobsSpawnTime.put(entity.getUniqueID().toString(), entity.getEntityWorld().getWorldTime());
// saveMobsSpawnTime(entity.getEntityWorld());
// }
// return mobsSpawnTime.get(entity.getUniqueID().toString());
// }
//
// public static void setMobSpawnTime(Entity entity) {
// if (!mobsSpawnTime.containsKey(entity.getUniqueID().toString())) {
// mobsSpawnTime.put(entity.getUniqueID().toString(), entity.getEntityWorld().getWorldTime());
// saveMobsSpawnTime(entity.getEntityWorld());
// }
// }
//
// public static void loadMobsSpawnTime(World world) {
// try {
// File file = new File(world.getSaveHandler().getWorldDirectory(), MOBS_SPAWN_TIME_FILE_NAME);
// File backup = new File(world.getSaveHandler().getWorldDirectory(), MOBS_SPAWN_TIME_BACKUP_FILE_NAME);
//
// NBTTagCompound data = null;
// boolean save = false;
// if (file != null && file.exists()) {
// data = getDataFromFile(file);
// }
// if (file == null || !file.exists() || data == null || data.hasNoTags()) {
// GSLogger.logError("Data not found. Trying to load backup data.");
// if (backup != null && backup.exists()) {
// data = getDataFromFile(backup);
// save = true;
// }
// }
// if (data != null) {
// Set keySet = data.getKeySet();
// Iterator it = keySet.iterator();
// while (it.hasNext()) {
// String tagName = (String) it.next();
// mobsSpawnTime.put(tagName, data.getLong(tagName));
// }
// if (save) {
// saveMobsSpawnTime(world);
// }
// }
// } catch (Exception e) {
// GSLogger.logError("Error loading mobs spawn time");
// e.printStackTrace();
// }
// }
//
// public static void saveMobsSpawnTime(World world) {
// if (world != null && !world.isRemote && mobsSpawnTime != null) {
// try {
// File file = new File(world.getSaveHandler().getWorldDirectory(), MOBS_SPAWN_TIME_FILE_NAME);
// File backup = new File(world.getSaveHandler().getWorldDirectory(), MOBS_SPAWN_TIME_BACKUP_FILE_NAME);
//
// if (file != null && file.exists()) {
// try {
// Files.copy(file, backup);
// } catch (Exception e) {
// GSLogger.logError("Could not backup old spawn time file");
// }
// }
// try {
// if (file != null) {
// NBTTagCompound data = new NBTTagCompound();
// for (Map.Entry<String, Long> entry : mobsSpawnTime.entrySet()) {
// if (entry != null) {
// data.setLong(entry.getKey(), entry.getValue());
// }
// }
// FileOutputStream fileoutputstream = new FileOutputStream(file);
// CompressedStreamTools.writeCompressed(data, fileoutputstream);
// fileoutputstream.close();
// }
// } catch (Exception e) {
// GSLogger.logError("Could not save spawn time file");
// e.printStackTrace();
// if (file.exists()) {
// try {
// file.delete();
// } catch (Exception e2) {
// }
// }
// }
// } catch (Exception e) {
// GSLogger.logError("Error saving mobs spawn time");
// e.printStackTrace();
// }
// }
// }
//
// private static NBTTagCompound getDataFromFile(File file) {
// NBTTagCompound data = null;
// try {
// FileInputStream fileinputstream = new FileInputStream(file);
// data = CompressedStreamTools.readCompressed(fileinputstream);
// fileinputstream.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// return data;
// }
// }
| import nightkosh.gravestone.core.MobHandler;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.PlayerEvent; | package nightkosh.gravestone.core.event;
/**
* GraveStone mod
*
* @author NightKosh
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
*/
public class EventHandlerNetwork {
@SubscribeEvent
public void playerLoggedInEvent(PlayerEvent.PlayerLoggedInEvent event) {
if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { | // Path: src/main/java/nightkosh/gravestone/core/MobHandler.java
// public class MobHandler {
// public static final String MOBS_SPAWN_TIME_FILE_NAME = "mobsSpawnTime.gs";
// public static final String MOBS_SPAWN_TIME_BACKUP_FILE_NAME = "mobsSpawnTimeBackup.gs";
//
// private static HashMap<String, Long> mobsSpawnTime = new HashMap<>();
//
// public static void clearMobsSpawnTime(Entity entity) {
// mobsSpawnTime.remove(entity.getUniqueID().toString());
// saveMobsSpawnTime(entity.getEntityWorld());
// }
//
// public static long getAndRemoveSpawnTime(Entity entity) {
// if (mobsSpawnTime.containsKey(entity.getUniqueID().toString())) {
// long time = mobsSpawnTime.get(entity.getUniqueID().toString());
// clearMobsSpawnTime(entity);
// return time;
// } else {
// return entity.getEntityWorld().getWorldTime();
// }
// }
//
// public static long getMobSpawnTime(Entity entity) {
// if (!mobsSpawnTime.containsKey(entity.getUniqueID().toString())) {
// mobsSpawnTime.put(entity.getUniqueID().toString(), entity.getEntityWorld().getWorldTime());
// saveMobsSpawnTime(entity.getEntityWorld());
// }
// return mobsSpawnTime.get(entity.getUniqueID().toString());
// }
//
// public static void setMobSpawnTime(Entity entity) {
// if (!mobsSpawnTime.containsKey(entity.getUniqueID().toString())) {
// mobsSpawnTime.put(entity.getUniqueID().toString(), entity.getEntityWorld().getWorldTime());
// saveMobsSpawnTime(entity.getEntityWorld());
// }
// }
//
// public static void loadMobsSpawnTime(World world) {
// try {
// File file = new File(world.getSaveHandler().getWorldDirectory(), MOBS_SPAWN_TIME_FILE_NAME);
// File backup = new File(world.getSaveHandler().getWorldDirectory(), MOBS_SPAWN_TIME_BACKUP_FILE_NAME);
//
// NBTTagCompound data = null;
// boolean save = false;
// if (file != null && file.exists()) {
// data = getDataFromFile(file);
// }
// if (file == null || !file.exists() || data == null || data.hasNoTags()) {
// GSLogger.logError("Data not found. Trying to load backup data.");
// if (backup != null && backup.exists()) {
// data = getDataFromFile(backup);
// save = true;
// }
// }
// if (data != null) {
// Set keySet = data.getKeySet();
// Iterator it = keySet.iterator();
// while (it.hasNext()) {
// String tagName = (String) it.next();
// mobsSpawnTime.put(tagName, data.getLong(tagName));
// }
// if (save) {
// saveMobsSpawnTime(world);
// }
// }
// } catch (Exception e) {
// GSLogger.logError("Error loading mobs spawn time");
// e.printStackTrace();
// }
// }
//
// public static void saveMobsSpawnTime(World world) {
// if (world != null && !world.isRemote && mobsSpawnTime != null) {
// try {
// File file = new File(world.getSaveHandler().getWorldDirectory(), MOBS_SPAWN_TIME_FILE_NAME);
// File backup = new File(world.getSaveHandler().getWorldDirectory(), MOBS_SPAWN_TIME_BACKUP_FILE_NAME);
//
// if (file != null && file.exists()) {
// try {
// Files.copy(file, backup);
// } catch (Exception e) {
// GSLogger.logError("Could not backup old spawn time file");
// }
// }
// try {
// if (file != null) {
// NBTTagCompound data = new NBTTagCompound();
// for (Map.Entry<String, Long> entry : mobsSpawnTime.entrySet()) {
// if (entry != null) {
// data.setLong(entry.getKey(), entry.getValue());
// }
// }
// FileOutputStream fileoutputstream = new FileOutputStream(file);
// CompressedStreamTools.writeCompressed(data, fileoutputstream);
// fileoutputstream.close();
// }
// } catch (Exception e) {
// GSLogger.logError("Could not save spawn time file");
// e.printStackTrace();
// if (file.exists()) {
// try {
// file.delete();
// } catch (Exception e2) {
// }
// }
// }
// } catch (Exception e) {
// GSLogger.logError("Error saving mobs spawn time");
// e.printStackTrace();
// }
// }
// }
//
// private static NBTTagCompound getDataFromFile(File file) {
// NBTTagCompound data = null;
// try {
// FileInputStream fileinputstream = new FileInputStream(file);
// data = CompressedStreamTools.readCompressed(fileinputstream);
// fileinputstream.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// return data;
// }
// }
// Path: src/main/java/nightkosh/gravestone/core/event/EventHandlerNetwork.java
import nightkosh.gravestone.core.MobHandler;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.PlayerEvent;
package nightkosh.gravestone.core.event;
/**
* GraveStone mod
*
* @author NightKosh
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
*/
public class EventHandlerNetwork {
@SubscribeEvent
public void playerLoggedInEvent(PlayerEvent.PlayerLoggedInEvent event) {
if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { | MobHandler.setMobSpawnTime(event.player); |
NightKosh/Gravestone-mod-Graves | src/main/java/nightkosh/gravestone/core/commands/Command.java | // Path: src/main/java/nightkosh/gravestone/core/commands/backup/SubCommandRestoreItems.java
// public class SubCommandRestoreItems extends SubCommandBackup {
//
// public static final String COMMAND_NAME = "restore_items";
// public static final String COMMAND_USAGE = Command.MAIN_COMMAND_NAME + COMMAND_NAME + " <player name>";
//
// @Override
// public String getCommandName() {
// return COMMAND_NAME;
// }
//
// @Override
// public String getCommandUsage() {
// return COMMAND_USAGE;
// }
//
// @Override
// protected void execute(Backup backup, ICommandSender sender, String name) {
// List<ItemStack> items = backup.getItems();
//
// if (items != null && !items.isEmpty()) {
// for (ItemStack item : items) {
// if (item != null) {
// GraveInventory.dropItem(item, sender.getEntityWorld(), sender.getPosition());
// }
// }
// } else {
// sender.sendMessage(new TextComponentTranslation("There are no items for player " + name)
// .setStyle(new Style().setColor(TextFormatting.RED)));
// }
// }
// }
| import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.text.Style;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.util.text.TextFormatting;
import nightkosh.gravestone.core.commands.backup.SubCommandGravePosition;
import nightkosh.gravestone.core.commands.backup.SubCommandRestoreItems;
import java.util.ArrayList;
import java.util.List; | package nightkosh.gravestone.core.commands;
/**
* GraveStone mod
*
* @author NightKosh
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
*/
public class Command extends CommandBase {
private static final SubCommandCustomGraveItems CUSTOM_GRAVES_ITEMS = new SubCommandCustomGraveItems();
private static final SubCommandCommandsList COMMANDS_LIST = new SubCommandCommandsList();
private static final SubCommandGravePosition GRAVE_POS = new SubCommandGravePosition(); | // Path: src/main/java/nightkosh/gravestone/core/commands/backup/SubCommandRestoreItems.java
// public class SubCommandRestoreItems extends SubCommandBackup {
//
// public static final String COMMAND_NAME = "restore_items";
// public static final String COMMAND_USAGE = Command.MAIN_COMMAND_NAME + COMMAND_NAME + " <player name>";
//
// @Override
// public String getCommandName() {
// return COMMAND_NAME;
// }
//
// @Override
// public String getCommandUsage() {
// return COMMAND_USAGE;
// }
//
// @Override
// protected void execute(Backup backup, ICommandSender sender, String name) {
// List<ItemStack> items = backup.getItems();
//
// if (items != null && !items.isEmpty()) {
// for (ItemStack item : items) {
// if (item != null) {
// GraveInventory.dropItem(item, sender.getEntityWorld(), sender.getPosition());
// }
// }
// } else {
// sender.sendMessage(new TextComponentTranslation("There are no items for player " + name)
// .setStyle(new Style().setColor(TextFormatting.RED)));
// }
// }
// }
// Path: src/main/java/nightkosh/gravestone/core/commands/Command.java
import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.text.Style;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.util.text.TextFormatting;
import nightkosh.gravestone.core.commands.backup.SubCommandGravePosition;
import nightkosh.gravestone.core.commands.backup.SubCommandRestoreItems;
import java.util.ArrayList;
import java.util.List;
package nightkosh.gravestone.core.commands;
/**
* GraveStone mod
*
* @author NightKosh
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
*/
public class Command extends CommandBase {
private static final SubCommandCustomGraveItems CUSTOM_GRAVES_ITEMS = new SubCommandCustomGraveItems();
private static final SubCommandCommandsList COMMANDS_LIST = new SubCommandCommandsList();
private static final SubCommandGravePosition GRAVE_POS = new SubCommandGravePosition(); | private static final SubCommandRestoreItems GRAVE_ITEMS = new SubCommandRestoreItems(); |
NightKosh/Gravestone-mod-Graves | src/main/java/nightkosh/gravestone/core/GSBlockOld.java | // Path: src/main/java/nightkosh/gravestone/item/itemblock/ItemBlockGraveStoneOld.java
// public class ItemBlockGraveStoneOld extends ItemBlock {
// //TODO remove !!!!!!!!!!!!!!!!!!!!!!!
// public ItemBlockGraveStoneOld(Block block) {
// super(block);
// this.setHasSubtypes(true);
// this.setRegistryName(GSBlockOld.GRAVE_STONE.getRegistryName());
// }
//
// @Override
// public int getMetadata(int damageValue) {
// return 0;
// }
//
// @Override
// public String getUnlocalizedName(ItemStack itemStack) {
// return EnumGraves.getById(itemStack.getItemDamage()).getUnLocalizedName();
// }
//
// @Override
// public void onCreated(ItemStack stack, World world, EntityPlayer player) {
// if (!stack.hasTagCompound()) {
// stack.setTagCompound(new NBTTagCompound());
// }
// }
//
// @Override
// public void addInformation(ItemStack stack, @Nullable World world, List<String> tooltipList, ITooltipFlag flag) {
// if (!stack.hasTagCompound()) {
// stack.setTagCompound(new NBTTagCompound());
// } else {
// NBTTagCompound nbt = stack.getTagCompound();
//
// String deathText = "";
// if (nbt.hasKey("DeathText") && StringUtils.isNotBlank(nbt.getString("DeathText"))) {
// deathText = nbt.getString("DeathText");
// }
//
// if (nbt.hasKey("isLocalized") && nbt.getBoolean("isLocalized")) {
// if (nbt.hasKey("name")) {
// String name = ModGraveStone.proxy.getLocalizedEntityName(nbt.getString("name"));
// String killerName = ModGraveStone.proxy.getLocalizedEntityName(nbt.getString("KillerName"));
// if (killerName.length() == 0) {
// tooltipList.add(new TextComponentTranslation(deathText, new Object[]{name}).getFormattedText());
// } else {
// tooltipList.add(new TextComponentTranslation(deathText, new Object[]{name, killerName.toLowerCase()}).getFormattedText());
// }
// }
// } else {
// tooltipList.add(deathText);
// }
//
// if (nbt.getInteger("Age") > 0) {
// tooltipList.add(ModGraveStone.proxy.getLocalizedString("item.grave.age") + " " + nbt.getInteger("Age") + " " + ModGraveStone.proxy.getLocalizedString("item.grave.days"));
// }
//
// EnumGraveMaterial material = EnumGraves.getById(stack.getItemDamage()).getMaterial();
// if (material != EnumGraveMaterial.OTHER) {
// StringBuilder materialStr = new StringBuilder();
// materialStr.append(ModGraveStone.proxy.getLocalizedString("material.title"))
// .append(" ")
// .append(ModGraveStone.proxy.getLocalizedMaterial(material));
// if (nbt.getBoolean("Mossy")) {
// materialStr.append(", ")
// .append(ModGraveStone.proxy.getLocalizedString("material.mossy"));
// }
// tooltipList.add(materialStr.toString());
// }
//
// if (nbt.hasKey("Sword")) {
// ItemStack sword = new ItemStack(nbt.getCompoundTag("Sword"));
//
// if (StringUtils.isNotBlank(sword.getDisplayName())) {
// tooltipList.add(ModGraveStone.proxy.getLocalizedString("item.grave.sword_name") + " - " + sword.getDisplayName());
// }
//
// if (sword.getItemDamage() != 0) {
// tooltipList.add(ModGraveStone.proxy.getLocalizedString("item.grave.sword_damage") + " - " + sword.getItemDamage());
// }
//
// if (sword.getTagCompound() != null && sword.getTagCompound().hasKey("ench")) {
// NBTTagList enchantments = sword.getTagCompound().getTagList("ench", 10);
//
// if (enchantments.tagCount() != 0) {
// for (int i = 0; i < enchantments.tagCount(); i++) {
// short enchantmentId = enchantments.getCompoundTagAt(i).getShort("id");
// short enchantmentLvl = enchantments.getCompoundTagAt(i).getShort("lvl");
//
// try {
// if (Enchantment.getEnchantmentByID(enchantmentId) != null) {
// tooltipList.add(Enchantment.getEnchantmentByID(enchantmentId).getTranslatedName(enchantmentLvl));
// }
// } catch (Exception e) {
//
// }
// }
// }
// }
// }
// }
// }
//
// @Override
// @SideOnly(Side.CLIENT)
// public boolean hasEffect(ItemStack stack) {
// return stack.hasTagCompound() && stack.getTagCompound().hasKey("Enchanted");
// }
// }
| import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraftforge.event.RegistryEvent;
import nightkosh.gravestone.block.BlockGraveStoneOld;
import nightkosh.gravestone.item.itemblock.ItemBlockGraveStoneOld; | package nightkosh.gravestone.core;
/**
* GraveStone mod
*
* @author NightKosh
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
*/
//@GameRegistry.ObjectHolder("gravestone")
public class GSBlockOld {
//TODO remove !!!!!!!!!!!!!!!!!!!!!!!
public static final Block GRAVE_STONE = new BlockGraveStoneOld(); | // Path: src/main/java/nightkosh/gravestone/item/itemblock/ItemBlockGraveStoneOld.java
// public class ItemBlockGraveStoneOld extends ItemBlock {
// //TODO remove !!!!!!!!!!!!!!!!!!!!!!!
// public ItemBlockGraveStoneOld(Block block) {
// super(block);
// this.setHasSubtypes(true);
// this.setRegistryName(GSBlockOld.GRAVE_STONE.getRegistryName());
// }
//
// @Override
// public int getMetadata(int damageValue) {
// return 0;
// }
//
// @Override
// public String getUnlocalizedName(ItemStack itemStack) {
// return EnumGraves.getById(itemStack.getItemDamage()).getUnLocalizedName();
// }
//
// @Override
// public void onCreated(ItemStack stack, World world, EntityPlayer player) {
// if (!stack.hasTagCompound()) {
// stack.setTagCompound(new NBTTagCompound());
// }
// }
//
// @Override
// public void addInformation(ItemStack stack, @Nullable World world, List<String> tooltipList, ITooltipFlag flag) {
// if (!stack.hasTagCompound()) {
// stack.setTagCompound(new NBTTagCompound());
// } else {
// NBTTagCompound nbt = stack.getTagCompound();
//
// String deathText = "";
// if (nbt.hasKey("DeathText") && StringUtils.isNotBlank(nbt.getString("DeathText"))) {
// deathText = nbt.getString("DeathText");
// }
//
// if (nbt.hasKey("isLocalized") && nbt.getBoolean("isLocalized")) {
// if (nbt.hasKey("name")) {
// String name = ModGraveStone.proxy.getLocalizedEntityName(nbt.getString("name"));
// String killerName = ModGraveStone.proxy.getLocalizedEntityName(nbt.getString("KillerName"));
// if (killerName.length() == 0) {
// tooltipList.add(new TextComponentTranslation(deathText, new Object[]{name}).getFormattedText());
// } else {
// tooltipList.add(new TextComponentTranslation(deathText, new Object[]{name, killerName.toLowerCase()}).getFormattedText());
// }
// }
// } else {
// tooltipList.add(deathText);
// }
//
// if (nbt.getInteger("Age") > 0) {
// tooltipList.add(ModGraveStone.proxy.getLocalizedString("item.grave.age") + " " + nbt.getInteger("Age") + " " + ModGraveStone.proxy.getLocalizedString("item.grave.days"));
// }
//
// EnumGraveMaterial material = EnumGraves.getById(stack.getItemDamage()).getMaterial();
// if (material != EnumGraveMaterial.OTHER) {
// StringBuilder materialStr = new StringBuilder();
// materialStr.append(ModGraveStone.proxy.getLocalizedString("material.title"))
// .append(" ")
// .append(ModGraveStone.proxy.getLocalizedMaterial(material));
// if (nbt.getBoolean("Mossy")) {
// materialStr.append(", ")
// .append(ModGraveStone.proxy.getLocalizedString("material.mossy"));
// }
// tooltipList.add(materialStr.toString());
// }
//
// if (nbt.hasKey("Sword")) {
// ItemStack sword = new ItemStack(nbt.getCompoundTag("Sword"));
//
// if (StringUtils.isNotBlank(sword.getDisplayName())) {
// tooltipList.add(ModGraveStone.proxy.getLocalizedString("item.grave.sword_name") + " - " + sword.getDisplayName());
// }
//
// if (sword.getItemDamage() != 0) {
// tooltipList.add(ModGraveStone.proxy.getLocalizedString("item.grave.sword_damage") + " - " + sword.getItemDamage());
// }
//
// if (sword.getTagCompound() != null && sword.getTagCompound().hasKey("ench")) {
// NBTTagList enchantments = sword.getTagCompound().getTagList("ench", 10);
//
// if (enchantments.tagCount() != 0) {
// for (int i = 0; i < enchantments.tagCount(); i++) {
// short enchantmentId = enchantments.getCompoundTagAt(i).getShort("id");
// short enchantmentLvl = enchantments.getCompoundTagAt(i).getShort("lvl");
//
// try {
// if (Enchantment.getEnchantmentByID(enchantmentId) != null) {
// tooltipList.add(Enchantment.getEnchantmentByID(enchantmentId).getTranslatedName(enchantmentLvl));
// }
// } catch (Exception e) {
//
// }
// }
// }
// }
// }
// }
// }
//
// @Override
// @SideOnly(Side.CLIENT)
// public boolean hasEffect(ItemStack stack) {
// return stack.hasTagCompound() && stack.getTagCompound().hasKey("Enchanted");
// }
// }
// Path: src/main/java/nightkosh/gravestone/core/GSBlockOld.java
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraftforge.event.RegistryEvent;
import nightkosh.gravestone.block.BlockGraveStoneOld;
import nightkosh.gravestone.item.itemblock.ItemBlockGraveStoneOld;
package nightkosh.gravestone.core;
/**
* GraveStone mod
*
* @author NightKosh
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
*/
//@GameRegistry.ObjectHolder("gravestone")
public class GSBlockOld {
//TODO remove !!!!!!!!!!!!!!!!!!!!!!!
public static final Block GRAVE_STONE = new BlockGraveStoneOld(); | public static final ItemBlock GRAVE_STONE_IB = new ItemBlockGraveStoneOld(GRAVE_STONE); |
NightKosh/Gravestone-mod-Graves | src/main/java/nightkosh/gravestone/models/block/ModelSkull.java | // Path: src/main/java/nightkosh/gravestone/models/ModelBaseAdapter.java
// public class ModelBaseAdapter extends ModelBase implements IModelBaseAdapter {
//
// @Override
// public void setTexturesOffset(String name, int xPos, int zPos) {
// super.setTextureOffset(name, xPos, zPos);
// }
// }
//
// Path: src/main/java/nightkosh/gravestone/models/ModelRendererSkull.java
// public class ModelRendererSkull extends ModelRenderer {
//
// public static enum EnumSkullType {
// SKELETON_SKULL,
// WITHER_SKULL,
// ZOMBIE_SKULL,
// STRAY_SKULL;
//
// public static EnumSkullType getTypeByClass(Entity entity) {
// if (entity instanceof EntityWitherSkeleton) {
// return WITHER_SKULL;
// } else {//if (entity instanceof EntitySkeleton) {
// return SKELETON_SKULL;
// }
// }
// }
//
// private final static String NAME = "skull";
// private ModelRenderer teeth;
//
// public <T extends ModelBase & IModelBaseAdapter> ModelRendererSkull(T modelBase) {
// this(modelBase, 0, 0, 0, -4, 16.6F, -4);
// }
//
// public <T extends ModelBase & IModelBaseAdapter> ModelRendererSkull(T modelBase, float xPos, float yPos, float zPos, float xRot, float yRot, float zRot) {
// super(modelBase, NAME);
//
// textureWidth = 32;
// textureHeight = 32;
//
// modelBase.setTexturesOffset("skull.skull", 0, 0);
// modelBase.setTexturesOffset("teeth.teeth", 0, 14);
//
// this.setRotationPoint(xRot, yRot, zRot);
// setRotation(this, -0.1745329F, 0, 0);
// this.addBox("skull", xPos, yPos, zPos, 8, 6, 8);
//
// teeth = new ModelRenderer(modelBase, "teeth");
// teeth.setRotationPoint(2, 5.4F, 0.1F);
// teeth.addBox("teeth", xPos, yPos, zPos, 4, 2, 1);
//
// this.addChild(teeth);
// }
//
// public void bindTexture(EnumSkullType skullType) {
// ResourceLocation texture;
// switch (skullType) {//TODO
// case SKELETON_SKULL:
// default:
// texture = Resources.SKELETON_SKULL;
// break;
// case WITHER_SKULL:
// texture = Resources.WITHER_SKULL;
// break;
// case ZOMBIE_SKULL:
// texture = Resources.ZOMBIE_SKULL;
// break;
// case STRAY_SKULL:
// texture = Resources.STRAY_SKULL;
// break;
// }
// Minecraft.getMinecraft().renderEngine.bindTexture(texture);
// }
//
// public void bindTexture(boolean isWither) {
// Minecraft.getMinecraft().renderEngine.bindTexture(isWither ? Resources.WITHER_SKULL : Resources.SKELETON_SKULL);
// }
//
// public void renderWithTexture(float p_78785_1_, boolean isWither) {
// bindTexture(isWither);
// this.render(p_78785_1_);
// }
//
// public void renderWithTexture(float p_78785_1_, EnumSkullType skullType) {
// bindTexture(skullType);
// this.render(p_78785_1_);
// }
//
// @Override
// public void render(float p_78785_1_) {
// super.render(p_78785_1_);
// }
//
// private void setRotation(ModelRenderer model, float x, float y, float z) {
// model.rotateAngleX = x;
// model.rotateAngleY = y;
// model.rotateAngleZ = z;
// }
// }
| import nightkosh.gravestone.models.ModelBaseAdapter;
import nightkosh.gravestone.models.ModelRendererSkull;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity; | package nightkosh.gravestone.models.block;
/**
* GraveStone mod
*
* @author NightKosh
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
*/
public class ModelSkull extends ModelBaseAdapter {
private ModelRenderer skull;
public ModelSkull() { | // Path: src/main/java/nightkosh/gravestone/models/ModelBaseAdapter.java
// public class ModelBaseAdapter extends ModelBase implements IModelBaseAdapter {
//
// @Override
// public void setTexturesOffset(String name, int xPos, int zPos) {
// super.setTextureOffset(name, xPos, zPos);
// }
// }
//
// Path: src/main/java/nightkosh/gravestone/models/ModelRendererSkull.java
// public class ModelRendererSkull extends ModelRenderer {
//
// public static enum EnumSkullType {
// SKELETON_SKULL,
// WITHER_SKULL,
// ZOMBIE_SKULL,
// STRAY_SKULL;
//
// public static EnumSkullType getTypeByClass(Entity entity) {
// if (entity instanceof EntityWitherSkeleton) {
// return WITHER_SKULL;
// } else {//if (entity instanceof EntitySkeleton) {
// return SKELETON_SKULL;
// }
// }
// }
//
// private final static String NAME = "skull";
// private ModelRenderer teeth;
//
// public <T extends ModelBase & IModelBaseAdapter> ModelRendererSkull(T modelBase) {
// this(modelBase, 0, 0, 0, -4, 16.6F, -4);
// }
//
// public <T extends ModelBase & IModelBaseAdapter> ModelRendererSkull(T modelBase, float xPos, float yPos, float zPos, float xRot, float yRot, float zRot) {
// super(modelBase, NAME);
//
// textureWidth = 32;
// textureHeight = 32;
//
// modelBase.setTexturesOffset("skull.skull", 0, 0);
// modelBase.setTexturesOffset("teeth.teeth", 0, 14);
//
// this.setRotationPoint(xRot, yRot, zRot);
// setRotation(this, -0.1745329F, 0, 0);
// this.addBox("skull", xPos, yPos, zPos, 8, 6, 8);
//
// teeth = new ModelRenderer(modelBase, "teeth");
// teeth.setRotationPoint(2, 5.4F, 0.1F);
// teeth.addBox("teeth", xPos, yPos, zPos, 4, 2, 1);
//
// this.addChild(teeth);
// }
//
// public void bindTexture(EnumSkullType skullType) {
// ResourceLocation texture;
// switch (skullType) {//TODO
// case SKELETON_SKULL:
// default:
// texture = Resources.SKELETON_SKULL;
// break;
// case WITHER_SKULL:
// texture = Resources.WITHER_SKULL;
// break;
// case ZOMBIE_SKULL:
// texture = Resources.ZOMBIE_SKULL;
// break;
// case STRAY_SKULL:
// texture = Resources.STRAY_SKULL;
// break;
// }
// Minecraft.getMinecraft().renderEngine.bindTexture(texture);
// }
//
// public void bindTexture(boolean isWither) {
// Minecraft.getMinecraft().renderEngine.bindTexture(isWither ? Resources.WITHER_SKULL : Resources.SKELETON_SKULL);
// }
//
// public void renderWithTexture(float p_78785_1_, boolean isWither) {
// bindTexture(isWither);
// this.render(p_78785_1_);
// }
//
// public void renderWithTexture(float p_78785_1_, EnumSkullType skullType) {
// bindTexture(skullType);
// this.render(p_78785_1_);
// }
//
// @Override
// public void render(float p_78785_1_) {
// super.render(p_78785_1_);
// }
//
// private void setRotation(ModelRenderer model, float x, float y, float z) {
// model.rotateAngleX = x;
// model.rotateAngleY = y;
// model.rotateAngleZ = z;
// }
// }
// Path: src/main/java/nightkosh/gravestone/models/block/ModelSkull.java
import nightkosh.gravestone.models.ModelBaseAdapter;
import nightkosh.gravestone.models.ModelRendererSkull;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
package nightkosh.gravestone.models.block;
/**
* GraveStone mod
*
* @author NightKosh
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
*/
public class ModelSkull extends ModelBaseAdapter {
private ModelRenderer skull;
public ModelSkull() { | skull = new ModelRendererSkull(this); |
NightKosh/Gravestone-mod-Graves | src/main/java/nightkosh/gravestone/tileentity/ISpawnerEntity.java | // Path: src/main/java/nightkosh/gravestone/helper/GroupOfGravesSpawnerHelper.java
// public abstract class GroupOfGravesSpawnerHelper extends Entity implements ISpawnerEntity {
//
// public GroupOfGravesSpawnerHelper(World worldIn) {
// super(worldIn);
// }
//
// @Override
// public World getIWorld() {
// return getEntityWorld();
// }
//
// @Override
// public BlockPos getIPos() {
// return getPosition();
// }
// }
| import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import nightkosh.gravestone.helper.GroupOfGravesSpawnerHelper; | package nightkosh.gravestone.tileentity;
/**
* GraveStone mod
*
* @author NightKosh
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
*/
public interface ISpawnerEntity {
public BlockPos getIPos();
public World getIWorld();
public boolean haveSpawnerHelper();
| // Path: src/main/java/nightkosh/gravestone/helper/GroupOfGravesSpawnerHelper.java
// public abstract class GroupOfGravesSpawnerHelper extends Entity implements ISpawnerEntity {
//
// public GroupOfGravesSpawnerHelper(World worldIn) {
// super(worldIn);
// }
//
// @Override
// public World getIWorld() {
// return getEntityWorld();
// }
//
// @Override
// public BlockPos getIPos() {
// return getPosition();
// }
// }
// Path: src/main/java/nightkosh/gravestone/tileentity/ISpawnerEntity.java
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import nightkosh.gravestone.helper.GroupOfGravesSpawnerHelper;
package nightkosh.gravestone.tileentity;
/**
* GraveStone mod
*
* @author NightKosh
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
*/
public interface ISpawnerEntity {
public BlockPos getIPos();
public World getIWorld();
public boolean haveSpawnerHelper();
| public GroupOfGravesSpawnerHelper getSpawnerHelper(); |
NightKosh/Gravestone-mod-Graves | src/main/java/nightkosh/gravestone/core/MobHandler.java | // Path: src/main/java/nightkosh/gravestone/core/logger/GSLogger.java
// public class GSLogger {
//
// private static Logger logger = LogManager.getLogger(ModInfo.ID);
// private static Logger graveLogger = new GravesLogger();
//
// public static void log(Level logLevel, String message) {
// logger.log(logLevel, message);
// }
//
// public static void logInfo(String message) {
// logger.log(Level.INFO, message);
// }
//
// public static void logError(String message) {
// logger.log(Level.ERROR, message);
// }
//
// public static void logGrave(Level logLevel, String message) {
// graveLogger.log(logLevel, message);
// }
//
// public static void logInfoGrave(String message) {
// graveLogger.log(Level.INFO, message);
// }
//
// public static void logErrorGrave(String message) {
// graveLogger.log(Level.ERROR, message);
// }
// }
| import com.google.common.io.Files;
import nightkosh.gravestone.core.logger.GSLogger;
import net.minecraft.entity.Entity;
import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set; | return entity.getEntityWorld().getWorldTime();
}
}
public static long getMobSpawnTime(Entity entity) {
if (!mobsSpawnTime.containsKey(entity.getUniqueID().toString())) {
mobsSpawnTime.put(entity.getUniqueID().toString(), entity.getEntityWorld().getWorldTime());
saveMobsSpawnTime(entity.getEntityWorld());
}
return mobsSpawnTime.get(entity.getUniqueID().toString());
}
public static void setMobSpawnTime(Entity entity) {
if (!mobsSpawnTime.containsKey(entity.getUniqueID().toString())) {
mobsSpawnTime.put(entity.getUniqueID().toString(), entity.getEntityWorld().getWorldTime());
saveMobsSpawnTime(entity.getEntityWorld());
}
}
public static void loadMobsSpawnTime(World world) {
try {
File file = new File(world.getSaveHandler().getWorldDirectory(), MOBS_SPAWN_TIME_FILE_NAME);
File backup = new File(world.getSaveHandler().getWorldDirectory(), MOBS_SPAWN_TIME_BACKUP_FILE_NAME);
NBTTagCompound data = null;
boolean save = false;
if (file != null && file.exists()) {
data = getDataFromFile(file);
}
if (file == null || !file.exists() || data == null || data.hasNoTags()) { | // Path: src/main/java/nightkosh/gravestone/core/logger/GSLogger.java
// public class GSLogger {
//
// private static Logger logger = LogManager.getLogger(ModInfo.ID);
// private static Logger graveLogger = new GravesLogger();
//
// public static void log(Level logLevel, String message) {
// logger.log(logLevel, message);
// }
//
// public static void logInfo(String message) {
// logger.log(Level.INFO, message);
// }
//
// public static void logError(String message) {
// logger.log(Level.ERROR, message);
// }
//
// public static void logGrave(Level logLevel, String message) {
// graveLogger.log(logLevel, message);
// }
//
// public static void logInfoGrave(String message) {
// graveLogger.log(Level.INFO, message);
// }
//
// public static void logErrorGrave(String message) {
// graveLogger.log(Level.ERROR, message);
// }
// }
// Path: src/main/java/nightkosh/gravestone/core/MobHandler.java
import com.google.common.io.Files;
import nightkosh.gravestone.core.logger.GSLogger;
import net.minecraft.entity.Entity;
import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
return entity.getEntityWorld().getWorldTime();
}
}
public static long getMobSpawnTime(Entity entity) {
if (!mobsSpawnTime.containsKey(entity.getUniqueID().toString())) {
mobsSpawnTime.put(entity.getUniqueID().toString(), entity.getEntityWorld().getWorldTime());
saveMobsSpawnTime(entity.getEntityWorld());
}
return mobsSpawnTime.get(entity.getUniqueID().toString());
}
public static void setMobSpawnTime(Entity entity) {
if (!mobsSpawnTime.containsKey(entity.getUniqueID().toString())) {
mobsSpawnTime.put(entity.getUniqueID().toString(), entity.getEntityWorld().getWorldTime());
saveMobsSpawnTime(entity.getEntityWorld());
}
}
public static void loadMobsSpawnTime(World world) {
try {
File file = new File(world.getSaveHandler().getWorldDirectory(), MOBS_SPAWN_TIME_FILE_NAME);
File backup = new File(world.getSaveHandler().getWorldDirectory(), MOBS_SPAWN_TIME_BACKUP_FILE_NAME);
NBTTagCompound data = null;
boolean save = false;
if (file != null && file.exists()) {
data = getDataFromFile(file);
}
if (file == null || !file.exists() || data == null || data.hasNoTags()) { | GSLogger.logError("Data not found. Trying to load backup data."); |
NightKosh/Gravestone-mod-Graves | src/main/java/nightkosh/gravestone/core/GSTileEntity.java | // Path: src/main/java/nightkosh/gravestone/ModGraveStone.java
// @Mod(modid = ModInfo.ID, name = ModInfo.NAME, version = ModInfo.VERSION, updateJSON = "https://raw.githubusercontent.com/NightKosh/GraveStone-mod/master/update.json")
// public class ModGraveStone {
//
// @Instance(ModInfo.ID)
// public static ModGraveStone instance;
// @SidedProxy(clientSide = "nightkosh.gravestone.core.proxy.ClientProxy", serverSide = "nightkosh.gravestone.core.proxy.CommonProxy")
// public static CommonProxy proxy;
//
// public static final IGraveStoneHelper gravestoneHelper = GraveGenerationHelper.INSTANCE;
// public static final IGraveGeneration apiGraveGeneration = APIGraveGeneration.INSTANCE;
//
// public ModGraveStone() {
// instance = this;
// }
//
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// Config.getInstance(event.getModConfigurationDirectory().getAbsolutePath() + "/GraveStoneMod/", "GraveStone.cfg");
//
// // API
// GraveStoneAPI.graveStone = gravestoneHelper;
// GraveStoneAPI.graveGenerationAtDeath = apiGraveGeneration;
//
// Tabs.registration();
// GSTileEntity.registration();
//
// CapabilityManager.INSTANCE.register(IBackups.class, new BackupStorage(), Backups.class);
// }
//
// @Mod.EventHandler
// public void load(FMLInitializationEvent event) {
// // register death event
// MinecraftForge.EVENT_BUS.register(new EventsHandler());
// MinecraftForge.EVENT_BUS.register(new CapabilityHandler());
// FMLCommonHandler.instance().bus().register(new EventHandlerNetwork());
//
// NetworkRegistry.INSTANCE.registerGuiHandler(this, new GuiHandler());
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// Compatibility.getInstance();
// }
//
// @Mod.EventHandler
// public void serverStarting(FMLServerStartingEvent event) {
// Commands.registration(event);
// }
// }
| import nightkosh.gravestone.ModGraveStone; | package nightkosh.gravestone.core;
/**
* GraveStone mod
*
* @author NightKosh
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
*/
public class GSTileEntity {
public static void registration() { | // Path: src/main/java/nightkosh/gravestone/ModGraveStone.java
// @Mod(modid = ModInfo.ID, name = ModInfo.NAME, version = ModInfo.VERSION, updateJSON = "https://raw.githubusercontent.com/NightKosh/GraveStone-mod/master/update.json")
// public class ModGraveStone {
//
// @Instance(ModInfo.ID)
// public static ModGraveStone instance;
// @SidedProxy(clientSide = "nightkosh.gravestone.core.proxy.ClientProxy", serverSide = "nightkosh.gravestone.core.proxy.CommonProxy")
// public static CommonProxy proxy;
//
// public static final IGraveStoneHelper gravestoneHelper = GraveGenerationHelper.INSTANCE;
// public static final IGraveGeneration apiGraveGeneration = APIGraveGeneration.INSTANCE;
//
// public ModGraveStone() {
// instance = this;
// }
//
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// Config.getInstance(event.getModConfigurationDirectory().getAbsolutePath() + "/GraveStoneMod/", "GraveStone.cfg");
//
// // API
// GraveStoneAPI.graveStone = gravestoneHelper;
// GraveStoneAPI.graveGenerationAtDeath = apiGraveGeneration;
//
// Tabs.registration();
// GSTileEntity.registration();
//
// CapabilityManager.INSTANCE.register(IBackups.class, new BackupStorage(), Backups.class);
// }
//
// @Mod.EventHandler
// public void load(FMLInitializationEvent event) {
// // register death event
// MinecraftForge.EVENT_BUS.register(new EventsHandler());
// MinecraftForge.EVENT_BUS.register(new CapabilityHandler());
// FMLCommonHandler.instance().bus().register(new EventHandlerNetwork());
//
// NetworkRegistry.INSTANCE.registerGuiHandler(this, new GuiHandler());
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// Compatibility.getInstance();
// }
//
// @Mod.EventHandler
// public void serverStarting(FMLServerStartingEvent event) {
// Commands.registration(event);
// }
// }
// Path: src/main/java/nightkosh/gravestone/core/GSTileEntity.java
import nightkosh.gravestone.ModGraveStone;
package nightkosh.gravestone.core;
/**
* GraveStone mod
*
* @author NightKosh
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
*/
public class GSTileEntity {
public static void registration() { | ModGraveStone.proxy.registerTERenderers(); |
NightKosh/Gravestone-mod-Graves | src/main/java/nightkosh/gravestone/core/Models.java | // Path: src/main/java/nightkosh/gravestone/ModGraveStone.java
// @Mod(modid = ModInfo.ID, name = ModInfo.NAME, version = ModInfo.VERSION, updateJSON = "https://raw.githubusercontent.com/NightKosh/GraveStone-mod/master/update.json")
// public class ModGraveStone {
//
// @Instance(ModInfo.ID)
// public static ModGraveStone instance;
// @SidedProxy(clientSide = "nightkosh.gravestone.core.proxy.ClientProxy", serverSide = "nightkosh.gravestone.core.proxy.CommonProxy")
// public static CommonProxy proxy;
//
// public static final IGraveStoneHelper gravestoneHelper = GraveGenerationHelper.INSTANCE;
// public static final IGraveGeneration apiGraveGeneration = APIGraveGeneration.INSTANCE;
//
// public ModGraveStone() {
// instance = this;
// }
//
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// Config.getInstance(event.getModConfigurationDirectory().getAbsolutePath() + "/GraveStoneMod/", "GraveStone.cfg");
//
// // API
// GraveStoneAPI.graveStone = gravestoneHelper;
// GraveStoneAPI.graveGenerationAtDeath = apiGraveGeneration;
//
// Tabs.registration();
// GSTileEntity.registration();
//
// CapabilityManager.INSTANCE.register(IBackups.class, new BackupStorage(), Backups.class);
// }
//
// @Mod.EventHandler
// public void load(FMLInitializationEvent event) {
// // register death event
// MinecraftForge.EVENT_BUS.register(new EventsHandler());
// MinecraftForge.EVENT_BUS.register(new CapabilityHandler());
// FMLCommonHandler.instance().bus().register(new EventHandlerNetwork());
//
// NetworkRegistry.INSTANCE.registerGuiHandler(this, new GuiHandler());
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// Compatibility.getInstance();
// }
//
// @Mod.EventHandler
// public void serverStarting(FMLServerStartingEvent event) {
// Commands.registration(event);
// }
// }
| import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;
import nightkosh.gravestone.ModGraveStone;
import nightkosh.gravestone.api.ModInfo; | package nightkosh.gravestone.core;
/**
* GraveStone mod
*
* @author NightKosh
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
*/
@GameRegistry.ObjectHolder(ModInfo.ID)
public class Models {
@Mod.EventBusSubscriber(modid = ModInfo.ID)
public static class RegistrationHandler {
@SubscribeEvent
public static void registerModels(final ModelRegistryEvent event) { | // Path: src/main/java/nightkosh/gravestone/ModGraveStone.java
// @Mod(modid = ModInfo.ID, name = ModInfo.NAME, version = ModInfo.VERSION, updateJSON = "https://raw.githubusercontent.com/NightKosh/GraveStone-mod/master/update.json")
// public class ModGraveStone {
//
// @Instance(ModInfo.ID)
// public static ModGraveStone instance;
// @SidedProxy(clientSide = "nightkosh.gravestone.core.proxy.ClientProxy", serverSide = "nightkosh.gravestone.core.proxy.CommonProxy")
// public static CommonProxy proxy;
//
// public static final IGraveStoneHelper gravestoneHelper = GraveGenerationHelper.INSTANCE;
// public static final IGraveGeneration apiGraveGeneration = APIGraveGeneration.INSTANCE;
//
// public ModGraveStone() {
// instance = this;
// }
//
// @Mod.EventHandler
// public void preInit(FMLPreInitializationEvent event) {
// Config.getInstance(event.getModConfigurationDirectory().getAbsolutePath() + "/GraveStoneMod/", "GraveStone.cfg");
//
// // API
// GraveStoneAPI.graveStone = gravestoneHelper;
// GraveStoneAPI.graveGenerationAtDeath = apiGraveGeneration;
//
// Tabs.registration();
// GSTileEntity.registration();
//
// CapabilityManager.INSTANCE.register(IBackups.class, new BackupStorage(), Backups.class);
// }
//
// @Mod.EventHandler
// public void load(FMLInitializationEvent event) {
// // register death event
// MinecraftForge.EVENT_BUS.register(new EventsHandler());
// MinecraftForge.EVENT_BUS.register(new CapabilityHandler());
// FMLCommonHandler.instance().bus().register(new EventHandlerNetwork());
//
// NetworkRegistry.INSTANCE.registerGuiHandler(this, new GuiHandler());
// }
//
// @Mod.EventHandler
// public void postInit(FMLPostInitializationEvent event) {
// Compatibility.getInstance();
// }
//
// @Mod.EventHandler
// public void serverStarting(FMLServerStartingEvent event) {
// Commands.registration(event);
// }
// }
// Path: src/main/java/nightkosh/gravestone/core/Models.java
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;
import nightkosh.gravestone.ModGraveStone;
import nightkosh.gravestone.api.ModInfo;
package nightkosh.gravestone.core;
/**
* GraveStone mod
*
* @author NightKosh
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
*/
@GameRegistry.ObjectHolder(ModInfo.ID)
public class Models {
@Mod.EventBusSubscriber(modid = ModInfo.ID)
public static class RegistrationHandler {
@SubscribeEvent
public static void registerModels(final ModelRegistryEvent event) { | ModGraveStone.proxy.registerTEISR(); |
NightKosh/Gravestone-mod-Graves | src/main/java/nightkosh/gravestone/core/commands/backup/SubCommandBackup.java | // Path: src/main/java/nightkosh/gravestone/capability/Backup.java
// public class Backup {
//
// private int dimensionId;
// private BlockPos pos;
// private List<ItemStack> items = new ArrayList<>();
//
// public Backup() {
// }
//
// public Backup(int dimensionId, BlockPos pos, List<ItemStack> items) {
// this.dimensionId = dimensionId;
// this.pos = pos;
// setItems(items);
// }
//
// public int getDimensionId() {
// return dimensionId;
// }
//
// public void setDimensionId(int dimensionId) {
// this.dimensionId = dimensionId;
// }
//
// public BlockPos getPos() {
// return pos;
// }
//
// public void setPos(BlockPos pos) {
// this.pos = pos;
// }
//
// public List<ItemStack> getItems() {
// return items;
// }
//
// public void setItems(List<ItemStack> items) {
// for (ItemStack stack : items) {
// if (stack != null && !stack.isEmpty()) {
// this.items.add(stack.copy());
// }
// }
// }
// }
//
// Path: src/main/java/nightkosh/gravestone/capability/IBackups.java
// public interface IBackups {
//
// Deque<Backup> getBackups();
//
// void setBackups(Deque<Backup> backups);
//
// Backup getBackup(int num);
//
// void addBackup(Backup backup);
// }
//
// Path: src/main/java/nightkosh/gravestone/core/commands/ISubCommand.java
// public interface ISubCommand {
//
// public String getCommandName();
//
// public default String getCommandUsage() {
// return Command.MAIN_COMMAND_NAME + getCommandName();
// }
//
// public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException;
// }
| import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.text.Style;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.util.text.TextFormatting;
import nightkosh.gravestone.capability.Backup;
import nightkosh.gravestone.capability.BackupProvider;
import nightkosh.gravestone.capability.IBackups;
import nightkosh.gravestone.core.commands.ISubCommand;
| package nightkosh.gravestone.core.commands.backup;
/**
* GraveStone mod
*
* @author NightKosh
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
*/
public abstract class SubCommandBackup implements ISubCommand {
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
String name = (args.length >= 2) ? args[1] : sender.getName();
try {
int num = (args.length >= 3) ? Integer.parseInt(args[2]) - 1 : 0;
| // Path: src/main/java/nightkosh/gravestone/capability/Backup.java
// public class Backup {
//
// private int dimensionId;
// private BlockPos pos;
// private List<ItemStack> items = new ArrayList<>();
//
// public Backup() {
// }
//
// public Backup(int dimensionId, BlockPos pos, List<ItemStack> items) {
// this.dimensionId = dimensionId;
// this.pos = pos;
// setItems(items);
// }
//
// public int getDimensionId() {
// return dimensionId;
// }
//
// public void setDimensionId(int dimensionId) {
// this.dimensionId = dimensionId;
// }
//
// public BlockPos getPos() {
// return pos;
// }
//
// public void setPos(BlockPos pos) {
// this.pos = pos;
// }
//
// public List<ItemStack> getItems() {
// return items;
// }
//
// public void setItems(List<ItemStack> items) {
// for (ItemStack stack : items) {
// if (stack != null && !stack.isEmpty()) {
// this.items.add(stack.copy());
// }
// }
// }
// }
//
// Path: src/main/java/nightkosh/gravestone/capability/IBackups.java
// public interface IBackups {
//
// Deque<Backup> getBackups();
//
// void setBackups(Deque<Backup> backups);
//
// Backup getBackup(int num);
//
// void addBackup(Backup backup);
// }
//
// Path: src/main/java/nightkosh/gravestone/core/commands/ISubCommand.java
// public interface ISubCommand {
//
// public String getCommandName();
//
// public default String getCommandUsage() {
// return Command.MAIN_COMMAND_NAME + getCommandName();
// }
//
// public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException;
// }
// Path: src/main/java/nightkosh/gravestone/core/commands/backup/SubCommandBackup.java
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.text.Style;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.util.text.TextFormatting;
import nightkosh.gravestone.capability.Backup;
import nightkosh.gravestone.capability.BackupProvider;
import nightkosh.gravestone.capability.IBackups;
import nightkosh.gravestone.core.commands.ISubCommand;
package nightkosh.gravestone.core.commands.backup;
/**
* GraveStone mod
*
* @author NightKosh
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
*/
public abstract class SubCommandBackup implements ISubCommand {
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
String name = (args.length >= 2) ? args[1] : sender.getName();
try {
int num = (args.length >= 3) ? Integer.parseInt(args[2]) - 1 : 0;
| IBackups backups = ((EntityPlayer) sender).getCapability(BackupProvider.BACKUP_CAP, null);
|
NightKosh/Gravestone-mod-Graves | src/main/java/nightkosh/gravestone/core/commands/backup/SubCommandBackup.java | // Path: src/main/java/nightkosh/gravestone/capability/Backup.java
// public class Backup {
//
// private int dimensionId;
// private BlockPos pos;
// private List<ItemStack> items = new ArrayList<>();
//
// public Backup() {
// }
//
// public Backup(int dimensionId, BlockPos pos, List<ItemStack> items) {
// this.dimensionId = dimensionId;
// this.pos = pos;
// setItems(items);
// }
//
// public int getDimensionId() {
// return dimensionId;
// }
//
// public void setDimensionId(int dimensionId) {
// this.dimensionId = dimensionId;
// }
//
// public BlockPos getPos() {
// return pos;
// }
//
// public void setPos(BlockPos pos) {
// this.pos = pos;
// }
//
// public List<ItemStack> getItems() {
// return items;
// }
//
// public void setItems(List<ItemStack> items) {
// for (ItemStack stack : items) {
// if (stack != null && !stack.isEmpty()) {
// this.items.add(stack.copy());
// }
// }
// }
// }
//
// Path: src/main/java/nightkosh/gravestone/capability/IBackups.java
// public interface IBackups {
//
// Deque<Backup> getBackups();
//
// void setBackups(Deque<Backup> backups);
//
// Backup getBackup(int num);
//
// void addBackup(Backup backup);
// }
//
// Path: src/main/java/nightkosh/gravestone/core/commands/ISubCommand.java
// public interface ISubCommand {
//
// public String getCommandName();
//
// public default String getCommandUsage() {
// return Command.MAIN_COMMAND_NAME + getCommandName();
// }
//
// public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException;
// }
| import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.text.Style;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.util.text.TextFormatting;
import nightkosh.gravestone.capability.Backup;
import nightkosh.gravestone.capability.BackupProvider;
import nightkosh.gravestone.capability.IBackups;
import nightkosh.gravestone.core.commands.ISubCommand;
| package nightkosh.gravestone.core.commands.backup;
/**
* GraveStone mod
*
* @author NightKosh
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
*/
public abstract class SubCommandBackup implements ISubCommand {
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
String name = (args.length >= 2) ? args[1] : sender.getName();
try {
int num = (args.length >= 3) ? Integer.parseInt(args[2]) - 1 : 0;
IBackups backups = ((EntityPlayer) sender).getCapability(BackupProvider.BACKUP_CAP, null);
| // Path: src/main/java/nightkosh/gravestone/capability/Backup.java
// public class Backup {
//
// private int dimensionId;
// private BlockPos pos;
// private List<ItemStack> items = new ArrayList<>();
//
// public Backup() {
// }
//
// public Backup(int dimensionId, BlockPos pos, List<ItemStack> items) {
// this.dimensionId = dimensionId;
// this.pos = pos;
// setItems(items);
// }
//
// public int getDimensionId() {
// return dimensionId;
// }
//
// public void setDimensionId(int dimensionId) {
// this.dimensionId = dimensionId;
// }
//
// public BlockPos getPos() {
// return pos;
// }
//
// public void setPos(BlockPos pos) {
// this.pos = pos;
// }
//
// public List<ItemStack> getItems() {
// return items;
// }
//
// public void setItems(List<ItemStack> items) {
// for (ItemStack stack : items) {
// if (stack != null && !stack.isEmpty()) {
// this.items.add(stack.copy());
// }
// }
// }
// }
//
// Path: src/main/java/nightkosh/gravestone/capability/IBackups.java
// public interface IBackups {
//
// Deque<Backup> getBackups();
//
// void setBackups(Deque<Backup> backups);
//
// Backup getBackup(int num);
//
// void addBackup(Backup backup);
// }
//
// Path: src/main/java/nightkosh/gravestone/core/commands/ISubCommand.java
// public interface ISubCommand {
//
// public String getCommandName();
//
// public default String getCommandUsage() {
// return Command.MAIN_COMMAND_NAME + getCommandName();
// }
//
// public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException;
// }
// Path: src/main/java/nightkosh/gravestone/core/commands/backup/SubCommandBackup.java
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.text.Style;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.util.text.TextFormatting;
import nightkosh.gravestone.capability.Backup;
import nightkosh.gravestone.capability.BackupProvider;
import nightkosh.gravestone.capability.IBackups;
import nightkosh.gravestone.core.commands.ISubCommand;
package nightkosh.gravestone.core.commands.backup;
/**
* GraveStone mod
*
* @author NightKosh
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
*/
public abstract class SubCommandBackup implements ISubCommand {
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
String name = (args.length >= 2) ? args[1] : sender.getName();
try {
int num = (args.length >= 3) ? Integer.parseInt(args[2]) - 1 : 0;
IBackups backups = ((EntityPlayer) sender).getCapability(BackupProvider.BACKUP_CAP, null);
| Backup backup = backups.getBackup(num);
|
NightKosh/Gravestone-mod-Graves | src/main/java/nightkosh/gravestone/config/ConfigsHelper.java | // Path: src/main/java/nightkosh/gravestone/core/logger/GSLogger.java
// public class GSLogger {
//
// private static Logger logger = LogManager.getLogger(ModInfo.ID);
// private static Logger graveLogger = new GravesLogger();
//
// public static void log(Level logLevel, String message) {
// logger.log(logLevel, message);
// }
//
// public static void logInfo(String message) {
// logger.log(Level.INFO, message);
// }
//
// public static void logError(String message) {
// logger.log(Level.ERROR, message);
// }
//
// public static void logGrave(Level logLevel, String message) {
// graveLogger.log(logLevel, message);
// }
//
// public static void logInfoGrave(String message) {
// graveLogger.log(Level.INFO, message);
// }
//
// public static void logErrorGrave(String message) {
// graveLogger.log(Level.ERROR, message);
// }
// }
| import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.common.config.Property;
import nightkosh.gravestone.core.logger.GSLogger;
import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
import java.util.List; | package nightkosh.gravestone.config;
/**
* GraveStone mod
*
* @author NightKosh
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
*/
public class ConfigsHelper {
public static List<Integer> getDimensionList(Configuration config, String category, String ConfigID, String defaultValue, String comment) {
Property dimensionIdProperty = config.get(category, ConfigID, defaultValue);
dimensionIdProperty.setComment(comment);
String ar = dimensionIdProperty.getString();
String[] ids = ar.split(";");
List<Integer> dimensionIds = new ArrayList<>(ids.length);
for (String id : ids) {
try {
if (StringUtils.isNotBlank(id)) {
dimensionIds.add(Integer.parseInt(id));
}
} catch (NumberFormatException e) { | // Path: src/main/java/nightkosh/gravestone/core/logger/GSLogger.java
// public class GSLogger {
//
// private static Logger logger = LogManager.getLogger(ModInfo.ID);
// private static Logger graveLogger = new GravesLogger();
//
// public static void log(Level logLevel, String message) {
// logger.log(logLevel, message);
// }
//
// public static void logInfo(String message) {
// logger.log(Level.INFO, message);
// }
//
// public static void logError(String message) {
// logger.log(Level.ERROR, message);
// }
//
// public static void logGrave(Level logLevel, String message) {
// graveLogger.log(logLevel, message);
// }
//
// public static void logInfoGrave(String message) {
// graveLogger.log(Level.INFO, message);
// }
//
// public static void logErrorGrave(String message) {
// graveLogger.log(Level.ERROR, message);
// }
// }
// Path: src/main/java/nightkosh/gravestone/config/ConfigsHelper.java
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.common.config.Property;
import nightkosh.gravestone.core.logger.GSLogger;
import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
import java.util.List;
package nightkosh.gravestone.config;
/**
* GraveStone mod
*
* @author NightKosh
* @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
*/
public class ConfigsHelper {
public static List<Integer> getDimensionList(Configuration config, String category, String ConfigID, String defaultValue, String comment) {
Property dimensionIdProperty = config.get(category, ConfigID, defaultValue);
dimensionIdProperty.setComment(comment);
String ar = dimensionIdProperty.getString();
String[] ids = ar.split(";");
List<Integer> dimensionIds = new ArrayList<>(ids.length);
for (String id : ids) {
try {
if (StringUtils.isNotBlank(id)) {
dimensionIds.add(Integer.parseInt(id));
}
} catch (NumberFormatException e) { | GSLogger.logError("Can't parse Dimension Id list!!!"); |
1and1/reactive | reactive-kafka-example/src/main/java/net/oneandone/incubator/neo/http/sink/TransientSubmission.java | // Path: reactive-kafka-example/src/main/java/net/oneandone/incubator/neo/http/sink/HttpSink.java
// public enum Method {
// POST, PUT
// };
//
// Path: reactive-kafka-example/src/main/java/net/oneandone/incubator/neo/http/sink/HttpQueryExecutor.java
// public static final class QueryResponse {
// private final Duration elapsedTime;
// private final RuntimeException error;
// private final String content;
//
// private QueryResponse(final Duration elapsedTime, final String content, final RuntimeException error) {
// this.elapsedTime = elapsedTime;
// this.error = error;
// this.content = content;
// }
//
// QueryResponse(final Duration elapsedTime, final Throwable error) {
// this(elapsedTime, null, unwrap(error));
// }
//
// QueryResponse(final Duration elapsedTime, final String content) {
// this(elapsedTime, content, null);
// }
//
// /**
// * @return the elapsed time
// */
// public Duration getElapsedTime() {
// return elapsedTime;
// }
//
// /**
// * @return true, if is success
// */
// public boolean isSuccess() {
// return (getStatus() / 100) == 2;
// }
//
// /**
// * @return the status code
// */
// public int getStatus() {
// return (content == null) ? toStatus(error) : 200;
// }
//
// /**
// * @return the error or null
// */
// public RuntimeException getError() {
// return error;
// }
//
// @Override
// public String toString() {
// return ((error == null) ? "success" : error.getMessage()) + " (elapsed: " + ((double) elapsedTime.toMillis() / 1000) + " sec)";
// }
//
// private static RuntimeException unwrap(Throwable error) {
// Throwable rootError = Exceptions.unwrap(error);
// if (rootError instanceof ResponseProcessingException) {
// rootError = ((ResponseProcessingException) rootError).getCause();
// }
// return Exceptions.propagate(rootError);
// }
//
// private static int toStatus(final Throwable error) {
// if (error == null) {
// return 200;
// } else {
// return (error instanceof WebApplicationException) ? ((WebApplicationException) error).getResponse().getStatus()
// : 500;
// }
// }
// }
| import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
import net.oneandone.incubator.neo.http.sink.HttpSink.Method;
import net.oneandone.incubator.neo.http.sink.HttpQueryExecutor.QueryResponse;
import java.net.URI;
import java.time.Duration;
import java.time.Instant;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import javax.ws.rs.client.Entity;
import org.glassfish.hk2.runlevel.RunLevelException; | /*
* Copyright 1&1 Internet AG, https://github.com/1and1/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.oneandone.incubator.neo.http.sink;
/**
* Transient submission task which lives in main memory only
*
*/
class TransientSubmission implements Submission {
private static final Logger LOG = LoggerFactory.getLogger(TransientSubmission.class);
private final SubmissionMonitor submissionMonitor;
private final String id;
private final URI target;
private final Entity<?> entity;
private final ImmutableSet<Integer> rejectStatusList;
private final ImmutableList<Duration> processDelays; | // Path: reactive-kafka-example/src/main/java/net/oneandone/incubator/neo/http/sink/HttpSink.java
// public enum Method {
// POST, PUT
// };
//
// Path: reactive-kafka-example/src/main/java/net/oneandone/incubator/neo/http/sink/HttpQueryExecutor.java
// public static final class QueryResponse {
// private final Duration elapsedTime;
// private final RuntimeException error;
// private final String content;
//
// private QueryResponse(final Duration elapsedTime, final String content, final RuntimeException error) {
// this.elapsedTime = elapsedTime;
// this.error = error;
// this.content = content;
// }
//
// QueryResponse(final Duration elapsedTime, final Throwable error) {
// this(elapsedTime, null, unwrap(error));
// }
//
// QueryResponse(final Duration elapsedTime, final String content) {
// this(elapsedTime, content, null);
// }
//
// /**
// * @return the elapsed time
// */
// public Duration getElapsedTime() {
// return elapsedTime;
// }
//
// /**
// * @return true, if is success
// */
// public boolean isSuccess() {
// return (getStatus() / 100) == 2;
// }
//
// /**
// * @return the status code
// */
// public int getStatus() {
// return (content == null) ? toStatus(error) : 200;
// }
//
// /**
// * @return the error or null
// */
// public RuntimeException getError() {
// return error;
// }
//
// @Override
// public String toString() {
// return ((error == null) ? "success" : error.getMessage()) + " (elapsed: " + ((double) elapsedTime.toMillis() / 1000) + " sec)";
// }
//
// private static RuntimeException unwrap(Throwable error) {
// Throwable rootError = Exceptions.unwrap(error);
// if (rootError instanceof ResponseProcessingException) {
// rootError = ((ResponseProcessingException) rootError).getCause();
// }
// return Exceptions.propagate(rootError);
// }
//
// private static int toStatus(final Throwable error) {
// if (error == null) {
// return 200;
// } else {
// return (error instanceof WebApplicationException) ? ((WebApplicationException) error).getResponse().getStatus()
// : 500;
// }
// }
// }
// Path: reactive-kafka-example/src/main/java/net/oneandone/incubator/neo/http/sink/TransientSubmission.java
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
import net.oneandone.incubator.neo.http.sink.HttpSink.Method;
import net.oneandone.incubator.neo.http.sink.HttpQueryExecutor.QueryResponse;
import java.net.URI;
import java.time.Duration;
import java.time.Instant;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import javax.ws.rs.client.Entity;
import org.glassfish.hk2.runlevel.RunLevelException;
/*
* Copyright 1&1 Internet AG, https://github.com/1and1/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.oneandone.incubator.neo.http.sink;
/**
* Transient submission task which lives in main memory only
*
*/
class TransientSubmission implements Submission {
private static final Logger LOG = LoggerFactory.getLogger(TransientSubmission.class);
private final SubmissionMonitor submissionMonitor;
private final String id;
private final URI target;
private final Entity<?> entity;
private final ImmutableSet<Integer> rejectStatusList;
private final ImmutableList<Duration> processDelays; | private final Method method; |
1and1/reactive | reactive-kafka-example/src/main/java/net/oneandone/incubator/neo/http/sink/TransientSubmission.java | // Path: reactive-kafka-example/src/main/java/net/oneandone/incubator/neo/http/sink/HttpSink.java
// public enum Method {
// POST, PUT
// };
//
// Path: reactive-kafka-example/src/main/java/net/oneandone/incubator/neo/http/sink/HttpQueryExecutor.java
// public static final class QueryResponse {
// private final Duration elapsedTime;
// private final RuntimeException error;
// private final String content;
//
// private QueryResponse(final Duration elapsedTime, final String content, final RuntimeException error) {
// this.elapsedTime = elapsedTime;
// this.error = error;
// this.content = content;
// }
//
// QueryResponse(final Duration elapsedTime, final Throwable error) {
// this(elapsedTime, null, unwrap(error));
// }
//
// QueryResponse(final Duration elapsedTime, final String content) {
// this(elapsedTime, content, null);
// }
//
// /**
// * @return the elapsed time
// */
// public Duration getElapsedTime() {
// return elapsedTime;
// }
//
// /**
// * @return true, if is success
// */
// public boolean isSuccess() {
// return (getStatus() / 100) == 2;
// }
//
// /**
// * @return the status code
// */
// public int getStatus() {
// return (content == null) ? toStatus(error) : 200;
// }
//
// /**
// * @return the error or null
// */
// public RuntimeException getError() {
// return error;
// }
//
// @Override
// public String toString() {
// return ((error == null) ? "success" : error.getMessage()) + " (elapsed: " + ((double) elapsedTime.toMillis() / 1000) + " sec)";
// }
//
// private static RuntimeException unwrap(Throwable error) {
// Throwable rootError = Exceptions.unwrap(error);
// if (rootError instanceof ResponseProcessingException) {
// rootError = ((ResponseProcessingException) rootError).getCause();
// }
// return Exceptions.propagate(rootError);
// }
//
// private static int toStatus(final Throwable error) {
// if (error == null) {
// return 200;
// } else {
// return (error instanceof WebApplicationException) ? ((WebApplicationException) error).getResponse().getStatus()
// : 500;
// }
// }
// }
| import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
import net.oneandone.incubator.neo.http.sink.HttpSink.Method;
import net.oneandone.incubator.neo.http.sink.HttpQueryExecutor.QueryResponse;
import java.net.URI;
import java.time.Duration;
import java.time.Instant;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import javax.ws.rs.client.Entity;
import org.glassfish.hk2.runlevel.RunLevelException; | * @return the submission future
*/
public CompletableFuture<Submission> processAsync(final HttpQueryExecutor executor) {
if (isReleased.get()) {
throw new RunLevelException(subInfo() + " is already released. Task will not been processed");
}
LOG.debug(subInfo() + " will be executed in " + nextExecutionDelay);
return executor.performHttpQueryAsync(subInfo(), getMethod(), getTarget(), getEntity(), nextExecutionDelay)
.thenApply(response -> {
lastTrials.add(Instant.now());
if (response.isSuccess()) { // success
onSuccess("executed with " + response);
} else if (getRejectStatusList().contains(response.getStatus())) { // no retryable error
throw onDiscard("Non retryable status code", response);
} else if (!onRetry(response, executor)) { // try retry
throw onDiscard("No retries left", response); // no retry left
}
return TransientSubmission.this;
});
}
protected void onSuccess(final String msg) {
actionLog.add("[" + Instant.now() + "] " + subInfo() + " " + msg);
LOG.debug(subInfo() + " " + msg);
stateRef.set(State.COMPLETED);
submissionMonitor.onSuccess(TransientSubmission.this);
}
| // Path: reactive-kafka-example/src/main/java/net/oneandone/incubator/neo/http/sink/HttpSink.java
// public enum Method {
// POST, PUT
// };
//
// Path: reactive-kafka-example/src/main/java/net/oneandone/incubator/neo/http/sink/HttpQueryExecutor.java
// public static final class QueryResponse {
// private final Duration elapsedTime;
// private final RuntimeException error;
// private final String content;
//
// private QueryResponse(final Duration elapsedTime, final String content, final RuntimeException error) {
// this.elapsedTime = elapsedTime;
// this.error = error;
// this.content = content;
// }
//
// QueryResponse(final Duration elapsedTime, final Throwable error) {
// this(elapsedTime, null, unwrap(error));
// }
//
// QueryResponse(final Duration elapsedTime, final String content) {
// this(elapsedTime, content, null);
// }
//
// /**
// * @return the elapsed time
// */
// public Duration getElapsedTime() {
// return elapsedTime;
// }
//
// /**
// * @return true, if is success
// */
// public boolean isSuccess() {
// return (getStatus() / 100) == 2;
// }
//
// /**
// * @return the status code
// */
// public int getStatus() {
// return (content == null) ? toStatus(error) : 200;
// }
//
// /**
// * @return the error or null
// */
// public RuntimeException getError() {
// return error;
// }
//
// @Override
// public String toString() {
// return ((error == null) ? "success" : error.getMessage()) + " (elapsed: " + ((double) elapsedTime.toMillis() / 1000) + " sec)";
// }
//
// private static RuntimeException unwrap(Throwable error) {
// Throwable rootError = Exceptions.unwrap(error);
// if (rootError instanceof ResponseProcessingException) {
// rootError = ((ResponseProcessingException) rootError).getCause();
// }
// return Exceptions.propagate(rootError);
// }
//
// private static int toStatus(final Throwable error) {
// if (error == null) {
// return 200;
// } else {
// return (error instanceof WebApplicationException) ? ((WebApplicationException) error).getResponse().getStatus()
// : 500;
// }
// }
// }
// Path: reactive-kafka-example/src/main/java/net/oneandone/incubator/neo/http/sink/TransientSubmission.java
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
import net.oneandone.incubator.neo.http.sink.HttpSink.Method;
import net.oneandone.incubator.neo.http.sink.HttpQueryExecutor.QueryResponse;
import java.net.URI;
import java.time.Duration;
import java.time.Instant;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import javax.ws.rs.client.Entity;
import org.glassfish.hk2.runlevel.RunLevelException;
* @return the submission future
*/
public CompletableFuture<Submission> processAsync(final HttpQueryExecutor executor) {
if (isReleased.get()) {
throw new RunLevelException(subInfo() + " is already released. Task will not been processed");
}
LOG.debug(subInfo() + " will be executed in " + nextExecutionDelay);
return executor.performHttpQueryAsync(subInfo(), getMethod(), getTarget(), getEntity(), nextExecutionDelay)
.thenApply(response -> {
lastTrials.add(Instant.now());
if (response.isSuccess()) { // success
onSuccess("executed with " + response);
} else if (getRejectStatusList().contains(response.getStatus())) { // no retryable error
throw onDiscard("Non retryable status code", response);
} else if (!onRetry(response, executor)) { // try retry
throw onDiscard("No retries left", response); // no retry left
}
return TransientSubmission.this;
});
}
protected void onSuccess(final String msg) {
actionLog.add("[" + Instant.now() + "] " + subInfo() + " " + msg);
LOG.debug(subInfo() + " " + msg);
stateRef.set(State.COMPLETED);
submissionMonitor.onSuccess(TransientSubmission.this);
}
| protected RuntimeException onDiscard(final String msg, final QueryResponse response) { |
1and1/reactive | reactive-http/src/main/java/net/oneandone/reactive/rest/container/ResultSubscriber.java | // Path: reactive-core/src/main/java/net/oneandone/reactive/utils/Utils.java
// public class Utils {
//
// private Utils() { }
//
//
//
//
// public static <T> T get(Future<T> future) {
// try {
// return future.get();
// } catch (InterruptedException | ExecutionException e) {
// throw propagate(e);
// }
// }
//
//
//
//
//
// /**
// * unwraps an exception
// *
// * @param ex the exception to unwrap
// * @return the unwrapped exception
// */
// public static RuntimeException propagate(Throwable ex) {
// Throwable t = unwrap(ex);
// return (t instanceof RuntimeException) ? (RuntimeException) t : new RuntimeException(t);
// }
//
//
// /**
// * unwraps an exception
// *
// * @param ex the exception to unwrap
// * @return the unwrapped exception
// */
// public static Throwable unwrap(Throwable ex) {
// return unwrap(ex, 9);
// }
//
//
// /**
// * unwraps an exception
// *
// * @param ex the exception to unwrap
// * @param maxDepth the max depth
// * @return the unwrapped exception
// */
// private static Throwable unwrap(Throwable ex, int maxDepth) {
// if (isCompletionException(ex) || isExecutionException(ex)) {
// Throwable e = ex.getCause();
// if (e != null) {
// if (maxDepth > 1) {
// return unwrap(e, maxDepth - 1);
// } else {
// return e;
// }
// }
// }
//
// return ex;
// }
//
//
// private static boolean isCompletionException(Throwable t) {
// return CompletionException.class.isAssignableFrom(t.getClass());
// }
//
//
// private static boolean isExecutionException(Throwable t) {
// return ExecutionException.class.isAssignableFrom(t.getClass());
// }
// }
| import java.util.concurrent.atomic.AtomicReference;
import javax.ws.rs.ClientErrorException;
import javax.ws.rs.NotFoundException;
import javax.ws.rs.container.AsyncResponse;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import net.oneandone.reactive.utils.Utils;
import org.reactivestreams.Subscriber;
import org.reactivestreams.Subscription; | /*
* Copyright 1&1 Internet AG, https://github.com/1and1/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.oneandone.reactive.rest.container;
/**
* ResultSubscriber
*
*/
public class ResultSubscriber {
/**
* maps the asyn HTTP response to a Subscriber which writes the first element into the HTTP response.
* If no element is available, a 204 No Content response is returned
*
* @param asyncResponse the async response
* @return the subscriber
*/
public static final <T> Subscriber<T> toConsumeFirstSubscriber(AsyncResponse asyncResponse) {
return new FirstSubscriber<T>(asyncResponse);
}
private static class FirstSubscriber<T> implements Subscriber<T> {
private final AsyncResponse asyncResponse;
private final AtomicReference<Subscription> subscriptionRef = new AtomicReference<>();
private FirstSubscriber(AsyncResponse asyncResponse) {
this.asyncResponse = asyncResponse;
}
@Override
public void onSubscribe(Subscription subscription) {
subscriptionRef.set(subscription);
subscription.request(1);
}
@Override
public void onError(Throwable error) { | // Path: reactive-core/src/main/java/net/oneandone/reactive/utils/Utils.java
// public class Utils {
//
// private Utils() { }
//
//
//
//
// public static <T> T get(Future<T> future) {
// try {
// return future.get();
// } catch (InterruptedException | ExecutionException e) {
// throw propagate(e);
// }
// }
//
//
//
//
//
// /**
// * unwraps an exception
// *
// * @param ex the exception to unwrap
// * @return the unwrapped exception
// */
// public static RuntimeException propagate(Throwable ex) {
// Throwable t = unwrap(ex);
// return (t instanceof RuntimeException) ? (RuntimeException) t : new RuntimeException(t);
// }
//
//
// /**
// * unwraps an exception
// *
// * @param ex the exception to unwrap
// * @return the unwrapped exception
// */
// public static Throwable unwrap(Throwable ex) {
// return unwrap(ex, 9);
// }
//
//
// /**
// * unwraps an exception
// *
// * @param ex the exception to unwrap
// * @param maxDepth the max depth
// * @return the unwrapped exception
// */
// private static Throwable unwrap(Throwable ex, int maxDepth) {
// if (isCompletionException(ex) || isExecutionException(ex)) {
// Throwable e = ex.getCause();
// if (e != null) {
// if (maxDepth > 1) {
// return unwrap(e, maxDepth - 1);
// } else {
// return e;
// }
// }
// }
//
// return ex;
// }
//
//
// private static boolean isCompletionException(Throwable t) {
// return CompletionException.class.isAssignableFrom(t.getClass());
// }
//
//
// private static boolean isExecutionException(Throwable t) {
// return ExecutionException.class.isAssignableFrom(t.getClass());
// }
// }
// Path: reactive-http/src/main/java/net/oneandone/reactive/rest/container/ResultSubscriber.java
import java.util.concurrent.atomic.AtomicReference;
import javax.ws.rs.ClientErrorException;
import javax.ws.rs.NotFoundException;
import javax.ws.rs.container.AsyncResponse;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import net.oneandone.reactive.utils.Utils;
import org.reactivestreams.Subscriber;
import org.reactivestreams.Subscription;
/*
* Copyright 1&1 Internet AG, https://github.com/1and1/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.oneandone.reactive.rest.container;
/**
* ResultSubscriber
*
*/
public class ResultSubscriber {
/**
* maps the asyn HTTP response to a Subscriber which writes the first element into the HTTP response.
* If no element is available, a 204 No Content response is returned
*
* @param asyncResponse the async response
* @return the subscriber
*/
public static final <T> Subscriber<T> toConsumeFirstSubscriber(AsyncResponse asyncResponse) {
return new FirstSubscriber<T>(asyncResponse);
}
private static class FirstSubscriber<T> implements Subscriber<T> {
private final AsyncResponse asyncResponse;
private final AtomicReference<Subscription> subscriptionRef = new AtomicReference<>();
private FirstSubscriber(AsyncResponse asyncResponse) {
this.asyncResponse = asyncResponse;
}
@Override
public void onSubscribe(Subscription subscription) {
subscriptionRef.set(subscription);
subscription.request(1);
}
@Override
public void onError(Throwable error) { | error = Utils.unwrap(error); |
1and1/reactive | reactive-core/src/main/java/net/oneandone/reactive/ReactiveSource.java | // Path: reactive-core/src/main/java/net/oneandone/reactive/utils/Utils.java
// public class Utils {
//
// private Utils() { }
//
//
//
//
// public static <T> T get(Future<T> future) {
// try {
// return future.get();
// } catch (InterruptedException | ExecutionException e) {
// throw propagate(e);
// }
// }
//
//
//
//
//
// /**
// * unwraps an exception
// *
// * @param ex the exception to unwrap
// * @return the unwrapped exception
// */
// public static RuntimeException propagate(Throwable ex) {
// Throwable t = unwrap(ex);
// return (t instanceof RuntimeException) ? (RuntimeException) t : new RuntimeException(t);
// }
//
//
// /**
// * unwraps an exception
// *
// * @param ex the exception to unwrap
// * @return the unwrapped exception
// */
// public static Throwable unwrap(Throwable ex) {
// return unwrap(ex, 9);
// }
//
//
// /**
// * unwraps an exception
// *
// * @param ex the exception to unwrap
// * @param maxDepth the max depth
// * @return the unwrapped exception
// */
// private static Throwable unwrap(Throwable ex, int maxDepth) {
// if (isCompletionException(ex) || isExecutionException(ex)) {
// Throwable e = ex.getCause();
// if (e != null) {
// if (maxDepth > 1) {
// return unwrap(e, maxDepth - 1);
// } else {
// return e;
// }
// }
// }
//
// return ex;
// }
//
//
// private static boolean isCompletionException(Throwable t) {
// return CompletionException.class.isAssignableFrom(t.getClass());
// }
//
//
// private static boolean isExecutionException(Throwable t) {
// return ExecutionException.class.isAssignableFrom(t.getClass());
// }
// }
| import java.io.Closeable;
import java.util.concurrent.CompletableFuture;
import java.util.function.Consumer;
import net.oneandone.reactive.utils.Utils;
import org.reactivestreams.Publisher; | /*
* Copyright 1&1 Internet AG, https://github.com/1and1/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.oneandone.reactive;
public interface ReactiveSource<T> extends Closeable {
CompletableFuture<T> readAsync();
T read();
void consume(Consumer<T> consumer);
void close();
static <T> ReactiveSource<T> subscribe(Publisher<T> publisher) { | // Path: reactive-core/src/main/java/net/oneandone/reactive/utils/Utils.java
// public class Utils {
//
// private Utils() { }
//
//
//
//
// public static <T> T get(Future<T> future) {
// try {
// return future.get();
// } catch (InterruptedException | ExecutionException e) {
// throw propagate(e);
// }
// }
//
//
//
//
//
// /**
// * unwraps an exception
// *
// * @param ex the exception to unwrap
// * @return the unwrapped exception
// */
// public static RuntimeException propagate(Throwable ex) {
// Throwable t = unwrap(ex);
// return (t instanceof RuntimeException) ? (RuntimeException) t : new RuntimeException(t);
// }
//
//
// /**
// * unwraps an exception
// *
// * @param ex the exception to unwrap
// * @return the unwrapped exception
// */
// public static Throwable unwrap(Throwable ex) {
// return unwrap(ex, 9);
// }
//
//
// /**
// * unwraps an exception
// *
// * @param ex the exception to unwrap
// * @param maxDepth the max depth
// * @return the unwrapped exception
// */
// private static Throwable unwrap(Throwable ex, int maxDepth) {
// if (isCompletionException(ex) || isExecutionException(ex)) {
// Throwable e = ex.getCause();
// if (e != null) {
// if (maxDepth > 1) {
// return unwrap(e, maxDepth - 1);
// } else {
// return e;
// }
// }
// }
//
// return ex;
// }
//
//
// private static boolean isCompletionException(Throwable t) {
// return CompletionException.class.isAssignableFrom(t.getClass());
// }
//
//
// private static boolean isExecutionException(Throwable t) {
// return ExecutionException.class.isAssignableFrom(t.getClass());
// }
// }
// Path: reactive-core/src/main/java/net/oneandone/reactive/ReactiveSource.java
import java.io.Closeable;
import java.util.concurrent.CompletableFuture;
import java.util.function.Consumer;
import net.oneandone.reactive.utils.Utils;
import org.reactivestreams.Publisher;
/*
* Copyright 1&1 Internet AG, https://github.com/1and1/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.oneandone.reactive;
public interface ReactiveSource<T> extends Closeable {
CompletableFuture<T> readAsync();
T read();
void consume(Consumer<T> consumer);
void close();
static <T> ReactiveSource<T> subscribe(Publisher<T> publisher) { | return Utils.get(subscribeAsync(publisher)); |
1and1/reactive | reactive-http/src/main/java/net/oneandone/reactive/rest/client/RxClientSubscriber.java | // Path: reactive-core/src/main/java/net/oneandone/reactive/utils/IllegalStateSubscription.java
// public class IllegalStateSubscription implements Subscription {
//
// @Override
// public void request(long n) {
// throw new IllegalStateException();
// }
//
// @Override
// public void cancel() {
// throw new IllegalStateException();
// }
// }
//
// Path: reactive-http/src/main/java/net/oneandone/reactive/utils/RetryScheduler.java
// public class RetryScheduler {
// private final RetrySequence retrySequence;
// private Instant lastSchedule = Instant.now();
// private Duration lastDelay = Duration.ZERO;
//
//
//
// public RetryScheduler() {
// this(0, 3, 25, 250, 500, 2000);
// }
//
// public RetryScheduler(int... delaysMillis) {
// retrySequence = new RetrySequence(delaysMillis);
// }
//
// public Duration scheduleWithDelay(Runnable connectTast) {
//
// // last schedule a while ago?
// Duration delaySinceLastSchedule = Duration.between(lastSchedule, Instant.now());
// if (retrySequence.getMaxDelay().multipliedBy(2).minus(delaySinceLastSchedule).isNegative()) {
// // yes
// lastDelay = Duration.ZERO;
// } else {
// // no
// lastDelay = retrySequence.nextDelay(lastDelay)
// .orElseThrow(() -> new RuntimeException("may retries reached"));
// }
//
// lastSchedule = Instant.now();
// ScheduledExceutor.common().schedule(connectTast, lastDelay.toMillis(), TimeUnit.MILLISECONDS);
//
// return lastDelay;
// }
//
//
//
// private static final class RetrySequence {
// private final ImmutableMap<Duration, Duration> delayMap;
// private final Duration lastDelay;
//
// public RetrySequence(int... delaysMillis) {
// Map<Duration, Duration> map = Maps.newHashMap();
// for (int i = 0; i < delaysMillis.length; i++) {
// map.put(Duration.ofMillis(delaysMillis[i]), Duration.ofMillis( (delaysMillis.length > (i+1)) ? delaysMillis[i+1] : delaysMillis[i]) );
// }
// delayMap = ImmutableMap.copyOf(map);
//
// lastDelay = Duration.ofMillis(delaysMillis[delaysMillis.length - 1]);
// }
//
// public Optional<Duration> nextDelay(Duration previous) {
// return Optional.ofNullable(delayMap.get(previous));
// }
//
// public Duration getMaxDelay() {
// return lastDelay;
// }
// }
// }
| import java.net.URI;
import java.time.Duration;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
import javax.ws.rs.ServerErrorException;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.MediaType;
import net.oneandone.reactive.utils.IllegalStateSubscription;
import net.oneandone.reactive.utils.RetryScheduler;
import org.reactivestreams.Subscriber;
import org.reactivestreams.Subscription;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | /*
* Copyright 1&1 Internet AG, https://github.com/1and1/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.oneandone.reactive.rest.client;
public class RxClientSubscriber<T> implements Subscriber<T> {
private static final Logger LOG = LoggerFactory.getLogger(RxClientSubscriber.class); | // Path: reactive-core/src/main/java/net/oneandone/reactive/utils/IllegalStateSubscription.java
// public class IllegalStateSubscription implements Subscription {
//
// @Override
// public void request(long n) {
// throw new IllegalStateException();
// }
//
// @Override
// public void cancel() {
// throw new IllegalStateException();
// }
// }
//
// Path: reactive-http/src/main/java/net/oneandone/reactive/utils/RetryScheduler.java
// public class RetryScheduler {
// private final RetrySequence retrySequence;
// private Instant lastSchedule = Instant.now();
// private Duration lastDelay = Duration.ZERO;
//
//
//
// public RetryScheduler() {
// this(0, 3, 25, 250, 500, 2000);
// }
//
// public RetryScheduler(int... delaysMillis) {
// retrySequence = new RetrySequence(delaysMillis);
// }
//
// public Duration scheduleWithDelay(Runnable connectTast) {
//
// // last schedule a while ago?
// Duration delaySinceLastSchedule = Duration.between(lastSchedule, Instant.now());
// if (retrySequence.getMaxDelay().multipliedBy(2).minus(delaySinceLastSchedule).isNegative()) {
// // yes
// lastDelay = Duration.ZERO;
// } else {
// // no
// lastDelay = retrySequence.nextDelay(lastDelay)
// .orElseThrow(() -> new RuntimeException("may retries reached"));
// }
//
// lastSchedule = Instant.now();
// ScheduledExceutor.common().schedule(connectTast, lastDelay.toMillis(), TimeUnit.MILLISECONDS);
//
// return lastDelay;
// }
//
//
//
// private static final class RetrySequence {
// private final ImmutableMap<Duration, Duration> delayMap;
// private final Duration lastDelay;
//
// public RetrySequence(int... delaysMillis) {
// Map<Duration, Duration> map = Maps.newHashMap();
// for (int i = 0; i < delaysMillis.length; i++) {
// map.put(Duration.ofMillis(delaysMillis[i]), Duration.ofMillis( (delaysMillis.length > (i+1)) ? delaysMillis[i+1] : delaysMillis[i]) );
// }
// delayMap = ImmutableMap.copyOf(map);
//
// lastDelay = Duration.ofMillis(delaysMillis[delaysMillis.length - 1]);
// }
//
// public Optional<Duration> nextDelay(Duration previous) {
// return Optional.ofNullable(delayMap.get(previous));
// }
//
// public Duration getMaxDelay() {
// return lastDelay;
// }
// }
// }
// Path: reactive-http/src/main/java/net/oneandone/reactive/rest/client/RxClientSubscriber.java
import java.net.URI;
import java.time.Duration;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
import javax.ws.rs.ServerErrorException;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.MediaType;
import net.oneandone.reactive.utils.IllegalStateSubscription;
import net.oneandone.reactive.utils.RetryScheduler;
import org.reactivestreams.Subscriber;
import org.reactivestreams.Subscription;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/*
* Copyright 1&1 Internet AG, https://github.com/1and1/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.oneandone.reactive.rest.client;
public class RxClientSubscriber<T> implements Subscriber<T> {
private static final Logger LOG = LoggerFactory.getLogger(RxClientSubscriber.class); | private final RetryScheduler retryScheduler = new RetryScheduler(); |
1and1/reactive | reactive-http/src/main/java/net/oneandone/reactive/rest/client/RxClientSubscriber.java | // Path: reactive-core/src/main/java/net/oneandone/reactive/utils/IllegalStateSubscription.java
// public class IllegalStateSubscription implements Subscription {
//
// @Override
// public void request(long n) {
// throw new IllegalStateException();
// }
//
// @Override
// public void cancel() {
// throw new IllegalStateException();
// }
// }
//
// Path: reactive-http/src/main/java/net/oneandone/reactive/utils/RetryScheduler.java
// public class RetryScheduler {
// private final RetrySequence retrySequence;
// private Instant lastSchedule = Instant.now();
// private Duration lastDelay = Duration.ZERO;
//
//
//
// public RetryScheduler() {
// this(0, 3, 25, 250, 500, 2000);
// }
//
// public RetryScheduler(int... delaysMillis) {
// retrySequence = new RetrySequence(delaysMillis);
// }
//
// public Duration scheduleWithDelay(Runnable connectTast) {
//
// // last schedule a while ago?
// Duration delaySinceLastSchedule = Duration.between(lastSchedule, Instant.now());
// if (retrySequence.getMaxDelay().multipliedBy(2).minus(delaySinceLastSchedule).isNegative()) {
// // yes
// lastDelay = Duration.ZERO;
// } else {
// // no
// lastDelay = retrySequence.nextDelay(lastDelay)
// .orElseThrow(() -> new RuntimeException("may retries reached"));
// }
//
// lastSchedule = Instant.now();
// ScheduledExceutor.common().schedule(connectTast, lastDelay.toMillis(), TimeUnit.MILLISECONDS);
//
// return lastDelay;
// }
//
//
//
// private static final class RetrySequence {
// private final ImmutableMap<Duration, Duration> delayMap;
// private final Duration lastDelay;
//
// public RetrySequence(int... delaysMillis) {
// Map<Duration, Duration> map = Maps.newHashMap();
// for (int i = 0; i < delaysMillis.length; i++) {
// map.put(Duration.ofMillis(delaysMillis[i]), Duration.ofMillis( (delaysMillis.length > (i+1)) ? delaysMillis[i+1] : delaysMillis[i]) );
// }
// delayMap = ImmutableMap.copyOf(map);
//
// lastDelay = Duration.ofMillis(delaysMillis[delaysMillis.length - 1]);
// }
//
// public Optional<Duration> nextDelay(Duration previous) {
// return Optional.ofNullable(delayMap.get(previous));
// }
//
// public Duration getMaxDelay() {
// return lastDelay;
// }
// }
// }
| import java.net.URI;
import java.time.Duration;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
import javax.ws.rs.ServerErrorException;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.MediaType;
import net.oneandone.reactive.utils.IllegalStateSubscription;
import net.oneandone.reactive.utils.RetryScheduler;
import org.reactivestreams.Subscriber;
import org.reactivestreams.Subscription;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | /*
* Copyright 1&1 Internet AG, https://github.com/1and1/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.oneandone.reactive.rest.client;
public class RxClientSubscriber<T> implements Subscriber<T> {
private static final Logger LOG = LoggerFactory.getLogger(RxClientSubscriber.class);
private final RetryScheduler retryScheduler = new RetryScheduler();
private final String id = UUID.randomUUID().toString();
private final AtomicBoolean isOpen = new AtomicBoolean(true);
// properties
private final RxClient client;
private final URI uri;
private final MediaType mediaType;
private final String method;
private final boolean isAutoRetry;
private final int maxInFlight;
private final boolean isFailOnInitialError;
private final AtomicBoolean isSubscribed = new AtomicBoolean(false); | // Path: reactive-core/src/main/java/net/oneandone/reactive/utils/IllegalStateSubscription.java
// public class IllegalStateSubscription implements Subscription {
//
// @Override
// public void request(long n) {
// throw new IllegalStateException();
// }
//
// @Override
// public void cancel() {
// throw new IllegalStateException();
// }
// }
//
// Path: reactive-http/src/main/java/net/oneandone/reactive/utils/RetryScheduler.java
// public class RetryScheduler {
// private final RetrySequence retrySequence;
// private Instant lastSchedule = Instant.now();
// private Duration lastDelay = Duration.ZERO;
//
//
//
// public RetryScheduler() {
// this(0, 3, 25, 250, 500, 2000);
// }
//
// public RetryScheduler(int... delaysMillis) {
// retrySequence = new RetrySequence(delaysMillis);
// }
//
// public Duration scheduleWithDelay(Runnable connectTast) {
//
// // last schedule a while ago?
// Duration delaySinceLastSchedule = Duration.between(lastSchedule, Instant.now());
// if (retrySequence.getMaxDelay().multipliedBy(2).minus(delaySinceLastSchedule).isNegative()) {
// // yes
// lastDelay = Duration.ZERO;
// } else {
// // no
// lastDelay = retrySequence.nextDelay(lastDelay)
// .orElseThrow(() -> new RuntimeException("may retries reached"));
// }
//
// lastSchedule = Instant.now();
// ScheduledExceutor.common().schedule(connectTast, lastDelay.toMillis(), TimeUnit.MILLISECONDS);
//
// return lastDelay;
// }
//
//
//
// private static final class RetrySequence {
// private final ImmutableMap<Duration, Duration> delayMap;
// private final Duration lastDelay;
//
// public RetrySequence(int... delaysMillis) {
// Map<Duration, Duration> map = Maps.newHashMap();
// for (int i = 0; i < delaysMillis.length; i++) {
// map.put(Duration.ofMillis(delaysMillis[i]), Duration.ofMillis( (delaysMillis.length > (i+1)) ? delaysMillis[i+1] : delaysMillis[i]) );
// }
// delayMap = ImmutableMap.copyOf(map);
//
// lastDelay = Duration.ofMillis(delaysMillis[delaysMillis.length - 1]);
// }
//
// public Optional<Duration> nextDelay(Duration previous) {
// return Optional.ofNullable(delayMap.get(previous));
// }
//
// public Duration getMaxDelay() {
// return lastDelay;
// }
// }
// }
// Path: reactive-http/src/main/java/net/oneandone/reactive/rest/client/RxClientSubscriber.java
import java.net.URI;
import java.time.Duration;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
import javax.ws.rs.ServerErrorException;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.MediaType;
import net.oneandone.reactive.utils.IllegalStateSubscription;
import net.oneandone.reactive.utils.RetryScheduler;
import org.reactivestreams.Subscriber;
import org.reactivestreams.Subscription;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/*
* Copyright 1&1 Internet AG, https://github.com/1and1/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.oneandone.reactive.rest.client;
public class RxClientSubscriber<T> implements Subscriber<T> {
private static final Logger LOG = LoggerFactory.getLogger(RxClientSubscriber.class);
private final RetryScheduler retryScheduler = new RetryScheduler();
private final String id = UUID.randomUUID().toString();
private final AtomicBoolean isOpen = new AtomicBoolean(true);
// properties
private final RxClient client;
private final URI uri;
private final MediaType mediaType;
private final String method;
private final boolean isAutoRetry;
private final int maxInFlight;
private final boolean isFailOnInitialError;
private final AtomicBoolean isSubscribed = new AtomicBoolean(false); | private final AtomicReference<Subscription> subscriptionRef = new AtomicReference<>(new IllegalStateSubscription()); |
1and1/reactive | reactive-http/src/test/java/net/oneandone/reactive/rest/client/RxClientSubscriberTest.java | // Path: reactive-core/src/main/java/net/oneandone/reactive/ReactiveSink.java
// public interface ReactiveSink<T> extends Closeable {
//
// boolean isWriteable();
//
//
// /**
// * @param element the element to write
// * @return the write future
// */
// CompletableFuture<Void> writeAsync(T element);
//
//
// /**
// * @param element the element to write
// */
// void write(T element);
//
//
//
// /**
// * shutdown the sink
// *
// * @return the unprocessed element list
// */
// public ImmutableList<T> shutdownNow();
//
//
// /**
// * shutdown the queue. Let the unprocessed elements be processed
// */
// public void shutdown();
//
//
//
// boolean isOpen();
//
//
//
// @Override
// public void close();
//
//
//
// static <T> ReactiveSink<T> publish(Subscriber<T> subscriber) {
// return Utils.get(publishAsync(subscriber));
// }
//
//
// static <T> CompletableFuture<ReactiveSink<T>> publishAsync(Subscriber<T> subscriber) {
// return ReactiveSinkSubscription.newSubscriptionAsync(subscriber, 25);
// }
//
//
// static ReactiveSinkBuilder buffersize(int buffersize) {
// return new ReactiveSinkBuilder(buffersize);
// }
//
//
// public static class ReactiveSinkBuilder {
// private final int bufferSize;
//
// ReactiveSinkBuilder(int bufferSize) {
// this.bufferSize = bufferSize;
// }
//
// public <T> ReactiveSink<T> publish(Subscriber<T> subscriber) {
// return Utils.get(publishAsync(subscriber));
// }
//
//
// public <T> CompletableFuture<ReactiveSink<T>> publishAsync(Subscriber<T> subscriber) {
// return ReactiveSinkSubscription.newSubscriptionAsync(subscriber, bufferSize);
// }
// }
// }
//
// Path: reactive-http/src/test/java/net/oneandone/reactive/TestServletbasedTest.java
// public abstract class TestServletbasedTest {
//
// private Client client;
// private WebContainer server;
//
//
// @Before
// public void before() throws Exception {
// server = new WebContainer("/ssetest");
// server.start();
//
// client = new ResteasyClientBuilder().socketTimeout(60, TimeUnit.SECONDS)
// .connectionPoolSize(10)
// .build();
// }
//
//
// @After
// public void after() throws Exception {
// client.close();
// server.stop();
// }
//
//
// protected Client getClient() {
// return client;
// }
//
// protected WebContainer getServer() {
// return server;
// }
//
//
//
// protected void sleep(long millis) {
// try {
// Thread.sleep(millis);
// } catch (InterruptedException ignore) {
//
// }
// }
//
//
// protected void waitUtil(Supplier<Boolean> condition, long maxSec) {
//
// long maxWaittimeMillis = maxSec * 1000;
// long sleeptimeMillis = 100;
// for (int i = 0; i < (maxWaittimeMillis / sleeptimeMillis); i++) {
// if (condition.get()) {
// return;
// } else {
// sleep(sleeptimeMillis);
// }
// }
// }
// }
| import java.net.URI;
import net.oneandone.reactive.ReactiveSink;
import net.oneandone.reactive.TestServletbasedTest;
import org.junit.Assert;
import org.junit.Test;
import org.reactivestreams.Subscriber; | /*
* Copyright 1&1 Internet AG, https://github.com/1and1/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.oneandone.reactive.rest.client;
public class RxClientSubscriberTest extends TestServletbasedTest {
/*
public RxClientSubscriberTest() {
System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", "DEBUG");
}
*/
@Test
public void testMaxInFlight() throws Exception {
URI uri = URI.create(getServer().getBaseUrl() + "/sink/?pauseMillis=700");
System.out.println(uri);
Subscriber<String> subscriber = new RxClientSubscriber<String>(getClient(), uri).maxInFlight(3); | // Path: reactive-core/src/main/java/net/oneandone/reactive/ReactiveSink.java
// public interface ReactiveSink<T> extends Closeable {
//
// boolean isWriteable();
//
//
// /**
// * @param element the element to write
// * @return the write future
// */
// CompletableFuture<Void> writeAsync(T element);
//
//
// /**
// * @param element the element to write
// */
// void write(T element);
//
//
//
// /**
// * shutdown the sink
// *
// * @return the unprocessed element list
// */
// public ImmutableList<T> shutdownNow();
//
//
// /**
// * shutdown the queue. Let the unprocessed elements be processed
// */
// public void shutdown();
//
//
//
// boolean isOpen();
//
//
//
// @Override
// public void close();
//
//
//
// static <T> ReactiveSink<T> publish(Subscriber<T> subscriber) {
// return Utils.get(publishAsync(subscriber));
// }
//
//
// static <T> CompletableFuture<ReactiveSink<T>> publishAsync(Subscriber<T> subscriber) {
// return ReactiveSinkSubscription.newSubscriptionAsync(subscriber, 25);
// }
//
//
// static ReactiveSinkBuilder buffersize(int buffersize) {
// return new ReactiveSinkBuilder(buffersize);
// }
//
//
// public static class ReactiveSinkBuilder {
// private final int bufferSize;
//
// ReactiveSinkBuilder(int bufferSize) {
// this.bufferSize = bufferSize;
// }
//
// public <T> ReactiveSink<T> publish(Subscriber<T> subscriber) {
// return Utils.get(publishAsync(subscriber));
// }
//
//
// public <T> CompletableFuture<ReactiveSink<T>> publishAsync(Subscriber<T> subscriber) {
// return ReactiveSinkSubscription.newSubscriptionAsync(subscriber, bufferSize);
// }
// }
// }
//
// Path: reactive-http/src/test/java/net/oneandone/reactive/TestServletbasedTest.java
// public abstract class TestServletbasedTest {
//
// private Client client;
// private WebContainer server;
//
//
// @Before
// public void before() throws Exception {
// server = new WebContainer("/ssetest");
// server.start();
//
// client = new ResteasyClientBuilder().socketTimeout(60, TimeUnit.SECONDS)
// .connectionPoolSize(10)
// .build();
// }
//
//
// @After
// public void after() throws Exception {
// client.close();
// server.stop();
// }
//
//
// protected Client getClient() {
// return client;
// }
//
// protected WebContainer getServer() {
// return server;
// }
//
//
//
// protected void sleep(long millis) {
// try {
// Thread.sleep(millis);
// } catch (InterruptedException ignore) {
//
// }
// }
//
//
// protected void waitUtil(Supplier<Boolean> condition, long maxSec) {
//
// long maxWaittimeMillis = maxSec * 1000;
// long sleeptimeMillis = 100;
// for (int i = 0; i < (maxWaittimeMillis / sleeptimeMillis); i++) {
// if (condition.get()) {
// return;
// } else {
// sleep(sleeptimeMillis);
// }
// }
// }
// }
// Path: reactive-http/src/test/java/net/oneandone/reactive/rest/client/RxClientSubscriberTest.java
import java.net.URI;
import net.oneandone.reactive.ReactiveSink;
import net.oneandone.reactive.TestServletbasedTest;
import org.junit.Assert;
import org.junit.Test;
import org.reactivestreams.Subscriber;
/*
* Copyright 1&1 Internet AG, https://github.com/1and1/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.oneandone.reactive.rest.client;
public class RxClientSubscriberTest extends TestServletbasedTest {
/*
public RxClientSubscriberTest() {
System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", "DEBUG");
}
*/
@Test
public void testMaxInFlight() throws Exception {
URI uri = URI.create(getServer().getBaseUrl() + "/sink/?pauseMillis=700");
System.out.println(uri);
Subscriber<String> subscriber = new RxClientSubscriber<String>(getClient(), uri).maxInFlight(3); | ReactiveSink<String> reactiveSink = ReactiveSink.buffersize(0).publish(subscriber); |
1and1/reactive | reactive-kafka-example/src/main/java/net/oneandone/incubator/neo/http/sink/HttpSinkBuilder.java | // Path: reactive-kafka-example/src/main/java/net/oneandone/incubator/neo/http/sink/HttpSink.java
// public enum Method {
// POST, PUT
// };
| import java.io.File;
import java.time.Duration;
import javax.ws.rs.client.Client;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import net.oneandone.incubator.neo.http.sink.HttpSink.Method; | /*
* Copyright 1&1 Internet AG, htt;ps://github.com/1and1/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.oneandone.incubator.neo.http.sink;
public interface HttpSinkBuilder {
/**
* @param client the client to use
* @return a new instance of the http sink
*/
HttpSinkBuilder withClient(Client client);
/**
* @param method the method. Supported are POST and PUT (default is {@link HttpSink#DEFAULT_METHOD})
* @return a new instance of the http sink
*/ | // Path: reactive-kafka-example/src/main/java/net/oneandone/incubator/neo/http/sink/HttpSink.java
// public enum Method {
// POST, PUT
// };
// Path: reactive-kafka-example/src/main/java/net/oneandone/incubator/neo/http/sink/HttpSinkBuilder.java
import java.io.File;
import java.time.Duration;
import javax.ws.rs.client.Client;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import net.oneandone.incubator.neo.http.sink.HttpSink.Method;
/*
* Copyright 1&1 Internet AG, htt;ps://github.com/1and1/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.oneandone.incubator.neo.http.sink;
public interface HttpSinkBuilder {
/**
* @param client the client to use
* @return a new instance of the http sink
*/
HttpSinkBuilder withClient(Client client);
/**
* @param method the method. Supported are POST and PUT (default is {@link HttpSink#DEFAULT_METHOD})
* @return a new instance of the http sink
*/ | HttpSinkBuilder withMethod(Method method); |
1and1/reactive | reactive-kafka-example/src/main/java/com/unitedinternet/mam/incubator/hammer/http/client/RestClientBuilder.java | // Path: reactive-kafka-example/src/main/java/net/oneandone/incubator/neo/http/client/AddAppHeaderClientFilter.java
// public class AddAppHeaderClientFilter implements ClientRequestFilter {
//
// private final String headername;
// private final String appName;
// private final String appVersion;
//
// public AddAppHeaderClientFilter(final String headername, final String appName, final String appVersion) {
// this.headername = headername;
// this.appName = appName;
// this.appVersion = appVersion;
//
// }
//
//
// @Override
// public void filter(ClientRequestContext requestContext) {
// MultivaluedMap<String, Object> headers = requestContext.getHeaders();
// if (!headers.containsKey(headername)) {
// headers.add(headername, appName + "/" + appVersion);
// }
// }
// }
| import java.security.KeyStore;
import java.util.Map;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.core.Configuration;
import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.client.JerseyClientBuilder;
import net.oneandone.incubator.neo.http.client.AddAppHeaderClientFilter; | /*
* Copyright 1&1 Internet AG, https://github.com/1and1/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.unitedinternet.mam.incubator.hammer.http.client;
public class RestClientBuilder extends ClientBuilder {
private final JerseyClientBuilder delegate; | // Path: reactive-kafka-example/src/main/java/net/oneandone/incubator/neo/http/client/AddAppHeaderClientFilter.java
// public class AddAppHeaderClientFilter implements ClientRequestFilter {
//
// private final String headername;
// private final String appName;
// private final String appVersion;
//
// public AddAppHeaderClientFilter(final String headername, final String appName, final String appVersion) {
// this.headername = headername;
// this.appName = appName;
// this.appVersion = appVersion;
//
// }
//
//
// @Override
// public void filter(ClientRequestContext requestContext) {
// MultivaluedMap<String, Object> headers = requestContext.getHeaders();
// if (!headers.containsKey(headername)) {
// headers.add(headername, appName + "/" + appVersion);
// }
// }
// }
// Path: reactive-kafka-example/src/main/java/com/unitedinternet/mam/incubator/hammer/http/client/RestClientBuilder.java
import java.security.KeyStore;
import java.util.Map;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLContext;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.core.Configuration;
import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.client.JerseyClientBuilder;
import net.oneandone.incubator.neo.http.client.AddAppHeaderClientFilter;
/*
* Copyright 1&1 Internet AG, https://github.com/1and1/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.unitedinternet.mam.incubator.hammer.http.client;
public class RestClientBuilder extends ClientBuilder {
private final JerseyClientBuilder delegate; | private final AddAppHeaderClientFilter addAppnamefilter; |
1and1/reactive | reactive-http/src/test/java/net/oneandone/reactive/rest/MyResource.java | // Path: reactive-http/src/main/java/net/oneandone/reactive/rest/container/ResultConsumer.java
// public class ResultConsumer implements BiConsumer<Object, Throwable> {
//
// private final AsyncResponse asyncResponse;
//
// private ResultConsumer(AsyncResponse asyncResponse) {
// this.asyncResponse = asyncResponse;
// }
//
//
// @Override
// public void accept(Object result, Throwable error) {
// if (error == null) {
// asyncResponse.resume(result);
// } else {
// asyncResponse.resume(Utils.unwrap(error));
// }
// }
//
//
// /**
// * forwards the response to the REST response object. Includes error handling also
// * @param asyncResponse the REST response
// * @return the BiConsumer consuming the response/error pair
// */
// public static final BiConsumer<Object, Throwable> writeTo(AsyncResponse asyncResponse) {
// return new ResultConsumer(asyncResponse);
// }
// }
| import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.NotFoundException;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.container.AsyncResponse;
import javax.ws.rs.container.Suspended;
import javax.ws.rs.core.MediaType;
import net.oneandone.reactive.rest.container.ResultConsumer; | /*
* Copyright 1&1 Internet AG, https://github.com/1and1/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.oneandone.reactive.rest;
@Path("/MyResource")
public class MyResource {
private final Dao dao = new Dao();
@Path("/{id}")
@GET
@Produces(MediaType.APPLICATION_JSON)
public void retrieveAsync(@PathParam("id") long id, @Suspended AsyncResponse resp) {
if (id == 999) {
new Thread() {
@Override
public void run() {
try {
Thread.sleep(10);
} catch (InterruptedException ignore) { }
resp.resume(new NotFoundException("not found"));
}
}.start();
}
dao.readAsync(id) | // Path: reactive-http/src/main/java/net/oneandone/reactive/rest/container/ResultConsumer.java
// public class ResultConsumer implements BiConsumer<Object, Throwable> {
//
// private final AsyncResponse asyncResponse;
//
// private ResultConsumer(AsyncResponse asyncResponse) {
// this.asyncResponse = asyncResponse;
// }
//
//
// @Override
// public void accept(Object result, Throwable error) {
// if (error == null) {
// asyncResponse.resume(result);
// } else {
// asyncResponse.resume(Utils.unwrap(error));
// }
// }
//
//
// /**
// * forwards the response to the REST response object. Includes error handling also
// * @param asyncResponse the REST response
// * @return the BiConsumer consuming the response/error pair
// */
// public static final BiConsumer<Object, Throwable> writeTo(AsyncResponse asyncResponse) {
// return new ResultConsumer(asyncResponse);
// }
// }
// Path: reactive-http/src/test/java/net/oneandone/reactive/rest/MyResource.java
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.NotFoundException;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.container.AsyncResponse;
import javax.ws.rs.container.Suspended;
import javax.ws.rs.core.MediaType;
import net.oneandone.reactive.rest.container.ResultConsumer;
/*
* Copyright 1&1 Internet AG, https://github.com/1and1/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.oneandone.reactive.rest;
@Path("/MyResource")
public class MyResource {
private final Dao dao = new Dao();
@Path("/{id}")
@GET
@Produces(MediaType.APPLICATION_JSON)
public void retrieveAsync(@PathParam("id") long id, @Suspended AsyncResponse resp) {
if (id == 999) {
new Thread() {
@Override
public void run() {
try {
Thread.sleep(10);
} catch (InterruptedException ignore) { }
resp.resume(new NotFoundException("not found"));
}
}.start();
}
dao.readAsync(id) | .whenComplete(ResultConsumer.writeTo(resp)); |
1and1/reactive | reactive-kafka-example/src/main/java/net/oneandone/reactive/kafka/rest/TopicRepresentation.java | // Path: reactive-kafka-example/src/main/java/net/oneandone/incubator/neo/hypermedia/LinksBuilder.java
// public class LinksBuilder {
//
// private final ImmutableMap<String, Object> links;
// private final URI selfHref;
//
// private LinksBuilder(URI selfHref, ImmutableMap<String, Object> links) {
// this.selfHref = selfHref.toString().endsWith("/") ? selfHref : URI.create(selfHref.toString() + "/");
// this.links = links;
// }
//
// public static LinksBuilder create(UriInfo uriInfo) {
// return create(uriInfo.getAbsolutePathBuilder().build());
// }
//
// public static LinksBuilder create(URI selfHref) {
// return new LinksBuilder(selfHref, ImmutableMap.of()).withHref("self", selfHref);
// }
//
// public LinksBuilder withHref(String name) {
// return withHref(name, name);
// }
//
// public LinksBuilder withHref(String name, String href) {
// if (name.toLowerCase(Locale.US).startsWith("http")) {
// return withHref(name, URI.create(href));
// } else {
// return withHref(name, URI.create(selfHref.toString() + href));
// }
// }
//
// public LinksBuilder withHref(String name, URI href) {
// return new LinksBuilder(selfHref,
// ImmutableMap.<String, Object>builder()
// .putAll(links)
// .put(name, ImmutableMap.of("href", href.toString()))
// .build());
// }
//
//
// public ImmutableMap<String, Object> build() {
// return links;
// }
// }
| import javax.ws.rs.core.UriInfo;
import com.google.common.collect.ImmutableMap;
import net.oneandone.incubator.neo.hypermedia.LinksBuilder; | /*
* Copyright 1&1 Internet AG, https://github.com/1and1/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.oneandone.reactive.kafka.rest;
public class TopicRepresentation {
public ImmutableMap<String, Object> _links;
public String name;
public TopicRepresentation() { }
public TopicRepresentation(UriInfo uriInfo, String path, String topicname) { | // Path: reactive-kafka-example/src/main/java/net/oneandone/incubator/neo/hypermedia/LinksBuilder.java
// public class LinksBuilder {
//
// private final ImmutableMap<String, Object> links;
// private final URI selfHref;
//
// private LinksBuilder(URI selfHref, ImmutableMap<String, Object> links) {
// this.selfHref = selfHref.toString().endsWith("/") ? selfHref : URI.create(selfHref.toString() + "/");
// this.links = links;
// }
//
// public static LinksBuilder create(UriInfo uriInfo) {
// return create(uriInfo.getAbsolutePathBuilder().build());
// }
//
// public static LinksBuilder create(URI selfHref) {
// return new LinksBuilder(selfHref, ImmutableMap.of()).withHref("self", selfHref);
// }
//
// public LinksBuilder withHref(String name) {
// return withHref(name, name);
// }
//
// public LinksBuilder withHref(String name, String href) {
// if (name.toLowerCase(Locale.US).startsWith("http")) {
// return withHref(name, URI.create(href));
// } else {
// return withHref(name, URI.create(selfHref.toString() + href));
// }
// }
//
// public LinksBuilder withHref(String name, URI href) {
// return new LinksBuilder(selfHref,
// ImmutableMap.<String, Object>builder()
// .putAll(links)
// .put(name, ImmutableMap.of("href", href.toString()))
// .build());
// }
//
//
// public ImmutableMap<String, Object> build() {
// return links;
// }
// }
// Path: reactive-kafka-example/src/main/java/net/oneandone/reactive/kafka/rest/TopicRepresentation.java
import javax.ws.rs.core.UriInfo;
import com.google.common.collect.ImmutableMap;
import net.oneandone.incubator.neo.hypermedia.LinksBuilder;
/*
* Copyright 1&1 Internet AG, https://github.com/1and1/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.oneandone.reactive.kafka.rest;
public class TopicRepresentation {
public ImmutableMap<String, Object> _links;
public String name;
public TopicRepresentation() { }
public TopicRepresentation(UriInfo uriInfo, String path, String topicname) { | this(LinksBuilder.create(uriInfo.getBaseUriBuilder() |
1and1/reactive | reactive-http/src/main/java/net/oneandone/reactive/rest/container/ResultConsumer.java | // Path: reactive-core/src/main/java/net/oneandone/reactive/utils/Utils.java
// public class Utils {
//
// private Utils() { }
//
//
//
//
// public static <T> T get(Future<T> future) {
// try {
// return future.get();
// } catch (InterruptedException | ExecutionException e) {
// throw propagate(e);
// }
// }
//
//
//
//
//
// /**
// * unwraps an exception
// *
// * @param ex the exception to unwrap
// * @return the unwrapped exception
// */
// public static RuntimeException propagate(Throwable ex) {
// Throwable t = unwrap(ex);
// return (t instanceof RuntimeException) ? (RuntimeException) t : new RuntimeException(t);
// }
//
//
// /**
// * unwraps an exception
// *
// * @param ex the exception to unwrap
// * @return the unwrapped exception
// */
// public static Throwable unwrap(Throwable ex) {
// return unwrap(ex, 9);
// }
//
//
// /**
// * unwraps an exception
// *
// * @param ex the exception to unwrap
// * @param maxDepth the max depth
// * @return the unwrapped exception
// */
// private static Throwable unwrap(Throwable ex, int maxDepth) {
// if (isCompletionException(ex) || isExecutionException(ex)) {
// Throwable e = ex.getCause();
// if (e != null) {
// if (maxDepth > 1) {
// return unwrap(e, maxDepth - 1);
// } else {
// return e;
// }
// }
// }
//
// return ex;
// }
//
//
// private static boolean isCompletionException(Throwable t) {
// return CompletionException.class.isAssignableFrom(t.getClass());
// }
//
//
// private static boolean isExecutionException(Throwable t) {
// return ExecutionException.class.isAssignableFrom(t.getClass());
// }
// }
| import java.util.function.BiConsumer;
import javax.ws.rs.container.AsyncResponse;
import net.oneandone.reactive.utils.Utils; | /*
* Copyright 1&1 Internet AG, https://github.com/1and1/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.oneandone.reactive.rest.container;
/**
* ResultConsumer
*
*/
public class ResultConsumer implements BiConsumer<Object, Throwable> {
private final AsyncResponse asyncResponse;
private ResultConsumer(AsyncResponse asyncResponse) {
this.asyncResponse = asyncResponse;
}
@Override
public void accept(Object result, Throwable error) {
if (error == null) {
asyncResponse.resume(result);
} else { | // Path: reactive-core/src/main/java/net/oneandone/reactive/utils/Utils.java
// public class Utils {
//
// private Utils() { }
//
//
//
//
// public static <T> T get(Future<T> future) {
// try {
// return future.get();
// } catch (InterruptedException | ExecutionException e) {
// throw propagate(e);
// }
// }
//
//
//
//
//
// /**
// * unwraps an exception
// *
// * @param ex the exception to unwrap
// * @return the unwrapped exception
// */
// public static RuntimeException propagate(Throwable ex) {
// Throwable t = unwrap(ex);
// return (t instanceof RuntimeException) ? (RuntimeException) t : new RuntimeException(t);
// }
//
//
// /**
// * unwraps an exception
// *
// * @param ex the exception to unwrap
// * @return the unwrapped exception
// */
// public static Throwable unwrap(Throwable ex) {
// return unwrap(ex, 9);
// }
//
//
// /**
// * unwraps an exception
// *
// * @param ex the exception to unwrap
// * @param maxDepth the max depth
// * @return the unwrapped exception
// */
// private static Throwable unwrap(Throwable ex, int maxDepth) {
// if (isCompletionException(ex) || isExecutionException(ex)) {
// Throwable e = ex.getCause();
// if (e != null) {
// if (maxDepth > 1) {
// return unwrap(e, maxDepth - 1);
// } else {
// return e;
// }
// }
// }
//
// return ex;
// }
//
//
// private static boolean isCompletionException(Throwable t) {
// return CompletionException.class.isAssignableFrom(t.getClass());
// }
//
//
// private static boolean isExecutionException(Throwable t) {
// return ExecutionException.class.isAssignableFrom(t.getClass());
// }
// }
// Path: reactive-http/src/main/java/net/oneandone/reactive/rest/container/ResultConsumer.java
import java.util.function.BiConsumer;
import javax.ws.rs.container.AsyncResponse;
import net.oneandone.reactive.utils.Utils;
/*
* Copyright 1&1 Internet AG, https://github.com/1and1/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.oneandone.reactive.rest.container;
/**
* ResultConsumer
*
*/
public class ResultConsumer implements BiConsumer<Object, Throwable> {
private final AsyncResponse asyncResponse;
private ResultConsumer(AsyncResponse asyncResponse) {
this.asyncResponse = asyncResponse;
}
@Override
public void accept(Object result, Throwable error) {
if (error == null) {
asyncResponse.resume(result);
} else { | asyncResponse.resume(Utils.unwrap(error)); |
1and1/reactive | reactive-kafka-example/src/main/java/net/oneandone/reactive/kafka/avro/json/AvroMessageMapper.java | // Path: reactive-core/src/main/java/net/oneandone/reactive/utils/Pair.java
// public class Pair<F,S> {
//
// private final F first;
// private final S second;
//
//
// private Pair(F first, S second) {
// this.first = first;
// this.second = second;
// }
//
// /**
// * @return the first item in the pair
// */
// public F getFirst() {
// return first;
// }
//
// /**
// * @return the second item in the pair
// */
// public S getSecond() {
// return second;
// }
//
// /**
// * @param first the first item to store in the pair
// * @param second the second item to store in the pair
// * @param <S> the type of the first item
// * @param <T> the type of the second item
// * @return a new pair wrapping the two items
// */
// public static <F, S> Pair<F, S> of(F first, S second) {
// return new Pair<>(first,second);
// }
//
//
// @Override
// public String toString() {
// return "[" + first + ", " + second + "]";
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(first, second);
// }
//
// @SuppressWarnings("rawtypes")
// @Override
// public boolean equals(Object other) {
//
// if ((other != null) && (other instanceof Pair)) {
// Pair otherPair = (Pair) other;
// return Optional.ofNullable(otherPair.getFirst()).equals(Optional.ofNullable(this.getFirst())) &&
// Optional.ofNullable(otherPair.getSecond()).equals(Optional.ofNullable(this.getSecond()));
//
// } else {
// return false;
// }
// }
// }
| import java.io.ByteArrayInputStream;
import java.io.StringWriter;
import java.util.List;
import java.util.Map.Entry;
import java.util.function.BiConsumer;
import java.util.function.Function;
import javax.json.Json;
import javax.json.JsonArray;
import javax.json.JsonObject;
import javax.json.JsonObjectBuilder;
import javax.json.JsonReader;
import javax.json.JsonString;
import javax.json.JsonValue;
import javax.json.JsonWriter;
import javax.json.JsonWriterFactory;
import javax.json.stream.JsonGenerator;
import javax.json.stream.JsonParser;
import javax.json.stream.JsonParser.Event;
import org.apache.avro.Schema;
import org.apache.avro.generic.GenericData;
import org.apache.avro.generic.GenericData.EnumSymbol;
import org.apache.avro.generic.GenericRecord;
import org.apache.avro.util.Utf8;
import org.mortbay.log.Log;
import com.google.common.base.Charsets;
import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import net.oneandone.reactive.utils.Pair; |
public JsonObject toJson(GenericRecord genericRecord) {
return avroRecordToJsonObjectWriter.apply(genericRecord);
}
@Override
public int hashCode() {
return toString().hashCode();
}
@Override
public boolean equals(Object other) {
return (other != null) && (other instanceof AvroMessageMapper) && ((AvroMessageMapper) other).toString().equals(this.toString());
}
@Override
public String toString() {
final StringWriter stringWriter = new StringWriter();
final ImmutableMap<String, Boolean> config = ImmutableMap.of(JsonGenerator.PRETTY_PRINTING, true);
final JsonWriterFactory writerFactory = Json.createWriterFactory(config);
final JsonWriter jsonWriter = writerFactory.createWriter(stringWriter);
jsonWriter.write(jsonSchema);
jsonWriter.close();
return stringWriter.toString();
}
| // Path: reactive-core/src/main/java/net/oneandone/reactive/utils/Pair.java
// public class Pair<F,S> {
//
// private final F first;
// private final S second;
//
//
// private Pair(F first, S second) {
// this.first = first;
// this.second = second;
// }
//
// /**
// * @return the first item in the pair
// */
// public F getFirst() {
// return first;
// }
//
// /**
// * @return the second item in the pair
// */
// public S getSecond() {
// return second;
// }
//
// /**
// * @param first the first item to store in the pair
// * @param second the second item to store in the pair
// * @param <S> the type of the first item
// * @param <T> the type of the second item
// * @return a new pair wrapping the two items
// */
// public static <F, S> Pair<F, S> of(F first, S second) {
// return new Pair<>(first,second);
// }
//
//
// @Override
// public String toString() {
// return "[" + first + ", " + second + "]";
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(first, second);
// }
//
// @SuppressWarnings("rawtypes")
// @Override
// public boolean equals(Object other) {
//
// if ((other != null) && (other instanceof Pair)) {
// Pair otherPair = (Pair) other;
// return Optional.ofNullable(otherPair.getFirst()).equals(Optional.ofNullable(this.getFirst())) &&
// Optional.ofNullable(otherPair.getSecond()).equals(Optional.ofNullable(this.getSecond()));
//
// } else {
// return false;
// }
// }
// }
// Path: reactive-kafka-example/src/main/java/net/oneandone/reactive/kafka/avro/json/AvroMessageMapper.java
import java.io.ByteArrayInputStream;
import java.io.StringWriter;
import java.util.List;
import java.util.Map.Entry;
import java.util.function.BiConsumer;
import java.util.function.Function;
import javax.json.Json;
import javax.json.JsonArray;
import javax.json.JsonObject;
import javax.json.JsonObjectBuilder;
import javax.json.JsonReader;
import javax.json.JsonString;
import javax.json.JsonValue;
import javax.json.JsonWriter;
import javax.json.JsonWriterFactory;
import javax.json.stream.JsonGenerator;
import javax.json.stream.JsonParser;
import javax.json.stream.JsonParser.Event;
import org.apache.avro.Schema;
import org.apache.avro.generic.GenericData;
import org.apache.avro.generic.GenericData.EnumSymbol;
import org.apache.avro.generic.GenericRecord;
import org.apache.avro.util.Utf8;
import org.mortbay.log.Log;
import com.google.common.base.Charsets;
import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import net.oneandone.reactive.utils.Pair;
public JsonObject toJson(GenericRecord genericRecord) {
return avroRecordToJsonObjectWriter.apply(genericRecord);
}
@Override
public int hashCode() {
return toString().hashCode();
}
@Override
public boolean equals(Object other) {
return (other != null) && (other instanceof AvroMessageMapper) && ((AvroMessageMapper) other).toString().equals(this.toString());
}
@Override
public String toString() {
final StringWriter stringWriter = new StringWriter();
final ImmutableMap<String, Boolean> config = ImmutableMap.of(JsonGenerator.PRETTY_PRINTING, true);
final JsonWriterFactory writerFactory = Json.createWriterFactory(config);
final JsonWriter jsonWriter = writerFactory.createWriter(stringWriter);
jsonWriter.write(jsonSchema);
jsonWriter.close();
return stringWriter.toString();
}
| public static Pair<AvroMessageMapper, SchemaInfo> createrMapper(SchemaInfo schemaInfo) throws SchemaException { |
1and1/reactive | reactive-kafka-example/src/main/java/net/oneandone/reactive/kafka/rest/TopicsRepresentation.java | // Path: reactive-kafka-example/src/main/java/net/oneandone/incubator/neo/hypermedia/LinksBuilder.java
// public class LinksBuilder {
//
// private final ImmutableMap<String, Object> links;
// private final URI selfHref;
//
// private LinksBuilder(URI selfHref, ImmutableMap<String, Object> links) {
// this.selfHref = selfHref.toString().endsWith("/") ? selfHref : URI.create(selfHref.toString() + "/");
// this.links = links;
// }
//
// public static LinksBuilder create(UriInfo uriInfo) {
// return create(uriInfo.getAbsolutePathBuilder().build());
// }
//
// public static LinksBuilder create(URI selfHref) {
// return new LinksBuilder(selfHref, ImmutableMap.of()).withHref("self", selfHref);
// }
//
// public LinksBuilder withHref(String name) {
// return withHref(name, name);
// }
//
// public LinksBuilder withHref(String name, String href) {
// if (name.toLowerCase(Locale.US).startsWith("http")) {
// return withHref(name, URI.create(href));
// } else {
// return withHref(name, URI.create(selfHref.toString() + href));
// }
// }
//
// public LinksBuilder withHref(String name, URI href) {
// return new LinksBuilder(selfHref,
// ImmutableMap.<String, Object>builder()
// .putAll(links)
// .put(name, ImmutableMap.of("href", href.toString()))
// .build());
// }
//
//
// public ImmutableMap<String, Object> build() {
// return links;
// }
// }
| import net.oneandone.incubator.neo.hypermedia.LinksBuilder;
import javax.ws.rs.core.UriInfo;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet; | /*
* Copyright 1&1 Internet AG, https://github.com/1and1/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.oneandone.reactive.kafka.rest;
public class TopicsRepresentation {
public ImmutableMap<String, Object> _links;
public ImmutableSet<TopicRepresentation> _elements;
public TopicsRepresentation() { }
public TopicsRepresentation(UriInfo uriInfo, String path, ImmutableSet<TopicRepresentation> elements) { | // Path: reactive-kafka-example/src/main/java/net/oneandone/incubator/neo/hypermedia/LinksBuilder.java
// public class LinksBuilder {
//
// private final ImmutableMap<String, Object> links;
// private final URI selfHref;
//
// private LinksBuilder(URI selfHref, ImmutableMap<String, Object> links) {
// this.selfHref = selfHref.toString().endsWith("/") ? selfHref : URI.create(selfHref.toString() + "/");
// this.links = links;
// }
//
// public static LinksBuilder create(UriInfo uriInfo) {
// return create(uriInfo.getAbsolutePathBuilder().build());
// }
//
// public static LinksBuilder create(URI selfHref) {
// return new LinksBuilder(selfHref, ImmutableMap.of()).withHref("self", selfHref);
// }
//
// public LinksBuilder withHref(String name) {
// return withHref(name, name);
// }
//
// public LinksBuilder withHref(String name, String href) {
// if (name.toLowerCase(Locale.US).startsWith("http")) {
// return withHref(name, URI.create(href));
// } else {
// return withHref(name, URI.create(selfHref.toString() + href));
// }
// }
//
// public LinksBuilder withHref(String name, URI href) {
// return new LinksBuilder(selfHref,
// ImmutableMap.<String, Object>builder()
// .putAll(links)
// .put(name, ImmutableMap.of("href", href.toString()))
// .build());
// }
//
//
// public ImmutableMap<String, Object> build() {
// return links;
// }
// }
// Path: reactive-kafka-example/src/main/java/net/oneandone/reactive/kafka/rest/TopicsRepresentation.java
import net.oneandone.incubator.neo.hypermedia.LinksBuilder;
import javax.ws.rs.core.UriInfo;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
/*
* Copyright 1&1 Internet AG, https://github.com/1and1/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.oneandone.reactive.kafka.rest;
public class TopicsRepresentation {
public ImmutableMap<String, Object> _links;
public ImmutableSet<TopicRepresentation> _elements;
public TopicsRepresentation() { }
public TopicsRepresentation(UriInfo uriInfo, String path, ImmutableSet<TopicRepresentation> elements) { | this(LinksBuilder.create(uriInfo.getBaseUriBuilder().path(path).build()).build(), elements); |
1and1/reactive | reactive-http/src/main/java/net/oneandone/reactive/utils/RetryScheduler.java | // Path: reactive-http/src/main/java/net/oneandone/reactive/utils/ScheduledExceutor.java
// public class ScheduledExceutor implements ScheduledExecutorService {
// private static final ScheduledThreadPoolExecutor EXECUTOR = new ScheduledThreadPoolExecutor(0);
// static {
// EXECUTOR.setKeepAliveTime(60, TimeUnit.SECONDS);
// EXECUTOR.allowCoreThreadTimeOut(true);
// }
//
// public static ScheduledExecutorService common() {
// return new ScheduledExceutor(EXECUTOR);
// }
//
//
// private final ScheduledExecutorService executor;
//
// public ScheduledExceutor(ScheduledExecutorService executor) {
// this.executor = executor;
// }
//
//
// @Override
// public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException {
// return executor.awaitTermination(timeout, unit);
// }
//
// @Override
// public void execute(Runnable command) {
// executor.execute(command);
// }
//
// @Override
// public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException {
// return executor.invokeAll(tasks);
// }
//
// @Override
// public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException {
// return executor.invokeAll(tasks, timeout, unit);
// }
//
// @Override
// public <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException {
// return executor.invokeAny(tasks);
// }
//
// @Override
// public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
// return executor.invokeAny(tasks, timeout, unit);
// }
//
// @Override
// public <V> ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit) {
// return executor.schedule(callable, delay, unit);
// }
//
// @Override
// public ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit) {
// return executor.schedule(command, delay, unit);
// }
//
// @Override
// public ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit) {
// return executor.scheduleAtFixedRate(command, initialDelay, period, unit);
// }
//
// @Override
// public ScheduledFuture<?> scheduleWithFixedDelay(Runnable command,long initialDelay, long delay, TimeUnit unit) {
// return executor.scheduleWithFixedDelay(command, initialDelay, delay, unit);
// }
//
// @Override
// public <T> Future<T> submit(Callable<T> task) {
// return executor.submit(task);
// }
//
// @Override
// public Future<?> submit(Runnable task) {
// return executor.submit(task);
// }
//
// @Override
// public <T> Future<T> submit(Runnable task, T result) {
// return executor.submit(task, result);
// }
//
// @Override
// public boolean isTerminated() {
// return false;
// }
//
// @Override
// public boolean isShutdown() {
// return false;
// }
//
//
// @Override
// public void shutdown() {
// }
//
// @Override
// public List<Runnable> shutdownNow() {
// return ImmutableList.of();
// }
// }
| import java.time.Duration;
import java.time.Instant;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
import net.oneandone.reactive.utils.ScheduledExceutor;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps; | /*
* Copyright 1&1 Internet AG, https://github.com/1and1/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.oneandone.reactive.utils;
public class RetryScheduler {
private final RetrySequence retrySequence;
private Instant lastSchedule = Instant.now();
private Duration lastDelay = Duration.ZERO;
public RetryScheduler() {
this(0, 3, 25, 250, 500, 2000);
}
public RetryScheduler(int... delaysMillis) {
retrySequence = new RetrySequence(delaysMillis);
}
public Duration scheduleWithDelay(Runnable connectTast) {
// last schedule a while ago?
Duration delaySinceLastSchedule = Duration.between(lastSchedule, Instant.now());
if (retrySequence.getMaxDelay().multipliedBy(2).minus(delaySinceLastSchedule).isNegative()) {
// yes
lastDelay = Duration.ZERO;
} else {
// no
lastDelay = retrySequence.nextDelay(lastDelay)
.orElseThrow(() -> new RuntimeException("may retries reached"));
}
lastSchedule = Instant.now(); | // Path: reactive-http/src/main/java/net/oneandone/reactive/utils/ScheduledExceutor.java
// public class ScheduledExceutor implements ScheduledExecutorService {
// private static final ScheduledThreadPoolExecutor EXECUTOR = new ScheduledThreadPoolExecutor(0);
// static {
// EXECUTOR.setKeepAliveTime(60, TimeUnit.SECONDS);
// EXECUTOR.allowCoreThreadTimeOut(true);
// }
//
// public static ScheduledExecutorService common() {
// return new ScheduledExceutor(EXECUTOR);
// }
//
//
// private final ScheduledExecutorService executor;
//
// public ScheduledExceutor(ScheduledExecutorService executor) {
// this.executor = executor;
// }
//
//
// @Override
// public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException {
// return executor.awaitTermination(timeout, unit);
// }
//
// @Override
// public void execute(Runnable command) {
// executor.execute(command);
// }
//
// @Override
// public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException {
// return executor.invokeAll(tasks);
// }
//
// @Override
// public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException {
// return executor.invokeAll(tasks, timeout, unit);
// }
//
// @Override
// public <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException {
// return executor.invokeAny(tasks);
// }
//
// @Override
// public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
// return executor.invokeAny(tasks, timeout, unit);
// }
//
// @Override
// public <V> ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit) {
// return executor.schedule(callable, delay, unit);
// }
//
// @Override
// public ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit) {
// return executor.schedule(command, delay, unit);
// }
//
// @Override
// public ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit) {
// return executor.scheduleAtFixedRate(command, initialDelay, period, unit);
// }
//
// @Override
// public ScheduledFuture<?> scheduleWithFixedDelay(Runnable command,long initialDelay, long delay, TimeUnit unit) {
// return executor.scheduleWithFixedDelay(command, initialDelay, delay, unit);
// }
//
// @Override
// public <T> Future<T> submit(Callable<T> task) {
// return executor.submit(task);
// }
//
// @Override
// public Future<?> submit(Runnable task) {
// return executor.submit(task);
// }
//
// @Override
// public <T> Future<T> submit(Runnable task, T result) {
// return executor.submit(task, result);
// }
//
// @Override
// public boolean isTerminated() {
// return false;
// }
//
// @Override
// public boolean isShutdown() {
// return false;
// }
//
//
// @Override
// public void shutdown() {
// }
//
// @Override
// public List<Runnable> shutdownNow() {
// return ImmutableList.of();
// }
// }
// Path: reactive-http/src/main/java/net/oneandone/reactive/utils/RetryScheduler.java
import java.time.Duration;
import java.time.Instant;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
import net.oneandone.reactive.utils.ScheduledExceutor;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
/*
* Copyright 1&1 Internet AG, https://github.com/1and1/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.oneandone.reactive.utils;
public class RetryScheduler {
private final RetrySequence retrySequence;
private Instant lastSchedule = Instant.now();
private Duration lastDelay = Duration.ZERO;
public RetryScheduler() {
this(0, 3, 25, 250, 500, 2000);
}
public RetryScheduler(int... delaysMillis) {
retrySequence = new RetrySequence(delaysMillis);
}
public Duration scheduleWithDelay(Runnable connectTast) {
// last schedule a while ago?
Duration delaySinceLastSchedule = Duration.between(lastSchedule, Instant.now());
if (retrySequence.getMaxDelay().multipliedBy(2).minus(delaySinceLastSchedule).isNegative()) {
// yes
lastDelay = Duration.ZERO;
} else {
// no
lastDelay = retrySequence.nextDelay(lastDelay)
.orElseThrow(() -> new RuntimeException("may retries reached"));
}
lastSchedule = Instant.now(); | ScheduledExceutor.common().schedule(connectTast, lastDelay.toMillis(), TimeUnit.MILLISECONDS); |
1and1/reactive | reactive-kafka-example/src/main/java/net/oneandone/incubator/neo/http/sink/Submission.java | // Path: reactive-kafka-example/src/main/java/net/oneandone/incubator/neo/http/sink/HttpSink.java
// public enum Method {
// POST, PUT
// };
| import java.net.URI;
import javax.ws.rs.client.Entity;
import com.google.common.collect.ImmutableSet;
import net.oneandone.incubator.neo.http.sink.HttpSink.Method; | /*
* Copyright 1&1 Internet AG, htt;ps://github.com/1and1/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.oneandone.incubator.neo.http.sink;
/**
* Represent the submission process
*/
public interface Submission {
/**
* submission state
*/
public enum State { PENDING, COMPLETED, DISCARDED }
/**
* @return the state
*/
State getState();
/**
* @return the id
*/
String getId();
/**
* @return the method
*/ | // Path: reactive-kafka-example/src/main/java/net/oneandone/incubator/neo/http/sink/HttpSink.java
// public enum Method {
// POST, PUT
// };
// Path: reactive-kafka-example/src/main/java/net/oneandone/incubator/neo/http/sink/Submission.java
import java.net.URI;
import javax.ws.rs.client.Entity;
import com.google.common.collect.ImmutableSet;
import net.oneandone.incubator.neo.http.sink.HttpSink.Method;
/*
* Copyright 1&1 Internet AG, htt;ps://github.com/1and1/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.oneandone.incubator.neo.http.sink;
/**
* Represent the submission process
*/
public interface Submission {
/**
* submission state
*/
public enum State { PENDING, COMPLETED, DISCARDED }
/**
* @return the state
*/
State getState();
/**
* @return the id
*/
String getId();
/**
* @return the method
*/ | Method getMethod(); |
1and1/reactive | reactive-http/src/main/java/net/oneandone/reactive/sse/client/NettyBasedHttpChannelProvider.java | // Path: reactive-core/src/main/java/net/oneandone/reactive/ConnectException.java
// public class ConnectException extends RuntimeException {
//
// private static final long serialVersionUID = 4790384678606033160L;
//
// public ConnectException(String reason) {
// super(reason);
// }
//
// public ConnectException(Throwable cause) {
// super(cause);
// }
//
// public ConnectException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
| import io.netty.bootstrap.Bootstrap;
import io.netty.buffer.Unpooled;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelOption;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.handler.codec.http.DefaultHttpContent;
import io.netty.handler.codec.http.DefaultHttpRequest;
import io.netty.handler.codec.http.HttpClientCodec;
import io.netty.handler.codec.http.HttpContent;
import io.netty.handler.codec.http.HttpContentDecompressor;
import io.netty.handler.codec.http.HttpHeaders;
import io.netty.handler.codec.http.HttpMethod;
import io.netty.handler.codec.http.HttpObject;
import io.netty.handler.codec.http.HttpResponse;
import io.netty.handler.codec.http.HttpVersion;
import io.netty.handler.codec.http.LastHttpContent;
import io.netty.handler.ssl.SslContext;
import io.netty.util.concurrent.Future;
import io.netty.util.concurrent.FutureListener;
import java.net.URI;
import java.nio.ByteBuffer;
import java.nio.channels.ClosedChannelException;
import java.nio.charset.StandardCharsets;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicReference;
import javax.net.ssl.SSLException;
import net.oneandone.reactive.ConnectException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.collect.ImmutableSet; |
@Override
public CompletableFuture<HttpChannel> newHttpChannelAsync(ConnectionParams params) {
CompletableFuture<HttpChannel> connectPromise = new CompletableFuture<>();
openHttpChannelAsync(params, connectPromise);
return connectPromise;
}
private void openHttpChannelAsync(ConnectionParams params, CompletableFuture<HttpChannel> connectPromise) {
openStreamAsync(params, new StatefulHttpChannelHandler(params, connectPromise));
}
private void openStreamAsync(ConnectionParams params, HttpChannelHandler channelHandler) {
try {
Bootstrap bootstrap = newConnectionBootstrap(params, channelHandler);
LOG.debug("[" + params.getId() + "] - opening channel with " + bootstrap.toString());
ChannelFutureListener listener = new ChannelFutureListener() {
@Override
public void operationComplete(ChannelFuture future) throws Exception {
if (future.isSuccess()) {
channelHandler.onConnect(future.channel());
} else { | // Path: reactive-core/src/main/java/net/oneandone/reactive/ConnectException.java
// public class ConnectException extends RuntimeException {
//
// private static final long serialVersionUID = 4790384678606033160L;
//
// public ConnectException(String reason) {
// super(reason);
// }
//
// public ConnectException(Throwable cause) {
// super(cause);
// }
//
// public ConnectException(String reason, Throwable cause) {
// super(reason, cause);
// }
// }
// Path: reactive-http/src/main/java/net/oneandone/reactive/sse/client/NettyBasedHttpChannelProvider.java
import io.netty.bootstrap.Bootstrap;
import io.netty.buffer.Unpooled;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelOption;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.handler.codec.http.DefaultHttpContent;
import io.netty.handler.codec.http.DefaultHttpRequest;
import io.netty.handler.codec.http.HttpClientCodec;
import io.netty.handler.codec.http.HttpContent;
import io.netty.handler.codec.http.HttpContentDecompressor;
import io.netty.handler.codec.http.HttpHeaders;
import io.netty.handler.codec.http.HttpMethod;
import io.netty.handler.codec.http.HttpObject;
import io.netty.handler.codec.http.HttpResponse;
import io.netty.handler.codec.http.HttpVersion;
import io.netty.handler.codec.http.LastHttpContent;
import io.netty.handler.ssl.SslContext;
import io.netty.util.concurrent.Future;
import io.netty.util.concurrent.FutureListener;
import java.net.URI;
import java.nio.ByteBuffer;
import java.nio.channels.ClosedChannelException;
import java.nio.charset.StandardCharsets;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicReference;
import javax.net.ssl.SSLException;
import net.oneandone.reactive.ConnectException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.collect.ImmutableSet;
@Override
public CompletableFuture<HttpChannel> newHttpChannelAsync(ConnectionParams params) {
CompletableFuture<HttpChannel> connectPromise = new CompletableFuture<>();
openHttpChannelAsync(params, connectPromise);
return connectPromise;
}
private void openHttpChannelAsync(ConnectionParams params, CompletableFuture<HttpChannel> connectPromise) {
openStreamAsync(params, new StatefulHttpChannelHandler(params, connectPromise));
}
private void openStreamAsync(ConnectionParams params, HttpChannelHandler channelHandler) {
try {
Bootstrap bootstrap = newConnectionBootstrap(params, channelHandler);
LOG.debug("[" + params.getId() + "] - opening channel with " + bootstrap.toString());
ChannelFutureListener listener = new ChannelFutureListener() {
@Override
public void operationComplete(ChannelFuture future) throws Exception {
if (future.isSuccess()) {
channelHandler.onConnect(future.channel());
} else { | channelHandler.onError(future.channel(), new ConnectException(future.cause())); |
1and1/reactive | reactive-core/src/main/java/net/oneandone/reactive/ReactiveSink.java | // Path: reactive-core/src/main/java/net/oneandone/reactive/utils/Utils.java
// public class Utils {
//
// private Utils() { }
//
//
//
//
// public static <T> T get(Future<T> future) {
// try {
// return future.get();
// } catch (InterruptedException | ExecutionException e) {
// throw propagate(e);
// }
// }
//
//
//
//
//
// /**
// * unwraps an exception
// *
// * @param ex the exception to unwrap
// * @return the unwrapped exception
// */
// public static RuntimeException propagate(Throwable ex) {
// Throwable t = unwrap(ex);
// return (t instanceof RuntimeException) ? (RuntimeException) t : new RuntimeException(t);
// }
//
//
// /**
// * unwraps an exception
// *
// * @param ex the exception to unwrap
// * @return the unwrapped exception
// */
// public static Throwable unwrap(Throwable ex) {
// return unwrap(ex, 9);
// }
//
//
// /**
// * unwraps an exception
// *
// * @param ex the exception to unwrap
// * @param maxDepth the max depth
// * @return the unwrapped exception
// */
// private static Throwable unwrap(Throwable ex, int maxDepth) {
// if (isCompletionException(ex) || isExecutionException(ex)) {
// Throwable e = ex.getCause();
// if (e != null) {
// if (maxDepth > 1) {
// return unwrap(e, maxDepth - 1);
// } else {
// return e;
// }
// }
// }
//
// return ex;
// }
//
//
// private static boolean isCompletionException(Throwable t) {
// return CompletionException.class.isAssignableFrom(t.getClass());
// }
//
//
// private static boolean isExecutionException(Throwable t) {
// return ExecutionException.class.isAssignableFrom(t.getClass());
// }
// }
| import java.io.Closeable;
import java.util.concurrent.CompletableFuture;
import net.oneandone.reactive.utils.Utils;
import org.reactivestreams.Subscriber;
import com.google.common.collect.ImmutableList; | /*
* Copyright 1&1 Internet AG, https://github.com/1and1/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.oneandone.reactive;
public interface ReactiveSink<T> extends Closeable {
boolean isWriteable();
/**
* @param element the element to write
* @return the write future
*/
CompletableFuture<Void> writeAsync(T element);
/**
* @param element the element to write
*/
void write(T element);
/**
* shutdown the sink
*
* @return the unprocessed element list
*/
public ImmutableList<T> shutdownNow();
/**
* shutdown the queue. Let the unprocessed elements be processed
*/
public void shutdown();
boolean isOpen();
@Override
public void close();
static <T> ReactiveSink<T> publish(Subscriber<T> subscriber) { | // Path: reactive-core/src/main/java/net/oneandone/reactive/utils/Utils.java
// public class Utils {
//
// private Utils() { }
//
//
//
//
// public static <T> T get(Future<T> future) {
// try {
// return future.get();
// } catch (InterruptedException | ExecutionException e) {
// throw propagate(e);
// }
// }
//
//
//
//
//
// /**
// * unwraps an exception
// *
// * @param ex the exception to unwrap
// * @return the unwrapped exception
// */
// public static RuntimeException propagate(Throwable ex) {
// Throwable t = unwrap(ex);
// return (t instanceof RuntimeException) ? (RuntimeException) t : new RuntimeException(t);
// }
//
//
// /**
// * unwraps an exception
// *
// * @param ex the exception to unwrap
// * @return the unwrapped exception
// */
// public static Throwable unwrap(Throwable ex) {
// return unwrap(ex, 9);
// }
//
//
// /**
// * unwraps an exception
// *
// * @param ex the exception to unwrap
// * @param maxDepth the max depth
// * @return the unwrapped exception
// */
// private static Throwable unwrap(Throwable ex, int maxDepth) {
// if (isCompletionException(ex) || isExecutionException(ex)) {
// Throwable e = ex.getCause();
// if (e != null) {
// if (maxDepth > 1) {
// return unwrap(e, maxDepth - 1);
// } else {
// return e;
// }
// }
// }
//
// return ex;
// }
//
//
// private static boolean isCompletionException(Throwable t) {
// return CompletionException.class.isAssignableFrom(t.getClass());
// }
//
//
// private static boolean isExecutionException(Throwable t) {
// return ExecutionException.class.isAssignableFrom(t.getClass());
// }
// }
// Path: reactive-core/src/main/java/net/oneandone/reactive/ReactiveSink.java
import java.io.Closeable;
import java.util.concurrent.CompletableFuture;
import net.oneandone.reactive.utils.Utils;
import org.reactivestreams.Subscriber;
import com.google.common.collect.ImmutableList;
/*
* Copyright 1&1 Internet AG, https://github.com/1and1/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.oneandone.reactive;
public interface ReactiveSink<T> extends Closeable {
boolean isWriteable();
/**
* @param element the element to write
* @return the write future
*/
CompletableFuture<Void> writeAsync(T element);
/**
* @param element the element to write
*/
void write(T element);
/**
* shutdown the sink
*
* @return the unprocessed element list
*/
public ImmutableList<T> shutdownNow();
/**
* shutdown the queue. Let the unprocessed elements be processed
*/
public void shutdown();
boolean isOpen();
@Override
public void close();
static <T> ReactiveSink<T> publish(Subscriber<T> subscriber) { | return Utils.get(publishAsync(subscriber)); |
1and1/reactive | reactive-kafka-example/src/main/java/net/oneandone/incubator/neo/http/sink/HttpQueryExecutor.java | // Path: reactive-kafka-example/src/main/java/net/oneandone/incubator/neo/exception/Exceptions.java
// public class Exceptions {
//
// private Exceptions() { }
//
//
//
//
//
// /**
// * unwraps an exception
// *
// * @param ex the exception to unwrap
// * @return the unwrapped exception
// */
// public static RuntimeException propagate(Throwable ex) {
// Throwable t = unwrap(ex);
// return (t instanceof RuntimeException) ? (RuntimeException) t : new RuntimeException(t);
// }
//
//
// /**
// * unwraps an exception
// *
// * @param ex the exception to unwrap
// * @return the unwrapped exception
// */
// public static Throwable unwrap(Throwable ex) {
// return unwrap(ex, 9);
// }
//
//
// /**
// * unwraps an exception
// *
// * @param ex the exception to unwrap
// * @param maxDepth the max depth
// * @return the unwrapped exception
// */
// private static Throwable unwrap(Throwable ex, int maxDepth) {
// if (isCompletionException(ex) || isExecutionException(ex)) {
// Throwable e = ex.getCause();
// if (e != null) {
// if (maxDepth > 1) {
// return unwrap(e, maxDepth - 1);
// } else {
// return e;
// }
// }
// }
//
// return ex;
// }
//
//
// private static boolean isCompletionException(Throwable t) {
// return CompletionException.class.isAssignableFrom(t.getClass());
// }
//
//
// private static boolean isExecutionException(Throwable t) {
// return ExecutionException.class.isAssignableFrom(t.getClass());
// }
//
//
// public static <T> CompletableFuture<T> completedFailedFuture(Throwable ex) {
// CompletableFuture<T> future = new CompletableFuture<>();
// future.completeExceptionally(ex);
// return future;
// }
// }
//
// Path: reactive-kafka-example/src/main/java/net/oneandone/incubator/neo/http/sink/HttpSink.java
// public enum Method {
// POST, PUT
// };
| import java.io.Closeable;
import java.net.URI;
import java.time.Duration;
import java.time.Instant;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.BiConsumer;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.InvocationCallback;
import javax.ws.rs.client.ResponseProcessingException;
import javax.ws.rs.client.Invocation.Builder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import net.oneandone.incubator.neo.exception.Exceptions;
import net.oneandone.incubator.neo.http.sink.HttpSink.Method; | /*
* Copyright 1&1 Internet AG, https://github.com/1and1/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.oneandone.incubator.neo.http.sink;
/**
* Query executor
*/
class HttpQueryExecutor implements Closeable {
private static final Logger LOG = LoggerFactory.getLogger(HttpQueryExecutor.class);
private final Client httpClient;
private final ScheduledThreadPoolExecutor executor;
private final AtomicBoolean isOpen = new AtomicBoolean(true);
/**
* @param httpClient the http client
* @param numParallelWorkers the number of workers
*/
public HttpQueryExecutor(final Client httpClient) {
this.executor = new ScheduledThreadPoolExecutor(2);
this.httpClient = httpClient;
}
@Override
public void close() {
if (isOpen.getAndSet(false)) {
executor.shutdown();
}
}
public boolean isOpen() {
return isOpen.get();
}
/**
* performs the query
* @param id the query id to log
* @param method the method
* @param target the target uri
* @param entity the entity
* @param delay the delay
* @return the response body future
*/
public CompletableFuture<QueryResponse> performHttpQueryAsync(final String id, | // Path: reactive-kafka-example/src/main/java/net/oneandone/incubator/neo/exception/Exceptions.java
// public class Exceptions {
//
// private Exceptions() { }
//
//
//
//
//
// /**
// * unwraps an exception
// *
// * @param ex the exception to unwrap
// * @return the unwrapped exception
// */
// public static RuntimeException propagate(Throwable ex) {
// Throwable t = unwrap(ex);
// return (t instanceof RuntimeException) ? (RuntimeException) t : new RuntimeException(t);
// }
//
//
// /**
// * unwraps an exception
// *
// * @param ex the exception to unwrap
// * @return the unwrapped exception
// */
// public static Throwable unwrap(Throwable ex) {
// return unwrap(ex, 9);
// }
//
//
// /**
// * unwraps an exception
// *
// * @param ex the exception to unwrap
// * @param maxDepth the max depth
// * @return the unwrapped exception
// */
// private static Throwable unwrap(Throwable ex, int maxDepth) {
// if (isCompletionException(ex) || isExecutionException(ex)) {
// Throwable e = ex.getCause();
// if (e != null) {
// if (maxDepth > 1) {
// return unwrap(e, maxDepth - 1);
// } else {
// return e;
// }
// }
// }
//
// return ex;
// }
//
//
// private static boolean isCompletionException(Throwable t) {
// return CompletionException.class.isAssignableFrom(t.getClass());
// }
//
//
// private static boolean isExecutionException(Throwable t) {
// return ExecutionException.class.isAssignableFrom(t.getClass());
// }
//
//
// public static <T> CompletableFuture<T> completedFailedFuture(Throwable ex) {
// CompletableFuture<T> future = new CompletableFuture<>();
// future.completeExceptionally(ex);
// return future;
// }
// }
//
// Path: reactive-kafka-example/src/main/java/net/oneandone/incubator/neo/http/sink/HttpSink.java
// public enum Method {
// POST, PUT
// };
// Path: reactive-kafka-example/src/main/java/net/oneandone/incubator/neo/http/sink/HttpQueryExecutor.java
import java.io.Closeable;
import java.net.URI;
import java.time.Duration;
import java.time.Instant;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.BiConsumer;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.InvocationCallback;
import javax.ws.rs.client.ResponseProcessingException;
import javax.ws.rs.client.Invocation.Builder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import net.oneandone.incubator.neo.exception.Exceptions;
import net.oneandone.incubator.neo.http.sink.HttpSink.Method;
/*
* Copyright 1&1 Internet AG, https://github.com/1and1/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.oneandone.incubator.neo.http.sink;
/**
* Query executor
*/
class HttpQueryExecutor implements Closeable {
private static final Logger LOG = LoggerFactory.getLogger(HttpQueryExecutor.class);
private final Client httpClient;
private final ScheduledThreadPoolExecutor executor;
private final AtomicBoolean isOpen = new AtomicBoolean(true);
/**
* @param httpClient the http client
* @param numParallelWorkers the number of workers
*/
public HttpQueryExecutor(final Client httpClient) {
this.executor = new ScheduledThreadPoolExecutor(2);
this.httpClient = httpClient;
}
@Override
public void close() {
if (isOpen.getAndSet(false)) {
executor.shutdown();
}
}
public boolean isOpen() {
return isOpen.get();
}
/**
* performs the query
* @param id the query id to log
* @param method the method
* @param target the target uri
* @param entity the entity
* @param delay the delay
* @return the response body future
*/
public CompletableFuture<QueryResponse> performHttpQueryAsync(final String id, | final Method method, |
1and1/reactive | reactive-kafka-example/src/main/java/net/oneandone/incubator/neo/http/sink/HttpQueryExecutor.java | // Path: reactive-kafka-example/src/main/java/net/oneandone/incubator/neo/exception/Exceptions.java
// public class Exceptions {
//
// private Exceptions() { }
//
//
//
//
//
// /**
// * unwraps an exception
// *
// * @param ex the exception to unwrap
// * @return the unwrapped exception
// */
// public static RuntimeException propagate(Throwable ex) {
// Throwable t = unwrap(ex);
// return (t instanceof RuntimeException) ? (RuntimeException) t : new RuntimeException(t);
// }
//
//
// /**
// * unwraps an exception
// *
// * @param ex the exception to unwrap
// * @return the unwrapped exception
// */
// public static Throwable unwrap(Throwable ex) {
// return unwrap(ex, 9);
// }
//
//
// /**
// * unwraps an exception
// *
// * @param ex the exception to unwrap
// * @param maxDepth the max depth
// * @return the unwrapped exception
// */
// private static Throwable unwrap(Throwable ex, int maxDepth) {
// if (isCompletionException(ex) || isExecutionException(ex)) {
// Throwable e = ex.getCause();
// if (e != null) {
// if (maxDepth > 1) {
// return unwrap(e, maxDepth - 1);
// } else {
// return e;
// }
// }
// }
//
// return ex;
// }
//
//
// private static boolean isCompletionException(Throwable t) {
// return CompletionException.class.isAssignableFrom(t.getClass());
// }
//
//
// private static boolean isExecutionException(Throwable t) {
// return ExecutionException.class.isAssignableFrom(t.getClass());
// }
//
//
// public static <T> CompletableFuture<T> completedFailedFuture(Throwable ex) {
// CompletableFuture<T> future = new CompletableFuture<>();
// future.completeExceptionally(ex);
// return future;
// }
// }
//
// Path: reactive-kafka-example/src/main/java/net/oneandone/incubator/neo/http/sink/HttpSink.java
// public enum Method {
// POST, PUT
// };
| import java.io.Closeable;
import java.net.URI;
import java.time.Duration;
import java.time.Instant;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.BiConsumer;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.InvocationCallback;
import javax.ws.rs.client.ResponseProcessingException;
import javax.ws.rs.client.Invocation.Builder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import net.oneandone.incubator.neo.exception.Exceptions;
import net.oneandone.incubator.neo.http.sink.HttpSink.Method; | return elapsedTime;
}
/**
* @return true, if is success
*/
public boolean isSuccess() {
return (getStatus() / 100) == 2;
}
/**
* @return the status code
*/
public int getStatus() {
return (content == null) ? toStatus(error) : 200;
}
/**
* @return the error or null
*/
public RuntimeException getError() {
return error;
}
@Override
public String toString() {
return ((error == null) ? "success" : error.getMessage()) + " (elapsed: " + ((double) elapsedTime.toMillis() / 1000) + " sec)";
}
private static RuntimeException unwrap(Throwable error) { | // Path: reactive-kafka-example/src/main/java/net/oneandone/incubator/neo/exception/Exceptions.java
// public class Exceptions {
//
// private Exceptions() { }
//
//
//
//
//
// /**
// * unwraps an exception
// *
// * @param ex the exception to unwrap
// * @return the unwrapped exception
// */
// public static RuntimeException propagate(Throwable ex) {
// Throwable t = unwrap(ex);
// return (t instanceof RuntimeException) ? (RuntimeException) t : new RuntimeException(t);
// }
//
//
// /**
// * unwraps an exception
// *
// * @param ex the exception to unwrap
// * @return the unwrapped exception
// */
// public static Throwable unwrap(Throwable ex) {
// return unwrap(ex, 9);
// }
//
//
// /**
// * unwraps an exception
// *
// * @param ex the exception to unwrap
// * @param maxDepth the max depth
// * @return the unwrapped exception
// */
// private static Throwable unwrap(Throwable ex, int maxDepth) {
// if (isCompletionException(ex) || isExecutionException(ex)) {
// Throwable e = ex.getCause();
// if (e != null) {
// if (maxDepth > 1) {
// return unwrap(e, maxDepth - 1);
// } else {
// return e;
// }
// }
// }
//
// return ex;
// }
//
//
// private static boolean isCompletionException(Throwable t) {
// return CompletionException.class.isAssignableFrom(t.getClass());
// }
//
//
// private static boolean isExecutionException(Throwable t) {
// return ExecutionException.class.isAssignableFrom(t.getClass());
// }
//
//
// public static <T> CompletableFuture<T> completedFailedFuture(Throwable ex) {
// CompletableFuture<T> future = new CompletableFuture<>();
// future.completeExceptionally(ex);
// return future;
// }
// }
//
// Path: reactive-kafka-example/src/main/java/net/oneandone/incubator/neo/http/sink/HttpSink.java
// public enum Method {
// POST, PUT
// };
// Path: reactive-kafka-example/src/main/java/net/oneandone/incubator/neo/http/sink/HttpQueryExecutor.java
import java.io.Closeable;
import java.net.URI;
import java.time.Duration;
import java.time.Instant;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.BiConsumer;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.InvocationCallback;
import javax.ws.rs.client.ResponseProcessingException;
import javax.ws.rs.client.Invocation.Builder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import net.oneandone.incubator.neo.exception.Exceptions;
import net.oneandone.incubator.neo.http.sink.HttpSink.Method;
return elapsedTime;
}
/**
* @return true, if is success
*/
public boolean isSuccess() {
return (getStatus() / 100) == 2;
}
/**
* @return the status code
*/
public int getStatus() {
return (content == null) ? toStatus(error) : 200;
}
/**
* @return the error or null
*/
public RuntimeException getError() {
return error;
}
@Override
public String toString() {
return ((error == null) ? "success" : error.getMessage()) + " (elapsed: " + ((double) elapsedTime.toMillis() / 1000) + " sec)";
}
private static RuntimeException unwrap(Throwable error) { | Throwable rootError = Exceptions.unwrap(error); |
1and1/reactive | reactive-http/src/test/java/net/oneandone/reactive/rest/PublisherResource.java | // Path: reactive-http/src/main/java/net/oneandone/reactive/rest/container/ResultSubscriber.java
// public class ResultSubscriber {
//
//
// /**
// * maps the asyn HTTP response to a Subscriber which writes the first element into the HTTP response.
// * If no element is available, a 204 No Content response is returned
// *
// * @param asyncResponse the async response
// * @return the subscriber
// */
// public static final <T> Subscriber<T> toConsumeFirstSubscriber(AsyncResponse asyncResponse) {
// return new FirstSubscriber<T>(asyncResponse);
// }
//
//
// private static class FirstSubscriber<T> implements Subscriber<T> {
//
// private final AsyncResponse asyncResponse;
// private final AtomicReference<Subscription> subscriptionRef = new AtomicReference<>();
//
// private FirstSubscriber(AsyncResponse asyncResponse) {
// this.asyncResponse = asyncResponse;
// }
//
// @Override
// public void onSubscribe(Subscription subscription) {
// subscriptionRef.set(subscription);
// subscription.request(1);
// }
//
// @Override
// public void onError(Throwable error) {
// error = Utils.unwrap(error);
// asyncResponse.resume(error);
// }
//
// @Override
// public void onNext(T element) {
// asyncResponse.resume(element);
// subscriptionRef.get().cancel();
// }
//
// @Override
// public void onComplete() {
// if (!asyncResponse.isDone()) {
// asyncResponse.resume(Response.noContent().build());
// }
// }
// }
//
//
// /**
// * maps the asyn HTTP response to a Subscriber which writes the first element into the HTTP response.
// * If no element is available, a 404 response is returned. If more than 1 element is available a
// * 409 Conflict response is returned
// *
// * @param asyncResponse the async response
// * @return the subscriber
// */
// public static final <T> Subscriber<T> toConsumeSingleSubscriber(AsyncResponse asyncResponse) {
// return new SingleSubscriber<T>(asyncResponse);
// }
//
//
// private static class SingleSubscriber<T> implements Subscriber<T> {
//
// private final AsyncResponse asyncResponse;
// private final AtomicReference<Subscription> subscriptionRef = new AtomicReference<>();
// private final AtomicReference<T> elementRef = new AtomicReference<>();
//
//
// private SingleSubscriber(AsyncResponse asyncResponse) {
// this.asyncResponse = asyncResponse;
// }
//
// @Override
// public void onSubscribe(Subscription subscription) {
// subscriptionRef.set(subscription);
// subscription.request(1);
// }
//
// @Override
// public void onError(Throwable error) {
// error = Utils.unwrap(error);
// asyncResponse.resume(error);
// }
//
// @Override
// public void onNext(T element) {
// if (elementRef.getAndSet(element) == null) {
// subscriptionRef.get().request(1);
//
// } else {
// // more than 1 element causes a conflict exception
// onError(new ClientErrorException(Status.CONFLICT));
// }
// }
//
// @Override
// public void onComplete() {
// if (!asyncResponse.isDone()) {
// T element = elementRef.get();
// if (element == null) {
// asyncResponse.resume(new NotFoundException());
// } else {
// asyncResponse.resume(element);
// }
// }
// }
// }
// }
| import net.oneandone.reactive.rest.container.ResultSubscriber;
import org.reactivestreams.Publisher;
import org.reactivestreams.Subscriber;
import org.reactivestreams.Subscription;
import com.google.common.collect.Lists;
import java.io.IOException;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.QueryParam;
import javax.ws.rs.container.AsyncResponse;
import javax.ws.rs.container.Suspended; | /*
* Copyright 1&1 Internet AG, https://github.com/1and1/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.oneandone.reactive.rest;
@Path("/Publisher")
public class PublisherResource {
@Path("/first")
@GET
public void retrievePublisherFirstAsync(@QueryParam("num") int num, @Suspended AsyncResponse resp) {
TestPublisher<String> publisher = new TestPublisher<>();
new Thread() {
public void run() {
if (num < 0) {
pause(100);
publisher.pushError(new IOException());
} else {
for (int i = 0; i < num; i++) {
pause(100);
publisher.push(Integer.toString(i + 1));
}
publisher.close();
}
};
}.start();
| // Path: reactive-http/src/main/java/net/oneandone/reactive/rest/container/ResultSubscriber.java
// public class ResultSubscriber {
//
//
// /**
// * maps the asyn HTTP response to a Subscriber which writes the first element into the HTTP response.
// * If no element is available, a 204 No Content response is returned
// *
// * @param asyncResponse the async response
// * @return the subscriber
// */
// public static final <T> Subscriber<T> toConsumeFirstSubscriber(AsyncResponse asyncResponse) {
// return new FirstSubscriber<T>(asyncResponse);
// }
//
//
// private static class FirstSubscriber<T> implements Subscriber<T> {
//
// private final AsyncResponse asyncResponse;
// private final AtomicReference<Subscription> subscriptionRef = new AtomicReference<>();
//
// private FirstSubscriber(AsyncResponse asyncResponse) {
// this.asyncResponse = asyncResponse;
// }
//
// @Override
// public void onSubscribe(Subscription subscription) {
// subscriptionRef.set(subscription);
// subscription.request(1);
// }
//
// @Override
// public void onError(Throwable error) {
// error = Utils.unwrap(error);
// asyncResponse.resume(error);
// }
//
// @Override
// public void onNext(T element) {
// asyncResponse.resume(element);
// subscriptionRef.get().cancel();
// }
//
// @Override
// public void onComplete() {
// if (!asyncResponse.isDone()) {
// asyncResponse.resume(Response.noContent().build());
// }
// }
// }
//
//
// /**
// * maps the asyn HTTP response to a Subscriber which writes the first element into the HTTP response.
// * If no element is available, a 404 response is returned. If more than 1 element is available a
// * 409 Conflict response is returned
// *
// * @param asyncResponse the async response
// * @return the subscriber
// */
// public static final <T> Subscriber<T> toConsumeSingleSubscriber(AsyncResponse asyncResponse) {
// return new SingleSubscriber<T>(asyncResponse);
// }
//
//
// private static class SingleSubscriber<T> implements Subscriber<T> {
//
// private final AsyncResponse asyncResponse;
// private final AtomicReference<Subscription> subscriptionRef = new AtomicReference<>();
// private final AtomicReference<T> elementRef = new AtomicReference<>();
//
//
// private SingleSubscriber(AsyncResponse asyncResponse) {
// this.asyncResponse = asyncResponse;
// }
//
// @Override
// public void onSubscribe(Subscription subscription) {
// subscriptionRef.set(subscription);
// subscription.request(1);
// }
//
// @Override
// public void onError(Throwable error) {
// error = Utils.unwrap(error);
// asyncResponse.resume(error);
// }
//
// @Override
// public void onNext(T element) {
// if (elementRef.getAndSet(element) == null) {
// subscriptionRef.get().request(1);
//
// } else {
// // more than 1 element causes a conflict exception
// onError(new ClientErrorException(Status.CONFLICT));
// }
// }
//
// @Override
// public void onComplete() {
// if (!asyncResponse.isDone()) {
// T element = elementRef.get();
// if (element == null) {
// asyncResponse.resume(new NotFoundException());
// } else {
// asyncResponse.resume(element);
// }
// }
// }
// }
// }
// Path: reactive-http/src/test/java/net/oneandone/reactive/rest/PublisherResource.java
import net.oneandone.reactive.rest.container.ResultSubscriber;
import org.reactivestreams.Publisher;
import org.reactivestreams.Subscriber;
import org.reactivestreams.Subscription;
import com.google.common.collect.Lists;
import java.io.IOException;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.QueryParam;
import javax.ws.rs.container.AsyncResponse;
import javax.ws.rs.container.Suspended;
/*
* Copyright 1&1 Internet AG, https://github.com/1and1/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.oneandone.reactive.rest;
@Path("/Publisher")
public class PublisherResource {
@Path("/first")
@GET
public void retrievePublisherFirstAsync(@QueryParam("num") int num, @Suspended AsyncResponse resp) {
TestPublisher<String> publisher = new TestPublisher<>();
new Thread() {
public void run() {
if (num < 0) {
pause(100);
publisher.pushError(new IOException());
} else {
for (int i = 0; i < num; i++) {
pause(100);
publisher.push(Integer.toString(i + 1));
}
publisher.close();
}
};
}.start();
| publisher.subscribe(ResultSubscriber.toConsumeFirstSubscriber(resp)); |
Bernardo-MG/repository-pattern-java | src/test/java/com/wandrell/pattern/test/util/test/integration/repository/access/AbstractITModify.java | // Path: src/main/java/com/wandrell/pattern/query/DefaultNamedParameterQueryData.java
// public final class DefaultNamedParameterQueryData
// implements NamedParameterQueryData {
//
// /**
// * Parameters for the query.
// * <p>
// * These are the parameters for a named query, and will be used to replace
// * placeholders on the query string when building the final string.
// */
// private final Map<String, Object> params;
//
// /**
// * The base query.
// * <p>
// * If there is any parameter, these will be applied to this string to build
// * the final query.
// */
// private final String queryStr;
//
// /**
// * Constructs a {@code DefaultQuery} with no parameters.
// *
// * @param query
// * the query string
// */
// public DefaultNamedParameterQueryData(final String query) {
// this(query, new LinkedHashMap<String, Object>());
// }
//
// /**
// * Constructs a {@code DefaultQuery} with the specified query and
// * parameters.
// * <p>
// * The parameters are the parameters for a named query, and will be used to
// * replace placeholders on the query string when building the final string.
// *
// * @param query
// * the query string
// * @param parameters
// * the query's parameters
// */
// public DefaultNamedParameterQueryData(final String query,
// final Map<String, Object> parameters) {
// super();
//
// checkNotNull(query, "Received a null pointer as query");
// checkNotNull(parameters, "Received a null pointer as parameters");
//
// queryStr = query;
// params = parameters;
// }
//
// @Override
// public final void addParameter(final String key, final Object value) {
// checkNotNull(key, "Received a null pointer as key");
// checkNotNull(value, "Received a null pointer as value");
//
// params.put(key, value);
// }
//
// @Override
// public final void addParameters(final Map<String, Object> parameters) {
// checkNotNull(parameters, "Received a null pointer as parameters");
//
// params.putAll(parameters);
// }
//
// @Override
// public final Map<String, Object> getParameters() {
// return Collections.unmodifiableMap(params);
// }
//
// @Override
// public final String getQuery() {
// return queryStr;
// }
//
// @Override
// public final void removeParameter(final String key) {
// params.remove(key);
// }
//
// }
//
// Path: src/main/java/com/wandrell/pattern/query/NamedParameterQueryData.java
// public interface NamedParameterQueryData {
//
// /**
// * Adds a parameter.
// * <p>
// * If a parameter with the specified key already exists the new one will
// * take its place.
// *
// * @param key
// * key for the parameter
// * @param value
// * value for the parameter
// */
// public void addParameter(final String key, final Object value);
//
// /**
// * Adds a collection of parameters.
// * <p>
// * If any parameter with one of the specified keys already exists the new
// * one will take its place.
// *
// * @param parameters
// * {@code Map} with all the parameter pairs
// */
// public void addParameters(final Map<String, Object> parameters);
//
// /**
// * The parameters to be applied to the query.
// * <p>
// * This is a collection of named parameters, where the names are not allowed
// * to be repeated.
// *
// * @return the query's parameters
// */
// public Map<String, Object> getParameters();
//
// /**
// * The base query.
// * <p>
// * If there are no parameters this should be an useable query. Otherwise the
// * parameters should be applied when building the final query.
// *
// * @return the base query for building the final query
// */
// public String getQuery();
//
// /**
// * Removes the parameter for the specified key.
// *
// * @param key
// * the key for the parameter to remove
// */
// public void removeParameter(final String key);
//
// }
| import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.test.context.testng.AbstractTransactionalTestNGSpringContextTests;
import org.springframework.transaction.annotation.Transactional;
import org.testng.Assert;
import org.testng.annotations.Test;
import com.wandrell.pattern.query.DefaultNamedParameterQueryData;
import com.wandrell.pattern.query.NamedParameterQueryData;
import com.wandrell.pattern.repository.FilteredRepository;
import com.wandrell.pattern.test.util.model.TestEntity;
import java.util.LinkedHashMap;
import java.util.Map;
import javax.persistence.EntityManager;
import org.springframework.beans.factory.annotation.Autowired; |
// Adds the entity
getRepository().add(newEntity);
if (emanager != null) {
// Flushed to force updating ids
emanager.flush();
}
// Checks the entity has been added
Assert.assertEquals(getRepository().getAll().size(), entitiesCount + 1);
// Checks that the id has been assigned
Assert.assertNotNull(newEntity.getId());
Assert.assertTrue(newEntity.getId() >= 0);
}
/**
* Tests that removing an entity changes the contents of the repository.
*/
@Test
@Transactional
public final void testRemove() {
final TestEntity entity; // Entity being tested
final Map<String, Object> parameters; // Params for the query
final NamedParameterQueryData query; // Query for retrieving the entity
// Acquires the entity
parameters = new LinkedHashMap<>();
parameters.put("id", 1); | // Path: src/main/java/com/wandrell/pattern/query/DefaultNamedParameterQueryData.java
// public final class DefaultNamedParameterQueryData
// implements NamedParameterQueryData {
//
// /**
// * Parameters for the query.
// * <p>
// * These are the parameters for a named query, and will be used to replace
// * placeholders on the query string when building the final string.
// */
// private final Map<String, Object> params;
//
// /**
// * The base query.
// * <p>
// * If there is any parameter, these will be applied to this string to build
// * the final query.
// */
// private final String queryStr;
//
// /**
// * Constructs a {@code DefaultQuery} with no parameters.
// *
// * @param query
// * the query string
// */
// public DefaultNamedParameterQueryData(final String query) {
// this(query, new LinkedHashMap<String, Object>());
// }
//
// /**
// * Constructs a {@code DefaultQuery} with the specified query and
// * parameters.
// * <p>
// * The parameters are the parameters for a named query, and will be used to
// * replace placeholders on the query string when building the final string.
// *
// * @param query
// * the query string
// * @param parameters
// * the query's parameters
// */
// public DefaultNamedParameterQueryData(final String query,
// final Map<String, Object> parameters) {
// super();
//
// checkNotNull(query, "Received a null pointer as query");
// checkNotNull(parameters, "Received a null pointer as parameters");
//
// queryStr = query;
// params = parameters;
// }
//
// @Override
// public final void addParameter(final String key, final Object value) {
// checkNotNull(key, "Received a null pointer as key");
// checkNotNull(value, "Received a null pointer as value");
//
// params.put(key, value);
// }
//
// @Override
// public final void addParameters(final Map<String, Object> parameters) {
// checkNotNull(parameters, "Received a null pointer as parameters");
//
// params.putAll(parameters);
// }
//
// @Override
// public final Map<String, Object> getParameters() {
// return Collections.unmodifiableMap(params);
// }
//
// @Override
// public final String getQuery() {
// return queryStr;
// }
//
// @Override
// public final void removeParameter(final String key) {
// params.remove(key);
// }
//
// }
//
// Path: src/main/java/com/wandrell/pattern/query/NamedParameterQueryData.java
// public interface NamedParameterQueryData {
//
// /**
// * Adds a parameter.
// * <p>
// * If a parameter with the specified key already exists the new one will
// * take its place.
// *
// * @param key
// * key for the parameter
// * @param value
// * value for the parameter
// */
// public void addParameter(final String key, final Object value);
//
// /**
// * Adds a collection of parameters.
// * <p>
// * If any parameter with one of the specified keys already exists the new
// * one will take its place.
// *
// * @param parameters
// * {@code Map} with all the parameter pairs
// */
// public void addParameters(final Map<String, Object> parameters);
//
// /**
// * The parameters to be applied to the query.
// * <p>
// * This is a collection of named parameters, where the names are not allowed
// * to be repeated.
// *
// * @return the query's parameters
// */
// public Map<String, Object> getParameters();
//
// /**
// * The base query.
// * <p>
// * If there are no parameters this should be an useable query. Otherwise the
// * parameters should be applied when building the final query.
// *
// * @return the base query for building the final query
// */
// public String getQuery();
//
// /**
// * Removes the parameter for the specified key.
// *
// * @param key
// * the key for the parameter to remove
// */
// public void removeParameter(final String key);
//
// }
// Path: src/test/java/com/wandrell/pattern/test/util/test/integration/repository/access/AbstractITModify.java
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.test.context.testng.AbstractTransactionalTestNGSpringContextTests;
import org.springframework.transaction.annotation.Transactional;
import org.testng.Assert;
import org.testng.annotations.Test;
import com.wandrell.pattern.query.DefaultNamedParameterQueryData;
import com.wandrell.pattern.query.NamedParameterQueryData;
import com.wandrell.pattern.repository.FilteredRepository;
import com.wandrell.pattern.test.util.model.TestEntity;
import java.util.LinkedHashMap;
import java.util.Map;
import javax.persistence.EntityManager;
import org.springframework.beans.factory.annotation.Autowired;
// Adds the entity
getRepository().add(newEntity);
if (emanager != null) {
// Flushed to force updating ids
emanager.flush();
}
// Checks the entity has been added
Assert.assertEquals(getRepository().getAll().size(), entitiesCount + 1);
// Checks that the id has been assigned
Assert.assertNotNull(newEntity.getId());
Assert.assertTrue(newEntity.getId() >= 0);
}
/**
* Tests that removing an entity changes the contents of the repository.
*/
@Test
@Transactional
public final void testRemove() {
final TestEntity entity; // Entity being tested
final Map<String, Object> parameters; // Params for the query
final NamedParameterQueryData query; // Query for retrieving the entity
// Acquires the entity
parameters = new LinkedHashMap<>();
parameters.put("id", 1); | query = new DefaultNamedParameterQueryData(selectByIdQuery, parameters); |
neurospeech/android-hypercube | hypercube/src/main/java/com/neurospeech/hypercube/HyperCubeApplication.java | // Path: hypercube/src/main/java/com/neurospeech/hypercube/ui/HyperViewHolder.java
// public abstract class HyperViewHolder<T> extends RecyclerView.ViewHolder {
//
//
// public RecyclerView.Adapter getAdapter() {
// return adapter;
// }
//
// private RecyclerView.Adapter adapter;
//
// public HyperViewHolder(View itemView) {
// super(itemView);
// }
//
// public void bindItem(RecyclerView.Adapter adapter, Object item){
// this.adapter = adapter;
// bind((T)item);
// }
//
// protected abstract void bind(T item);
//
//
//
// }
| import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.app.AlertDialog;
import android.util.Log;
import android.view.View;
import com.neurospeech.hypercube.ui.HyperItemViewHolder;
import com.neurospeech.hypercube.ui.HyperViewHolder;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.HashMap; | package com.neurospeech.hypercube;
/**
* Created by akash.kava on 21-03-2016.
*/
public class HyperCubeApplication {
/**
* We need to store layout from model and view holder from layout as we do not have this facility
* directly available in android, hence the below maps are created
*
* modelLayouts and layoutViewHolders are declared as static to improve performance
*/
/**
* modelLayouts - stores the layout Id for given Model class
*/
public static HashMap<Class,Integer> modelLayouts
= new HashMap<>();
/**
* layoutViewHolders - stores the ViewHolder class for given layout Id (viewType)
*/
public static HashMap<Integer,ViewHolderInfo> layoutViewHolders
= new HashMap<>();
| // Path: hypercube/src/main/java/com/neurospeech/hypercube/ui/HyperViewHolder.java
// public abstract class HyperViewHolder<T> extends RecyclerView.ViewHolder {
//
//
// public RecyclerView.Adapter getAdapter() {
// return adapter;
// }
//
// private RecyclerView.Adapter adapter;
//
// public HyperViewHolder(View itemView) {
// super(itemView);
// }
//
// public void bindItem(RecyclerView.Adapter adapter, Object item){
// this.adapter = adapter;
// bind((T)item);
// }
//
// protected abstract void bind(T item);
//
//
//
// }
// Path: hypercube/src/main/java/com/neurospeech/hypercube/HyperCubeApplication.java
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.app.AlertDialog;
import android.util.Log;
import android.view.View;
import com.neurospeech.hypercube.ui.HyperItemViewHolder;
import com.neurospeech.hypercube.ui.HyperViewHolder;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.HashMap;
package com.neurospeech.hypercube;
/**
* Created by akash.kava on 21-03-2016.
*/
public class HyperCubeApplication {
/**
* We need to store layout from model and view holder from layout as we do not have this facility
* directly available in android, hence the below maps are created
*
* modelLayouts and layoutViewHolders are declared as static to improve performance
*/
/**
* modelLayouts - stores the layout Id for given Model class
*/
public static HashMap<Class,Integer> modelLayouts
= new HashMap<>();
/**
* layoutViewHolders - stores the ViewHolder class for given layout Id (viewType)
*/
public static HashMap<Integer,ViewHolderInfo> layoutViewHolders
= new HashMap<>();
| public static void registerViewHolderType(Class<? extends HyperViewHolder<?>> viewHolderClass){ |
neurospeech/android-hypercube | app/src/main/java/com/neurospeech/hypercubesample/MainActivity.java | // Path: app/src/main/java/com/neurospeech/hypercubesample/adapters/NavigationListAdapter.java
// public abstract class NavigationListAdapter
// extends HeaderedAdapter<MenuModel,RecyclerView.ViewHolder> {
//
// public NavigationListAdapter(Context context) {
// super(context);
// }
//
// @Override
// public Object getHeader(MenuModel item) {
// return item.header;
// }
//
//
// public abstract void onItemClick(MenuModel item);
//
//
//
// }
//
// Path: app/src/main/java/com/neurospeech/hypercubesample/fragments/HomeFragment.java
// public class HomeFragment extends Fragment {
//
// @Nullable
// @Override
// public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// View view = inflater.inflate(R.layout.fragment_home,container,false);
//
// return view;
// }
// }
//
// Path: app/src/main/java/com/neurospeech/hypercubesample/fragments/form/EditTextFragment.java
// public class EditTextFragment extends Fragment {
// @Nullable
// @Override
// public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// View view = inflater.inflate(R.layout.form_edit_text_fragment,container,false);
//
// TextValidator tv = new TextValidator() {
// @Override
// public Object invalidError(String value) {
// if(value == null || value.isEmpty())
// return "Field cannot be empty";
// return null;
// }
// };
//
// HyperEditText editText;
// editText = (HyperEditText)view.findViewById(R.id.edit_validate_on_lost_focus);
// editText.setValidator(true,false,tv);
//
// editText.setText("1000");
//
//
//
// editText = (HyperEditText)view.findViewById(R.id.edit_validate_on_typing);
// editText.setValidator(true,true,tv);
//
//
// editText = (HyperEditText)view.findViewById(R.id.edit_validate_no_auto);
// editText.setValidator(false,false,tv);
//
// view.findViewById(R.id.validate_button).setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
//
// }
// });
//
// return view;
// }
// }
//
// Path: app/src/main/java/com/neurospeech/hypercubesample/fragments/recyclerviewsamples/HeaderFooterFragment.java
// public class HeaderFooterFragment extends Fragment {
// }
//
// Path: app/src/main/java/com/neurospeech/hypercubesample/fragments/recyclerviewsamples/ItemHeadersFragment.java
// public class ItemHeadersFragment extends Fragment {
// }
//
// Path: app/src/main/java/com/neurospeech/hypercubesample/model/MenuModel.java
// public class MenuModel {
//
// private final Class activity;
// public String name;
//
// public String header;
//
// public MenuModel(String header, String name, Class activity) {
// super();
// this.name = name;
// this.header = header;
// this.activity = activity;
// }
//
// public Object newInstance(){
// try {
// return activity.newInstance();
// }catch (Exception ex){
// ex.printStackTrace();
// }
// return null;
// }
// }
| import android.app.Activity;
import android.app.SearchManager;
import android.content.res.Resources;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.MenuItemCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.SearchView;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.TextView;
import com.neurospeech.hypercubesample.adapters.NavigationListAdapter;
import com.neurospeech.hypercubesample.fragments.HomeFragment;
import com.neurospeech.hypercubesample.fragments.form.EditTextFragment;
import com.neurospeech.hypercubesample.fragments.recyclerviewsamples.HeaderFooterFragment;
import com.neurospeech.hypercubesample.fragments.recyclerviewsamples.ItemHeadersFragment;
import com.neurospeech.hypercubesample.model.MenuModel;
import java.util.ArrayList; | package com.neurospeech.hypercubesample;
/**
* Home Activity
*/
public class MainActivity extends AppCompatActivity {
TextView errorMessage; | // Path: app/src/main/java/com/neurospeech/hypercubesample/adapters/NavigationListAdapter.java
// public abstract class NavigationListAdapter
// extends HeaderedAdapter<MenuModel,RecyclerView.ViewHolder> {
//
// public NavigationListAdapter(Context context) {
// super(context);
// }
//
// @Override
// public Object getHeader(MenuModel item) {
// return item.header;
// }
//
//
// public abstract void onItemClick(MenuModel item);
//
//
//
// }
//
// Path: app/src/main/java/com/neurospeech/hypercubesample/fragments/HomeFragment.java
// public class HomeFragment extends Fragment {
//
// @Nullable
// @Override
// public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// View view = inflater.inflate(R.layout.fragment_home,container,false);
//
// return view;
// }
// }
//
// Path: app/src/main/java/com/neurospeech/hypercubesample/fragments/form/EditTextFragment.java
// public class EditTextFragment extends Fragment {
// @Nullable
// @Override
// public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// View view = inflater.inflate(R.layout.form_edit_text_fragment,container,false);
//
// TextValidator tv = new TextValidator() {
// @Override
// public Object invalidError(String value) {
// if(value == null || value.isEmpty())
// return "Field cannot be empty";
// return null;
// }
// };
//
// HyperEditText editText;
// editText = (HyperEditText)view.findViewById(R.id.edit_validate_on_lost_focus);
// editText.setValidator(true,false,tv);
//
// editText.setText("1000");
//
//
//
// editText = (HyperEditText)view.findViewById(R.id.edit_validate_on_typing);
// editText.setValidator(true,true,tv);
//
//
// editText = (HyperEditText)view.findViewById(R.id.edit_validate_no_auto);
// editText.setValidator(false,false,tv);
//
// view.findViewById(R.id.validate_button).setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
//
// }
// });
//
// return view;
// }
// }
//
// Path: app/src/main/java/com/neurospeech/hypercubesample/fragments/recyclerviewsamples/HeaderFooterFragment.java
// public class HeaderFooterFragment extends Fragment {
// }
//
// Path: app/src/main/java/com/neurospeech/hypercubesample/fragments/recyclerviewsamples/ItemHeadersFragment.java
// public class ItemHeadersFragment extends Fragment {
// }
//
// Path: app/src/main/java/com/neurospeech/hypercubesample/model/MenuModel.java
// public class MenuModel {
//
// private final Class activity;
// public String name;
//
// public String header;
//
// public MenuModel(String header, String name, Class activity) {
// super();
// this.name = name;
// this.header = header;
// this.activity = activity;
// }
//
// public Object newInstance(){
// try {
// return activity.newInstance();
// }catch (Exception ex){
// ex.printStackTrace();
// }
// return null;
// }
// }
// Path: app/src/main/java/com/neurospeech/hypercubesample/MainActivity.java
import android.app.Activity;
import android.app.SearchManager;
import android.content.res.Resources;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.MenuItemCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.SearchView;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.TextView;
import com.neurospeech.hypercubesample.adapters.NavigationListAdapter;
import com.neurospeech.hypercubesample.fragments.HomeFragment;
import com.neurospeech.hypercubesample.fragments.form.EditTextFragment;
import com.neurospeech.hypercubesample.fragments.recyclerviewsamples.HeaderFooterFragment;
import com.neurospeech.hypercubesample.fragments.recyclerviewsamples.ItemHeadersFragment;
import com.neurospeech.hypercubesample.model.MenuModel;
import java.util.ArrayList;
package com.neurospeech.hypercubesample;
/**
* Home Activity
*/
public class MainActivity extends AppCompatActivity {
TextView errorMessage; | NavigationListAdapter navigationListAdapter; |
neurospeech/android-hypercube | app/src/main/java/com/neurospeech/hypercubesample/MainActivity.java | // Path: app/src/main/java/com/neurospeech/hypercubesample/adapters/NavigationListAdapter.java
// public abstract class NavigationListAdapter
// extends HeaderedAdapter<MenuModel,RecyclerView.ViewHolder> {
//
// public NavigationListAdapter(Context context) {
// super(context);
// }
//
// @Override
// public Object getHeader(MenuModel item) {
// return item.header;
// }
//
//
// public abstract void onItemClick(MenuModel item);
//
//
//
// }
//
// Path: app/src/main/java/com/neurospeech/hypercubesample/fragments/HomeFragment.java
// public class HomeFragment extends Fragment {
//
// @Nullable
// @Override
// public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// View view = inflater.inflate(R.layout.fragment_home,container,false);
//
// return view;
// }
// }
//
// Path: app/src/main/java/com/neurospeech/hypercubesample/fragments/form/EditTextFragment.java
// public class EditTextFragment extends Fragment {
// @Nullable
// @Override
// public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// View view = inflater.inflate(R.layout.form_edit_text_fragment,container,false);
//
// TextValidator tv = new TextValidator() {
// @Override
// public Object invalidError(String value) {
// if(value == null || value.isEmpty())
// return "Field cannot be empty";
// return null;
// }
// };
//
// HyperEditText editText;
// editText = (HyperEditText)view.findViewById(R.id.edit_validate_on_lost_focus);
// editText.setValidator(true,false,tv);
//
// editText.setText("1000");
//
//
//
// editText = (HyperEditText)view.findViewById(R.id.edit_validate_on_typing);
// editText.setValidator(true,true,tv);
//
//
// editText = (HyperEditText)view.findViewById(R.id.edit_validate_no_auto);
// editText.setValidator(false,false,tv);
//
// view.findViewById(R.id.validate_button).setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
//
// }
// });
//
// return view;
// }
// }
//
// Path: app/src/main/java/com/neurospeech/hypercubesample/fragments/recyclerviewsamples/HeaderFooterFragment.java
// public class HeaderFooterFragment extends Fragment {
// }
//
// Path: app/src/main/java/com/neurospeech/hypercubesample/fragments/recyclerviewsamples/ItemHeadersFragment.java
// public class ItemHeadersFragment extends Fragment {
// }
//
// Path: app/src/main/java/com/neurospeech/hypercubesample/model/MenuModel.java
// public class MenuModel {
//
// private final Class activity;
// public String name;
//
// public String header;
//
// public MenuModel(String header, String name, Class activity) {
// super();
// this.name = name;
// this.header = header;
// this.activity = activity;
// }
//
// public Object newInstance(){
// try {
// return activity.newInstance();
// }catch (Exception ex){
// ex.printStackTrace();
// }
// return null;
// }
// }
| import android.app.Activity;
import android.app.SearchManager;
import android.content.res.Resources;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.MenuItemCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.SearchView;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.TextView;
import com.neurospeech.hypercubesample.adapters.NavigationListAdapter;
import com.neurospeech.hypercubesample.fragments.HomeFragment;
import com.neurospeech.hypercubesample.fragments.form.EditTextFragment;
import com.neurospeech.hypercubesample.fragments.recyclerviewsamples.HeaderFooterFragment;
import com.neurospeech.hypercubesample.fragments.recyclerviewsamples.ItemHeadersFragment;
import com.neurospeech.hypercubesample.model.MenuModel;
import java.util.ArrayList; | package com.neurospeech.hypercubesample;
/**
* Home Activity
*/
public class MainActivity extends AppCompatActivity {
TextView errorMessage;
NavigationListAdapter navigationListAdapter;
private DrawerLayout drawerLayout;
private View navigationView;
RecyclerView leftDrawer;
FrameLayout frameLayout;
private Toolbar toolbar;
private ActionBarDrawerToggle actionBarDrawerToggle;
@Override
protected void onCreate(Bundle saveInstanceState) {
super.onCreate(saveInstanceState);
setContentView(R.layout.activity_main);
toolbar = (Toolbar)findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
/**
* Initializing Drawer layout
*/
drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
drawerLayout.setScrimColor(ContextCompat.getColor(getApplicationContext(), R.color.white_transparent));
navigationListAdapter = new NavigationListAdapter(this){
@Override | // Path: app/src/main/java/com/neurospeech/hypercubesample/adapters/NavigationListAdapter.java
// public abstract class NavigationListAdapter
// extends HeaderedAdapter<MenuModel,RecyclerView.ViewHolder> {
//
// public NavigationListAdapter(Context context) {
// super(context);
// }
//
// @Override
// public Object getHeader(MenuModel item) {
// return item.header;
// }
//
//
// public abstract void onItemClick(MenuModel item);
//
//
//
// }
//
// Path: app/src/main/java/com/neurospeech/hypercubesample/fragments/HomeFragment.java
// public class HomeFragment extends Fragment {
//
// @Nullable
// @Override
// public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// View view = inflater.inflate(R.layout.fragment_home,container,false);
//
// return view;
// }
// }
//
// Path: app/src/main/java/com/neurospeech/hypercubesample/fragments/form/EditTextFragment.java
// public class EditTextFragment extends Fragment {
// @Nullable
// @Override
// public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// View view = inflater.inflate(R.layout.form_edit_text_fragment,container,false);
//
// TextValidator tv = new TextValidator() {
// @Override
// public Object invalidError(String value) {
// if(value == null || value.isEmpty())
// return "Field cannot be empty";
// return null;
// }
// };
//
// HyperEditText editText;
// editText = (HyperEditText)view.findViewById(R.id.edit_validate_on_lost_focus);
// editText.setValidator(true,false,tv);
//
// editText.setText("1000");
//
//
//
// editText = (HyperEditText)view.findViewById(R.id.edit_validate_on_typing);
// editText.setValidator(true,true,tv);
//
//
// editText = (HyperEditText)view.findViewById(R.id.edit_validate_no_auto);
// editText.setValidator(false,false,tv);
//
// view.findViewById(R.id.validate_button).setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
//
// }
// });
//
// return view;
// }
// }
//
// Path: app/src/main/java/com/neurospeech/hypercubesample/fragments/recyclerviewsamples/HeaderFooterFragment.java
// public class HeaderFooterFragment extends Fragment {
// }
//
// Path: app/src/main/java/com/neurospeech/hypercubesample/fragments/recyclerviewsamples/ItemHeadersFragment.java
// public class ItemHeadersFragment extends Fragment {
// }
//
// Path: app/src/main/java/com/neurospeech/hypercubesample/model/MenuModel.java
// public class MenuModel {
//
// private final Class activity;
// public String name;
//
// public String header;
//
// public MenuModel(String header, String name, Class activity) {
// super();
// this.name = name;
// this.header = header;
// this.activity = activity;
// }
//
// public Object newInstance(){
// try {
// return activity.newInstance();
// }catch (Exception ex){
// ex.printStackTrace();
// }
// return null;
// }
// }
// Path: app/src/main/java/com/neurospeech/hypercubesample/MainActivity.java
import android.app.Activity;
import android.app.SearchManager;
import android.content.res.Resources;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.MenuItemCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.SearchView;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.TextView;
import com.neurospeech.hypercubesample.adapters.NavigationListAdapter;
import com.neurospeech.hypercubesample.fragments.HomeFragment;
import com.neurospeech.hypercubesample.fragments.form.EditTextFragment;
import com.neurospeech.hypercubesample.fragments.recyclerviewsamples.HeaderFooterFragment;
import com.neurospeech.hypercubesample.fragments.recyclerviewsamples.ItemHeadersFragment;
import com.neurospeech.hypercubesample.model.MenuModel;
import java.util.ArrayList;
package com.neurospeech.hypercubesample;
/**
* Home Activity
*/
public class MainActivity extends AppCompatActivity {
TextView errorMessage;
NavigationListAdapter navigationListAdapter;
private DrawerLayout drawerLayout;
private View navigationView;
RecyclerView leftDrawer;
FrameLayout frameLayout;
private Toolbar toolbar;
private ActionBarDrawerToggle actionBarDrawerToggle;
@Override
protected void onCreate(Bundle saveInstanceState) {
super.onCreate(saveInstanceState);
setContentView(R.layout.activity_main);
toolbar = (Toolbar)findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
/**
* Initializing Drawer layout
*/
drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
drawerLayout.setScrimColor(ContextCompat.getColor(getApplicationContext(), R.color.white_transparent));
navigationListAdapter = new NavigationListAdapter(this){
@Override | public void onItemClick(MenuModel item) { |
neurospeech/android-hypercube | app/src/main/java/com/neurospeech/hypercubesample/MainActivity.java | // Path: app/src/main/java/com/neurospeech/hypercubesample/adapters/NavigationListAdapter.java
// public abstract class NavigationListAdapter
// extends HeaderedAdapter<MenuModel,RecyclerView.ViewHolder> {
//
// public NavigationListAdapter(Context context) {
// super(context);
// }
//
// @Override
// public Object getHeader(MenuModel item) {
// return item.header;
// }
//
//
// public abstract void onItemClick(MenuModel item);
//
//
//
// }
//
// Path: app/src/main/java/com/neurospeech/hypercubesample/fragments/HomeFragment.java
// public class HomeFragment extends Fragment {
//
// @Nullable
// @Override
// public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// View view = inflater.inflate(R.layout.fragment_home,container,false);
//
// return view;
// }
// }
//
// Path: app/src/main/java/com/neurospeech/hypercubesample/fragments/form/EditTextFragment.java
// public class EditTextFragment extends Fragment {
// @Nullable
// @Override
// public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// View view = inflater.inflate(R.layout.form_edit_text_fragment,container,false);
//
// TextValidator tv = new TextValidator() {
// @Override
// public Object invalidError(String value) {
// if(value == null || value.isEmpty())
// return "Field cannot be empty";
// return null;
// }
// };
//
// HyperEditText editText;
// editText = (HyperEditText)view.findViewById(R.id.edit_validate_on_lost_focus);
// editText.setValidator(true,false,tv);
//
// editText.setText("1000");
//
//
//
// editText = (HyperEditText)view.findViewById(R.id.edit_validate_on_typing);
// editText.setValidator(true,true,tv);
//
//
// editText = (HyperEditText)view.findViewById(R.id.edit_validate_no_auto);
// editText.setValidator(false,false,tv);
//
// view.findViewById(R.id.validate_button).setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
//
// }
// });
//
// return view;
// }
// }
//
// Path: app/src/main/java/com/neurospeech/hypercubesample/fragments/recyclerviewsamples/HeaderFooterFragment.java
// public class HeaderFooterFragment extends Fragment {
// }
//
// Path: app/src/main/java/com/neurospeech/hypercubesample/fragments/recyclerviewsamples/ItemHeadersFragment.java
// public class ItemHeadersFragment extends Fragment {
// }
//
// Path: app/src/main/java/com/neurospeech/hypercubesample/model/MenuModel.java
// public class MenuModel {
//
// private final Class activity;
// public String name;
//
// public String header;
//
// public MenuModel(String header, String name, Class activity) {
// super();
// this.name = name;
// this.header = header;
// this.activity = activity;
// }
//
// public Object newInstance(){
// try {
// return activity.newInstance();
// }catch (Exception ex){
// ex.printStackTrace();
// }
// return null;
// }
// }
| import android.app.Activity;
import android.app.SearchManager;
import android.content.res.Resources;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.MenuItemCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.SearchView;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.TextView;
import com.neurospeech.hypercubesample.adapters.NavigationListAdapter;
import com.neurospeech.hypercubesample.fragments.HomeFragment;
import com.neurospeech.hypercubesample.fragments.form.EditTextFragment;
import com.neurospeech.hypercubesample.fragments.recyclerviewsamples.HeaderFooterFragment;
import com.neurospeech.hypercubesample.fragments.recyclerviewsamples.ItemHeadersFragment;
import com.neurospeech.hypercubesample.model.MenuModel;
import java.util.ArrayList; | public void onDrawerClosed(View drawerView) {
super.onDrawerClosed(drawerView);
}
@Override
public void onDrawerOpened(View drawerView) {
//getFragmentManager().popBackStackImmediate();
super.onDrawerOpened(drawerView);
}
};
drawerLayout.setDrawerListener(actionBarDrawerToggle);
actionBarDrawerToggle.setDrawerIndicatorEnabled(true);
actionBarDrawerToggle.syncState();
leftDrawer=(RecyclerView) navigationView.findViewById(R.id.left_drawer);
loadItems();
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(this);
leftDrawer.setLayoutManager(layoutManager);
leftDrawer.setItemAnimator(new DefaultItemAnimator());
leftDrawer.setAdapter(navigationListAdapter);
frameLayout =(FrameLayout) findViewById(R.id.fragment_container);
if (findViewById(R.id.fragment_container) != null) {
// Create a new Fragment to be placed in the activity layout | // Path: app/src/main/java/com/neurospeech/hypercubesample/adapters/NavigationListAdapter.java
// public abstract class NavigationListAdapter
// extends HeaderedAdapter<MenuModel,RecyclerView.ViewHolder> {
//
// public NavigationListAdapter(Context context) {
// super(context);
// }
//
// @Override
// public Object getHeader(MenuModel item) {
// return item.header;
// }
//
//
// public abstract void onItemClick(MenuModel item);
//
//
//
// }
//
// Path: app/src/main/java/com/neurospeech/hypercubesample/fragments/HomeFragment.java
// public class HomeFragment extends Fragment {
//
// @Nullable
// @Override
// public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// View view = inflater.inflate(R.layout.fragment_home,container,false);
//
// return view;
// }
// }
//
// Path: app/src/main/java/com/neurospeech/hypercubesample/fragments/form/EditTextFragment.java
// public class EditTextFragment extends Fragment {
// @Nullable
// @Override
// public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// View view = inflater.inflate(R.layout.form_edit_text_fragment,container,false);
//
// TextValidator tv = new TextValidator() {
// @Override
// public Object invalidError(String value) {
// if(value == null || value.isEmpty())
// return "Field cannot be empty";
// return null;
// }
// };
//
// HyperEditText editText;
// editText = (HyperEditText)view.findViewById(R.id.edit_validate_on_lost_focus);
// editText.setValidator(true,false,tv);
//
// editText.setText("1000");
//
//
//
// editText = (HyperEditText)view.findViewById(R.id.edit_validate_on_typing);
// editText.setValidator(true,true,tv);
//
//
// editText = (HyperEditText)view.findViewById(R.id.edit_validate_no_auto);
// editText.setValidator(false,false,tv);
//
// view.findViewById(R.id.validate_button).setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
//
// }
// });
//
// return view;
// }
// }
//
// Path: app/src/main/java/com/neurospeech/hypercubesample/fragments/recyclerviewsamples/HeaderFooterFragment.java
// public class HeaderFooterFragment extends Fragment {
// }
//
// Path: app/src/main/java/com/neurospeech/hypercubesample/fragments/recyclerviewsamples/ItemHeadersFragment.java
// public class ItemHeadersFragment extends Fragment {
// }
//
// Path: app/src/main/java/com/neurospeech/hypercubesample/model/MenuModel.java
// public class MenuModel {
//
// private final Class activity;
// public String name;
//
// public String header;
//
// public MenuModel(String header, String name, Class activity) {
// super();
// this.name = name;
// this.header = header;
// this.activity = activity;
// }
//
// public Object newInstance(){
// try {
// return activity.newInstance();
// }catch (Exception ex){
// ex.printStackTrace();
// }
// return null;
// }
// }
// Path: app/src/main/java/com/neurospeech/hypercubesample/MainActivity.java
import android.app.Activity;
import android.app.SearchManager;
import android.content.res.Resources;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.MenuItemCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.SearchView;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.TextView;
import com.neurospeech.hypercubesample.adapters.NavigationListAdapter;
import com.neurospeech.hypercubesample.fragments.HomeFragment;
import com.neurospeech.hypercubesample.fragments.form.EditTextFragment;
import com.neurospeech.hypercubesample.fragments.recyclerviewsamples.HeaderFooterFragment;
import com.neurospeech.hypercubesample.fragments.recyclerviewsamples.ItemHeadersFragment;
import com.neurospeech.hypercubesample.model.MenuModel;
import java.util.ArrayList;
public void onDrawerClosed(View drawerView) {
super.onDrawerClosed(drawerView);
}
@Override
public void onDrawerOpened(View drawerView) {
//getFragmentManager().popBackStackImmediate();
super.onDrawerOpened(drawerView);
}
};
drawerLayout.setDrawerListener(actionBarDrawerToggle);
actionBarDrawerToggle.setDrawerIndicatorEnabled(true);
actionBarDrawerToggle.syncState();
leftDrawer=(RecyclerView) navigationView.findViewById(R.id.left_drawer);
loadItems();
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(this);
leftDrawer.setLayoutManager(layoutManager);
leftDrawer.setItemAnimator(new DefaultItemAnimator());
leftDrawer.setAdapter(navigationListAdapter);
frameLayout =(FrameLayout) findViewById(R.id.fragment_container);
if (findViewById(R.id.fragment_container) != null) {
// Create a new Fragment to be placed in the activity layout | HomeFragment homeFragment = new HomeFragment(); |
neurospeech/android-hypercube | app/src/main/java/com/neurospeech/hypercubesample/MainActivity.java | // Path: app/src/main/java/com/neurospeech/hypercubesample/adapters/NavigationListAdapter.java
// public abstract class NavigationListAdapter
// extends HeaderedAdapter<MenuModel,RecyclerView.ViewHolder> {
//
// public NavigationListAdapter(Context context) {
// super(context);
// }
//
// @Override
// public Object getHeader(MenuModel item) {
// return item.header;
// }
//
//
// public abstract void onItemClick(MenuModel item);
//
//
//
// }
//
// Path: app/src/main/java/com/neurospeech/hypercubesample/fragments/HomeFragment.java
// public class HomeFragment extends Fragment {
//
// @Nullable
// @Override
// public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// View view = inflater.inflate(R.layout.fragment_home,container,false);
//
// return view;
// }
// }
//
// Path: app/src/main/java/com/neurospeech/hypercubesample/fragments/form/EditTextFragment.java
// public class EditTextFragment extends Fragment {
// @Nullable
// @Override
// public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// View view = inflater.inflate(R.layout.form_edit_text_fragment,container,false);
//
// TextValidator tv = new TextValidator() {
// @Override
// public Object invalidError(String value) {
// if(value == null || value.isEmpty())
// return "Field cannot be empty";
// return null;
// }
// };
//
// HyperEditText editText;
// editText = (HyperEditText)view.findViewById(R.id.edit_validate_on_lost_focus);
// editText.setValidator(true,false,tv);
//
// editText.setText("1000");
//
//
//
// editText = (HyperEditText)view.findViewById(R.id.edit_validate_on_typing);
// editText.setValidator(true,true,tv);
//
//
// editText = (HyperEditText)view.findViewById(R.id.edit_validate_no_auto);
// editText.setValidator(false,false,tv);
//
// view.findViewById(R.id.validate_button).setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
//
// }
// });
//
// return view;
// }
// }
//
// Path: app/src/main/java/com/neurospeech/hypercubesample/fragments/recyclerviewsamples/HeaderFooterFragment.java
// public class HeaderFooterFragment extends Fragment {
// }
//
// Path: app/src/main/java/com/neurospeech/hypercubesample/fragments/recyclerviewsamples/ItemHeadersFragment.java
// public class ItemHeadersFragment extends Fragment {
// }
//
// Path: app/src/main/java/com/neurospeech/hypercubesample/model/MenuModel.java
// public class MenuModel {
//
// private final Class activity;
// public String name;
//
// public String header;
//
// public MenuModel(String header, String name, Class activity) {
// super();
// this.name = name;
// this.header = header;
// this.activity = activity;
// }
//
// public Object newInstance(){
// try {
// return activity.newInstance();
// }catch (Exception ex){
// ex.printStackTrace();
// }
// return null;
// }
// }
| import android.app.Activity;
import android.app.SearchManager;
import android.content.res.Resources;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.MenuItemCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.SearchView;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.TextView;
import com.neurospeech.hypercubesample.adapters.NavigationListAdapter;
import com.neurospeech.hypercubesample.fragments.HomeFragment;
import com.neurospeech.hypercubesample.fragments.form.EditTextFragment;
import com.neurospeech.hypercubesample.fragments.recyclerviewsamples.HeaderFooterFragment;
import com.neurospeech.hypercubesample.fragments.recyclerviewsamples.ItemHeadersFragment;
import com.neurospeech.hypercubesample.model.MenuModel;
import java.util.ArrayList; | fragmentTransactions.addToBackStack(null);
fragmentTransactions.commit();
//drawerLayout.closeDrawer(navigationView);
}
@Override
protected void onResume() {
super.onResume();
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
/**
* Handle action bar item clicks here. The action bar will
automatically handle clicks on the Home/Up button, so long
as you specify a parent activity in AndroidManifest.xml.
*/
return super.onOptionsItemSelected(item);
}
/**
* Load the drawer layout items
*/
public void loadItems(){
Resources resources = getResources();
ArrayList<MenuModel> navigationModels = new ArrayList<>();
| // Path: app/src/main/java/com/neurospeech/hypercubesample/adapters/NavigationListAdapter.java
// public abstract class NavigationListAdapter
// extends HeaderedAdapter<MenuModel,RecyclerView.ViewHolder> {
//
// public NavigationListAdapter(Context context) {
// super(context);
// }
//
// @Override
// public Object getHeader(MenuModel item) {
// return item.header;
// }
//
//
// public abstract void onItemClick(MenuModel item);
//
//
//
// }
//
// Path: app/src/main/java/com/neurospeech/hypercubesample/fragments/HomeFragment.java
// public class HomeFragment extends Fragment {
//
// @Nullable
// @Override
// public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// View view = inflater.inflate(R.layout.fragment_home,container,false);
//
// return view;
// }
// }
//
// Path: app/src/main/java/com/neurospeech/hypercubesample/fragments/form/EditTextFragment.java
// public class EditTextFragment extends Fragment {
// @Nullable
// @Override
// public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// View view = inflater.inflate(R.layout.form_edit_text_fragment,container,false);
//
// TextValidator tv = new TextValidator() {
// @Override
// public Object invalidError(String value) {
// if(value == null || value.isEmpty())
// return "Field cannot be empty";
// return null;
// }
// };
//
// HyperEditText editText;
// editText = (HyperEditText)view.findViewById(R.id.edit_validate_on_lost_focus);
// editText.setValidator(true,false,tv);
//
// editText.setText("1000");
//
//
//
// editText = (HyperEditText)view.findViewById(R.id.edit_validate_on_typing);
// editText.setValidator(true,true,tv);
//
//
// editText = (HyperEditText)view.findViewById(R.id.edit_validate_no_auto);
// editText.setValidator(false,false,tv);
//
// view.findViewById(R.id.validate_button).setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
//
// }
// });
//
// return view;
// }
// }
//
// Path: app/src/main/java/com/neurospeech/hypercubesample/fragments/recyclerviewsamples/HeaderFooterFragment.java
// public class HeaderFooterFragment extends Fragment {
// }
//
// Path: app/src/main/java/com/neurospeech/hypercubesample/fragments/recyclerviewsamples/ItemHeadersFragment.java
// public class ItemHeadersFragment extends Fragment {
// }
//
// Path: app/src/main/java/com/neurospeech/hypercubesample/model/MenuModel.java
// public class MenuModel {
//
// private final Class activity;
// public String name;
//
// public String header;
//
// public MenuModel(String header, String name, Class activity) {
// super();
// this.name = name;
// this.header = header;
// this.activity = activity;
// }
//
// public Object newInstance(){
// try {
// return activity.newInstance();
// }catch (Exception ex){
// ex.printStackTrace();
// }
// return null;
// }
// }
// Path: app/src/main/java/com/neurospeech/hypercubesample/MainActivity.java
import android.app.Activity;
import android.app.SearchManager;
import android.content.res.Resources;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.MenuItemCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.SearchView;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.TextView;
import com.neurospeech.hypercubesample.adapters.NavigationListAdapter;
import com.neurospeech.hypercubesample.fragments.HomeFragment;
import com.neurospeech.hypercubesample.fragments.form.EditTextFragment;
import com.neurospeech.hypercubesample.fragments.recyclerviewsamples.HeaderFooterFragment;
import com.neurospeech.hypercubesample.fragments.recyclerviewsamples.ItemHeadersFragment;
import com.neurospeech.hypercubesample.model.MenuModel;
import java.util.ArrayList;
fragmentTransactions.addToBackStack(null);
fragmentTransactions.commit();
//drawerLayout.closeDrawer(navigationView);
}
@Override
protected void onResume() {
super.onResume();
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
/**
* Handle action bar item clicks here. The action bar will
automatically handle clicks on the Home/Up button, so long
as you specify a parent activity in AndroidManifest.xml.
*/
return super.onOptionsItemSelected(item);
}
/**
* Load the drawer layout items
*/
public void loadItems(){
Resources resources = getResources();
ArrayList<MenuModel> navigationModels = new ArrayList<>();
| navigationModels.add(new MenuModel("Recycler View","Header/Footer", HeaderFooterFragment.class)); |
neurospeech/android-hypercube | app/src/main/java/com/neurospeech/hypercubesample/MainActivity.java | // Path: app/src/main/java/com/neurospeech/hypercubesample/adapters/NavigationListAdapter.java
// public abstract class NavigationListAdapter
// extends HeaderedAdapter<MenuModel,RecyclerView.ViewHolder> {
//
// public NavigationListAdapter(Context context) {
// super(context);
// }
//
// @Override
// public Object getHeader(MenuModel item) {
// return item.header;
// }
//
//
// public abstract void onItemClick(MenuModel item);
//
//
//
// }
//
// Path: app/src/main/java/com/neurospeech/hypercubesample/fragments/HomeFragment.java
// public class HomeFragment extends Fragment {
//
// @Nullable
// @Override
// public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// View view = inflater.inflate(R.layout.fragment_home,container,false);
//
// return view;
// }
// }
//
// Path: app/src/main/java/com/neurospeech/hypercubesample/fragments/form/EditTextFragment.java
// public class EditTextFragment extends Fragment {
// @Nullable
// @Override
// public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// View view = inflater.inflate(R.layout.form_edit_text_fragment,container,false);
//
// TextValidator tv = new TextValidator() {
// @Override
// public Object invalidError(String value) {
// if(value == null || value.isEmpty())
// return "Field cannot be empty";
// return null;
// }
// };
//
// HyperEditText editText;
// editText = (HyperEditText)view.findViewById(R.id.edit_validate_on_lost_focus);
// editText.setValidator(true,false,tv);
//
// editText.setText("1000");
//
//
//
// editText = (HyperEditText)view.findViewById(R.id.edit_validate_on_typing);
// editText.setValidator(true,true,tv);
//
//
// editText = (HyperEditText)view.findViewById(R.id.edit_validate_no_auto);
// editText.setValidator(false,false,tv);
//
// view.findViewById(R.id.validate_button).setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
//
// }
// });
//
// return view;
// }
// }
//
// Path: app/src/main/java/com/neurospeech/hypercubesample/fragments/recyclerviewsamples/HeaderFooterFragment.java
// public class HeaderFooterFragment extends Fragment {
// }
//
// Path: app/src/main/java/com/neurospeech/hypercubesample/fragments/recyclerviewsamples/ItemHeadersFragment.java
// public class ItemHeadersFragment extends Fragment {
// }
//
// Path: app/src/main/java/com/neurospeech/hypercubesample/model/MenuModel.java
// public class MenuModel {
//
// private final Class activity;
// public String name;
//
// public String header;
//
// public MenuModel(String header, String name, Class activity) {
// super();
// this.name = name;
// this.header = header;
// this.activity = activity;
// }
//
// public Object newInstance(){
// try {
// return activity.newInstance();
// }catch (Exception ex){
// ex.printStackTrace();
// }
// return null;
// }
// }
| import android.app.Activity;
import android.app.SearchManager;
import android.content.res.Resources;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.MenuItemCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.SearchView;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.TextView;
import com.neurospeech.hypercubesample.adapters.NavigationListAdapter;
import com.neurospeech.hypercubesample.fragments.HomeFragment;
import com.neurospeech.hypercubesample.fragments.form.EditTextFragment;
import com.neurospeech.hypercubesample.fragments.recyclerviewsamples.HeaderFooterFragment;
import com.neurospeech.hypercubesample.fragments.recyclerviewsamples.ItemHeadersFragment;
import com.neurospeech.hypercubesample.model.MenuModel;
import java.util.ArrayList; | fragmentTransactions.commit();
//drawerLayout.closeDrawer(navigationView);
}
@Override
protected void onResume() {
super.onResume();
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
/**
* Handle action bar item clicks here. The action bar will
automatically handle clicks on the Home/Up button, so long
as you specify a parent activity in AndroidManifest.xml.
*/
return super.onOptionsItemSelected(item);
}
/**
* Load the drawer layout items
*/
public void loadItems(){
Resources resources = getResources();
ArrayList<MenuModel> navigationModels = new ArrayList<>();
navigationModels.add(new MenuModel("Recycler View","Header/Footer", HeaderFooterFragment.class)); | // Path: app/src/main/java/com/neurospeech/hypercubesample/adapters/NavigationListAdapter.java
// public abstract class NavigationListAdapter
// extends HeaderedAdapter<MenuModel,RecyclerView.ViewHolder> {
//
// public NavigationListAdapter(Context context) {
// super(context);
// }
//
// @Override
// public Object getHeader(MenuModel item) {
// return item.header;
// }
//
//
// public abstract void onItemClick(MenuModel item);
//
//
//
// }
//
// Path: app/src/main/java/com/neurospeech/hypercubesample/fragments/HomeFragment.java
// public class HomeFragment extends Fragment {
//
// @Nullable
// @Override
// public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// View view = inflater.inflate(R.layout.fragment_home,container,false);
//
// return view;
// }
// }
//
// Path: app/src/main/java/com/neurospeech/hypercubesample/fragments/form/EditTextFragment.java
// public class EditTextFragment extends Fragment {
// @Nullable
// @Override
// public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// View view = inflater.inflate(R.layout.form_edit_text_fragment,container,false);
//
// TextValidator tv = new TextValidator() {
// @Override
// public Object invalidError(String value) {
// if(value == null || value.isEmpty())
// return "Field cannot be empty";
// return null;
// }
// };
//
// HyperEditText editText;
// editText = (HyperEditText)view.findViewById(R.id.edit_validate_on_lost_focus);
// editText.setValidator(true,false,tv);
//
// editText.setText("1000");
//
//
//
// editText = (HyperEditText)view.findViewById(R.id.edit_validate_on_typing);
// editText.setValidator(true,true,tv);
//
//
// editText = (HyperEditText)view.findViewById(R.id.edit_validate_no_auto);
// editText.setValidator(false,false,tv);
//
// view.findViewById(R.id.validate_button).setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
//
// }
// });
//
// return view;
// }
// }
//
// Path: app/src/main/java/com/neurospeech/hypercubesample/fragments/recyclerviewsamples/HeaderFooterFragment.java
// public class HeaderFooterFragment extends Fragment {
// }
//
// Path: app/src/main/java/com/neurospeech/hypercubesample/fragments/recyclerviewsamples/ItemHeadersFragment.java
// public class ItemHeadersFragment extends Fragment {
// }
//
// Path: app/src/main/java/com/neurospeech/hypercubesample/model/MenuModel.java
// public class MenuModel {
//
// private final Class activity;
// public String name;
//
// public String header;
//
// public MenuModel(String header, String name, Class activity) {
// super();
// this.name = name;
// this.header = header;
// this.activity = activity;
// }
//
// public Object newInstance(){
// try {
// return activity.newInstance();
// }catch (Exception ex){
// ex.printStackTrace();
// }
// return null;
// }
// }
// Path: app/src/main/java/com/neurospeech/hypercubesample/MainActivity.java
import android.app.Activity;
import android.app.SearchManager;
import android.content.res.Resources;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.MenuItemCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.SearchView;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.TextView;
import com.neurospeech.hypercubesample.adapters.NavigationListAdapter;
import com.neurospeech.hypercubesample.fragments.HomeFragment;
import com.neurospeech.hypercubesample.fragments.form.EditTextFragment;
import com.neurospeech.hypercubesample.fragments.recyclerviewsamples.HeaderFooterFragment;
import com.neurospeech.hypercubesample.fragments.recyclerviewsamples.ItemHeadersFragment;
import com.neurospeech.hypercubesample.model.MenuModel;
import java.util.ArrayList;
fragmentTransactions.commit();
//drawerLayout.closeDrawer(navigationView);
}
@Override
protected void onResume() {
super.onResume();
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
/**
* Handle action bar item clicks here. The action bar will
automatically handle clicks on the Home/Up button, so long
as you specify a parent activity in AndroidManifest.xml.
*/
return super.onOptionsItemSelected(item);
}
/**
* Load the drawer layout items
*/
public void loadItems(){
Resources resources = getResources();
ArrayList<MenuModel> navigationModels = new ArrayList<>();
navigationModels.add(new MenuModel("Recycler View","Header/Footer", HeaderFooterFragment.class)); | navigationModels.add(new MenuModel("Recycler View","Item Headers", ItemHeadersFragment.class)); |
neurospeech/android-hypercube | app/src/main/java/com/neurospeech/hypercubesample/MainActivity.java | // Path: app/src/main/java/com/neurospeech/hypercubesample/adapters/NavigationListAdapter.java
// public abstract class NavigationListAdapter
// extends HeaderedAdapter<MenuModel,RecyclerView.ViewHolder> {
//
// public NavigationListAdapter(Context context) {
// super(context);
// }
//
// @Override
// public Object getHeader(MenuModel item) {
// return item.header;
// }
//
//
// public abstract void onItemClick(MenuModel item);
//
//
//
// }
//
// Path: app/src/main/java/com/neurospeech/hypercubesample/fragments/HomeFragment.java
// public class HomeFragment extends Fragment {
//
// @Nullable
// @Override
// public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// View view = inflater.inflate(R.layout.fragment_home,container,false);
//
// return view;
// }
// }
//
// Path: app/src/main/java/com/neurospeech/hypercubesample/fragments/form/EditTextFragment.java
// public class EditTextFragment extends Fragment {
// @Nullable
// @Override
// public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// View view = inflater.inflate(R.layout.form_edit_text_fragment,container,false);
//
// TextValidator tv = new TextValidator() {
// @Override
// public Object invalidError(String value) {
// if(value == null || value.isEmpty())
// return "Field cannot be empty";
// return null;
// }
// };
//
// HyperEditText editText;
// editText = (HyperEditText)view.findViewById(R.id.edit_validate_on_lost_focus);
// editText.setValidator(true,false,tv);
//
// editText.setText("1000");
//
//
//
// editText = (HyperEditText)view.findViewById(R.id.edit_validate_on_typing);
// editText.setValidator(true,true,tv);
//
//
// editText = (HyperEditText)view.findViewById(R.id.edit_validate_no_auto);
// editText.setValidator(false,false,tv);
//
// view.findViewById(R.id.validate_button).setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
//
// }
// });
//
// return view;
// }
// }
//
// Path: app/src/main/java/com/neurospeech/hypercubesample/fragments/recyclerviewsamples/HeaderFooterFragment.java
// public class HeaderFooterFragment extends Fragment {
// }
//
// Path: app/src/main/java/com/neurospeech/hypercubesample/fragments/recyclerviewsamples/ItemHeadersFragment.java
// public class ItemHeadersFragment extends Fragment {
// }
//
// Path: app/src/main/java/com/neurospeech/hypercubesample/model/MenuModel.java
// public class MenuModel {
//
// private final Class activity;
// public String name;
//
// public String header;
//
// public MenuModel(String header, String name, Class activity) {
// super();
// this.name = name;
// this.header = header;
// this.activity = activity;
// }
//
// public Object newInstance(){
// try {
// return activity.newInstance();
// }catch (Exception ex){
// ex.printStackTrace();
// }
// return null;
// }
// }
| import android.app.Activity;
import android.app.SearchManager;
import android.content.res.Resources;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.MenuItemCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.SearchView;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.TextView;
import com.neurospeech.hypercubesample.adapters.NavigationListAdapter;
import com.neurospeech.hypercubesample.fragments.HomeFragment;
import com.neurospeech.hypercubesample.fragments.form.EditTextFragment;
import com.neurospeech.hypercubesample.fragments.recyclerviewsamples.HeaderFooterFragment;
import com.neurospeech.hypercubesample.fragments.recyclerviewsamples.ItemHeadersFragment;
import com.neurospeech.hypercubesample.model.MenuModel;
import java.util.ArrayList; | //drawerLayout.closeDrawer(navigationView);
}
@Override
protected void onResume() {
super.onResume();
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
/**
* Handle action bar item clicks here. The action bar will
automatically handle clicks on the Home/Up button, so long
as you specify a parent activity in AndroidManifest.xml.
*/
return super.onOptionsItemSelected(item);
}
/**
* Load the drawer layout items
*/
public void loadItems(){
Resources resources = getResources();
ArrayList<MenuModel> navigationModels = new ArrayList<>();
navigationModels.add(new MenuModel("Recycler View","Header/Footer", HeaderFooterFragment.class));
navigationModels.add(new MenuModel("Recycler View","Item Headers", ItemHeadersFragment.class)); | // Path: app/src/main/java/com/neurospeech/hypercubesample/adapters/NavigationListAdapter.java
// public abstract class NavigationListAdapter
// extends HeaderedAdapter<MenuModel,RecyclerView.ViewHolder> {
//
// public NavigationListAdapter(Context context) {
// super(context);
// }
//
// @Override
// public Object getHeader(MenuModel item) {
// return item.header;
// }
//
//
// public abstract void onItemClick(MenuModel item);
//
//
//
// }
//
// Path: app/src/main/java/com/neurospeech/hypercubesample/fragments/HomeFragment.java
// public class HomeFragment extends Fragment {
//
// @Nullable
// @Override
// public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// View view = inflater.inflate(R.layout.fragment_home,container,false);
//
// return view;
// }
// }
//
// Path: app/src/main/java/com/neurospeech/hypercubesample/fragments/form/EditTextFragment.java
// public class EditTextFragment extends Fragment {
// @Nullable
// @Override
// public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// View view = inflater.inflate(R.layout.form_edit_text_fragment,container,false);
//
// TextValidator tv = new TextValidator() {
// @Override
// public Object invalidError(String value) {
// if(value == null || value.isEmpty())
// return "Field cannot be empty";
// return null;
// }
// };
//
// HyperEditText editText;
// editText = (HyperEditText)view.findViewById(R.id.edit_validate_on_lost_focus);
// editText.setValidator(true,false,tv);
//
// editText.setText("1000");
//
//
//
// editText = (HyperEditText)view.findViewById(R.id.edit_validate_on_typing);
// editText.setValidator(true,true,tv);
//
//
// editText = (HyperEditText)view.findViewById(R.id.edit_validate_no_auto);
// editText.setValidator(false,false,tv);
//
// view.findViewById(R.id.validate_button).setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
//
// }
// });
//
// return view;
// }
// }
//
// Path: app/src/main/java/com/neurospeech/hypercubesample/fragments/recyclerviewsamples/HeaderFooterFragment.java
// public class HeaderFooterFragment extends Fragment {
// }
//
// Path: app/src/main/java/com/neurospeech/hypercubesample/fragments/recyclerviewsamples/ItemHeadersFragment.java
// public class ItemHeadersFragment extends Fragment {
// }
//
// Path: app/src/main/java/com/neurospeech/hypercubesample/model/MenuModel.java
// public class MenuModel {
//
// private final Class activity;
// public String name;
//
// public String header;
//
// public MenuModel(String header, String name, Class activity) {
// super();
// this.name = name;
// this.header = header;
// this.activity = activity;
// }
//
// public Object newInstance(){
// try {
// return activity.newInstance();
// }catch (Exception ex){
// ex.printStackTrace();
// }
// return null;
// }
// }
// Path: app/src/main/java/com/neurospeech/hypercubesample/MainActivity.java
import android.app.Activity;
import android.app.SearchManager;
import android.content.res.Resources;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.MenuItemCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.SearchView;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.TextView;
import com.neurospeech.hypercubesample.adapters.NavigationListAdapter;
import com.neurospeech.hypercubesample.fragments.HomeFragment;
import com.neurospeech.hypercubesample.fragments.form.EditTextFragment;
import com.neurospeech.hypercubesample.fragments.recyclerviewsamples.HeaderFooterFragment;
import com.neurospeech.hypercubesample.fragments.recyclerviewsamples.ItemHeadersFragment;
import com.neurospeech.hypercubesample.model.MenuModel;
import java.util.ArrayList;
//drawerLayout.closeDrawer(navigationView);
}
@Override
protected void onResume() {
super.onResume();
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
/**
* Handle action bar item clicks here. The action bar will
automatically handle clicks on the Home/Up button, so long
as you specify a parent activity in AndroidManifest.xml.
*/
return super.onOptionsItemSelected(item);
}
/**
* Load the drawer layout items
*/
public void loadItems(){
Resources resources = getResources();
ArrayList<MenuModel> navigationModels = new ArrayList<>();
navigationModels.add(new MenuModel("Recycler View","Header/Footer", HeaderFooterFragment.class));
navigationModels.add(new MenuModel("Recycler View","Item Headers", ItemHeadersFragment.class)); | navigationModels.add(new MenuModel("Form","Edit Text", EditTextFragment.class)); |
xebia-france/xebia-cloudcomputing-extras | src/main/java/fr/xebia/workshop/continuousdelivery/DocumentationGenerator.java | // Path: src/main/java/fr/xebia/cloud/cloudinit/FreemarkerUtils.java
// public class FreemarkerUtils {
//
// /**
// *
// * @param rootMap
// * root node of the freemarker datamodel.
// * @param templatePath
// * classpath classpath path of the template (e.g. "/my-template.ftl")
// * @return generated file
// */
// @SuppressWarnings("unchecked")
// @Nonnull
// public static String generate(@Nullable Map<String, ? extends Object> rootMap, @Nonnull String templatePath) {
// Preconditions.checkNotNull(templatePath, "'templatePath' can NOT be null");
// rootMap = (Map<String, Object>) Objects.firstNonNull(rootMap, Collections.emptyMap());
//
// try {
// Configuration cfg = new Configuration();
// cfg.setClassForTemplateLoading(FreemarkerUtils.class, "/");
//
// Template template = cfg.getTemplate(templatePath);
// Writer out = new StringWriter();
// template.process(rootMap, out);
// return out.toString();
// } catch (IOException e) {
// throw Throwables.propagate(e);
// } catch (TemplateException e) {
// throw Throwables.propagate(e);
// }
// }
//
// }
| import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.joda.time.DateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.Charsets;
import com.google.common.base.Joiner;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.io.Files;
import fr.xebia.cloud.cloudinit.FreemarkerUtils; | /*
* Copyright 2008-2010 Xebia and the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package fr.xebia.workshop.continuousdelivery;
public class DocumentationGenerator {
private static final Logger logger = LoggerFactory.getLogger(DocumentationGenerator.class);
private static final String TEMPLATE_ROOT_PATH = "/fr/xebia/workshop/continuousdelivery/lab/";
private static final List<String> TEMPLATE_LAB_NAMES = Arrays.asList(
"apache-tomcat-maven-plugin",
"jenkins-remote-ssh",
"rundeck",
"deployit");
private static final String SETUP_TEMPLATE_NAME = "setup";
public void generateDocs(Collection<TeamInfrastructure> teamsInfrastructures, String baseWikiFolder) throws IOException {
File wikiBaseFolder = new File(baseWikiFolder);
if (wikiBaseFolder.exists()) {
logger.debug("Delete wiki folder {}", wikiBaseFolder);
wikiBaseFolder.delete();
}
wikiBaseFolder.mkdirs();
List<String> generatedWikiPageNames = Lists.newArrayList();
List<String> setupGeneratedWikiPageNames = Lists.newArrayList();
HashMap<TeamInfrastructure, List<String>> teamsPages = Maps.newHashMap();
for (TeamInfrastructure infrastructure : teamsInfrastructures) {
List<String> generatedForTeam = Lists.newArrayList();
for (String template : TEMPLATE_LAB_NAMES) {
try {
Map<String, Object> rootMap = Maps.newHashMap();
rootMap.put("infrastructure", infrastructure);
String templatePath = TEMPLATE_ROOT_PATH + template + ".ftl";
rootMap.put("generator", "This page has been generaterd by '{{{" + getClass() + "}}}' with template '{{{" + templatePath + "}}}' on the "
+ new DateTime()); | // Path: src/main/java/fr/xebia/cloud/cloudinit/FreemarkerUtils.java
// public class FreemarkerUtils {
//
// /**
// *
// * @param rootMap
// * root node of the freemarker datamodel.
// * @param templatePath
// * classpath classpath path of the template (e.g. "/my-template.ftl")
// * @return generated file
// */
// @SuppressWarnings("unchecked")
// @Nonnull
// public static String generate(@Nullable Map<String, ? extends Object> rootMap, @Nonnull String templatePath) {
// Preconditions.checkNotNull(templatePath, "'templatePath' can NOT be null");
// rootMap = (Map<String, Object>) Objects.firstNonNull(rootMap, Collections.emptyMap());
//
// try {
// Configuration cfg = new Configuration();
// cfg.setClassForTemplateLoading(FreemarkerUtils.class, "/");
//
// Template template = cfg.getTemplate(templatePath);
// Writer out = new StringWriter();
// template.process(rootMap, out);
// return out.toString();
// } catch (IOException e) {
// throw Throwables.propagate(e);
// } catch (TemplateException e) {
// throw Throwables.propagate(e);
// }
// }
//
// }
// Path: src/main/java/fr/xebia/workshop/continuousdelivery/DocumentationGenerator.java
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.joda.time.DateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.Charsets;
import com.google.common.base.Joiner;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.io.Files;
import fr.xebia.cloud.cloudinit.FreemarkerUtils;
/*
* Copyright 2008-2010 Xebia and the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package fr.xebia.workshop.continuousdelivery;
public class DocumentationGenerator {
private static final Logger logger = LoggerFactory.getLogger(DocumentationGenerator.class);
private static final String TEMPLATE_ROOT_PATH = "/fr/xebia/workshop/continuousdelivery/lab/";
private static final List<String> TEMPLATE_LAB_NAMES = Arrays.asList(
"apache-tomcat-maven-plugin",
"jenkins-remote-ssh",
"rundeck",
"deployit");
private static final String SETUP_TEMPLATE_NAME = "setup";
public void generateDocs(Collection<TeamInfrastructure> teamsInfrastructures, String baseWikiFolder) throws IOException {
File wikiBaseFolder = new File(baseWikiFolder);
if (wikiBaseFolder.exists()) {
logger.debug("Delete wiki folder {}", wikiBaseFolder);
wikiBaseFolder.delete();
}
wikiBaseFolder.mkdirs();
List<String> generatedWikiPageNames = Lists.newArrayList();
List<String> setupGeneratedWikiPageNames = Lists.newArrayList();
HashMap<TeamInfrastructure, List<String>> teamsPages = Maps.newHashMap();
for (TeamInfrastructure infrastructure : teamsInfrastructures) {
List<String> generatedForTeam = Lists.newArrayList();
for (String template : TEMPLATE_LAB_NAMES) {
try {
Map<String, Object> rootMap = Maps.newHashMap();
rootMap.put("infrastructure", infrastructure);
String templatePath = TEMPLATE_ROOT_PATH + template + ".ftl";
rootMap.put("generator", "This page has been generaterd by '{{{" + getClass() + "}}}' with template '{{{" + templatePath + "}}}' on the "
+ new DateTime()); | String page = FreemarkerUtils.generate(rootMap, templatePath); |
xebia-france/xebia-cloudcomputing-extras | src/test/java/fr/xebia/workshop/continuousdelivery/LabWikiPageGeneratorTest.java | // Path: src/main/java/fr/xebia/cloud/cloudinit/FreemarkerUtils.java
// public class FreemarkerUtils {
//
// /**
// *
// * @param rootMap
// * root node of the freemarker datamodel.
// * @param templatePath
// * classpath classpath path of the template (e.g. "/my-template.ftl")
// * @return generated file
// */
// @SuppressWarnings("unchecked")
// @Nonnull
// public static String generate(@Nullable Map<String, ? extends Object> rootMap, @Nonnull String templatePath) {
// Preconditions.checkNotNull(templatePath, "'templatePath' can NOT be null");
// rootMap = (Map<String, Object>) Objects.firstNonNull(rootMap, Collections.emptyMap());
//
// try {
// Configuration cfg = new Configuration();
// cfg.setClassForTemplateLoading(FreemarkerUtils.class, "/");
//
// Template template = cfg.getTemplate(templatePath);
// Writer out = new StringWriter();
// template.process(rootMap, out);
// return out.toString();
// } catch (IOException e) {
// throw Throwables.propagate(e);
// } catch (TemplateException e) {
// throw Throwables.propagate(e);
// }
// }
//
// }
| import static java.util.Arrays.asList;
import java.util.Map;
import org.junit.Test;
import com.amazonaws.services.ec2.model.Instance;
import com.google.common.collect.Maps;
import fr.xebia.cloud.cloudinit.FreemarkerUtils; | infrastructure.setJenkinsName("jenkins-clc");
infrastructure.setRundeck(jenkins);
infrastructure.setRundeckName("jenkins-clc");
Instance devTomcat = new Instance() //
.withPublicDnsName("ec2-79-125-53-61-devtomcat.eu-west-1.compute.amazonaws.com") //
.withPrivateDnsName("ip-10-234-33-147.eu-west-1.compute.internal") //
.withPrivateIpAddress("10.234.33.147");
infrastructure.setDevTomcat(devTomcat);
infrastructure.setDevTomcatName("tomcat-clc-dev-1");
Instance validTomcat1 = new Instance() //
.withPublicDnsName("ec2-79-011-33-55-validtomcat1.eu-west-1.compute.amazonaws.com") //
.withPrivateDnsName("ip-10-01-03-05.eu-west-1.compute.internal") //
.withPrivateIpAddress("10.01.03.05");
infrastructure.setValidTomcat1(validTomcat1);
infrastructure.setValidTomcat1Name("tomcat-clc-valid-1");
Instance validTomcat2 = new Instance() //
.withPublicDnsName("ec2-80-022-44-66-validtomcat2.eu-west-1.compute.amazonaws.com") //
.withPrivateDnsName("ip-10-02-04-04.eu-west-1.compute.internal") //
.withPrivateIpAddress("10.02.04.06");
infrastructure.setValidTomcat2(validTomcat2);
infrastructure.setValidTomcat2Name("tomcat-clc-valid-2");
Map<String, Object> rootMap = Maps.newHashMap();
rootMap.put("infrastructure", infrastructure);
rootMap.put("generator", "This page has been generaterd by '{{{" + getClass() + "}}}'");
rootMap.put("generatedWikiPageNames", asList("page1", "page2")); | // Path: src/main/java/fr/xebia/cloud/cloudinit/FreemarkerUtils.java
// public class FreemarkerUtils {
//
// /**
// *
// * @param rootMap
// * root node of the freemarker datamodel.
// * @param templatePath
// * classpath classpath path of the template (e.g. "/my-template.ftl")
// * @return generated file
// */
// @SuppressWarnings("unchecked")
// @Nonnull
// public static String generate(@Nullable Map<String, ? extends Object> rootMap, @Nonnull String templatePath) {
// Preconditions.checkNotNull(templatePath, "'templatePath' can NOT be null");
// rootMap = (Map<String, Object>) Objects.firstNonNull(rootMap, Collections.emptyMap());
//
// try {
// Configuration cfg = new Configuration();
// cfg.setClassForTemplateLoading(FreemarkerUtils.class, "/");
//
// Template template = cfg.getTemplate(templatePath);
// Writer out = new StringWriter();
// template.process(rootMap, out);
// return out.toString();
// } catch (IOException e) {
// throw Throwables.propagate(e);
// } catch (TemplateException e) {
// throw Throwables.propagate(e);
// }
// }
//
// }
// Path: src/test/java/fr/xebia/workshop/continuousdelivery/LabWikiPageGeneratorTest.java
import static java.util.Arrays.asList;
import java.util.Map;
import org.junit.Test;
import com.amazonaws.services.ec2.model.Instance;
import com.google.common.collect.Maps;
import fr.xebia.cloud.cloudinit.FreemarkerUtils;
infrastructure.setJenkinsName("jenkins-clc");
infrastructure.setRundeck(jenkins);
infrastructure.setRundeckName("jenkins-clc");
Instance devTomcat = new Instance() //
.withPublicDnsName("ec2-79-125-53-61-devtomcat.eu-west-1.compute.amazonaws.com") //
.withPrivateDnsName("ip-10-234-33-147.eu-west-1.compute.internal") //
.withPrivateIpAddress("10.234.33.147");
infrastructure.setDevTomcat(devTomcat);
infrastructure.setDevTomcatName("tomcat-clc-dev-1");
Instance validTomcat1 = new Instance() //
.withPublicDnsName("ec2-79-011-33-55-validtomcat1.eu-west-1.compute.amazonaws.com") //
.withPrivateDnsName("ip-10-01-03-05.eu-west-1.compute.internal") //
.withPrivateIpAddress("10.01.03.05");
infrastructure.setValidTomcat1(validTomcat1);
infrastructure.setValidTomcat1Name("tomcat-clc-valid-1");
Instance validTomcat2 = new Instance() //
.withPublicDnsName("ec2-80-022-44-66-validtomcat2.eu-west-1.compute.amazonaws.com") //
.withPrivateDnsName("ip-10-02-04-04.eu-west-1.compute.internal") //
.withPrivateIpAddress("10.02.04.06");
infrastructure.setValidTomcat2(validTomcat2);
infrastructure.setValidTomcat2Name("tomcat-clc-valid-2");
Map<String, Object> rootMap = Maps.newHashMap();
rootMap.put("infrastructure", infrastructure);
rootMap.put("generator", "This page has been generaterd by '{{{" + getClass() + "}}}'");
rootMap.put("generatedWikiPageNames", asList("page1", "page2")); | String page = FreemarkerUtils.generate(rootMap, "/fr/xebia/workshop/continuousdelivery/lab/setup.ftl"); |
xebia-france/xebia-cloudcomputing-extras | src/main/java/fr/xebia/cloud/amazon/aws/tools/AmazonAwsToolsSender.java | // Path: src/main/java/fr/xebia/cloud/cloudinit/FreemarkerUtils.java
// public class FreemarkerUtils {
//
// /**
// *
// * @param rootMap
// * root node of the freemarker datamodel.
// * @param templatePath
// * classpath classpath path of the template (e.g. "/my-template.ftl")
// * @return generated file
// */
// @SuppressWarnings("unchecked")
// @Nonnull
// public static String generate(@Nullable Map<String, ? extends Object> rootMap, @Nonnull String templatePath) {
// Preconditions.checkNotNull(templatePath, "'templatePath' can NOT be null");
// rootMap = (Map<String, Object>) Objects.firstNonNull(rootMap, Collections.emptyMap());
//
// try {
// Configuration cfg = new Configuration();
// cfg.setClassForTemplateLoading(FreemarkerUtils.class, "/");
//
// Template template = cfg.getTemplate(templatePath);
// Writer out = new StringWriter();
// template.process(rootMap, out);
// return out.toString();
// } catch (IOException e) {
// throw Throwables.propagate(e);
// } catch (TemplateException e) {
// throw Throwables.propagate(e);
// }
// }
//
// }
| import java.io.InputStream;
import java.net.URL;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import javax.annotation.Nonnull;
import javax.mail.BodyPart;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
import com.amazonaws.services.identitymanagement.model.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.PropertiesCredentials;
import com.amazonaws.services.ec2.AmazonEC2;
import com.amazonaws.services.ec2.AmazonEC2Client;
import com.amazonaws.services.identitymanagement.AmazonIdentityManagement;
import com.amazonaws.services.identitymanagement.AmazonIdentityManagementClient;
import com.amazonaws.services.identitymanagement.model.StatusType;
import com.amazonaws.services.simpleemail.AmazonSimpleEmailService;
import com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient;
import com.google.common.base.Charsets;
import com.google.common.base.Preconditions;
import com.google.common.base.Predicate;
import com.google.common.base.Throwables;
import com.google.common.collect.Collections2;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.io.Resources;
import fr.xebia.cloud.cloudinit.FreemarkerUtils; | for (String userName : userNames) {
try {
sendEmail(userName);
} catch (Exception e) {
logger.error("Failure to send email to user '{}'", userName, e);
}
// sleep 10 seconds to prevent "Throttling exception"
try {
Thread.sleep(10 * 1000);
} catch (InterruptedException e) {
throw Throwables.propagate(e);
}
}
}
/**
*
* @param toAddress
* @throws MessagingException
*/
public void sendEmail(Map<String, String> templatesParams, List<BodyPart> attachments, String toAddress) throws MessagingException {
MimeBodyPart htmlAndPlainTextAlternativeBody = new MimeBodyPart();
// TEXT AND HTML MESSAGE (gmail requires plain text alternative,
// otherwise, it displays the 1st plain text attachment in the preview)
MimeMultipart cover = new MimeMultipart("alternative");
htmlAndPlainTextAlternativeBody.setContent(cover);
BodyPart textHtmlBodyPart = new MimeBodyPart(); | // Path: src/main/java/fr/xebia/cloud/cloudinit/FreemarkerUtils.java
// public class FreemarkerUtils {
//
// /**
// *
// * @param rootMap
// * root node of the freemarker datamodel.
// * @param templatePath
// * classpath classpath path of the template (e.g. "/my-template.ftl")
// * @return generated file
// */
// @SuppressWarnings("unchecked")
// @Nonnull
// public static String generate(@Nullable Map<String, ? extends Object> rootMap, @Nonnull String templatePath) {
// Preconditions.checkNotNull(templatePath, "'templatePath' can NOT be null");
// rootMap = (Map<String, Object>) Objects.firstNonNull(rootMap, Collections.emptyMap());
//
// try {
// Configuration cfg = new Configuration();
// cfg.setClassForTemplateLoading(FreemarkerUtils.class, "/");
//
// Template template = cfg.getTemplate(templatePath);
// Writer out = new StringWriter();
// template.process(rootMap, out);
// return out.toString();
// } catch (IOException e) {
// throw Throwables.propagate(e);
// } catch (TemplateException e) {
// throw Throwables.propagate(e);
// }
// }
//
// }
// Path: src/main/java/fr/xebia/cloud/amazon/aws/tools/AmazonAwsToolsSender.java
import java.io.InputStream;
import java.net.URL;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import javax.annotation.Nonnull;
import javax.mail.BodyPart;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
import com.amazonaws.services.identitymanagement.model.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.PropertiesCredentials;
import com.amazonaws.services.ec2.AmazonEC2;
import com.amazonaws.services.ec2.AmazonEC2Client;
import com.amazonaws.services.identitymanagement.AmazonIdentityManagement;
import com.amazonaws.services.identitymanagement.AmazonIdentityManagementClient;
import com.amazonaws.services.identitymanagement.model.StatusType;
import com.amazonaws.services.simpleemail.AmazonSimpleEmailService;
import com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient;
import com.google.common.base.Charsets;
import com.google.common.base.Preconditions;
import com.google.common.base.Predicate;
import com.google.common.base.Throwables;
import com.google.common.collect.Collections2;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.io.Resources;
import fr.xebia.cloud.cloudinit.FreemarkerUtils;
for (String userName : userNames) {
try {
sendEmail(userName);
} catch (Exception e) {
logger.error("Failure to send email to user '{}'", userName, e);
}
// sleep 10 seconds to prevent "Throttling exception"
try {
Thread.sleep(10 * 1000);
} catch (InterruptedException e) {
throw Throwables.propagate(e);
}
}
}
/**
*
* @param toAddress
* @throws MessagingException
*/
public void sendEmail(Map<String, String> templatesParams, List<BodyPart> attachments, String toAddress) throws MessagingException {
MimeBodyPart htmlAndPlainTextAlternativeBody = new MimeBodyPart();
// TEXT AND HTML MESSAGE (gmail requires plain text alternative,
// otherwise, it displays the 1st plain text attachment in the preview)
MimeMultipart cover = new MimeMultipart("alternative");
htmlAndPlainTextAlternativeBody.setContent(cover);
BodyPart textHtmlBodyPart = new MimeBodyPart(); | String textHtmlBody = FreemarkerUtils.generate(templatesParams, "/fr/xebia/cloud/amazon/aws/tools/amazon-aws-tools-email.html.ftl"); |
xebia-france/xebia-cloudcomputing-extras | src/main/java/fr/xebia/cloud/amazon/aws/tools/AmazonAwsUtils.java | // Path: src/main/java/fr/xebia/workshop/monitoring/InfrastructureCreationStep.java
// public abstract class InfrastructureCreationStep {
//
// protected final Logger logger = LoggerFactory.getLogger(getClass());
//
// public static final String NAGIOS_IMAGE_ID = "ami-ff1a278b";
// public static final String GRAPHITE_IMAGE_ID = "ami-e51d2091";
//
// public abstract void execute(AmazonEC2 ec2, WorkshopInfrastructure workshopInfrastructure) throws Exception;
//
// protected void createTags(Instance instance, CreateTagsRequest createTagsRequest, AmazonEC2 ec2) {
// // "AWS Error Code: InvalidInstanceID.NotFound, AWS Error Message: The instance ID 'i-d1638198' does not exist"
// AmazonAwsUtils.awaitForEc2Instance(instance, ec2);
//
// try {
// ec2.createTags(createTagsRequest);
// } catch (AmazonServiceException e) {
// // retries 5s later
// try {
// Thread.sleep(5 * 1000);
// } catch (InterruptedException e1) {
// e1.printStackTrace();
// }
// ec2.createTags(createTagsRequest);
// }
// }
//
// }
| import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.*;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import com.amazonaws.AmazonServiceException;
import com.amazonaws.services.ec2.model.*;
import com.amazonaws.services.ec2.model.Instance;
import com.amazonaws.services.elasticbeanstalk.AWSElasticBeanstalk;
import com.amazonaws.services.elasticbeanstalk.model.*;
import com.amazonaws.services.route53.AmazonRoute53;
import com.amazonaws.services.route53.model.*;
import com.google.common.collect.*;
import fr.xebia.workshop.monitoring.InfrastructureCreationStep;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.PropertiesCredentials;
import com.amazonaws.services.ec2.AmazonEC2;
import com.amazonaws.services.rds.AmazonRDS;
import com.amazonaws.services.rds.model.DBInstance;
import com.amazonaws.services.rds.model.DBInstanceNotFoundException;
import com.amazonaws.services.rds.model.DescribeDBInstancesRequest;
import com.amazonaws.services.rds.model.DescribeDBInstancesResult;
import com.google.common.base.Function;
import com.google.common.base.Joiner;
import com.google.common.base.Preconditions;
import com.google.common.base.Predicate;
import com.google.common.base.Throwables;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.Session; | /*
* Copyright 2008-2010 Xebia and the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package fr.xebia.cloud.amazon.aws.tools;
public class AmazonAwsUtils {
/**
* private constructor for utils class.
*/
private AmazonAwsUtils() {
}
/**
* <p>
* Create EC2 instances and ensure these instances are successfully started.
* </p>
* <p>
* Successfully started means they reached the
* {@link InstanceStateName#Running} state.
* </p>
* <p>
* If the startup of an instance failed (e.g.
* "Server.InternalError: Internal error on launch"), the instance is
* terminated and another one is launched.
* </p>
* <p>
* Max retry count: 3.
* </p>
*
* @param runInstancesRequest
* @param ec2
* @return list of "Running" created instances. List size is greater or
* equals to given {@link RunInstancesRequest#getMinCount()}
*/
@Nonnull
public static List<Instance> reliableEc2RunInstances(@Nonnull RunInstancesRequest runInstancesRequest, @Nonnull AmazonEC2 ec2) {
int initialInstanceMinCount = runInstancesRequest.getMinCount();
int initialInstanceMaxCount = runInstancesRequest.getMaxCount();
try {
int tryCount = 1;
List<Instance> result = ec2.runInstances(runInstancesRequest).getReservation().getInstances();
result = AmazonAwsUtils.awaitForEc2Instances(result, ec2);
//Check for instances state
while (result.size() < initialInstanceMinCount && tryCount < 3) {
runInstancesRequest.setMinCount(initialInstanceMinCount - result.size());
runInstancesRequest.setMaxCount(initialInstanceMinCount - result.size());
List<Instance> instances = ec2.runInstances(runInstancesRequest).getReservation().getInstances();
instances = AmazonAwsUtils.awaitForEc2Instances(instances, ec2);
result.addAll(instances);
tryCount++;
}
//Check for SSH availability
for (Iterator<Instance> itInstance = result.iterator(); itInstance.hasNext(); ) {
Instance instance = itInstance.next();
try { | // Path: src/main/java/fr/xebia/workshop/monitoring/InfrastructureCreationStep.java
// public abstract class InfrastructureCreationStep {
//
// protected final Logger logger = LoggerFactory.getLogger(getClass());
//
// public static final String NAGIOS_IMAGE_ID = "ami-ff1a278b";
// public static final String GRAPHITE_IMAGE_ID = "ami-e51d2091";
//
// public abstract void execute(AmazonEC2 ec2, WorkshopInfrastructure workshopInfrastructure) throws Exception;
//
// protected void createTags(Instance instance, CreateTagsRequest createTagsRequest, AmazonEC2 ec2) {
// // "AWS Error Code: InvalidInstanceID.NotFound, AWS Error Message: The instance ID 'i-d1638198' does not exist"
// AmazonAwsUtils.awaitForEc2Instance(instance, ec2);
//
// try {
// ec2.createTags(createTagsRequest);
// } catch (AmazonServiceException e) {
// // retries 5s later
// try {
// Thread.sleep(5 * 1000);
// } catch (InterruptedException e1) {
// e1.printStackTrace();
// }
// ec2.createTags(createTagsRequest);
// }
// }
//
// }
// Path: src/main/java/fr/xebia/cloud/amazon/aws/tools/AmazonAwsUtils.java
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.*;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import com.amazonaws.AmazonServiceException;
import com.amazonaws.services.ec2.model.*;
import com.amazonaws.services.ec2.model.Instance;
import com.amazonaws.services.elasticbeanstalk.AWSElasticBeanstalk;
import com.amazonaws.services.elasticbeanstalk.model.*;
import com.amazonaws.services.route53.AmazonRoute53;
import com.amazonaws.services.route53.model.*;
import com.google.common.collect.*;
import fr.xebia.workshop.monitoring.InfrastructureCreationStep;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.auth.PropertiesCredentials;
import com.amazonaws.services.ec2.AmazonEC2;
import com.amazonaws.services.rds.AmazonRDS;
import com.amazonaws.services.rds.model.DBInstance;
import com.amazonaws.services.rds.model.DBInstanceNotFoundException;
import com.amazonaws.services.rds.model.DescribeDBInstancesRequest;
import com.amazonaws.services.rds.model.DescribeDBInstancesResult;
import com.google.common.base.Function;
import com.google.common.base.Joiner;
import com.google.common.base.Preconditions;
import com.google.common.base.Predicate;
import com.google.common.base.Throwables;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.Session;
/*
* Copyright 2008-2010 Xebia and the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package fr.xebia.cloud.amazon.aws.tools;
public class AmazonAwsUtils {
/**
* private constructor for utils class.
*/
private AmazonAwsUtils() {
}
/**
* <p>
* Create EC2 instances and ensure these instances are successfully started.
* </p>
* <p>
* Successfully started means they reached the
* {@link InstanceStateName#Running} state.
* </p>
* <p>
* If the startup of an instance failed (e.g.
* "Server.InternalError: Internal error on launch"), the instance is
* terminated and another one is launched.
* </p>
* <p>
* Max retry count: 3.
* </p>
*
* @param runInstancesRequest
* @param ec2
* @return list of "Running" created instances. List size is greater or
* equals to given {@link RunInstancesRequest#getMinCount()}
*/
@Nonnull
public static List<Instance> reliableEc2RunInstances(@Nonnull RunInstancesRequest runInstancesRequest, @Nonnull AmazonEC2 ec2) {
int initialInstanceMinCount = runInstancesRequest.getMinCount();
int initialInstanceMaxCount = runInstancesRequest.getMaxCount();
try {
int tryCount = 1;
List<Instance> result = ec2.runInstances(runInstancesRequest).getReservation().getInstances();
result = AmazonAwsUtils.awaitForEc2Instances(result, ec2);
//Check for instances state
while (result.size() < initialInstanceMinCount && tryCount < 3) {
runInstancesRequest.setMinCount(initialInstanceMinCount - result.size());
runInstancesRequest.setMaxCount(initialInstanceMinCount - result.size());
List<Instance> instances = ec2.runInstances(runInstancesRequest).getReservation().getInstances();
instances = AmazonAwsUtils.awaitForEc2Instances(instances, ec2);
result.addAll(instances);
tryCount++;
}
//Check for SSH availability
for (Iterator<Instance> itInstance = result.iterator(); itInstance.hasNext(); ) {
Instance instance = itInstance.next();
try { | if (instance.getImageId().equals(InfrastructureCreationStep.GRAPHITE_IMAGE_ID)) { |
xebia-france/xebia-cloudcomputing-extras | src/main/java/fr/xebia/workshop/monitoring/DocumentationGenerator.java | // Path: src/main/java/fr/xebia/cloud/cloudinit/FreemarkerUtils.java
// public class FreemarkerUtils {
//
// /**
// *
// * @param rootMap
// * root node of the freemarker datamodel.
// * @param templatePath
// * classpath classpath path of the template (e.g. "/my-template.ftl")
// * @return generated file
// */
// @SuppressWarnings("unchecked")
// @Nonnull
// public static String generate(@Nullable Map<String, ? extends Object> rootMap, @Nonnull String templatePath) {
// Preconditions.checkNotNull(templatePath, "'templatePath' can NOT be null");
// rootMap = (Map<String, Object>) Objects.firstNonNull(rootMap, Collections.emptyMap());
//
// try {
// Configuration cfg = new Configuration();
// cfg.setClassForTemplateLoading(FreemarkerUtils.class, "/");
//
// Template template = cfg.getTemplate(templatePath);
// Writer out = new StringWriter();
// template.process(rootMap, out);
// return out.toString();
// } catch (IOException e) {
// throw Throwables.propagate(e);
// } catch (TemplateException e) {
// throw Throwables.propagate(e);
// }
// }
//
// }
| import com.google.common.base.Charsets;
import com.google.common.base.Joiner;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.io.Files;
import fr.xebia.cloud.cloudinit.FreemarkerUtils;
import org.joda.time.DateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.*; | /*
* Copyright 2008-2010 Xebia and the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package fr.xebia.workshop.monitoring;
public class DocumentationGenerator {
private static final Logger logger = LoggerFactory.getLogger(DocumentationGenerator.class);
private static final String TEMPLATE_ROOT_PATH = "/fr/xebia/workshop/monitoring/lab/";
private static final List<String> TEMPLATE_LAB_NAMES = Arrays.asList(
"architecture");
public void generateDocs(Collection<TeamInfrastructure> teamsInfrastructures, String baseWikiFolder) throws IOException {
File wikiBaseFolder = new File(baseWikiFolder);
if (wikiBaseFolder.exists()) {
logger.debug("Delete wiki folder {}", wikiBaseFolder);
wikiBaseFolder.delete();
}
wikiBaseFolder.mkdirs();
List<String> generatedWikiPageNames = Lists.newArrayList();
List<String> setupGeneratedWikiPageNames = Lists.newArrayList();
HashMap<TeamInfrastructure, List<String>> teamsPages = Maps.newHashMap();
for (TeamInfrastructure infrastructure : teamsInfrastructures) {
List<String> generatedForTeam = Lists.newArrayList();
for (String template : TEMPLATE_LAB_NAMES) {
try {
Map<String, Object> rootMap = Maps.newHashMap();
rootMap.put("infrastructure", infrastructure);
String templatePath = TEMPLATE_ROOT_PATH + template + ".ftl";
rootMap.put("generator", "This page has been generaterd by '{{{" + getClass() + "}}}' with template '{{{" + templatePath + "}}}' on the "
+ new DateTime()); | // Path: src/main/java/fr/xebia/cloud/cloudinit/FreemarkerUtils.java
// public class FreemarkerUtils {
//
// /**
// *
// * @param rootMap
// * root node of the freemarker datamodel.
// * @param templatePath
// * classpath classpath path of the template (e.g. "/my-template.ftl")
// * @return generated file
// */
// @SuppressWarnings("unchecked")
// @Nonnull
// public static String generate(@Nullable Map<String, ? extends Object> rootMap, @Nonnull String templatePath) {
// Preconditions.checkNotNull(templatePath, "'templatePath' can NOT be null");
// rootMap = (Map<String, Object>) Objects.firstNonNull(rootMap, Collections.emptyMap());
//
// try {
// Configuration cfg = new Configuration();
// cfg.setClassForTemplateLoading(FreemarkerUtils.class, "/");
//
// Template template = cfg.getTemplate(templatePath);
// Writer out = new StringWriter();
// template.process(rootMap, out);
// return out.toString();
// } catch (IOException e) {
// throw Throwables.propagate(e);
// } catch (TemplateException e) {
// throw Throwables.propagate(e);
// }
// }
//
// }
// Path: src/main/java/fr/xebia/workshop/monitoring/DocumentationGenerator.java
import com.google.common.base.Charsets;
import com.google.common.base.Joiner;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.io.Files;
import fr.xebia.cloud.cloudinit.FreemarkerUtils;
import org.joda.time.DateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.*;
/*
* Copyright 2008-2010 Xebia and the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package fr.xebia.workshop.monitoring;
public class DocumentationGenerator {
private static final Logger logger = LoggerFactory.getLogger(DocumentationGenerator.class);
private static final String TEMPLATE_ROOT_PATH = "/fr/xebia/workshop/monitoring/lab/";
private static final List<String> TEMPLATE_LAB_NAMES = Arrays.asList(
"architecture");
public void generateDocs(Collection<TeamInfrastructure> teamsInfrastructures, String baseWikiFolder) throws IOException {
File wikiBaseFolder = new File(baseWikiFolder);
if (wikiBaseFolder.exists()) {
logger.debug("Delete wiki folder {}", wikiBaseFolder);
wikiBaseFolder.delete();
}
wikiBaseFolder.mkdirs();
List<String> generatedWikiPageNames = Lists.newArrayList();
List<String> setupGeneratedWikiPageNames = Lists.newArrayList();
HashMap<TeamInfrastructure, List<String>> teamsPages = Maps.newHashMap();
for (TeamInfrastructure infrastructure : teamsInfrastructures) {
List<String> generatedForTeam = Lists.newArrayList();
for (String template : TEMPLATE_LAB_NAMES) {
try {
Map<String, Object> rootMap = Maps.newHashMap();
rootMap.put("infrastructure", infrastructure);
String templatePath = TEMPLATE_ROOT_PATH + template + ".ftl";
rootMap.put("generator", "This page has been generaterd by '{{{" + getClass() + "}}}' with template '{{{" + templatePath + "}}}' on the "
+ new DateTime()); | String page = FreemarkerUtils.generate(rootMap, templatePath); |
xebia-france/xebia-cloudcomputing-extras | src/main/java/fr/xebia/workshop/continuousdelivery/PetclinicJenkinsJobCreator.java | // Path: src/main/java/fr/xebia/cloud/cloudinit/FreemarkerUtils.java
// public class FreemarkerUtils {
//
// /**
// *
// * @param rootMap
// * root node of the freemarker datamodel.
// * @param templatePath
// * classpath classpath path of the template (e.g. "/my-template.ftl")
// * @return generated file
// */
// @SuppressWarnings("unchecked")
// @Nonnull
// public static String generate(@Nullable Map<String, ? extends Object> rootMap, @Nonnull String templatePath) {
// Preconditions.checkNotNull(templatePath, "'templatePath' can NOT be null");
// rootMap = (Map<String, Object>) Objects.firstNonNull(rootMap, Collections.emptyMap());
//
// try {
// Configuration cfg = new Configuration();
// cfg.setClassForTemplateLoading(FreemarkerUtils.class, "/");
//
// Template template = cfg.getTemplate(templatePath);
// Writer out = new StringWriter();
// template.process(rootMap, out);
// return out.toString();
// } catch (IOException e) {
// throw Throwables.propagate(e);
// } catch (TemplateException e) {
// throw Throwables.propagate(e);
// }
// }
//
// }
| import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.xebia.cloud.cloudinit.FreemarkerUtils;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.Maps.newHashMap;
import static com.google.common.collect.Sets.newHashSet;
import java.io.UnsupportedEncodingException;
import java.util.Map;
import javax.annotation.Nonnull;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost; | /*
* Copyright 2008-2010 Xebia and the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package fr.xebia.workshop.continuousdelivery;
/**
* Creates a job in a Jenkins server for a "Petclinic" project hosted on Github.
*
* Example:
*
* <pre>
* new PetclinicJenkinsJobCreator("http://ec2-46-137-62-232.eu-west-1.compute.amazonaws.com:8080").create(new PetclinicProjectInstance("xebia-guest", "42"))
* .triggerBuild();
* </pre>
*/
public class PetclinicJenkinsJobCreator {
private static final Logger logger = LoggerFactory.getLogger(PetclinicJenkinsJobCreator.class);
private final String jenkinsUrl;
public PetclinicJenkinsJobCreator(@Nonnull String jenkinsUrl) {
this.jenkinsUrl = checkNotNull(jenkinsUrl);
checkArgument(jenkinsUrl.startsWith("http://"), "Invalid URL provided for Jenkins server: " + jenkinsUrl);
}
public PostCreationActions create(@Nonnull PetclinicJobInstance project) {
checkNotNull(project);
HttpPost post = new HttpPost(jenkinsUrl + "/createItem?name=" + project.getProjectName());
Map<String, Object> parameters = newHashMap();
parameters.put("githubAccountName", project.getGithubAccountName());
parameters.put("projectName", project.getProjectName());
parameters.put("groupId", project.getGroupId());
parameters.put("artifactId", project.getArtifactId()); | // Path: src/main/java/fr/xebia/cloud/cloudinit/FreemarkerUtils.java
// public class FreemarkerUtils {
//
// /**
// *
// * @param rootMap
// * root node of the freemarker datamodel.
// * @param templatePath
// * classpath classpath path of the template (e.g. "/my-template.ftl")
// * @return generated file
// */
// @SuppressWarnings("unchecked")
// @Nonnull
// public static String generate(@Nullable Map<String, ? extends Object> rootMap, @Nonnull String templatePath) {
// Preconditions.checkNotNull(templatePath, "'templatePath' can NOT be null");
// rootMap = (Map<String, Object>) Objects.firstNonNull(rootMap, Collections.emptyMap());
//
// try {
// Configuration cfg = new Configuration();
// cfg.setClassForTemplateLoading(FreemarkerUtils.class, "/");
//
// Template template = cfg.getTemplate(templatePath);
// Writer out = new StringWriter();
// template.process(rootMap, out);
// return out.toString();
// } catch (IOException e) {
// throw Throwables.propagate(e);
// } catch (TemplateException e) {
// throw Throwables.propagate(e);
// }
// }
//
// }
// Path: src/main/java/fr/xebia/workshop/continuousdelivery/PetclinicJenkinsJobCreator.java
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.xebia.cloud.cloudinit.FreemarkerUtils;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.Maps.newHashMap;
import static com.google.common.collect.Sets.newHashSet;
import java.io.UnsupportedEncodingException;
import java.util.Map;
import javax.annotation.Nonnull;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
/*
* Copyright 2008-2010 Xebia and the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package fr.xebia.workshop.continuousdelivery;
/**
* Creates a job in a Jenkins server for a "Petclinic" project hosted on Github.
*
* Example:
*
* <pre>
* new PetclinicJenkinsJobCreator("http://ec2-46-137-62-232.eu-west-1.compute.amazonaws.com:8080").create(new PetclinicProjectInstance("xebia-guest", "42"))
* .triggerBuild();
* </pre>
*/
public class PetclinicJenkinsJobCreator {
private static final Logger logger = LoggerFactory.getLogger(PetclinicJenkinsJobCreator.class);
private final String jenkinsUrl;
public PetclinicJenkinsJobCreator(@Nonnull String jenkinsUrl) {
this.jenkinsUrl = checkNotNull(jenkinsUrl);
checkArgument(jenkinsUrl.startsWith("http://"), "Invalid URL provided for Jenkins server: " + jenkinsUrl);
}
public PostCreationActions create(@Nonnull PetclinicJobInstance project) {
checkNotNull(project);
HttpPost post = new HttpPost(jenkinsUrl + "/createItem?name=" + project.getProjectName());
Map<String, Object> parameters = newHashMap();
parameters.put("githubAccountName", project.getGithubAccountName());
parameters.put("projectName", project.getProjectName());
parameters.put("groupId", project.getGroupId());
parameters.put("artifactId", project.getArtifactId()); | String jobConfig = FreemarkerUtils.generate(parameters, "/fr/xebia/workshop/continuousdelivery/petclinic-jenkins-job-config.xml.ftl"); |
pashna/XSS-scanner | src/main/java/xss/Tasks/StoredXssChecker.java | // Path: src/main/java/xss/LinkContainer/XssContainer.java
// public class XssContainer extends LinkedHashSet<XssStruct> {
//
// XssContainerCallback callback;
//
// @Override
// public boolean add(XssStruct xssStruct) {
// boolean wasAdded = super.add(xssStruct);
// if (wasAdded)
// if (callback != null)
// callback.onXssAdded(xssStruct);
// return wasAdded;
// }
//
// public void setCallback(XssContainerCallback callback) {
// this.callback = callback;
// }
//
// public interface XssContainerCallback {
// public void onXssAdded(XssStruct xssStruct);
// }
// }
//
// Path: src/main/java/xss/LinkContainer/XssStruct.java
// public class XssStruct {
// static public int REFLECTED = 1;
// static public int STORED = 2;
//
// public String url;
// public String xss;
// public int form;
// public int type;
//
// public XssStruct(String url, String xss, int type) {
// this(url, xss, type, -1);
// }
//
// public XssStruct(String url, String xss, int type, int form) {
// this.xss = xss;
// this.url = url;
// this.form = form;
// this.type = type;
// }
//
// }
| import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.WebElement;
import xss.LinkContainer.XssContainer;
import xss.LinkContainer.XssStruct;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit; | " if (input[i].type == undefined || input[i].type.toLowerCase() == \"text\") {\n" +
" array.push(input[i]);\n" +
" }\n" +
"}\n" +
"\n" +
"var textArea = document.forms[0].getElementsByTagName('textarea');\n" +
"for (var i=0; i<textArea.length; i++) \n" +
" array.push(textArea[i]) \n" +
"return array.length";
private final String INPUT_NUMBER = "INPUT";
private final String FILL_INPUT_INSIDE_FORM =
"var input = document.forms["+FORM_NUMBER_TO_REPLACE+"].getElementsByTagName('input')\n" +
"var array = new Array();\n" +
"for (var i=0; i<input.length; i++) {\n" +
" if (input[i].type == undefined || input[i].type.toLowerCase() == \"text\") {\n" +
" array.push(input[i]);\n" +
" }\n" +
"}\n" +
"\n" +
"var textArea = document.forms[0].getElementsByTagName('textarea');\n" +
"for (var i=0; i<textArea.length; i++) \n" +
" array.push(textArea[i]) \n" +
"array[" + INPUT_NUMBER + "].value = ' " +TEXT_TO_REPLACE +"';\n";
private String SUBMIT_FORM = "document.forms[" + FORM_NUMBER_TO_REPLACE +"].querySelector(\"[type=submit]\").click()";
private ArrayList<String> xssArrayList; | // Path: src/main/java/xss/LinkContainer/XssContainer.java
// public class XssContainer extends LinkedHashSet<XssStruct> {
//
// XssContainerCallback callback;
//
// @Override
// public boolean add(XssStruct xssStruct) {
// boolean wasAdded = super.add(xssStruct);
// if (wasAdded)
// if (callback != null)
// callback.onXssAdded(xssStruct);
// return wasAdded;
// }
//
// public void setCallback(XssContainerCallback callback) {
// this.callback = callback;
// }
//
// public interface XssContainerCallback {
// public void onXssAdded(XssStruct xssStruct);
// }
// }
//
// Path: src/main/java/xss/LinkContainer/XssStruct.java
// public class XssStruct {
// static public int REFLECTED = 1;
// static public int STORED = 2;
//
// public String url;
// public String xss;
// public int form;
// public int type;
//
// public XssStruct(String url, String xss, int type) {
// this(url, xss, type, -1);
// }
//
// public XssStruct(String url, String xss, int type, int form) {
// this.xss = xss;
// this.url = url;
// this.form = form;
// this.type = type;
// }
//
// }
// Path: src/main/java/xss/Tasks/StoredXssChecker.java
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.WebElement;
import xss.LinkContainer.XssContainer;
import xss.LinkContainer.XssStruct;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
" if (input[i].type == undefined || input[i].type.toLowerCase() == \"text\") {\n" +
" array.push(input[i]);\n" +
" }\n" +
"}\n" +
"\n" +
"var textArea = document.forms[0].getElementsByTagName('textarea');\n" +
"for (var i=0; i<textArea.length; i++) \n" +
" array.push(textArea[i]) \n" +
"return array.length";
private final String INPUT_NUMBER = "INPUT";
private final String FILL_INPUT_INSIDE_FORM =
"var input = document.forms["+FORM_NUMBER_TO_REPLACE+"].getElementsByTagName('input')\n" +
"var array = new Array();\n" +
"for (var i=0; i<input.length; i++) {\n" +
" if (input[i].type == undefined || input[i].type.toLowerCase() == \"text\") {\n" +
" array.push(input[i]);\n" +
" }\n" +
"}\n" +
"\n" +
"var textArea = document.forms[0].getElementsByTagName('textarea');\n" +
"for (var i=0; i<textArea.length; i++) \n" +
" array.push(textArea[i]) \n" +
"array[" + INPUT_NUMBER + "].value = ' " +TEXT_TO_REPLACE +"';\n";
private String SUBMIT_FORM = "document.forms[" + FORM_NUMBER_TO_REPLACE +"].querySelector(\"[type=submit]\").click()";
private ArrayList<String> xssArrayList; | private XssContainer xssContainer; |
pashna/XSS-scanner | src/main/java/xss/Tasks/StoredXssChecker.java | // Path: src/main/java/xss/LinkContainer/XssContainer.java
// public class XssContainer extends LinkedHashSet<XssStruct> {
//
// XssContainerCallback callback;
//
// @Override
// public boolean add(XssStruct xssStruct) {
// boolean wasAdded = super.add(xssStruct);
// if (wasAdded)
// if (callback != null)
// callback.onXssAdded(xssStruct);
// return wasAdded;
// }
//
// public void setCallback(XssContainerCallback callback) {
// this.callback = callback;
// }
//
// public interface XssContainerCallback {
// public void onXssAdded(XssStruct xssStruct);
// }
// }
//
// Path: src/main/java/xss/LinkContainer/XssStruct.java
// public class XssStruct {
// static public int REFLECTED = 1;
// static public int STORED = 2;
//
// public String url;
// public String xss;
// public int form;
// public int type;
//
// public XssStruct(String url, String xss, int type) {
// this(url, xss, type, -1);
// }
//
// public XssStruct(String url, String xss, int type, int form) {
// this.xss = xss;
// this.url = url;
// this.form = form;
// this.type = type;
// }
//
// }
| import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.WebElement;
import xss.LinkContainer.XssContainer;
import xss.LinkContainer.XssStruct;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit; |
private ArrayList<String> xssArrayList;
private XssContainer xssContainer;
public StoredXssChecker(String url, int formNumber, ArrayList<String> xssArrayList, XssContainer xssContainer) {
this.url = url;
this.formNumber = formNumber;
this.xssArrayList = xssArrayList;
this.xssContainer = xssContainer;
SUBMIT_FORM = SUBMIT_FORM.replace(FORM_NUMBER_TO_REPLACE, formNumber + "");
}
@Override
public void run() {
long inputCount = getCountOfInputInsideForm();
for (int i=0; i<inputCount; i++) {
for (String xss : xssArrayList) {
getWebDriver().navigate().to(url);
getWebDriver().manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS); // Ждем загрузки
fillAllForm("randomText");
fillInputInsideForm(i, xss);
submitForm();
getWebDriver().manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS); // Ждем загрузки
if (wasScriptExecuted()) {
synchronized (xssContainer) { | // Path: src/main/java/xss/LinkContainer/XssContainer.java
// public class XssContainer extends LinkedHashSet<XssStruct> {
//
// XssContainerCallback callback;
//
// @Override
// public boolean add(XssStruct xssStruct) {
// boolean wasAdded = super.add(xssStruct);
// if (wasAdded)
// if (callback != null)
// callback.onXssAdded(xssStruct);
// return wasAdded;
// }
//
// public void setCallback(XssContainerCallback callback) {
// this.callback = callback;
// }
//
// public interface XssContainerCallback {
// public void onXssAdded(XssStruct xssStruct);
// }
// }
//
// Path: src/main/java/xss/LinkContainer/XssStruct.java
// public class XssStruct {
// static public int REFLECTED = 1;
// static public int STORED = 2;
//
// public String url;
// public String xss;
// public int form;
// public int type;
//
// public XssStruct(String url, String xss, int type) {
// this(url, xss, type, -1);
// }
//
// public XssStruct(String url, String xss, int type, int form) {
// this.xss = xss;
// this.url = url;
// this.form = form;
// this.type = type;
// }
//
// }
// Path: src/main/java/xss/Tasks/StoredXssChecker.java
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.WebElement;
import xss.LinkContainer.XssContainer;
import xss.LinkContainer.XssStruct;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
private ArrayList<String> xssArrayList;
private XssContainer xssContainer;
public StoredXssChecker(String url, int formNumber, ArrayList<String> xssArrayList, XssContainer xssContainer) {
this.url = url;
this.formNumber = formNumber;
this.xssArrayList = xssArrayList;
this.xssContainer = xssContainer;
SUBMIT_FORM = SUBMIT_FORM.replace(FORM_NUMBER_TO_REPLACE, formNumber + "");
}
@Override
public void run() {
long inputCount = getCountOfInputInsideForm();
for (int i=0; i<inputCount; i++) {
for (String xss : xssArrayList) {
getWebDriver().navigate().to(url);
getWebDriver().manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS); // Ждем загрузки
fillAllForm("randomText");
fillInputInsideForm(i, xss);
submitForm();
getWebDriver().manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS); // Ждем загрузки
if (wasScriptExecuted()) {
synchronized (xssContainer) { | xssContainer.add(new XssStruct(url, xss, XssStruct.STORED, formNumber)); |
pashna/XSS-scanner | src/main/java/xss/Tasks/LinkFinder.java | // Path: src/main/java/xss/LinkContainer/LinkContainer.java
// public class LinkContainer extends LinkedHashSet<String> {
//
// LinkContainerCallback callback;
//
// public LinkContainer() {
// }
//
// @Override
// public boolean add(String url) {
// url = url.toLowerCase();
// boolean wasAdded = super.add(url);
// if (wasAdded)
// if (callback != null)
// callback.onLinkAdded(url);
// return wasAdded;
// }
//
// public void setCallback(LinkContainerCallback callback) {
// this.callback = callback;
// }
//
// public interface LinkContainerCallback {
// public void onLinkAdded(String url);
// }
// }
| import org.openqa.selenium.JavascriptExecutor;
import xss.LinkContainer.LinkContainer;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern; | package xss.Tasks;
/**
* Created by popka on 22.03.15.
*/
public class LinkFinder extends BrowserRunnable {
final private String LINK_TAG = "a";
final private String HREF = "HREF";
private String url; | // Path: src/main/java/xss/LinkContainer/LinkContainer.java
// public class LinkContainer extends LinkedHashSet<String> {
//
// LinkContainerCallback callback;
//
// public LinkContainer() {
// }
//
// @Override
// public boolean add(String url) {
// url = url.toLowerCase();
// boolean wasAdded = super.add(url);
// if (wasAdded)
// if (callback != null)
// callback.onLinkAdded(url);
// return wasAdded;
// }
//
// public void setCallback(LinkContainerCallback callback) {
// this.callback = callback;
// }
//
// public interface LinkContainerCallback {
// public void onLinkAdded(String url);
// }
// }
// Path: src/main/java/xss/Tasks/LinkFinder.java
import org.openqa.selenium.JavascriptExecutor;
import xss.LinkContainer.LinkContainer;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
package xss.Tasks;
/**
* Created by popka on 22.03.15.
*/
public class LinkFinder extends BrowserRunnable {
final private String LINK_TAG = "a";
final private String HREF = "HREF";
private String url; | private LinkContainer linkContainer; |
pashna/XSS-scanner | src/main/java/xss/Tasks/ReflectXssChecker.java | // Path: src/main/java/xss/LinkContainer/XssContainer.java
// public class XssContainer extends LinkedHashSet<XssStruct> {
//
// XssContainerCallback callback;
//
// @Override
// public boolean add(XssStruct xssStruct) {
// boolean wasAdded = super.add(xssStruct);
// if (wasAdded)
// if (callback != null)
// callback.onXssAdded(xssStruct);
// return wasAdded;
// }
//
// public void setCallback(XssContainerCallback callback) {
// this.callback = callback;
// }
//
// public interface XssContainerCallback {
// public void onXssAdded(XssStruct xssStruct);
// }
// }
//
// Path: src/main/java/xss/LinkContainer/XssStruct.java
// public class XssStruct {
// static public int REFLECTED = 1;
// static public int STORED = 2;
//
// public String url;
// public String xss;
// public int form;
// public int type;
//
// public XssStruct(String url, String xss, int type) {
// this(url, xss, type, -1);
// }
//
// public XssStruct(String url, String xss, int type, int form) {
// this.xss = xss;
// this.url = url;
// this.form = form;
// this.type = type;
// }
//
// }
| import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.TimeoutException;
import org.openqa.selenium.WebDriverException;
import xss.LinkContainer.XssContainer;
import xss.LinkContainer.XssStruct;
import java.util.ArrayList;
import java.util.concurrent.TimeUnit; | package xss.Tasks;
/**
* Created by popka on 03.04.15.
*/
public class ReflectXssChecker extends BrowserRunnable{
private String url;
private ArrayList<String> xssArrayList; | // Path: src/main/java/xss/LinkContainer/XssContainer.java
// public class XssContainer extends LinkedHashSet<XssStruct> {
//
// XssContainerCallback callback;
//
// @Override
// public boolean add(XssStruct xssStruct) {
// boolean wasAdded = super.add(xssStruct);
// if (wasAdded)
// if (callback != null)
// callback.onXssAdded(xssStruct);
// return wasAdded;
// }
//
// public void setCallback(XssContainerCallback callback) {
// this.callback = callback;
// }
//
// public interface XssContainerCallback {
// public void onXssAdded(XssStruct xssStruct);
// }
// }
//
// Path: src/main/java/xss/LinkContainer/XssStruct.java
// public class XssStruct {
// static public int REFLECTED = 1;
// static public int STORED = 2;
//
// public String url;
// public String xss;
// public int form;
// public int type;
//
// public XssStruct(String url, String xss, int type) {
// this(url, xss, type, -1);
// }
//
// public XssStruct(String url, String xss, int type, int form) {
// this.xss = xss;
// this.url = url;
// this.form = form;
// this.type = type;
// }
//
// }
// Path: src/main/java/xss/Tasks/ReflectXssChecker.java
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.TimeoutException;
import org.openqa.selenium.WebDriverException;
import xss.LinkContainer.XssContainer;
import xss.LinkContainer.XssStruct;
import java.util.ArrayList;
import java.util.concurrent.TimeUnit;
package xss.Tasks;
/**
* Created by popka on 03.04.15.
*/
public class ReflectXssChecker extends BrowserRunnable{
private String url;
private ArrayList<String> xssArrayList; | private XssContainer xssContainer; |
pashna/XSS-scanner | src/main/java/xss/Tasks/ReflectXssChecker.java | // Path: src/main/java/xss/LinkContainer/XssContainer.java
// public class XssContainer extends LinkedHashSet<XssStruct> {
//
// XssContainerCallback callback;
//
// @Override
// public boolean add(XssStruct xssStruct) {
// boolean wasAdded = super.add(xssStruct);
// if (wasAdded)
// if (callback != null)
// callback.onXssAdded(xssStruct);
// return wasAdded;
// }
//
// public void setCallback(XssContainerCallback callback) {
// this.callback = callback;
// }
//
// public interface XssContainerCallback {
// public void onXssAdded(XssStruct xssStruct);
// }
// }
//
// Path: src/main/java/xss/LinkContainer/XssStruct.java
// public class XssStruct {
// static public int REFLECTED = 1;
// static public int STORED = 2;
//
// public String url;
// public String xss;
// public int form;
// public int type;
//
// public XssStruct(String url, String xss, int type) {
// this(url, xss, type, -1);
// }
//
// public XssStruct(String url, String xss, int type, int form) {
// this.xss = xss;
// this.url = url;
// this.form = form;
// this.type = type;
// }
//
// }
| import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.TimeoutException;
import org.openqa.selenium.WebDriverException;
import xss.LinkContainer.XssContainer;
import xss.LinkContainer.XssStruct;
import java.util.ArrayList;
import java.util.concurrent.TimeUnit; | package xss.Tasks;
/**
* Created by popka on 03.04.15.
*/
public class ReflectXssChecker extends BrowserRunnable{
private String url;
private ArrayList<String> xssArrayList;
private XssContainer xssContainer;
public ReflectXssChecker(String url, ArrayList<String> xssArrayList, XssContainer xssContainer) {
this.url = url;
this.xssArrayList = xssArrayList;
this.xssContainer = xssContainer;
}
@Override
public void run() {
System.out.println("Проверяем урл " + url + " на ReflectedXSS");
for (String xss : xssArrayList) {
String urlWithXss = url.replaceAll(XssPreparer.INPUT_VALUE, xss); // Заменяем INPUT_VALUE на XSS
try {
getWebDriver().navigate().to(urlWithXss);
getWebDriver().manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS); // Ждем загрузки
if (wasScriptExecuted()) {
synchronized (xssContainer) { | // Path: src/main/java/xss/LinkContainer/XssContainer.java
// public class XssContainer extends LinkedHashSet<XssStruct> {
//
// XssContainerCallback callback;
//
// @Override
// public boolean add(XssStruct xssStruct) {
// boolean wasAdded = super.add(xssStruct);
// if (wasAdded)
// if (callback != null)
// callback.onXssAdded(xssStruct);
// return wasAdded;
// }
//
// public void setCallback(XssContainerCallback callback) {
// this.callback = callback;
// }
//
// public interface XssContainerCallback {
// public void onXssAdded(XssStruct xssStruct);
// }
// }
//
// Path: src/main/java/xss/LinkContainer/XssStruct.java
// public class XssStruct {
// static public int REFLECTED = 1;
// static public int STORED = 2;
//
// public String url;
// public String xss;
// public int form;
// public int type;
//
// public XssStruct(String url, String xss, int type) {
// this(url, xss, type, -1);
// }
//
// public XssStruct(String url, String xss, int type, int form) {
// this.xss = xss;
// this.url = url;
// this.form = form;
// this.type = type;
// }
//
// }
// Path: src/main/java/xss/Tasks/ReflectXssChecker.java
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.TimeoutException;
import org.openqa.selenium.WebDriverException;
import xss.LinkContainer.XssContainer;
import xss.LinkContainer.XssStruct;
import java.util.ArrayList;
import java.util.concurrent.TimeUnit;
package xss.Tasks;
/**
* Created by popka on 03.04.15.
*/
public class ReflectXssChecker extends BrowserRunnable{
private String url;
private ArrayList<String> xssArrayList;
private XssContainer xssContainer;
public ReflectXssChecker(String url, ArrayList<String> xssArrayList, XssContainer xssContainer) {
this.url = url;
this.xssArrayList = xssArrayList;
this.xssContainer = xssContainer;
}
@Override
public void run() {
System.out.println("Проверяем урл " + url + " на ReflectedXSS");
for (String xss : xssArrayList) {
String urlWithXss = url.replaceAll(XssPreparer.INPUT_VALUE, xss); // Заменяем INPUT_VALUE на XSS
try {
getWebDriver().navigate().to(urlWithXss);
getWebDriver().manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS); // Ждем загрузки
if (wasScriptExecuted()) {
synchronized (xssContainer) { | xssContainer.add(new XssStruct(url, xss, XssStruct.REFLECTED)); |
pashna/XSS-scanner | src/main/java/xss/Tasks/XssPreparer.java | // Path: src/main/java/xss/LinkContainer/LinkContainer.java
// public class LinkContainer extends LinkedHashSet<String> {
//
// LinkContainerCallback callback;
//
// public LinkContainer() {
// }
//
// @Override
// public boolean add(String url) {
// url = url.toLowerCase();
// boolean wasAdded = super.add(url);
// if (wasAdded)
// if (callback != null)
// callback.onLinkAdded(url);
// return wasAdded;
// }
//
// public void setCallback(LinkContainerCallback callback) {
// this.callback = callback;
// }
//
// public interface LinkContainerCallback {
// public void onLinkAdded(String url);
// }
// }
//
// Path: src/main/java/xss/LinkContainer/XssStoredContainer.java
// public class XssStoredContainer extends LinkedHashSet<XssStored> {
//
// XssContainerCallback callback;
//
// public XssStoredContainer() {
// }
//
// @Override
// public boolean add(XssStored xssStored) {
// xssStored.url = xssStored.url.toLowerCase();
// boolean wasAdded = super.add(xssStored);
// if (wasAdded)
// callback.onLinkAdded(xssStored);
// return wasAdded;
// }
//
// public void setCallback(XssContainerCallback callback) {
// this.callback = callback;
// }
//
// public interface XssContainerCallback {
// public void onLinkAdded(XssStored url);
// }
//
// }
//
// Path: src/main/java/xss/LinkContainer/XssStored.java
// public class XssStored {
// public String url;
// public int formNumber;
//
// public XssStored(String url, int formNumber) {
// this.url = url;
// this.formNumber = formNumber;
// }
// }
| import xss.LinkContainer.LinkContainer;
import xss.LinkContainer.XssStoredContainer;
import xss.LinkContainer.XssStored;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.WebElement;
import java.net.URLDecoder;
import java.util.List;
import java.util.concurrent.TimeUnit; | package xss.Tasks;
/**
* Created by popka on 01.04.15.
*/
/*
Заходит на заданный урл.
Поочередно заполняет и отправляет все формы.
В зависимости от результата, определяет, возможно ли на этой страничке XSS.
Если определила потенциальный ReflectXSS, то добавляем этот урл с параметрами в StoredXSS
*/
public class XssPreparer extends BrowserRunnable {
private String url;
private final String FORM = "FORM";
private final String TEXT_TO_REPLACE = "TEXT_TO_REPLACE";
public static final String INPUT_VALUE = "aaa99999xzc9999ccc"; | // Path: src/main/java/xss/LinkContainer/LinkContainer.java
// public class LinkContainer extends LinkedHashSet<String> {
//
// LinkContainerCallback callback;
//
// public LinkContainer() {
// }
//
// @Override
// public boolean add(String url) {
// url = url.toLowerCase();
// boolean wasAdded = super.add(url);
// if (wasAdded)
// if (callback != null)
// callback.onLinkAdded(url);
// return wasAdded;
// }
//
// public void setCallback(LinkContainerCallback callback) {
// this.callback = callback;
// }
//
// public interface LinkContainerCallback {
// public void onLinkAdded(String url);
// }
// }
//
// Path: src/main/java/xss/LinkContainer/XssStoredContainer.java
// public class XssStoredContainer extends LinkedHashSet<XssStored> {
//
// XssContainerCallback callback;
//
// public XssStoredContainer() {
// }
//
// @Override
// public boolean add(XssStored xssStored) {
// xssStored.url = xssStored.url.toLowerCase();
// boolean wasAdded = super.add(xssStored);
// if (wasAdded)
// callback.onLinkAdded(xssStored);
// return wasAdded;
// }
//
// public void setCallback(XssContainerCallback callback) {
// this.callback = callback;
// }
//
// public interface XssContainerCallback {
// public void onLinkAdded(XssStored url);
// }
//
// }
//
// Path: src/main/java/xss/LinkContainer/XssStored.java
// public class XssStored {
// public String url;
// public int formNumber;
//
// public XssStored(String url, int formNumber) {
// this.url = url;
// this.formNumber = formNumber;
// }
// }
// Path: src/main/java/xss/Tasks/XssPreparer.java
import xss.LinkContainer.LinkContainer;
import xss.LinkContainer.XssStoredContainer;
import xss.LinkContainer.XssStored;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.WebElement;
import java.net.URLDecoder;
import java.util.List;
import java.util.concurrent.TimeUnit;
package xss.Tasks;
/**
* Created by popka on 01.04.15.
*/
/*
Заходит на заданный урл.
Поочередно заполняет и отправляет все формы.
В зависимости от результата, определяет, возможно ли на этой страничке XSS.
Если определила потенциальный ReflectXSS, то добавляем этот урл с параметрами в StoredXSS
*/
public class XssPreparer extends BrowserRunnable {
private String url;
private final String FORM = "FORM";
private final String TEXT_TO_REPLACE = "TEXT_TO_REPLACE";
public static final String INPUT_VALUE = "aaa99999xzc9999ccc"; | private LinkContainer reflectXSSUrlContainer; |
pashna/XSS-scanner | src/main/java/xss/Tasks/XssPreparer.java | // Path: src/main/java/xss/LinkContainer/LinkContainer.java
// public class LinkContainer extends LinkedHashSet<String> {
//
// LinkContainerCallback callback;
//
// public LinkContainer() {
// }
//
// @Override
// public boolean add(String url) {
// url = url.toLowerCase();
// boolean wasAdded = super.add(url);
// if (wasAdded)
// if (callback != null)
// callback.onLinkAdded(url);
// return wasAdded;
// }
//
// public void setCallback(LinkContainerCallback callback) {
// this.callback = callback;
// }
//
// public interface LinkContainerCallback {
// public void onLinkAdded(String url);
// }
// }
//
// Path: src/main/java/xss/LinkContainer/XssStoredContainer.java
// public class XssStoredContainer extends LinkedHashSet<XssStored> {
//
// XssContainerCallback callback;
//
// public XssStoredContainer() {
// }
//
// @Override
// public boolean add(XssStored xssStored) {
// xssStored.url = xssStored.url.toLowerCase();
// boolean wasAdded = super.add(xssStored);
// if (wasAdded)
// callback.onLinkAdded(xssStored);
// return wasAdded;
// }
//
// public void setCallback(XssContainerCallback callback) {
// this.callback = callback;
// }
//
// public interface XssContainerCallback {
// public void onLinkAdded(XssStored url);
// }
//
// }
//
// Path: src/main/java/xss/LinkContainer/XssStored.java
// public class XssStored {
// public String url;
// public int formNumber;
//
// public XssStored(String url, int formNumber) {
// this.url = url;
// this.formNumber = formNumber;
// }
// }
| import xss.LinkContainer.LinkContainer;
import xss.LinkContainer.XssStoredContainer;
import xss.LinkContainer.XssStored;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.WebElement;
import java.net.URLDecoder;
import java.util.List;
import java.util.concurrent.TimeUnit; | package xss.Tasks;
/**
* Created by popka on 01.04.15.
*/
/*
Заходит на заданный урл.
Поочередно заполняет и отправляет все формы.
В зависимости от результата, определяет, возможно ли на этой страничке XSS.
Если определила потенциальный ReflectXSS, то добавляем этот урл с параметрами в StoredXSS
*/
public class XssPreparer extends BrowserRunnable {
private String url;
private final String FORM = "FORM";
private final String TEXT_TO_REPLACE = "TEXT_TO_REPLACE";
public static final String INPUT_VALUE = "aaa99999xzc9999ccc";
private LinkContainer reflectXSSUrlContainer; | // Path: src/main/java/xss/LinkContainer/LinkContainer.java
// public class LinkContainer extends LinkedHashSet<String> {
//
// LinkContainerCallback callback;
//
// public LinkContainer() {
// }
//
// @Override
// public boolean add(String url) {
// url = url.toLowerCase();
// boolean wasAdded = super.add(url);
// if (wasAdded)
// if (callback != null)
// callback.onLinkAdded(url);
// return wasAdded;
// }
//
// public void setCallback(LinkContainerCallback callback) {
// this.callback = callback;
// }
//
// public interface LinkContainerCallback {
// public void onLinkAdded(String url);
// }
// }
//
// Path: src/main/java/xss/LinkContainer/XssStoredContainer.java
// public class XssStoredContainer extends LinkedHashSet<XssStored> {
//
// XssContainerCallback callback;
//
// public XssStoredContainer() {
// }
//
// @Override
// public boolean add(XssStored xssStored) {
// xssStored.url = xssStored.url.toLowerCase();
// boolean wasAdded = super.add(xssStored);
// if (wasAdded)
// callback.onLinkAdded(xssStored);
// return wasAdded;
// }
//
// public void setCallback(XssContainerCallback callback) {
// this.callback = callback;
// }
//
// public interface XssContainerCallback {
// public void onLinkAdded(XssStored url);
// }
//
// }
//
// Path: src/main/java/xss/LinkContainer/XssStored.java
// public class XssStored {
// public String url;
// public int formNumber;
//
// public XssStored(String url, int formNumber) {
// this.url = url;
// this.formNumber = formNumber;
// }
// }
// Path: src/main/java/xss/Tasks/XssPreparer.java
import xss.LinkContainer.LinkContainer;
import xss.LinkContainer.XssStoredContainer;
import xss.LinkContainer.XssStored;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.WebElement;
import java.net.URLDecoder;
import java.util.List;
import java.util.concurrent.TimeUnit;
package xss.Tasks;
/**
* Created by popka on 01.04.15.
*/
/*
Заходит на заданный урл.
Поочередно заполняет и отправляет все формы.
В зависимости от результата, определяет, возможно ли на этой страничке XSS.
Если определила потенциальный ReflectXSS, то добавляем этот урл с параметрами в StoredXSS
*/
public class XssPreparer extends BrowserRunnable {
private String url;
private final String FORM = "FORM";
private final String TEXT_TO_REPLACE = "TEXT_TO_REPLACE";
public static final String INPUT_VALUE = "aaa99999xzc9999ccc";
private LinkContainer reflectXSSUrlContainer; | private XssStoredContainer storedXSSUrlContainer; |
pashna/XSS-scanner | src/main/java/xss/Tasks/XssPreparer.java | // Path: src/main/java/xss/LinkContainer/LinkContainer.java
// public class LinkContainer extends LinkedHashSet<String> {
//
// LinkContainerCallback callback;
//
// public LinkContainer() {
// }
//
// @Override
// public boolean add(String url) {
// url = url.toLowerCase();
// boolean wasAdded = super.add(url);
// if (wasAdded)
// if (callback != null)
// callback.onLinkAdded(url);
// return wasAdded;
// }
//
// public void setCallback(LinkContainerCallback callback) {
// this.callback = callback;
// }
//
// public interface LinkContainerCallback {
// public void onLinkAdded(String url);
// }
// }
//
// Path: src/main/java/xss/LinkContainer/XssStoredContainer.java
// public class XssStoredContainer extends LinkedHashSet<XssStored> {
//
// XssContainerCallback callback;
//
// public XssStoredContainer() {
// }
//
// @Override
// public boolean add(XssStored xssStored) {
// xssStored.url = xssStored.url.toLowerCase();
// boolean wasAdded = super.add(xssStored);
// if (wasAdded)
// callback.onLinkAdded(xssStored);
// return wasAdded;
// }
//
// public void setCallback(XssContainerCallback callback) {
// this.callback = callback;
// }
//
// public interface XssContainerCallback {
// public void onLinkAdded(XssStored url);
// }
//
// }
//
// Path: src/main/java/xss/LinkContainer/XssStored.java
// public class XssStored {
// public String url;
// public int formNumber;
//
// public XssStored(String url, int formNumber) {
// this.url = url;
// this.formNumber = formNumber;
// }
// }
| import xss.LinkContainer.LinkContainer;
import xss.LinkContainer.XssStoredContainer;
import xss.LinkContainer.XssStored;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.WebElement;
import java.net.URLDecoder;
import java.util.List;
import java.util.concurrent.TimeUnit; |
}
}
}
}
*/
// =========
if (isPageContainsInputValue()) {// если на страничке после чистки инпутов, есть слово, которое мы ввели (INPUT_VALUE), будем проверять эту страничку
String decodedUrl = URLDecoder.decode(getWebDriver().getCurrentUrl());
if (decodedUrl.contains(INPUT_VALUE)) { // Если в списке параметров есть наш ввод - все ок
if (isPageContainsInputValue()) { // если на страничке после чистки инпутов, есть слово, которое мы ввели (INPUT_VALUE), будем проверять эту страничку
System.out.println(currentUrl + " REFLECT");
synchronized (reflectXSSUrlContainer) {
reflectXSSUrlContainer.add(decodedUrl);
}
/*
Пока не оттестировано!
*/
decodedUrl = decodedUrl.substring(0, decodedUrl.indexOf("?")); // Обрезаем по аргументы и добавляем в карту сайта (вдруг там новые ссылки)
synchronized (linkContainer) {
linkContainer.add(decodedUrl);
}
}
} else {
System.out.println(currentUrl + " STORED"); | // Path: src/main/java/xss/LinkContainer/LinkContainer.java
// public class LinkContainer extends LinkedHashSet<String> {
//
// LinkContainerCallback callback;
//
// public LinkContainer() {
// }
//
// @Override
// public boolean add(String url) {
// url = url.toLowerCase();
// boolean wasAdded = super.add(url);
// if (wasAdded)
// if (callback != null)
// callback.onLinkAdded(url);
// return wasAdded;
// }
//
// public void setCallback(LinkContainerCallback callback) {
// this.callback = callback;
// }
//
// public interface LinkContainerCallback {
// public void onLinkAdded(String url);
// }
// }
//
// Path: src/main/java/xss/LinkContainer/XssStoredContainer.java
// public class XssStoredContainer extends LinkedHashSet<XssStored> {
//
// XssContainerCallback callback;
//
// public XssStoredContainer() {
// }
//
// @Override
// public boolean add(XssStored xssStored) {
// xssStored.url = xssStored.url.toLowerCase();
// boolean wasAdded = super.add(xssStored);
// if (wasAdded)
// callback.onLinkAdded(xssStored);
// return wasAdded;
// }
//
// public void setCallback(XssContainerCallback callback) {
// this.callback = callback;
// }
//
// public interface XssContainerCallback {
// public void onLinkAdded(XssStored url);
// }
//
// }
//
// Path: src/main/java/xss/LinkContainer/XssStored.java
// public class XssStored {
// public String url;
// public int formNumber;
//
// public XssStored(String url, int formNumber) {
// this.url = url;
// this.formNumber = formNumber;
// }
// }
// Path: src/main/java/xss/Tasks/XssPreparer.java
import xss.LinkContainer.LinkContainer;
import xss.LinkContainer.XssStoredContainer;
import xss.LinkContainer.XssStored;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.WebElement;
import java.net.URLDecoder;
import java.util.List;
import java.util.concurrent.TimeUnit;
}
}
}
}
*/
// =========
if (isPageContainsInputValue()) {// если на страничке после чистки инпутов, есть слово, которое мы ввели (INPUT_VALUE), будем проверять эту страничку
String decodedUrl = URLDecoder.decode(getWebDriver().getCurrentUrl());
if (decodedUrl.contains(INPUT_VALUE)) { // Если в списке параметров есть наш ввод - все ок
if (isPageContainsInputValue()) { // если на страничке после чистки инпутов, есть слово, которое мы ввели (INPUT_VALUE), будем проверять эту страничку
System.out.println(currentUrl + " REFLECT");
synchronized (reflectXSSUrlContainer) {
reflectXSSUrlContainer.add(decodedUrl);
}
/*
Пока не оттестировано!
*/
decodedUrl = decodedUrl.substring(0, decodedUrl.indexOf("?")); // Обрезаем по аргументы и добавляем в карту сайта (вдруг там новые ссылки)
synchronized (linkContainer) {
linkContainer.add(decodedUrl);
}
}
} else {
System.out.println(currentUrl + " STORED"); | storedXSSUrlContainer.add(new XssStored(url, i)); |
pashna/XSS-scanner | src/main/java/xss/Starter.java | // Path: src/main/java/xss/LinkContainer/XssContainer.java
// public class XssContainer extends LinkedHashSet<XssStruct> {
//
// XssContainerCallback callback;
//
// @Override
// public boolean add(XssStruct xssStruct) {
// boolean wasAdded = super.add(xssStruct);
// if (wasAdded)
// if (callback != null)
// callback.onXssAdded(xssStruct);
// return wasAdded;
// }
//
// public void setCallback(XssContainerCallback callback) {
// this.callback = callback;
// }
//
// public interface XssContainerCallback {
// public void onXssAdded(XssStruct xssStruct);
// }
// }
//
// Path: src/main/java/xss/LinkContainer/XssStruct.java
// public class XssStruct {
// static public int REFLECTED = 1;
// static public int STORED = 2;
//
// public String url;
// public String xss;
// public int form;
// public int type;
//
// public XssStruct(String url, String xss, int type) {
// this(url, xss, type, -1);
// }
//
// public XssStruct(String url, String xss, int type, int form) {
// this.xss = xss;
// this.url = url;
// this.form = form;
// this.type = type;
// }
//
// }
| import xss.LinkContainer.XssContainer;
import xss.LinkContainer.XssStruct; | package xss;
/**
* Created by popka on 02.04.15.
*/
public class Starter implements Engine.EngineListener{
private String url = "http://www.insecurelabs.org/Task";
//private String url = "https://xss-game.appspot.com/level2/frame";
private int nBrowser = 6;
private Engine engine;
public void start() {
engine = new Engine(url, nBrowser, this);
engine.setEngineListener(this);
engine.createMapOfSite();
//System.out.print(readFile("xssCheatSheet"));
//xss.XmlParser parser = new xss.XmlParser();
//parser.parse();
}
@Override
public void onCreateMapEnds() {
System.out.println("createMapsEnds");
engine.prepareXSS(FileReader.TEST);
}
@Override
public void onXssPrepareEnds() {
System.out.println("XssPreparedEnds");
}
@Override
public void onBrowsersReady() {
}
@Override | // Path: src/main/java/xss/LinkContainer/XssContainer.java
// public class XssContainer extends LinkedHashSet<XssStruct> {
//
// XssContainerCallback callback;
//
// @Override
// public boolean add(XssStruct xssStruct) {
// boolean wasAdded = super.add(xssStruct);
// if (wasAdded)
// if (callback != null)
// callback.onXssAdded(xssStruct);
// return wasAdded;
// }
//
// public void setCallback(XssContainerCallback callback) {
// this.callback = callback;
// }
//
// public interface XssContainerCallback {
// public void onXssAdded(XssStruct xssStruct);
// }
// }
//
// Path: src/main/java/xss/LinkContainer/XssStruct.java
// public class XssStruct {
// static public int REFLECTED = 1;
// static public int STORED = 2;
//
// public String url;
// public String xss;
// public int form;
// public int type;
//
// public XssStruct(String url, String xss, int type) {
// this(url, xss, type, -1);
// }
//
// public XssStruct(String url, String xss, int type, int form) {
// this.xss = xss;
// this.url = url;
// this.form = form;
// this.type = type;
// }
//
// }
// Path: src/main/java/xss/Starter.java
import xss.LinkContainer.XssContainer;
import xss.LinkContainer.XssStruct;
package xss;
/**
* Created by popka on 02.04.15.
*/
public class Starter implements Engine.EngineListener{
private String url = "http://www.insecurelabs.org/Task";
//private String url = "https://xss-game.appspot.com/level2/frame";
private int nBrowser = 6;
private Engine engine;
public void start() {
engine = new Engine(url, nBrowser, this);
engine.setEngineListener(this);
engine.createMapOfSite();
//System.out.print(readFile("xssCheatSheet"));
//xss.XmlParser parser = new xss.XmlParser();
//parser.parse();
}
@Override
public void onCreateMapEnds() {
System.out.println("createMapsEnds");
engine.prepareXSS(FileReader.TEST);
}
@Override
public void onXssPrepareEnds() {
System.out.println("XssPreparedEnds");
}
@Override
public void onBrowsersReady() {
}
@Override | public void onXssAdded(XssStruct xssStruct) { |
pashna/XSS-scanner | src/main/java/xss/BrowserPool.java | // Path: src/main/java/xss/Tasks/BrowserRunnable.java
// public abstract class BrowserRunnable implements Runnable {
// private WebDriver webDriver;
//
// public void run(WebDriver webDriver) {
// this.webDriver = webDriver;
// run();
// }
//
//
// public WebDriver getWebDriver() {
// return webDriver;
// }
// }
| import xss.Tasks.BrowserRunnable;
import org.openqa.selenium.Cookie;
import org.openqa.selenium.InvalidCookieDomainException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import java.util.LinkedList;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger; | package xss;
/**
* Created by popka on 21.03.15.
*/
public class BrowserPool {
private static AtomicInteger countOfRunningThreads = new AtomicInteger(0);
private final int nBrowsers;
private final BrowserWorker[] browsers;
private final LinkedList queue;
private TasksEndListener tasksEndListener;
public BrowserPool(int nBrowsers) {
this.nBrowsers = nBrowsers; | // Path: src/main/java/xss/Tasks/BrowserRunnable.java
// public abstract class BrowserRunnable implements Runnable {
// private WebDriver webDriver;
//
// public void run(WebDriver webDriver) {
// this.webDriver = webDriver;
// run();
// }
//
//
// public WebDriver getWebDriver() {
// return webDriver;
// }
// }
// Path: src/main/java/xss/BrowserPool.java
import xss.Tasks.BrowserRunnable;
import org.openqa.selenium.Cookie;
import org.openqa.selenium.InvalidCookieDomainException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import java.util.LinkedList;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
package xss;
/**
* Created by popka on 21.03.15.
*/
public class BrowserPool {
private static AtomicInteger countOfRunningThreads = new AtomicInteger(0);
private final int nBrowsers;
private final BrowserWorker[] browsers;
private final LinkedList queue;
private TasksEndListener tasksEndListener;
public BrowserPool(int nBrowsers) {
this.nBrowsers = nBrowsers; | queue = new LinkedList<BrowserRunnable>(); |
echocat/adam | src/main/java/org/echocat/adam/profile/Profile.java | // Path: src/main/java/org/echocat/adam/profile/element/ElementModel.java
// public interface ElementModel extends Localized {
//
// @Nonnull
// public static final String PERSONAL_INFORMATION_ELEMENT_ID = "personalInformation";
// @Nonnull
// public static final String FULL_NAME_ELEMENT_ID = "fullName";
// @Nonnull
// public static final String USER_NAME_ELEMENT_ID = "username";
// @Nonnull
// public static final String EMAIL_ELEMENT_ID = "email";
// @Nonnull
// public static final String WEBSITE_ELEMENT_ID = "website";
// @Nonnull
// public static final String PHONE_ELEMENT_ID = "phone";
//
// public boolean isStandard();
//
// public boolean isDefaultForReports();
//
// @Nullable
// public List<String> getContextAttributeKeys();
//
// public boolean isSearchable();
//
// public boolean isVisibleIfEmpty();
//
// @Nonnull
// public ViewEditAccess getAccess();
//
// @Nonnull
// public Type getType();
//
// @Nullable
// public Template getTemplate();
//
// public static enum Type {
// singleLineText,
// multiLineText,
// emailAddress,
// url,
// phoneNumber,
// wikiMarkup,
// html
// }
//
// }
| import org.slf4j.LoggerFactory;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.security.Principal;
import static com.atlassian.confluence.setup.bandana.ConfluenceBandanaContext.GLOBAL_CONTEXT;
import static org.apache.commons.lang3.StringUtils.isEmpty;
import com.atlassian.bandana.BandanaManager;
import com.atlassian.confluence.search.ConfluenceIndexer;
import com.atlassian.confluence.user.PersonalInformation;
import com.atlassian.confluence.user.PersonalInformationManager;
import com.atlassian.confluence.user.UserAccessor;
import com.atlassian.confluence.user.UserDetailsManager;
import com.atlassian.user.User;
import org.echocat.adam.profile.element.ElementModel;
import org.slf4j.Logger; | private final PersonalInformationManager _personalInformationManager;
@Nonnull
private final ConfluenceIndexer _confluenceIndexer;
@Nonnull
private final String _name;
@Nullable
private String _fullName;
@Nullable
private String _email;
public Profile(@Nonnull User user, @Nonnull BandanaManager bandanaManager, @Nonnull UserDetailsManager userDetailsManager, @Nonnull PersonalInformationManager personalInformationManager, @Nonnull ConfluenceIndexer confluenceIndexer, @Nonnull UserAccessor userAccessor) {
this(user.getName(), user.getFullName(), user.getEmail(), bandanaManager, userDetailsManager, personalInformationManager, confluenceIndexer, userAccessor);
}
public Profile(@Nonnull String name, @Nullable String fullName, @Nullable String email, @Nonnull BandanaManager bandanaManager, @Nonnull UserDetailsManager userDetailsManager, @Nonnull PersonalInformationManager personalInformationManager, @Nonnull ConfluenceIndexer confluenceIndexer, @Nonnull UserAccessor userAccessor) {
_userAccessor = userAccessor;
_name = name;
_fullName = fullName;
_email = email;
_bandanaManager = bandanaManager;
_userDetailsManager = userDetailsManager;
_personalInformationManager = personalInformationManager;
_confluenceIndexer = confluenceIndexer;
}
public void reIndex() {
_confluenceIndexer.index(getPersonalInformation());
}
| // Path: src/main/java/org/echocat/adam/profile/element/ElementModel.java
// public interface ElementModel extends Localized {
//
// @Nonnull
// public static final String PERSONAL_INFORMATION_ELEMENT_ID = "personalInformation";
// @Nonnull
// public static final String FULL_NAME_ELEMENT_ID = "fullName";
// @Nonnull
// public static final String USER_NAME_ELEMENT_ID = "username";
// @Nonnull
// public static final String EMAIL_ELEMENT_ID = "email";
// @Nonnull
// public static final String WEBSITE_ELEMENT_ID = "website";
// @Nonnull
// public static final String PHONE_ELEMENT_ID = "phone";
//
// public boolean isStandard();
//
// public boolean isDefaultForReports();
//
// @Nullable
// public List<String> getContextAttributeKeys();
//
// public boolean isSearchable();
//
// public boolean isVisibleIfEmpty();
//
// @Nonnull
// public ViewEditAccess getAccess();
//
// @Nonnull
// public Type getType();
//
// @Nullable
// public Template getTemplate();
//
// public static enum Type {
// singleLineText,
// multiLineText,
// emailAddress,
// url,
// phoneNumber,
// wikiMarkup,
// html
// }
//
// }
// Path: src/main/java/org/echocat/adam/profile/Profile.java
import org.slf4j.LoggerFactory;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.security.Principal;
import static com.atlassian.confluence.setup.bandana.ConfluenceBandanaContext.GLOBAL_CONTEXT;
import static org.apache.commons.lang3.StringUtils.isEmpty;
import com.atlassian.bandana.BandanaManager;
import com.atlassian.confluence.search.ConfluenceIndexer;
import com.atlassian.confluence.user.PersonalInformation;
import com.atlassian.confluence.user.PersonalInformationManager;
import com.atlassian.confluence.user.UserAccessor;
import com.atlassian.confluence.user.UserDetailsManager;
import com.atlassian.user.User;
import org.echocat.adam.profile.element.ElementModel;
import org.slf4j.Logger;
private final PersonalInformationManager _personalInformationManager;
@Nonnull
private final ConfluenceIndexer _confluenceIndexer;
@Nonnull
private final String _name;
@Nullable
private String _fullName;
@Nullable
private String _email;
public Profile(@Nonnull User user, @Nonnull BandanaManager bandanaManager, @Nonnull UserDetailsManager userDetailsManager, @Nonnull PersonalInformationManager personalInformationManager, @Nonnull ConfluenceIndexer confluenceIndexer, @Nonnull UserAccessor userAccessor) {
this(user.getName(), user.getFullName(), user.getEmail(), bandanaManager, userDetailsManager, personalInformationManager, confluenceIndexer, userAccessor);
}
public Profile(@Nonnull String name, @Nullable String fullName, @Nullable String email, @Nonnull BandanaManager bandanaManager, @Nonnull UserDetailsManager userDetailsManager, @Nonnull PersonalInformationManager personalInformationManager, @Nonnull ConfluenceIndexer confluenceIndexer, @Nonnull UserAccessor userAccessor) {
_userAccessor = userAccessor;
_name = name;
_fullName = fullName;
_email = email;
_bandanaManager = bandanaManager;
_userDetailsManager = userDetailsManager;
_personalInformationManager = personalInformationManager;
_confluenceIndexer = confluenceIndexer;
}
public void reIndex() {
_confluenceIndexer.index(getPersonalInformation());
}
| public void setValue(@Nonnull ElementModel of, @Nullable String to) { |
echocat/adam | src/main/java/org/echocat/adam/profile/element/ElementModel.java | // Path: src/main/java/org/echocat/adam/localization/Localized.java
// public interface Localized extends IdEnabled<String> {
//
// @Nullable
// public Map<Locale, Localization> getLocalizations();
//
// }
//
// Path: src/main/java/org/echocat/adam/template/Template.java
// public interface Template {
//
// @Nonnull
// public String getSource();
//
// @Nonnull
// public TemplateFormat getFormat();
//
// public static class Simple implements Template {
//
// @Nonnull
// public static Template simpleTemplateFor(@Nonnull String elementId) {
// return new Simple(elementId);
// }
//
// @Nonnull
// private final String _elementId;
//
// public Simple(@Nonnull String elementId) {
// _elementId = elementId;
// }
//
// @Nonnull
// @Override
// public String getSource() {
// return "$!{" + _elementId + "}";
// }
//
// @Nonnull
// @Override
// public TemplateFormat getFormat() {
// return TemplateFormat.velocity;
// }
//
// }
//
// }
| import org.echocat.adam.access.ViewEditAccess;
import org.echocat.adam.localization.Localized;
import org.echocat.adam.template.Template;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List; | /*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.profile.element;
public interface ElementModel extends Localized {
@Nonnull
public static final String PERSONAL_INFORMATION_ELEMENT_ID = "personalInformation";
@Nonnull
public static final String FULL_NAME_ELEMENT_ID = "fullName";
@Nonnull
public static final String USER_NAME_ELEMENT_ID = "username";
@Nonnull
public static final String EMAIL_ELEMENT_ID = "email";
@Nonnull
public static final String WEBSITE_ELEMENT_ID = "website";
@Nonnull
public static final String PHONE_ELEMENT_ID = "phone";
public boolean isStandard();
public boolean isDefaultForReports();
@Nullable
public List<String> getContextAttributeKeys();
public boolean isSearchable();
public boolean isVisibleIfEmpty();
@Nonnull
public ViewEditAccess getAccess();
@Nonnull
public Type getType();
@Nullable | // Path: src/main/java/org/echocat/adam/localization/Localized.java
// public interface Localized extends IdEnabled<String> {
//
// @Nullable
// public Map<Locale, Localization> getLocalizations();
//
// }
//
// Path: src/main/java/org/echocat/adam/template/Template.java
// public interface Template {
//
// @Nonnull
// public String getSource();
//
// @Nonnull
// public TemplateFormat getFormat();
//
// public static class Simple implements Template {
//
// @Nonnull
// public static Template simpleTemplateFor(@Nonnull String elementId) {
// return new Simple(elementId);
// }
//
// @Nonnull
// private final String _elementId;
//
// public Simple(@Nonnull String elementId) {
// _elementId = elementId;
// }
//
// @Nonnull
// @Override
// public String getSource() {
// return "$!{" + _elementId + "}";
// }
//
// @Nonnull
// @Override
// public TemplateFormat getFormat() {
// return TemplateFormat.velocity;
// }
//
// }
//
// }
// Path: src/main/java/org/echocat/adam/profile/element/ElementModel.java
import org.echocat.adam.access.ViewEditAccess;
import org.echocat.adam.localization.Localized;
import org.echocat.adam.template.Template;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List;
/*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.profile.element;
public interface ElementModel extends Localized {
@Nonnull
public static final String PERSONAL_INFORMATION_ELEMENT_ID = "personalInformation";
@Nonnull
public static final String FULL_NAME_ELEMENT_ID = "fullName";
@Nonnull
public static final String USER_NAME_ELEMENT_ID = "username";
@Nonnull
public static final String EMAIL_ELEMENT_ID = "email";
@Nonnull
public static final String WEBSITE_ELEMENT_ID = "website";
@Nonnull
public static final String PHONE_ELEMENT_ID = "phone";
public boolean isStandard();
public boolean isDefaultForReports();
@Nullable
public List<String> getContextAttributeKeys();
public boolean isSearchable();
public boolean isVisibleIfEmpty();
@Nonnull
public ViewEditAccess getAccess();
@Nonnull
public Type getType();
@Nullable | public Template getTemplate(); |
echocat/adam | src/main/java/org/echocat/adam/profile/ExtendedEditUserAction.java | // Path: src/main/java/org/echocat/adam/profile/element/ElementModel.java
// public interface ElementModel extends Localized {
//
// @Nonnull
// public static final String PERSONAL_INFORMATION_ELEMENT_ID = "personalInformation";
// @Nonnull
// public static final String FULL_NAME_ELEMENT_ID = "fullName";
// @Nonnull
// public static final String USER_NAME_ELEMENT_ID = "username";
// @Nonnull
// public static final String EMAIL_ELEMENT_ID = "email";
// @Nonnull
// public static final String WEBSITE_ELEMENT_ID = "website";
// @Nonnull
// public static final String PHONE_ELEMENT_ID = "phone";
//
// public boolean isStandard();
//
// public boolean isDefaultForReports();
//
// @Nullable
// public List<String> getContextAttributeKeys();
//
// public boolean isSearchable();
//
// public boolean isVisibleIfEmpty();
//
// @Nonnull
// public ViewEditAccess getAccess();
//
// @Nonnull
// public Type getType();
//
// @Nullable
// public Template getTemplate();
//
// public static enum Type {
// singleLineText,
// multiLineText,
// emailAddress,
// url,
// phoneNumber,
// wikiMarkup,
// html
// }
//
// }
//
// Path: src/main/java/org/echocat/adam/profile/ProfileModelProvider.java
// @Nonnull
// public static ProfileModelProvider profileModelProvider() {
// final ProfileModelProvider result = c_instance;
// if (result == null) {
// throw new IllegalStateException("There is currently no instance registered.");
// }
// return result;
// }
//
// Path: src/main/java/org/echocat/adam/profile/ProfileProvider.java
// @Nonnull
// public static ProfileProvider profileProvider() {
// final ProfileProvider result = c_instance;
// if (result == null) {
// throw new IllegalStateException("There is currently no instance registered.");
// }
// return result;
// }
//
// Path: src/main/java/org/echocat/adam/profile/element/ElementModel.java
// public interface ElementModel extends Localized {
//
// @Nonnull
// public static final String PERSONAL_INFORMATION_ELEMENT_ID = "personalInformation";
// @Nonnull
// public static final String FULL_NAME_ELEMENT_ID = "fullName";
// @Nonnull
// public static final String USER_NAME_ELEMENT_ID = "username";
// @Nonnull
// public static final String EMAIL_ELEMENT_ID = "email";
// @Nonnull
// public static final String WEBSITE_ELEMENT_ID = "website";
// @Nonnull
// public static final String PHONE_ELEMENT_ID = "phone";
//
// public boolean isStandard();
//
// public boolean isDefaultForReports();
//
// @Nullable
// public List<String> getContextAttributeKeys();
//
// public boolean isSearchable();
//
// public boolean isVisibleIfEmpty();
//
// @Nonnull
// public ViewEditAccess getAccess();
//
// @Nonnull
// public Type getType();
//
// @Nullable
// public Template getTemplate();
//
// public static enum Type {
// singleLineText,
// multiLineText,
// emailAddress,
// url,
// phoneNumber,
// wikiMarkup,
// html
// }
//
// }
| import static org.echocat.adam.profile.ProfileModelProvider.profileModelProvider;
import static org.echocat.adam.profile.ProfileProvider.profileProvider;
import static org.echocat.adam.profile.element.ElementModel.*;
import com.atlassian.confluence.user.AuthenticatedUserThreadLocal;
import com.atlassian.confluence.user.ConfluenceUser;
import com.atlassian.confluence.user.actions.EditUserAction;
import org.echocat.adam.profile.element.ElementModel;
import javax.annotation.Nonnull;
import java.util.Map;
import static org.apache.commons.lang3.StringUtils.join; | /*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014-2016 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.profile;
public class ExtendedEditUserAction extends EditUserAction {
private Map<String, String[]> _parameters;
@Override
public String doEdit() throws Exception {
final String result = super.doEdit();
final ConfluenceUser user = getUser(); | // Path: src/main/java/org/echocat/adam/profile/element/ElementModel.java
// public interface ElementModel extends Localized {
//
// @Nonnull
// public static final String PERSONAL_INFORMATION_ELEMENT_ID = "personalInformation";
// @Nonnull
// public static final String FULL_NAME_ELEMENT_ID = "fullName";
// @Nonnull
// public static final String USER_NAME_ELEMENT_ID = "username";
// @Nonnull
// public static final String EMAIL_ELEMENT_ID = "email";
// @Nonnull
// public static final String WEBSITE_ELEMENT_ID = "website";
// @Nonnull
// public static final String PHONE_ELEMENT_ID = "phone";
//
// public boolean isStandard();
//
// public boolean isDefaultForReports();
//
// @Nullable
// public List<String> getContextAttributeKeys();
//
// public boolean isSearchable();
//
// public boolean isVisibleIfEmpty();
//
// @Nonnull
// public ViewEditAccess getAccess();
//
// @Nonnull
// public Type getType();
//
// @Nullable
// public Template getTemplate();
//
// public static enum Type {
// singleLineText,
// multiLineText,
// emailAddress,
// url,
// phoneNumber,
// wikiMarkup,
// html
// }
//
// }
//
// Path: src/main/java/org/echocat/adam/profile/ProfileModelProvider.java
// @Nonnull
// public static ProfileModelProvider profileModelProvider() {
// final ProfileModelProvider result = c_instance;
// if (result == null) {
// throw new IllegalStateException("There is currently no instance registered.");
// }
// return result;
// }
//
// Path: src/main/java/org/echocat/adam/profile/ProfileProvider.java
// @Nonnull
// public static ProfileProvider profileProvider() {
// final ProfileProvider result = c_instance;
// if (result == null) {
// throw new IllegalStateException("There is currently no instance registered.");
// }
// return result;
// }
//
// Path: src/main/java/org/echocat/adam/profile/element/ElementModel.java
// public interface ElementModel extends Localized {
//
// @Nonnull
// public static final String PERSONAL_INFORMATION_ELEMENT_ID = "personalInformation";
// @Nonnull
// public static final String FULL_NAME_ELEMENT_ID = "fullName";
// @Nonnull
// public static final String USER_NAME_ELEMENT_ID = "username";
// @Nonnull
// public static final String EMAIL_ELEMENT_ID = "email";
// @Nonnull
// public static final String WEBSITE_ELEMENT_ID = "website";
// @Nonnull
// public static final String PHONE_ELEMENT_ID = "phone";
//
// public boolean isStandard();
//
// public boolean isDefaultForReports();
//
// @Nullable
// public List<String> getContextAttributeKeys();
//
// public boolean isSearchable();
//
// public boolean isVisibleIfEmpty();
//
// @Nonnull
// public ViewEditAccess getAccess();
//
// @Nonnull
// public Type getType();
//
// @Nullable
// public Template getTemplate();
//
// public static enum Type {
// singleLineText,
// multiLineText,
// emailAddress,
// url,
// phoneNumber,
// wikiMarkup,
// html
// }
//
// }
// Path: src/main/java/org/echocat/adam/profile/ExtendedEditUserAction.java
import static org.echocat.adam.profile.ProfileModelProvider.profileModelProvider;
import static org.echocat.adam.profile.ProfileProvider.profileProvider;
import static org.echocat.adam.profile.element.ElementModel.*;
import com.atlassian.confluence.user.AuthenticatedUserThreadLocal;
import com.atlassian.confluence.user.ConfluenceUser;
import com.atlassian.confluence.user.actions.EditUserAction;
import org.echocat.adam.profile.element.ElementModel;
import javax.annotation.Nonnull;
import java.util.Map;
import static org.apache.commons.lang3.StringUtils.join;
/*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014-2016 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.profile;
public class ExtendedEditUserAction extends EditUserAction {
private Map<String, String[]> _parameters;
@Override
public String doEdit() throws Exception {
final String result = super.doEdit();
final ConfluenceUser user = getUser(); | final Profile profile = user != null ? profileProvider().provideFor(user) : null; |
echocat/adam | src/main/java/org/echocat/adam/profile/ExtendedEditUserAction.java | // Path: src/main/java/org/echocat/adam/profile/element/ElementModel.java
// public interface ElementModel extends Localized {
//
// @Nonnull
// public static final String PERSONAL_INFORMATION_ELEMENT_ID = "personalInformation";
// @Nonnull
// public static final String FULL_NAME_ELEMENT_ID = "fullName";
// @Nonnull
// public static final String USER_NAME_ELEMENT_ID = "username";
// @Nonnull
// public static final String EMAIL_ELEMENT_ID = "email";
// @Nonnull
// public static final String WEBSITE_ELEMENT_ID = "website";
// @Nonnull
// public static final String PHONE_ELEMENT_ID = "phone";
//
// public boolean isStandard();
//
// public boolean isDefaultForReports();
//
// @Nullable
// public List<String> getContextAttributeKeys();
//
// public boolean isSearchable();
//
// public boolean isVisibleIfEmpty();
//
// @Nonnull
// public ViewEditAccess getAccess();
//
// @Nonnull
// public Type getType();
//
// @Nullable
// public Template getTemplate();
//
// public static enum Type {
// singleLineText,
// multiLineText,
// emailAddress,
// url,
// phoneNumber,
// wikiMarkup,
// html
// }
//
// }
//
// Path: src/main/java/org/echocat/adam/profile/ProfileModelProvider.java
// @Nonnull
// public static ProfileModelProvider profileModelProvider() {
// final ProfileModelProvider result = c_instance;
// if (result == null) {
// throw new IllegalStateException("There is currently no instance registered.");
// }
// return result;
// }
//
// Path: src/main/java/org/echocat/adam/profile/ProfileProvider.java
// @Nonnull
// public static ProfileProvider profileProvider() {
// final ProfileProvider result = c_instance;
// if (result == null) {
// throw new IllegalStateException("There is currently no instance registered.");
// }
// return result;
// }
//
// Path: src/main/java/org/echocat/adam/profile/element/ElementModel.java
// public interface ElementModel extends Localized {
//
// @Nonnull
// public static final String PERSONAL_INFORMATION_ELEMENT_ID = "personalInformation";
// @Nonnull
// public static final String FULL_NAME_ELEMENT_ID = "fullName";
// @Nonnull
// public static final String USER_NAME_ELEMENT_ID = "username";
// @Nonnull
// public static final String EMAIL_ELEMENT_ID = "email";
// @Nonnull
// public static final String WEBSITE_ELEMENT_ID = "website";
// @Nonnull
// public static final String PHONE_ELEMENT_ID = "phone";
//
// public boolean isStandard();
//
// public boolean isDefaultForReports();
//
// @Nullable
// public List<String> getContextAttributeKeys();
//
// public boolean isSearchable();
//
// public boolean isVisibleIfEmpty();
//
// @Nonnull
// public ViewEditAccess getAccess();
//
// @Nonnull
// public Type getType();
//
// @Nullable
// public Template getTemplate();
//
// public static enum Type {
// singleLineText,
// multiLineText,
// emailAddress,
// url,
// phoneNumber,
// wikiMarkup,
// html
// }
//
// }
| import static org.echocat.adam.profile.ProfileModelProvider.profileModelProvider;
import static org.echocat.adam.profile.ProfileProvider.profileProvider;
import static org.echocat.adam.profile.element.ElementModel.*;
import com.atlassian.confluence.user.AuthenticatedUserThreadLocal;
import com.atlassian.confluence.user.ConfluenceUser;
import com.atlassian.confluence.user.actions.EditUserAction;
import org.echocat.adam.profile.element.ElementModel;
import javax.annotation.Nonnull;
import java.util.Map;
import static org.apache.commons.lang3.StringUtils.join; | /*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014-2016 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.profile;
public class ExtendedEditUserAction extends EditUserAction {
private Map<String, String[]> _parameters;
@Override
public String doEdit() throws Exception {
final String result = super.doEdit();
final ConfluenceUser user = getUser();
final Profile profile = user != null ? profileProvider().provideFor(user) : null;
if (profile != null && "success".equals(result)) {
updateFields(profile);
profile.reIndex();
}
return result;
}
private void updateFields(@Nonnull Profile profile) { | // Path: src/main/java/org/echocat/adam/profile/element/ElementModel.java
// public interface ElementModel extends Localized {
//
// @Nonnull
// public static final String PERSONAL_INFORMATION_ELEMENT_ID = "personalInformation";
// @Nonnull
// public static final String FULL_NAME_ELEMENT_ID = "fullName";
// @Nonnull
// public static final String USER_NAME_ELEMENT_ID = "username";
// @Nonnull
// public static final String EMAIL_ELEMENT_ID = "email";
// @Nonnull
// public static final String WEBSITE_ELEMENT_ID = "website";
// @Nonnull
// public static final String PHONE_ELEMENT_ID = "phone";
//
// public boolean isStandard();
//
// public boolean isDefaultForReports();
//
// @Nullable
// public List<String> getContextAttributeKeys();
//
// public boolean isSearchable();
//
// public boolean isVisibleIfEmpty();
//
// @Nonnull
// public ViewEditAccess getAccess();
//
// @Nonnull
// public Type getType();
//
// @Nullable
// public Template getTemplate();
//
// public static enum Type {
// singleLineText,
// multiLineText,
// emailAddress,
// url,
// phoneNumber,
// wikiMarkup,
// html
// }
//
// }
//
// Path: src/main/java/org/echocat/adam/profile/ProfileModelProvider.java
// @Nonnull
// public static ProfileModelProvider profileModelProvider() {
// final ProfileModelProvider result = c_instance;
// if (result == null) {
// throw new IllegalStateException("There is currently no instance registered.");
// }
// return result;
// }
//
// Path: src/main/java/org/echocat/adam/profile/ProfileProvider.java
// @Nonnull
// public static ProfileProvider profileProvider() {
// final ProfileProvider result = c_instance;
// if (result == null) {
// throw new IllegalStateException("There is currently no instance registered.");
// }
// return result;
// }
//
// Path: src/main/java/org/echocat/adam/profile/element/ElementModel.java
// public interface ElementModel extends Localized {
//
// @Nonnull
// public static final String PERSONAL_INFORMATION_ELEMENT_ID = "personalInformation";
// @Nonnull
// public static final String FULL_NAME_ELEMENT_ID = "fullName";
// @Nonnull
// public static final String USER_NAME_ELEMENT_ID = "username";
// @Nonnull
// public static final String EMAIL_ELEMENT_ID = "email";
// @Nonnull
// public static final String WEBSITE_ELEMENT_ID = "website";
// @Nonnull
// public static final String PHONE_ELEMENT_ID = "phone";
//
// public boolean isStandard();
//
// public boolean isDefaultForReports();
//
// @Nullable
// public List<String> getContextAttributeKeys();
//
// public boolean isSearchable();
//
// public boolean isVisibleIfEmpty();
//
// @Nonnull
// public ViewEditAccess getAccess();
//
// @Nonnull
// public Type getType();
//
// @Nullable
// public Template getTemplate();
//
// public static enum Type {
// singleLineText,
// multiLineText,
// emailAddress,
// url,
// phoneNumber,
// wikiMarkup,
// html
// }
//
// }
// Path: src/main/java/org/echocat/adam/profile/ExtendedEditUserAction.java
import static org.echocat.adam.profile.ProfileModelProvider.profileModelProvider;
import static org.echocat.adam.profile.ProfileProvider.profileProvider;
import static org.echocat.adam.profile.element.ElementModel.*;
import com.atlassian.confluence.user.AuthenticatedUserThreadLocal;
import com.atlassian.confluence.user.ConfluenceUser;
import com.atlassian.confluence.user.actions.EditUserAction;
import org.echocat.adam.profile.element.ElementModel;
import javax.annotation.Nonnull;
import java.util.Map;
import static org.apache.commons.lang3.StringUtils.join;
/*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014-2016 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.profile;
public class ExtendedEditUserAction extends EditUserAction {
private Map<String, String[]> _parameters;
@Override
public String doEdit() throws Exception {
final String result = super.doEdit();
final ConfluenceUser user = getUser();
final Profile profile = user != null ? profileProvider().provideFor(user) : null;
if (profile != null && "success".equals(result)) {
updateFields(profile);
profile.reIndex();
}
return result;
}
private void updateFields(@Nonnull Profile profile) { | for (final Group group : profileModelProvider().get()) { |
echocat/adam | src/main/java/org/echocat/adam/profile/ExtendedEditUserAction.java | // Path: src/main/java/org/echocat/adam/profile/element/ElementModel.java
// public interface ElementModel extends Localized {
//
// @Nonnull
// public static final String PERSONAL_INFORMATION_ELEMENT_ID = "personalInformation";
// @Nonnull
// public static final String FULL_NAME_ELEMENT_ID = "fullName";
// @Nonnull
// public static final String USER_NAME_ELEMENT_ID = "username";
// @Nonnull
// public static final String EMAIL_ELEMENT_ID = "email";
// @Nonnull
// public static final String WEBSITE_ELEMENT_ID = "website";
// @Nonnull
// public static final String PHONE_ELEMENT_ID = "phone";
//
// public boolean isStandard();
//
// public boolean isDefaultForReports();
//
// @Nullable
// public List<String> getContextAttributeKeys();
//
// public boolean isSearchable();
//
// public boolean isVisibleIfEmpty();
//
// @Nonnull
// public ViewEditAccess getAccess();
//
// @Nonnull
// public Type getType();
//
// @Nullable
// public Template getTemplate();
//
// public static enum Type {
// singleLineText,
// multiLineText,
// emailAddress,
// url,
// phoneNumber,
// wikiMarkup,
// html
// }
//
// }
//
// Path: src/main/java/org/echocat/adam/profile/ProfileModelProvider.java
// @Nonnull
// public static ProfileModelProvider profileModelProvider() {
// final ProfileModelProvider result = c_instance;
// if (result == null) {
// throw new IllegalStateException("There is currently no instance registered.");
// }
// return result;
// }
//
// Path: src/main/java/org/echocat/adam/profile/ProfileProvider.java
// @Nonnull
// public static ProfileProvider profileProvider() {
// final ProfileProvider result = c_instance;
// if (result == null) {
// throw new IllegalStateException("There is currently no instance registered.");
// }
// return result;
// }
//
// Path: src/main/java/org/echocat/adam/profile/element/ElementModel.java
// public interface ElementModel extends Localized {
//
// @Nonnull
// public static final String PERSONAL_INFORMATION_ELEMENT_ID = "personalInformation";
// @Nonnull
// public static final String FULL_NAME_ELEMENT_ID = "fullName";
// @Nonnull
// public static final String USER_NAME_ELEMENT_ID = "username";
// @Nonnull
// public static final String EMAIL_ELEMENT_ID = "email";
// @Nonnull
// public static final String WEBSITE_ELEMENT_ID = "website";
// @Nonnull
// public static final String PHONE_ELEMENT_ID = "phone";
//
// public boolean isStandard();
//
// public boolean isDefaultForReports();
//
// @Nullable
// public List<String> getContextAttributeKeys();
//
// public boolean isSearchable();
//
// public boolean isVisibleIfEmpty();
//
// @Nonnull
// public ViewEditAccess getAccess();
//
// @Nonnull
// public Type getType();
//
// @Nullable
// public Template getTemplate();
//
// public static enum Type {
// singleLineText,
// multiLineText,
// emailAddress,
// url,
// phoneNumber,
// wikiMarkup,
// html
// }
//
// }
| import static org.echocat.adam.profile.ProfileModelProvider.profileModelProvider;
import static org.echocat.adam.profile.ProfileProvider.profileProvider;
import static org.echocat.adam.profile.element.ElementModel.*;
import com.atlassian.confluence.user.AuthenticatedUserThreadLocal;
import com.atlassian.confluence.user.ConfluenceUser;
import com.atlassian.confluence.user.actions.EditUserAction;
import org.echocat.adam.profile.element.ElementModel;
import javax.annotation.Nonnull;
import java.util.Map;
import static org.apache.commons.lang3.StringUtils.join; | /*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014-2016 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.profile;
public class ExtendedEditUserAction extends EditUserAction {
private Map<String, String[]> _parameters;
@Override
public String doEdit() throws Exception {
final String result = super.doEdit();
final ConfluenceUser user = getUser();
final Profile profile = user != null ? profileProvider().provideFor(user) : null;
if (profile != null && "success".equals(result)) {
updateFields(profile);
profile.reIndex();
}
return result;
}
private void updateFields(@Nonnull Profile profile) {
for (final Group group : profileModelProvider().get()) { | // Path: src/main/java/org/echocat/adam/profile/element/ElementModel.java
// public interface ElementModel extends Localized {
//
// @Nonnull
// public static final String PERSONAL_INFORMATION_ELEMENT_ID = "personalInformation";
// @Nonnull
// public static final String FULL_NAME_ELEMENT_ID = "fullName";
// @Nonnull
// public static final String USER_NAME_ELEMENT_ID = "username";
// @Nonnull
// public static final String EMAIL_ELEMENT_ID = "email";
// @Nonnull
// public static final String WEBSITE_ELEMENT_ID = "website";
// @Nonnull
// public static final String PHONE_ELEMENT_ID = "phone";
//
// public boolean isStandard();
//
// public boolean isDefaultForReports();
//
// @Nullable
// public List<String> getContextAttributeKeys();
//
// public boolean isSearchable();
//
// public boolean isVisibleIfEmpty();
//
// @Nonnull
// public ViewEditAccess getAccess();
//
// @Nonnull
// public Type getType();
//
// @Nullable
// public Template getTemplate();
//
// public static enum Type {
// singleLineText,
// multiLineText,
// emailAddress,
// url,
// phoneNumber,
// wikiMarkup,
// html
// }
//
// }
//
// Path: src/main/java/org/echocat/adam/profile/ProfileModelProvider.java
// @Nonnull
// public static ProfileModelProvider profileModelProvider() {
// final ProfileModelProvider result = c_instance;
// if (result == null) {
// throw new IllegalStateException("There is currently no instance registered.");
// }
// return result;
// }
//
// Path: src/main/java/org/echocat/adam/profile/ProfileProvider.java
// @Nonnull
// public static ProfileProvider profileProvider() {
// final ProfileProvider result = c_instance;
// if (result == null) {
// throw new IllegalStateException("There is currently no instance registered.");
// }
// return result;
// }
//
// Path: src/main/java/org/echocat/adam/profile/element/ElementModel.java
// public interface ElementModel extends Localized {
//
// @Nonnull
// public static final String PERSONAL_INFORMATION_ELEMENT_ID = "personalInformation";
// @Nonnull
// public static final String FULL_NAME_ELEMENT_ID = "fullName";
// @Nonnull
// public static final String USER_NAME_ELEMENT_ID = "username";
// @Nonnull
// public static final String EMAIL_ELEMENT_ID = "email";
// @Nonnull
// public static final String WEBSITE_ELEMENT_ID = "website";
// @Nonnull
// public static final String PHONE_ELEMENT_ID = "phone";
//
// public boolean isStandard();
//
// public boolean isDefaultForReports();
//
// @Nullable
// public List<String> getContextAttributeKeys();
//
// public boolean isSearchable();
//
// public boolean isVisibleIfEmpty();
//
// @Nonnull
// public ViewEditAccess getAccess();
//
// @Nonnull
// public Type getType();
//
// @Nullable
// public Template getTemplate();
//
// public static enum Type {
// singleLineText,
// multiLineText,
// emailAddress,
// url,
// phoneNumber,
// wikiMarkup,
// html
// }
//
// }
// Path: src/main/java/org/echocat/adam/profile/ExtendedEditUserAction.java
import static org.echocat.adam.profile.ProfileModelProvider.profileModelProvider;
import static org.echocat.adam.profile.ProfileProvider.profileProvider;
import static org.echocat.adam.profile.element.ElementModel.*;
import com.atlassian.confluence.user.AuthenticatedUserThreadLocal;
import com.atlassian.confluence.user.ConfluenceUser;
import com.atlassian.confluence.user.actions.EditUserAction;
import org.echocat.adam.profile.element.ElementModel;
import javax.annotation.Nonnull;
import java.util.Map;
import static org.apache.commons.lang3.StringUtils.join;
/*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014-2016 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.profile;
public class ExtendedEditUserAction extends EditUserAction {
private Map<String, String[]> _parameters;
@Override
public String doEdit() throws Exception {
final String result = super.doEdit();
final ConfluenceUser user = getUser();
final Profile profile = user != null ? profileProvider().provideFor(user) : null;
if (profile != null && "success".equals(result)) {
updateFields(profile);
profile.reIndex();
}
return result;
}
private void updateFields(@Nonnull Profile profile) {
for (final Group group : profileModelProvider().get()) { | for (final ElementModel elementModel : group) { |
echocat/adam | src/main/java/org/echocat/adam/profile/ExtendedEditMyProfileAction.java | // Path: src/main/java/org/echocat/adam/profile/element/ElementModel.java
// public interface ElementModel extends Localized {
//
// @Nonnull
// public static final String PERSONAL_INFORMATION_ELEMENT_ID = "personalInformation";
// @Nonnull
// public static final String FULL_NAME_ELEMENT_ID = "fullName";
// @Nonnull
// public static final String USER_NAME_ELEMENT_ID = "username";
// @Nonnull
// public static final String EMAIL_ELEMENT_ID = "email";
// @Nonnull
// public static final String WEBSITE_ELEMENT_ID = "website";
// @Nonnull
// public static final String PHONE_ELEMENT_ID = "phone";
//
// public boolean isStandard();
//
// public boolean isDefaultForReports();
//
// @Nullable
// public List<String> getContextAttributeKeys();
//
// public boolean isSearchable();
//
// public boolean isVisibleIfEmpty();
//
// @Nonnull
// public ViewEditAccess getAccess();
//
// @Nonnull
// public Type getType();
//
// @Nullable
// public Template getTemplate();
//
// public static enum Type {
// singleLineText,
// multiLineText,
// emailAddress,
// url,
// phoneNumber,
// wikiMarkup,
// html
// }
//
// }
//
// Path: src/main/java/org/echocat/adam/profile/ProfileModelProvider.java
// @Nonnull
// public static ProfileModelProvider profileModelProvider() {
// final ProfileModelProvider result = c_instance;
// if (result == null) {
// throw new IllegalStateException("There is currently no instance registered.");
// }
// return result;
// }
//
// Path: src/main/java/org/echocat/adam/profile/ProfileProvider.java
// @Nonnull
// public static ProfileProvider profileProvider() {
// final ProfileProvider result = c_instance;
// if (result == null) {
// throw new IllegalStateException("There is currently no instance registered.");
// }
// return result;
// }
| import static org.echocat.adam.profile.ProfileProvider.profileProvider;
import static org.echocat.adam.profile.element.ElementModel.EMAIL_ELEMENT_ID;
import static org.echocat.adam.profile.element.ElementModel.FULL_NAME_ELEMENT_ID;
import static org.echocat.adam.profile.element.ElementModel.USER_NAME_ELEMENT_ID;
import com.atlassian.confluence.user.ConfluenceUser;
import com.atlassian.confluence.user.actions.EditMyProfileAction;
import org.echocat.adam.profile.element.ElementModel;
import javax.annotation.Nonnull;
import java.util.Map;
import static org.apache.commons.lang3.StringUtils.join;
import static org.echocat.adam.profile.ProfileModelProvider.profileModelProvider; | /*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014-2016 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.profile;
public class ExtendedEditMyProfileAction extends EditMyProfileAction {
private Map<String, String[]> _parameters;
@Override
public String doEdit() throws Exception {
final String result = super.doEdit();
final ConfluenceUser user = getUser(); | // Path: src/main/java/org/echocat/adam/profile/element/ElementModel.java
// public interface ElementModel extends Localized {
//
// @Nonnull
// public static final String PERSONAL_INFORMATION_ELEMENT_ID = "personalInformation";
// @Nonnull
// public static final String FULL_NAME_ELEMENT_ID = "fullName";
// @Nonnull
// public static final String USER_NAME_ELEMENT_ID = "username";
// @Nonnull
// public static final String EMAIL_ELEMENT_ID = "email";
// @Nonnull
// public static final String WEBSITE_ELEMENT_ID = "website";
// @Nonnull
// public static final String PHONE_ELEMENT_ID = "phone";
//
// public boolean isStandard();
//
// public boolean isDefaultForReports();
//
// @Nullable
// public List<String> getContextAttributeKeys();
//
// public boolean isSearchable();
//
// public boolean isVisibleIfEmpty();
//
// @Nonnull
// public ViewEditAccess getAccess();
//
// @Nonnull
// public Type getType();
//
// @Nullable
// public Template getTemplate();
//
// public static enum Type {
// singleLineText,
// multiLineText,
// emailAddress,
// url,
// phoneNumber,
// wikiMarkup,
// html
// }
//
// }
//
// Path: src/main/java/org/echocat/adam/profile/ProfileModelProvider.java
// @Nonnull
// public static ProfileModelProvider profileModelProvider() {
// final ProfileModelProvider result = c_instance;
// if (result == null) {
// throw new IllegalStateException("There is currently no instance registered.");
// }
// return result;
// }
//
// Path: src/main/java/org/echocat/adam/profile/ProfileProvider.java
// @Nonnull
// public static ProfileProvider profileProvider() {
// final ProfileProvider result = c_instance;
// if (result == null) {
// throw new IllegalStateException("There is currently no instance registered.");
// }
// return result;
// }
// Path: src/main/java/org/echocat/adam/profile/ExtendedEditMyProfileAction.java
import static org.echocat.adam.profile.ProfileProvider.profileProvider;
import static org.echocat.adam.profile.element.ElementModel.EMAIL_ELEMENT_ID;
import static org.echocat.adam.profile.element.ElementModel.FULL_NAME_ELEMENT_ID;
import static org.echocat.adam.profile.element.ElementModel.USER_NAME_ELEMENT_ID;
import com.atlassian.confluence.user.ConfluenceUser;
import com.atlassian.confluence.user.actions.EditMyProfileAction;
import org.echocat.adam.profile.element.ElementModel;
import javax.annotation.Nonnull;
import java.util.Map;
import static org.apache.commons.lang3.StringUtils.join;
import static org.echocat.adam.profile.ProfileModelProvider.profileModelProvider;
/*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014-2016 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.profile;
public class ExtendedEditMyProfileAction extends EditMyProfileAction {
private Map<String, String[]> _parameters;
@Override
public String doEdit() throws Exception {
final String result = super.doEdit();
final ConfluenceUser user = getUser(); | final Profile profile = user != null ? profileProvider().provideFor(user) : null; |
echocat/adam | src/main/java/org/echocat/adam/profile/ExtendedEditMyProfileAction.java | // Path: src/main/java/org/echocat/adam/profile/element/ElementModel.java
// public interface ElementModel extends Localized {
//
// @Nonnull
// public static final String PERSONAL_INFORMATION_ELEMENT_ID = "personalInformation";
// @Nonnull
// public static final String FULL_NAME_ELEMENT_ID = "fullName";
// @Nonnull
// public static final String USER_NAME_ELEMENT_ID = "username";
// @Nonnull
// public static final String EMAIL_ELEMENT_ID = "email";
// @Nonnull
// public static final String WEBSITE_ELEMENT_ID = "website";
// @Nonnull
// public static final String PHONE_ELEMENT_ID = "phone";
//
// public boolean isStandard();
//
// public boolean isDefaultForReports();
//
// @Nullable
// public List<String> getContextAttributeKeys();
//
// public boolean isSearchable();
//
// public boolean isVisibleIfEmpty();
//
// @Nonnull
// public ViewEditAccess getAccess();
//
// @Nonnull
// public Type getType();
//
// @Nullable
// public Template getTemplate();
//
// public static enum Type {
// singleLineText,
// multiLineText,
// emailAddress,
// url,
// phoneNumber,
// wikiMarkup,
// html
// }
//
// }
//
// Path: src/main/java/org/echocat/adam/profile/ProfileModelProvider.java
// @Nonnull
// public static ProfileModelProvider profileModelProvider() {
// final ProfileModelProvider result = c_instance;
// if (result == null) {
// throw new IllegalStateException("There is currently no instance registered.");
// }
// return result;
// }
//
// Path: src/main/java/org/echocat/adam/profile/ProfileProvider.java
// @Nonnull
// public static ProfileProvider profileProvider() {
// final ProfileProvider result = c_instance;
// if (result == null) {
// throw new IllegalStateException("There is currently no instance registered.");
// }
// return result;
// }
| import static org.echocat.adam.profile.ProfileProvider.profileProvider;
import static org.echocat.adam.profile.element.ElementModel.EMAIL_ELEMENT_ID;
import static org.echocat.adam.profile.element.ElementModel.FULL_NAME_ELEMENT_ID;
import static org.echocat.adam.profile.element.ElementModel.USER_NAME_ELEMENT_ID;
import com.atlassian.confluence.user.ConfluenceUser;
import com.atlassian.confluence.user.actions.EditMyProfileAction;
import org.echocat.adam.profile.element.ElementModel;
import javax.annotation.Nonnull;
import java.util.Map;
import static org.apache.commons.lang3.StringUtils.join;
import static org.echocat.adam.profile.ProfileModelProvider.profileModelProvider; | /*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014-2016 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.profile;
public class ExtendedEditMyProfileAction extends EditMyProfileAction {
private Map<String, String[]> _parameters;
@Override
public String doEdit() throws Exception {
final String result = super.doEdit();
final ConfluenceUser user = getUser();
final Profile profile = user != null ? profileProvider().provideFor(user) : null;
if (profile != null && "success".equals(result)) {
updateFields(profile);
profile.reIndex();
}
return result;
}
private void updateFields(@Nonnull Profile profile) { | // Path: src/main/java/org/echocat/adam/profile/element/ElementModel.java
// public interface ElementModel extends Localized {
//
// @Nonnull
// public static final String PERSONAL_INFORMATION_ELEMENT_ID = "personalInformation";
// @Nonnull
// public static final String FULL_NAME_ELEMENT_ID = "fullName";
// @Nonnull
// public static final String USER_NAME_ELEMENT_ID = "username";
// @Nonnull
// public static final String EMAIL_ELEMENT_ID = "email";
// @Nonnull
// public static final String WEBSITE_ELEMENT_ID = "website";
// @Nonnull
// public static final String PHONE_ELEMENT_ID = "phone";
//
// public boolean isStandard();
//
// public boolean isDefaultForReports();
//
// @Nullable
// public List<String> getContextAttributeKeys();
//
// public boolean isSearchable();
//
// public boolean isVisibleIfEmpty();
//
// @Nonnull
// public ViewEditAccess getAccess();
//
// @Nonnull
// public Type getType();
//
// @Nullable
// public Template getTemplate();
//
// public static enum Type {
// singleLineText,
// multiLineText,
// emailAddress,
// url,
// phoneNumber,
// wikiMarkup,
// html
// }
//
// }
//
// Path: src/main/java/org/echocat/adam/profile/ProfileModelProvider.java
// @Nonnull
// public static ProfileModelProvider profileModelProvider() {
// final ProfileModelProvider result = c_instance;
// if (result == null) {
// throw new IllegalStateException("There is currently no instance registered.");
// }
// return result;
// }
//
// Path: src/main/java/org/echocat/adam/profile/ProfileProvider.java
// @Nonnull
// public static ProfileProvider profileProvider() {
// final ProfileProvider result = c_instance;
// if (result == null) {
// throw new IllegalStateException("There is currently no instance registered.");
// }
// return result;
// }
// Path: src/main/java/org/echocat/adam/profile/ExtendedEditMyProfileAction.java
import static org.echocat.adam.profile.ProfileProvider.profileProvider;
import static org.echocat.adam.profile.element.ElementModel.EMAIL_ELEMENT_ID;
import static org.echocat.adam.profile.element.ElementModel.FULL_NAME_ELEMENT_ID;
import static org.echocat.adam.profile.element.ElementModel.USER_NAME_ELEMENT_ID;
import com.atlassian.confluence.user.ConfluenceUser;
import com.atlassian.confluence.user.actions.EditMyProfileAction;
import org.echocat.adam.profile.element.ElementModel;
import javax.annotation.Nonnull;
import java.util.Map;
import static org.apache.commons.lang3.StringUtils.join;
import static org.echocat.adam.profile.ProfileModelProvider.profileModelProvider;
/*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014-2016 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.profile;
public class ExtendedEditMyProfileAction extends EditMyProfileAction {
private Map<String, String[]> _parameters;
@Override
public String doEdit() throws Exception {
final String result = super.doEdit();
final ConfluenceUser user = getUser();
final Profile profile = user != null ? profileProvider().provideFor(user) : null;
if (profile != null && "success".equals(result)) {
updateFields(profile);
profile.reIndex();
}
return result;
}
private void updateFields(@Nonnull Profile profile) { | for (final Group group : profileModelProvider().get()) { |
echocat/adam | src/main/java/org/echocat/adam/profile/ExtendedEditMyProfileAction.java | // Path: src/main/java/org/echocat/adam/profile/element/ElementModel.java
// public interface ElementModel extends Localized {
//
// @Nonnull
// public static final String PERSONAL_INFORMATION_ELEMENT_ID = "personalInformation";
// @Nonnull
// public static final String FULL_NAME_ELEMENT_ID = "fullName";
// @Nonnull
// public static final String USER_NAME_ELEMENT_ID = "username";
// @Nonnull
// public static final String EMAIL_ELEMENT_ID = "email";
// @Nonnull
// public static final String WEBSITE_ELEMENT_ID = "website";
// @Nonnull
// public static final String PHONE_ELEMENT_ID = "phone";
//
// public boolean isStandard();
//
// public boolean isDefaultForReports();
//
// @Nullable
// public List<String> getContextAttributeKeys();
//
// public boolean isSearchable();
//
// public boolean isVisibleIfEmpty();
//
// @Nonnull
// public ViewEditAccess getAccess();
//
// @Nonnull
// public Type getType();
//
// @Nullable
// public Template getTemplate();
//
// public static enum Type {
// singleLineText,
// multiLineText,
// emailAddress,
// url,
// phoneNumber,
// wikiMarkup,
// html
// }
//
// }
//
// Path: src/main/java/org/echocat/adam/profile/ProfileModelProvider.java
// @Nonnull
// public static ProfileModelProvider profileModelProvider() {
// final ProfileModelProvider result = c_instance;
// if (result == null) {
// throw new IllegalStateException("There is currently no instance registered.");
// }
// return result;
// }
//
// Path: src/main/java/org/echocat/adam/profile/ProfileProvider.java
// @Nonnull
// public static ProfileProvider profileProvider() {
// final ProfileProvider result = c_instance;
// if (result == null) {
// throw new IllegalStateException("There is currently no instance registered.");
// }
// return result;
// }
| import static org.echocat.adam.profile.ProfileProvider.profileProvider;
import static org.echocat.adam.profile.element.ElementModel.EMAIL_ELEMENT_ID;
import static org.echocat.adam.profile.element.ElementModel.FULL_NAME_ELEMENT_ID;
import static org.echocat.adam.profile.element.ElementModel.USER_NAME_ELEMENT_ID;
import com.atlassian.confluence.user.ConfluenceUser;
import com.atlassian.confluence.user.actions.EditMyProfileAction;
import org.echocat.adam.profile.element.ElementModel;
import javax.annotation.Nonnull;
import java.util.Map;
import static org.apache.commons.lang3.StringUtils.join;
import static org.echocat.adam.profile.ProfileModelProvider.profileModelProvider; | /*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014-2016 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.profile;
public class ExtendedEditMyProfileAction extends EditMyProfileAction {
private Map<String, String[]> _parameters;
@Override
public String doEdit() throws Exception {
final String result = super.doEdit();
final ConfluenceUser user = getUser();
final Profile profile = user != null ? profileProvider().provideFor(user) : null;
if (profile != null && "success".equals(result)) {
updateFields(profile);
profile.reIndex();
}
return result;
}
private void updateFields(@Nonnull Profile profile) {
for (final Group group : profileModelProvider().get()) { | // Path: src/main/java/org/echocat/adam/profile/element/ElementModel.java
// public interface ElementModel extends Localized {
//
// @Nonnull
// public static final String PERSONAL_INFORMATION_ELEMENT_ID = "personalInformation";
// @Nonnull
// public static final String FULL_NAME_ELEMENT_ID = "fullName";
// @Nonnull
// public static final String USER_NAME_ELEMENT_ID = "username";
// @Nonnull
// public static final String EMAIL_ELEMENT_ID = "email";
// @Nonnull
// public static final String WEBSITE_ELEMENT_ID = "website";
// @Nonnull
// public static final String PHONE_ELEMENT_ID = "phone";
//
// public boolean isStandard();
//
// public boolean isDefaultForReports();
//
// @Nullable
// public List<String> getContextAttributeKeys();
//
// public boolean isSearchable();
//
// public boolean isVisibleIfEmpty();
//
// @Nonnull
// public ViewEditAccess getAccess();
//
// @Nonnull
// public Type getType();
//
// @Nullable
// public Template getTemplate();
//
// public static enum Type {
// singleLineText,
// multiLineText,
// emailAddress,
// url,
// phoneNumber,
// wikiMarkup,
// html
// }
//
// }
//
// Path: src/main/java/org/echocat/adam/profile/ProfileModelProvider.java
// @Nonnull
// public static ProfileModelProvider profileModelProvider() {
// final ProfileModelProvider result = c_instance;
// if (result == null) {
// throw new IllegalStateException("There is currently no instance registered.");
// }
// return result;
// }
//
// Path: src/main/java/org/echocat/adam/profile/ProfileProvider.java
// @Nonnull
// public static ProfileProvider profileProvider() {
// final ProfileProvider result = c_instance;
// if (result == null) {
// throw new IllegalStateException("There is currently no instance registered.");
// }
// return result;
// }
// Path: src/main/java/org/echocat/adam/profile/ExtendedEditMyProfileAction.java
import static org.echocat.adam.profile.ProfileProvider.profileProvider;
import static org.echocat.adam.profile.element.ElementModel.EMAIL_ELEMENT_ID;
import static org.echocat.adam.profile.element.ElementModel.FULL_NAME_ELEMENT_ID;
import static org.echocat.adam.profile.element.ElementModel.USER_NAME_ELEMENT_ID;
import com.atlassian.confluence.user.ConfluenceUser;
import com.atlassian.confluence.user.actions.EditMyProfileAction;
import org.echocat.adam.profile.element.ElementModel;
import javax.annotation.Nonnull;
import java.util.Map;
import static org.apache.commons.lang3.StringUtils.join;
import static org.echocat.adam.profile.ProfileModelProvider.profileModelProvider;
/*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014-2016 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.profile;
public class ExtendedEditMyProfileAction extends EditMyProfileAction {
private Map<String, String[]> _parameters;
@Override
public String doEdit() throws Exception {
final String result = super.doEdit();
final ConfluenceUser user = getUser();
final Profile profile = user != null ? profileProvider().provideFor(user) : null;
if (profile != null && "success".equals(result)) {
updateFields(profile);
profile.reIndex();
}
return result;
}
private void updateFields(@Nonnull Profile profile) {
for (final Group group : profileModelProvider().get()) { | for (final ElementModel elementModel : group) { |
echocat/adam | src/main/java/org/echocat/adam/profile/ProfileDataExtractor.java | // Path: src/main/java/org/echocat/adam/profile/element/ElementModel.java
// public interface ElementModel extends Localized {
//
// @Nonnull
// public static final String PERSONAL_INFORMATION_ELEMENT_ID = "personalInformation";
// @Nonnull
// public static final String FULL_NAME_ELEMENT_ID = "fullName";
// @Nonnull
// public static final String USER_NAME_ELEMENT_ID = "username";
// @Nonnull
// public static final String EMAIL_ELEMENT_ID = "email";
// @Nonnull
// public static final String WEBSITE_ELEMENT_ID = "website";
// @Nonnull
// public static final String PHONE_ELEMENT_ID = "phone";
//
// public boolean isStandard();
//
// public boolean isDefaultForReports();
//
// @Nullable
// public List<String> getContextAttributeKeys();
//
// public boolean isSearchable();
//
// public boolean isVisibleIfEmpty();
//
// @Nonnull
// public ViewEditAccess getAccess();
//
// @Nonnull
// public Type getType();
//
// @Nullable
// public Template getTemplate();
//
// public static enum Type {
// singleLineText,
// multiLineText,
// emailAddress,
// url,
// phoneNumber,
// wikiMarkup,
// html
// }
//
// }
| import org.echocat.adam.profile.element.ElementModel;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Nonnull;
import static org.apache.lucene.document.Field.Store.YES;
import static org.echocat.adam.profile.element.ElementModel.PERSONAL_INFORMATION_ELEMENT_ID;
import com.atlassian.bonnie.Searchable;
import com.atlassian.bonnie.search.Extractor;
import com.atlassian.confluence.user.ConfluenceUser;
import com.atlassian.confluence.user.PersonalInformation;
import com.atlassian.user.EntityException;
import com.atlassian.user.GroupManager;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.StringField;
import org.apache.lucene.document.TextField; | /*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.profile;
public class ProfileDataExtractor implements Extractor {
@Nonnull
private final ProfileProvider _profileProvider;
@Nonnull
private final GroupProvider _groupProvider;
@Nonnull
private final GroupManager _groupManager;
@Autowired
public ProfileDataExtractor(@Nonnull ProfileProvider profileProvider, @Nonnull GroupProvider groupProvider, @Nonnull GroupManager groupManager) {
_profileProvider = profileProvider;
_groupProvider = groupProvider;
_groupManager = groupManager;
}
@Override
public void addFields(@Nonnull Document document, @Nonnull StringBuffer defaultSearchable, @Nonnull Searchable searchable) {
if ((searchable instanceof PersonalInformation)) {
try {
addFields(document, defaultSearchable, (PersonalInformation) searchable);
} catch (final RuntimeException e) {
if (!e.getClass().getName().equals("org.springframework.osgi.service.importer.ServiceProxyDestroyedException")) {
throw e;
}
}
}
}
public void addFields(@Nonnull Document document, @Nonnull StringBuffer defaultSearchable, @Nonnull PersonalInformation personalInformation) {
final ConfluenceUser user = personalInformation.getUser();
final Profile profile = _profileProvider.provideFor(user);
for (final Group group : _groupProvider) { | // Path: src/main/java/org/echocat/adam/profile/element/ElementModel.java
// public interface ElementModel extends Localized {
//
// @Nonnull
// public static final String PERSONAL_INFORMATION_ELEMENT_ID = "personalInformation";
// @Nonnull
// public static final String FULL_NAME_ELEMENT_ID = "fullName";
// @Nonnull
// public static final String USER_NAME_ELEMENT_ID = "username";
// @Nonnull
// public static final String EMAIL_ELEMENT_ID = "email";
// @Nonnull
// public static final String WEBSITE_ELEMENT_ID = "website";
// @Nonnull
// public static final String PHONE_ELEMENT_ID = "phone";
//
// public boolean isStandard();
//
// public boolean isDefaultForReports();
//
// @Nullable
// public List<String> getContextAttributeKeys();
//
// public boolean isSearchable();
//
// public boolean isVisibleIfEmpty();
//
// @Nonnull
// public ViewEditAccess getAccess();
//
// @Nonnull
// public Type getType();
//
// @Nullable
// public Template getTemplate();
//
// public static enum Type {
// singleLineText,
// multiLineText,
// emailAddress,
// url,
// phoneNumber,
// wikiMarkup,
// html
// }
//
// }
// Path: src/main/java/org/echocat/adam/profile/ProfileDataExtractor.java
import org.echocat.adam.profile.element.ElementModel;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Nonnull;
import static org.apache.lucene.document.Field.Store.YES;
import static org.echocat.adam.profile.element.ElementModel.PERSONAL_INFORMATION_ELEMENT_ID;
import com.atlassian.bonnie.Searchable;
import com.atlassian.bonnie.search.Extractor;
import com.atlassian.confluence.user.ConfluenceUser;
import com.atlassian.confluence.user.PersonalInformation;
import com.atlassian.user.EntityException;
import com.atlassian.user.GroupManager;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.StringField;
import org.apache.lucene.document.TextField;
/*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.profile;
public class ProfileDataExtractor implements Extractor {
@Nonnull
private final ProfileProvider _profileProvider;
@Nonnull
private final GroupProvider _groupProvider;
@Nonnull
private final GroupManager _groupManager;
@Autowired
public ProfileDataExtractor(@Nonnull ProfileProvider profileProvider, @Nonnull GroupProvider groupProvider, @Nonnull GroupManager groupManager) {
_profileProvider = profileProvider;
_groupProvider = groupProvider;
_groupManager = groupManager;
}
@Override
public void addFields(@Nonnull Document document, @Nonnull StringBuffer defaultSearchable, @Nonnull Searchable searchable) {
if ((searchable instanceof PersonalInformation)) {
try {
addFields(document, defaultSearchable, (PersonalInformation) searchable);
} catch (final RuntimeException e) {
if (!e.getClass().getName().equals("org.springframework.osgi.service.importer.ServiceProxyDestroyedException")) {
throw e;
}
}
}
}
public void addFields(@Nonnull Document document, @Nonnull StringBuffer defaultSearchable, @Nonnull PersonalInformation personalInformation) {
final ConfluenceUser user = personalInformation.getUser();
final Profile profile = _profileProvider.provideFor(user);
for (final Group group : _groupProvider) { | for (final ElementModel elementModel : group) { |
echocat/adam | src/main/java/org/echocat/adam/report/Column.java | // Path: src/main/java/org/echocat/adam/access/ViewAccess.java
// public interface ViewAccess {
//
// @Nonnull
// public Visibility checkView(@Nullable User forUser, @Nullable User target);
//
// public static enum Visibility {
// allowed,
// masked,
// forbidden;
//
// public boolean isViewAllowed() {
// return this == allowed || this == masked;
// }
//
// public boolean isMasked() {
// return this == masked;
// }
//
// public boolean isBetterThen(@Nonnull Visibility other) {
// return other == null || ordinal() < other.ordinal();
// }
//
// public boolean isBest() {
// return ordinal() == 0;
// }
//
// public static boolean isBestVisibility(@Nullable Visibility what) {
// return what != null && what.isBest();
// }
//
// public static boolean isBetterVisibility(@Nullable Visibility what, @Nullable Visibility then) {
// return what != null && what.isBetterThen(then);
// }
// }
//
// }
//
// Path: src/main/java/org/echocat/adam/localization/Localized.java
// public interface Localized extends IdEnabled<String> {
//
// @Nullable
// public Map<Locale, Localization> getLocalizations();
//
// }
//
// Path: src/main/java/org/echocat/adam/template/Template.java
// public interface Template {
//
// @Nonnull
// public String getSource();
//
// @Nonnull
// public TemplateFormat getFormat();
//
// public static class Simple implements Template {
//
// @Nonnull
// public static Template simpleTemplateFor(@Nonnull String elementId) {
// return new Simple(elementId);
// }
//
// @Nonnull
// private final String _elementId;
//
// public Simple(@Nonnull String elementId) {
// _elementId = elementId;
// }
//
// @Nonnull
// @Override
// public String getSource() {
// return "$!{" + _elementId + "}";
// }
//
// @Nonnull
// @Override
// public TemplateFormat getFormat() {
// return TemplateFormat.velocity;
// }
//
// }
//
// }
| import org.echocat.adam.access.ViewAccess;
import org.echocat.adam.localization.Localized;
import org.echocat.adam.template.Template;
import javax.annotation.Nonnull;
import javax.annotation.Nullable; | /*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.report;
public interface Column extends Localized, Iterable<ColumnElementModel> {
@Nullable | // Path: src/main/java/org/echocat/adam/access/ViewAccess.java
// public interface ViewAccess {
//
// @Nonnull
// public Visibility checkView(@Nullable User forUser, @Nullable User target);
//
// public static enum Visibility {
// allowed,
// masked,
// forbidden;
//
// public boolean isViewAllowed() {
// return this == allowed || this == masked;
// }
//
// public boolean isMasked() {
// return this == masked;
// }
//
// public boolean isBetterThen(@Nonnull Visibility other) {
// return other == null || ordinal() < other.ordinal();
// }
//
// public boolean isBest() {
// return ordinal() == 0;
// }
//
// public static boolean isBestVisibility(@Nullable Visibility what) {
// return what != null && what.isBest();
// }
//
// public static boolean isBetterVisibility(@Nullable Visibility what, @Nullable Visibility then) {
// return what != null && what.isBetterThen(then);
// }
// }
//
// }
//
// Path: src/main/java/org/echocat/adam/localization/Localized.java
// public interface Localized extends IdEnabled<String> {
//
// @Nullable
// public Map<Locale, Localization> getLocalizations();
//
// }
//
// Path: src/main/java/org/echocat/adam/template/Template.java
// public interface Template {
//
// @Nonnull
// public String getSource();
//
// @Nonnull
// public TemplateFormat getFormat();
//
// public static class Simple implements Template {
//
// @Nonnull
// public static Template simpleTemplateFor(@Nonnull String elementId) {
// return new Simple(elementId);
// }
//
// @Nonnull
// private final String _elementId;
//
// public Simple(@Nonnull String elementId) {
// _elementId = elementId;
// }
//
// @Nonnull
// @Override
// public String getSource() {
// return "$!{" + _elementId + "}";
// }
//
// @Nonnull
// @Override
// public TemplateFormat getFormat() {
// return TemplateFormat.velocity;
// }
//
// }
//
// }
// Path: src/main/java/org/echocat/adam/report/Column.java
import org.echocat.adam.access.ViewAccess;
import org.echocat.adam.localization.Localized;
import org.echocat.adam.template.Template;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.report;
public interface Column extends Localized, Iterable<ColumnElementModel> {
@Nullable | public Template getTemplate(); |
echocat/adam | src/main/java/org/echocat/adam/report/Column.java | // Path: src/main/java/org/echocat/adam/access/ViewAccess.java
// public interface ViewAccess {
//
// @Nonnull
// public Visibility checkView(@Nullable User forUser, @Nullable User target);
//
// public static enum Visibility {
// allowed,
// masked,
// forbidden;
//
// public boolean isViewAllowed() {
// return this == allowed || this == masked;
// }
//
// public boolean isMasked() {
// return this == masked;
// }
//
// public boolean isBetterThen(@Nonnull Visibility other) {
// return other == null || ordinal() < other.ordinal();
// }
//
// public boolean isBest() {
// return ordinal() == 0;
// }
//
// public static boolean isBestVisibility(@Nullable Visibility what) {
// return what != null && what.isBest();
// }
//
// public static boolean isBetterVisibility(@Nullable Visibility what, @Nullable Visibility then) {
// return what != null && what.isBetterThen(then);
// }
// }
//
// }
//
// Path: src/main/java/org/echocat/adam/localization/Localized.java
// public interface Localized extends IdEnabled<String> {
//
// @Nullable
// public Map<Locale, Localization> getLocalizations();
//
// }
//
// Path: src/main/java/org/echocat/adam/template/Template.java
// public interface Template {
//
// @Nonnull
// public String getSource();
//
// @Nonnull
// public TemplateFormat getFormat();
//
// public static class Simple implements Template {
//
// @Nonnull
// public static Template simpleTemplateFor(@Nonnull String elementId) {
// return new Simple(elementId);
// }
//
// @Nonnull
// private final String _elementId;
//
// public Simple(@Nonnull String elementId) {
// _elementId = elementId;
// }
//
// @Nonnull
// @Override
// public String getSource() {
// return "$!{" + _elementId + "}";
// }
//
// @Nonnull
// @Override
// public TemplateFormat getFormat() {
// return TemplateFormat.velocity;
// }
//
// }
//
// }
| import org.echocat.adam.access.ViewAccess;
import org.echocat.adam.localization.Localized;
import org.echocat.adam.template.Template;
import javax.annotation.Nonnull;
import javax.annotation.Nullable; | /*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.report;
public interface Column extends Localized, Iterable<ColumnElementModel> {
@Nullable
public Template getTemplate();
@Nonnull | // Path: src/main/java/org/echocat/adam/access/ViewAccess.java
// public interface ViewAccess {
//
// @Nonnull
// public Visibility checkView(@Nullable User forUser, @Nullable User target);
//
// public static enum Visibility {
// allowed,
// masked,
// forbidden;
//
// public boolean isViewAllowed() {
// return this == allowed || this == masked;
// }
//
// public boolean isMasked() {
// return this == masked;
// }
//
// public boolean isBetterThen(@Nonnull Visibility other) {
// return other == null || ordinal() < other.ordinal();
// }
//
// public boolean isBest() {
// return ordinal() == 0;
// }
//
// public static boolean isBestVisibility(@Nullable Visibility what) {
// return what != null && what.isBest();
// }
//
// public static boolean isBetterVisibility(@Nullable Visibility what, @Nullable Visibility then) {
// return what != null && what.isBetterThen(then);
// }
// }
//
// }
//
// Path: src/main/java/org/echocat/adam/localization/Localized.java
// public interface Localized extends IdEnabled<String> {
//
// @Nullable
// public Map<Locale, Localization> getLocalizations();
//
// }
//
// Path: src/main/java/org/echocat/adam/template/Template.java
// public interface Template {
//
// @Nonnull
// public String getSource();
//
// @Nonnull
// public TemplateFormat getFormat();
//
// public static class Simple implements Template {
//
// @Nonnull
// public static Template simpleTemplateFor(@Nonnull String elementId) {
// return new Simple(elementId);
// }
//
// @Nonnull
// private final String _elementId;
//
// public Simple(@Nonnull String elementId) {
// _elementId = elementId;
// }
//
// @Nonnull
// @Override
// public String getSource() {
// return "$!{" + _elementId + "}";
// }
//
// @Nonnull
// @Override
// public TemplateFormat getFormat() {
// return TemplateFormat.velocity;
// }
//
// }
//
// }
// Path: src/main/java/org/echocat/adam/report/Column.java
import org.echocat.adam.access.ViewAccess;
import org.echocat.adam.localization.Localized;
import org.echocat.adam.template.Template;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.report;
public interface Column extends Localized, Iterable<ColumnElementModel> {
@Nullable
public Template getTemplate();
@Nonnull | public ViewAccess getAccess(); |
echocat/adam | src/main/java/org/echocat/adam/configuration/template/Template.java | // Path: src/main/java/org/echocat/adam/template/TemplateFormat.java
// public enum TemplateFormat {
// velocity,
// plain
// }
//
// Path: src/main/java/org/echocat/adam/template/TemplateSupport.java
// @XmlTransient
// public abstract class TemplateSupport implements Template {
//
// @Override
// public boolean equals(Object o) {
// final boolean result;
// if (this == o) {
// result = true;
// } else if (!(o instanceof Template)) {
// result = false;
// } else {
// result = getFormat().equals(((Template)o).getFormat()) && getSource().equals(((Template)o).getSource());
// }
// return result;
// }
//
// @Override
// public int hashCode() {
// return getFormat().hashCode() * getSource().hashCode();
// }
//
//
// @Override
// public String toString() {
// final String source = getSource();
// final String trimmedSource = source.replaceAll("\\s+", " ").trim();
// final String shorterSource = abbreviate(trimmedSource, 50);
// return "template{" + getFormat() + ":" + shorterSource + "}";
// }
// }
//
// Path: src/main/java/org/echocat/adam/configuration/ConfigurationContants.java
// public static final String SCHEMA_NAMESPACE = "https://adam.echocat.org/schemas/configuration.xsd";
| import static org.echocat.adam.configuration.ConfigurationContants.SCHEMA_NAMESPACE;
import static org.echocat.adam.template.TemplateFormat.velocity;
import org.echocat.adam.template.TemplateFormat;
import org.echocat.adam.template.TemplateSupport;
import org.eclipse.persistence.oxm.annotations.XmlValueExtension;
import javax.annotation.Nonnull;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.XmlValue; | /*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014-2016 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.configuration.template;
@XmlType(name = "template", namespace = SCHEMA_NAMESPACE)
public class Template extends TemplateSupport {
@Nonnull
private String _source = "";
@Nonnull | // Path: src/main/java/org/echocat/adam/template/TemplateFormat.java
// public enum TemplateFormat {
// velocity,
// plain
// }
//
// Path: src/main/java/org/echocat/adam/template/TemplateSupport.java
// @XmlTransient
// public abstract class TemplateSupport implements Template {
//
// @Override
// public boolean equals(Object o) {
// final boolean result;
// if (this == o) {
// result = true;
// } else if (!(o instanceof Template)) {
// result = false;
// } else {
// result = getFormat().equals(((Template)o).getFormat()) && getSource().equals(((Template)o).getSource());
// }
// return result;
// }
//
// @Override
// public int hashCode() {
// return getFormat().hashCode() * getSource().hashCode();
// }
//
//
// @Override
// public String toString() {
// final String source = getSource();
// final String trimmedSource = source.replaceAll("\\s+", " ").trim();
// final String shorterSource = abbreviate(trimmedSource, 50);
// return "template{" + getFormat() + ":" + shorterSource + "}";
// }
// }
//
// Path: src/main/java/org/echocat/adam/configuration/ConfigurationContants.java
// public static final String SCHEMA_NAMESPACE = "https://adam.echocat.org/schemas/configuration.xsd";
// Path: src/main/java/org/echocat/adam/configuration/template/Template.java
import static org.echocat.adam.configuration.ConfigurationContants.SCHEMA_NAMESPACE;
import static org.echocat.adam.template.TemplateFormat.velocity;
import org.echocat.adam.template.TemplateFormat;
import org.echocat.adam.template.TemplateSupport;
import org.eclipse.persistence.oxm.annotations.XmlValueExtension;
import javax.annotation.Nonnull;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.XmlValue;
/*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014-2016 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.configuration.template;
@XmlType(name = "template", namespace = SCHEMA_NAMESPACE)
public class Template extends TemplateSupport {
@Nonnull
private String _source = "";
@Nonnull | private TemplateFormat _format = velocity; |
echocat/adam | src/main/java/org/echocat/adam/profile/UserProfileDataQuery.java | // Path: src/main/java/org/echocat/adam/report/Column.java
// public interface Column extends Localized, Iterable<ColumnElementModel> {
//
// @Nullable
// public Template getTemplate();
//
// @Nonnull
// public ViewAccess getAccess();
//
// @Nonnull
// public Link getLink();
//
// public static enum Link {
// none,
// profile
// }
//
// }
| import static org.echocat.jomon.runtime.CollectionUtils.asList;
import com.atlassian.confluence.search.v2.SearchFilter;
import com.atlassian.confluence.search.v2.SearchQuery;
import org.echocat.adam.report.Column;
import org.echocat.jomon.runtime.CollectionUtils;
import org.echocat.jomon.runtime.StringUtils;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List; | /*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014-2016 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.profile;
public class UserProfileDataQuery implements SearchQuery {
@Nullable | // Path: src/main/java/org/echocat/adam/report/Column.java
// public interface Column extends Localized, Iterable<ColumnElementModel> {
//
// @Nullable
// public Template getTemplate();
//
// @Nonnull
// public ViewAccess getAccess();
//
// @Nonnull
// public Link getLink();
//
// public static enum Link {
// none,
// profile
// }
//
// }
// Path: src/main/java/org/echocat/adam/profile/UserProfileDataQuery.java
import static org.echocat.jomon.runtime.CollectionUtils.asList;
import com.atlassian.confluence.search.v2.SearchFilter;
import com.atlassian.confluence.search.v2.SearchQuery;
import org.echocat.adam.report.Column;
import org.echocat.jomon.runtime.CollectionUtils;
import org.echocat.jomon.runtime.StringUtils;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List;
/*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014-2016 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.profile;
public class UserProfileDataQuery implements SearchQuery {
@Nullable | public static UserProfileDataQuery userProfileDataQueryFor(@Nullable String searchTerm, @Nullable Iterable<Column> onColumns) { |
echocat/adam | src/main/java/org/echocat/adam/configuration/ConfigurationRepository.java | // Path: src/main/java/org/echocat/adam/configuration/ConfigurationMarshaller.java
// @Nullable
// public static Configuration unmarshall(@Nonnull Reader content) {
// return unmarshall(content, null);
// }
| import javax.annotation.Nullable;
import java.io.IOException;
import java.io.InputStream;
import java.util.concurrent.TimeUnit;
import static com.atlassian.confluence.setup.bandana.ConfluenceBandanaContext.GLOBAL_CONTEXT;
import static java.lang.System.currentTimeMillis;
import static org.echocat.adam.configuration.ConfigurationMarshaller.unmarshall;
import com.atlassian.bandana.BandanaManager;
import org.apache.commons.io.IOUtils;
import org.echocat.jomon.runtime.util.Duration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Nonnegative;
import javax.annotation.Nonnull; | result = getInternal();
_cached = result;
_expiresAt = currentTimeMillis() + CACHE_EXPIRES_AT.in(TimeUnit.MILLISECONDS);
}
return result;
}
@Nonnull
public String getPlain() {
final Object plain = _bandanaManager.getValue(GLOBAL_CONTEXT, KEY);
String result;
if (plain instanceof String) {
result = (String) plain;
} else {
try (final InputStream is = getClass().getResourceAsStream("default.configuration.xml")) {
result = IOUtils.toString(is);
} catch (final IOException e) {
LOG.warn("Could not load the default configuration. Will use an empty one.", e);
result = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<configuration></configuration>";
}
}
return result;
}
@Nonnull
protected Configuration getInternal() {
final String plain = getPlain();
Configuration result;
try { | // Path: src/main/java/org/echocat/adam/configuration/ConfigurationMarshaller.java
// @Nullable
// public static Configuration unmarshall(@Nonnull Reader content) {
// return unmarshall(content, null);
// }
// Path: src/main/java/org/echocat/adam/configuration/ConfigurationRepository.java
import javax.annotation.Nullable;
import java.io.IOException;
import java.io.InputStream;
import java.util.concurrent.TimeUnit;
import static com.atlassian.confluence.setup.bandana.ConfluenceBandanaContext.GLOBAL_CONTEXT;
import static java.lang.System.currentTimeMillis;
import static org.echocat.adam.configuration.ConfigurationMarshaller.unmarshall;
import com.atlassian.bandana.BandanaManager;
import org.apache.commons.io.IOUtils;
import org.echocat.jomon.runtime.util.Duration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Nonnegative;
import javax.annotation.Nonnull;
result = getInternal();
_cached = result;
_expiresAt = currentTimeMillis() + CACHE_EXPIRES_AT.in(TimeUnit.MILLISECONDS);
}
return result;
}
@Nonnull
public String getPlain() {
final Object plain = _bandanaManager.getValue(GLOBAL_CONTEXT, KEY);
String result;
if (plain instanceof String) {
result = (String) plain;
} else {
try (final InputStream is = getClass().getResourceAsStream("default.configuration.xml")) {
result = IOUtils.toString(is);
} catch (final IOException e) {
LOG.warn("Could not load the default configuration. Will use an empty one.", e);
result = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<configuration></configuration>";
}
}
return result;
}
@Nonnull
protected Configuration getInternal() {
final String plain = getPlain();
Configuration result;
try { | result = unmarshall(plain, "database:configuration.xml"); |
echocat/adam | src/main/java/org/echocat/adam/configuration/ConfigurationNamespacePrefixMapper.java | // Path: src/main/java/org/echocat/adam/configuration/ConfigurationContants.java
// public static final String SCHEMA_NAMESPACE = "https://adam.echocat.org/schemas/configuration.xsd";
| import org.eclipse.persistence.oxm.NamespacePrefixMapper;
import static org.echocat.adam.configuration.ConfigurationContants.SCHEMA_NAMESPACE; | /*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.configuration;
public class ConfigurationNamespacePrefixMapper extends NamespacePrefixMapper {
@Override
public String getPreferredPrefix(String namespaceUri, String suggestion, boolean requirePrefix) {
final String result; | // Path: src/main/java/org/echocat/adam/configuration/ConfigurationContants.java
// public static final String SCHEMA_NAMESPACE = "https://adam.echocat.org/schemas/configuration.xsd";
// Path: src/main/java/org/echocat/adam/configuration/ConfigurationNamespacePrefixMapper.java
import org.eclipse.persistence.oxm.NamespacePrefixMapper;
import static org.echocat.adam.configuration.ConfigurationContants.SCHEMA_NAMESPACE;
/*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.configuration;
public class ConfigurationNamespacePrefixMapper extends NamespacePrefixMapper {
@Override
public String getPreferredPrefix(String namespaceUri, String suggestion, boolean requirePrefix) {
final String result; | if (SCHEMA_NAMESPACE.equals(namespaceUri)) { |
echocat/adam | src/main/java/org/echocat/adam/localization/LocalizationHelper.java | // Path: src/main/java/org/echocat/adam/profile/element/ElementModel.java
// public interface ElementModel extends Localized {
//
// @Nonnull
// public static final String PERSONAL_INFORMATION_ELEMENT_ID = "personalInformation";
// @Nonnull
// public static final String FULL_NAME_ELEMENT_ID = "fullName";
// @Nonnull
// public static final String USER_NAME_ELEMENT_ID = "username";
// @Nonnull
// public static final String EMAIL_ELEMENT_ID = "email";
// @Nonnull
// public static final String WEBSITE_ELEMENT_ID = "website";
// @Nonnull
// public static final String PHONE_ELEMENT_ID = "phone";
//
// public boolean isStandard();
//
// public boolean isDefaultForReports();
//
// @Nullable
// public List<String> getContextAttributeKeys();
//
// public boolean isSearchable();
//
// public boolean isVisibleIfEmpty();
//
// @Nonnull
// public ViewEditAccess getAccess();
//
// @Nonnull
// public Type getType();
//
// @Nullable
// public Template getTemplate();
//
// public static enum Type {
// singleLineText,
// multiLineText,
// emailAddress,
// url,
// phoneNumber,
// wikiMarkup,
// html
// }
//
// }
| import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Locale;
import java.util.Map;
import static java.util.Locale.US;
import static org.apache.commons.lang3.StringUtils.capitalize;
import static org.echocat.adam.profile.element.ElementModel.Type.wikiMarkup;
import com.atlassian.confluence.languages.LocaleManager;
import com.atlassian.confluence.util.i18n.DocumentationBean;
import com.atlassian.confluence.util.i18n.DocumentationBeanFactory;
import com.atlassian.confluence.util.i18n.I18NBean;
import com.atlassian.confluence.util.i18n.I18NBeanFactory;
import com.atlassian.confluence.velocity.htmlsafe.HtmlSafe;
import com.atlassian.user.User;
import org.echocat.adam.profile.element.ElementModel;
import org.springframework.beans.factory.DisposableBean; | @Nonnull
private final I18NBeanFactory _i18NBeanFactory;
@Nonnull
private final DocumentationBeanFactory _documentationBeanFactory;
@Nonnull
private final LocaleManager _localeManager;
@Autowired
public LocalizationHelper(@Nonnull LocaleManager localeManager, @Nonnull I18NBeanFactory i18NBeanFactory, @Nonnull DocumentationBeanFactory documentationBeanFactory) {
_localeManager = localeManager;
_i18NBeanFactory = i18NBeanFactory;
_documentationBeanFactory = documentationBeanFactory;
c_instance = this;
}
@Nonnull
public String getTitleFor(@Nonnull Localized localized) {
return getTitleFor(localized, DEFAULT_LOCALE);
}
@Nonnull
public String getTitleFor(@Nonnull Localized localized, @Nullable Locale locale) {
final Map<Locale, Localization> localizations = localized.getLocalizations();
return localizations != null ? getTitleFor(localized, locale, localizations) : getDefaultTitleFor(localized, locale);
}
@Nonnull
protected String getDefaultTitleFor(@Nonnull Localized localized, @Nullable Locale locale) {
final String result; | // Path: src/main/java/org/echocat/adam/profile/element/ElementModel.java
// public interface ElementModel extends Localized {
//
// @Nonnull
// public static final String PERSONAL_INFORMATION_ELEMENT_ID = "personalInformation";
// @Nonnull
// public static final String FULL_NAME_ELEMENT_ID = "fullName";
// @Nonnull
// public static final String USER_NAME_ELEMENT_ID = "username";
// @Nonnull
// public static final String EMAIL_ELEMENT_ID = "email";
// @Nonnull
// public static final String WEBSITE_ELEMENT_ID = "website";
// @Nonnull
// public static final String PHONE_ELEMENT_ID = "phone";
//
// public boolean isStandard();
//
// public boolean isDefaultForReports();
//
// @Nullable
// public List<String> getContextAttributeKeys();
//
// public boolean isSearchable();
//
// public boolean isVisibleIfEmpty();
//
// @Nonnull
// public ViewEditAccess getAccess();
//
// @Nonnull
// public Type getType();
//
// @Nullable
// public Template getTemplate();
//
// public static enum Type {
// singleLineText,
// multiLineText,
// emailAddress,
// url,
// phoneNumber,
// wikiMarkup,
// html
// }
//
// }
// Path: src/main/java/org/echocat/adam/localization/LocalizationHelper.java
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Locale;
import java.util.Map;
import static java.util.Locale.US;
import static org.apache.commons.lang3.StringUtils.capitalize;
import static org.echocat.adam.profile.element.ElementModel.Type.wikiMarkup;
import com.atlassian.confluence.languages.LocaleManager;
import com.atlassian.confluence.util.i18n.DocumentationBean;
import com.atlassian.confluence.util.i18n.DocumentationBeanFactory;
import com.atlassian.confluence.util.i18n.I18NBean;
import com.atlassian.confluence.util.i18n.I18NBeanFactory;
import com.atlassian.confluence.velocity.htmlsafe.HtmlSafe;
import com.atlassian.user.User;
import org.echocat.adam.profile.element.ElementModel;
import org.springframework.beans.factory.DisposableBean;
@Nonnull
private final I18NBeanFactory _i18NBeanFactory;
@Nonnull
private final DocumentationBeanFactory _documentationBeanFactory;
@Nonnull
private final LocaleManager _localeManager;
@Autowired
public LocalizationHelper(@Nonnull LocaleManager localeManager, @Nonnull I18NBeanFactory i18NBeanFactory, @Nonnull DocumentationBeanFactory documentationBeanFactory) {
_localeManager = localeManager;
_i18NBeanFactory = i18NBeanFactory;
_documentationBeanFactory = documentationBeanFactory;
c_instance = this;
}
@Nonnull
public String getTitleFor(@Nonnull Localized localized) {
return getTitleFor(localized, DEFAULT_LOCALE);
}
@Nonnull
public String getTitleFor(@Nonnull Localized localized, @Nullable Locale locale) {
final Map<Locale, Localization> localizations = localized.getLocalizations();
return localizations != null ? getTitleFor(localized, locale, localizations) : getDefaultTitleFor(localized, locale);
}
@Nonnull
protected String getDefaultTitleFor(@Nonnull Localized localized, @Nullable Locale locale) {
final String result; | if (localized instanceof ElementModel && !((ElementModel)localized).isStandard()) { |
echocat/adam | src/main/java/org/echocat/adam/configuration/access/view/RuleSupport.java | // Path: src/main/java/org/echocat/adam/access/ViewAccess.java
// public static enum Visibility {
// allowed,
// masked,
// forbidden;
//
// public boolean isViewAllowed() {
// return this == allowed || this == masked;
// }
//
// public boolean isMasked() {
// return this == masked;
// }
//
// public boolean isBetterThen(@Nonnull Visibility other) {
// return other == null || ordinal() < other.ordinal();
// }
//
// public boolean isBest() {
// return ordinal() == 0;
// }
//
// public static boolean isBestVisibility(@Nullable Visibility what) {
// return what != null && what.isBest();
// }
//
// public static boolean isBetterVisibility(@Nullable Visibility what, @Nullable Visibility then) {
// return what != null && what.isBetterThen(then);
// }
// }
| import javax.annotation.Nonnull;
import javax.xml.bind.annotation.XmlAttribute;
import org.echocat.adam.access.ViewAccess.Visibility; | /*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.configuration.access.view;
public abstract class RuleSupport implements Rule {
@Nonnull | // Path: src/main/java/org/echocat/adam/access/ViewAccess.java
// public static enum Visibility {
// allowed,
// masked,
// forbidden;
//
// public boolean isViewAllowed() {
// return this == allowed || this == masked;
// }
//
// public boolean isMasked() {
// return this == masked;
// }
//
// public boolean isBetterThen(@Nonnull Visibility other) {
// return other == null || ordinal() < other.ordinal();
// }
//
// public boolean isBest() {
// return ordinal() == 0;
// }
//
// public static boolean isBestVisibility(@Nullable Visibility what) {
// return what != null && what.isBest();
// }
//
// public static boolean isBetterVisibility(@Nullable Visibility what, @Nullable Visibility then) {
// return what != null && what.isBetterThen(then);
// }
// }
// Path: src/main/java/org/echocat/adam/configuration/access/view/RuleSupport.java
import javax.annotation.Nonnull;
import javax.xml.bind.annotation.XmlAttribute;
import org.echocat.adam.access.ViewAccess.Visibility;
/*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.configuration.access.view;
public abstract class RuleSupport implements Rule {
@Nonnull | private Visibility _view = Visibility.allowed; |
echocat/adam | src/main/java/org/echocat/adam/profile/UserProfileDataQueryMapper.java | // Path: src/main/java/org/echocat/adam/report/Column.java
// public interface Column extends Localized, Iterable<ColumnElementModel> {
//
// @Nullable
// public Template getTemplate();
//
// @Nonnull
// public ViewAccess getAccess();
//
// @Nonnull
// public Link getLink();
//
// public static enum Link {
// none,
// profile
// }
//
// }
//
// Path: src/main/java/org/echocat/adam/report/ColumnElementModel.java
// public interface ColumnElementModel extends ElementModel {
//
// @Nonnull
// public Format getFormat();
//
// public static enum Format {
// plain,
// formatted
// }
//
// }
| import javax.annotation.Nonnull;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import static com.atlassian.bonnie.BonnieConstants.LUCENE_VERSION;
import static org.apache.lucene.queryparser.classic.QueryParser.Operator.AND;
import com.atlassian.bonnie.analyzer.LuceneAnalyzerFactory;
import com.atlassian.confluence.search.v2.lucene.LuceneQueryMapper;
import org.apache.lucene.queryparser.classic.MultiFieldQueryParser;
import org.apache.lucene.queryparser.classic.ParseException;
import org.apache.lucene.queryparser.classic.QueryParser;
import org.apache.lucene.search.Query;
import org.echocat.adam.report.Column;
import org.echocat.adam.report.ColumnElementModel; | /*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.profile;
public class UserProfileDataQueryMapper implements LuceneQueryMapper<UserProfileDataQuery> {
@Nonnull
private final LuceneAnalyzerFactory _luceneAnalyzerFactory;
public UserProfileDataQueryMapper(@Nonnull LuceneAnalyzerFactory luceneAnalyzerFactory) {
_luceneAnalyzerFactory = luceneAnalyzerFactory;
}
@Override
public Query convertToLuceneQuery(@Nonnull UserProfileDataQuery query) {
final QueryParser parser = new MultiFieldQueryParser(LUCENE_VERSION, toFieldsArray(query), _luceneAnalyzerFactory.createAnalyzer());
parser.setDefaultOperator(AND);
final String searchTerm = query.getSearchTerm();
try {
return parser.parse(searchTerm != null ? searchTerm : "");
} catch (final ParseException e) {
throw new RuntimeException("Unable to parse query: " + searchTerm, e);
}
}
@Nonnull
protected Set<String> toFields(@Nonnull UserProfileDataQuery query) {
final Set<String> fields = new HashSet<>(); | // Path: src/main/java/org/echocat/adam/report/Column.java
// public interface Column extends Localized, Iterable<ColumnElementModel> {
//
// @Nullable
// public Template getTemplate();
//
// @Nonnull
// public ViewAccess getAccess();
//
// @Nonnull
// public Link getLink();
//
// public static enum Link {
// none,
// profile
// }
//
// }
//
// Path: src/main/java/org/echocat/adam/report/ColumnElementModel.java
// public interface ColumnElementModel extends ElementModel {
//
// @Nonnull
// public Format getFormat();
//
// public static enum Format {
// plain,
// formatted
// }
//
// }
// Path: src/main/java/org/echocat/adam/profile/UserProfileDataQueryMapper.java
import javax.annotation.Nonnull;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import static com.atlassian.bonnie.BonnieConstants.LUCENE_VERSION;
import static org.apache.lucene.queryparser.classic.QueryParser.Operator.AND;
import com.atlassian.bonnie.analyzer.LuceneAnalyzerFactory;
import com.atlassian.confluence.search.v2.lucene.LuceneQueryMapper;
import org.apache.lucene.queryparser.classic.MultiFieldQueryParser;
import org.apache.lucene.queryparser.classic.ParseException;
import org.apache.lucene.queryparser.classic.QueryParser;
import org.apache.lucene.search.Query;
import org.echocat.adam.report.Column;
import org.echocat.adam.report.ColumnElementModel;
/*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.profile;
public class UserProfileDataQueryMapper implements LuceneQueryMapper<UserProfileDataQuery> {
@Nonnull
private final LuceneAnalyzerFactory _luceneAnalyzerFactory;
public UserProfileDataQueryMapper(@Nonnull LuceneAnalyzerFactory luceneAnalyzerFactory) {
_luceneAnalyzerFactory = luceneAnalyzerFactory;
}
@Override
public Query convertToLuceneQuery(@Nonnull UserProfileDataQuery query) {
final QueryParser parser = new MultiFieldQueryParser(LUCENE_VERSION, toFieldsArray(query), _luceneAnalyzerFactory.createAnalyzer());
parser.setDefaultOperator(AND);
final String searchTerm = query.getSearchTerm();
try {
return parser.parse(searchTerm != null ? searchTerm : "");
} catch (final ParseException e) {
throw new RuntimeException("Unable to parse query: " + searchTerm, e);
}
}
@Nonnull
protected Set<String> toFields(@Nonnull UserProfileDataQuery query) {
final Set<String> fields = new HashSet<>(); | final Iterable<Column> columns = query.getColumns(); |
echocat/adam | src/main/java/org/echocat/adam/profile/UserProfileDataQueryMapper.java | // Path: src/main/java/org/echocat/adam/report/Column.java
// public interface Column extends Localized, Iterable<ColumnElementModel> {
//
// @Nullable
// public Template getTemplate();
//
// @Nonnull
// public ViewAccess getAccess();
//
// @Nonnull
// public Link getLink();
//
// public static enum Link {
// none,
// profile
// }
//
// }
//
// Path: src/main/java/org/echocat/adam/report/ColumnElementModel.java
// public interface ColumnElementModel extends ElementModel {
//
// @Nonnull
// public Format getFormat();
//
// public static enum Format {
// plain,
// formatted
// }
//
// }
| import javax.annotation.Nonnull;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import static com.atlassian.bonnie.BonnieConstants.LUCENE_VERSION;
import static org.apache.lucene.queryparser.classic.QueryParser.Operator.AND;
import com.atlassian.bonnie.analyzer.LuceneAnalyzerFactory;
import com.atlassian.confluence.search.v2.lucene.LuceneQueryMapper;
import org.apache.lucene.queryparser.classic.MultiFieldQueryParser;
import org.apache.lucene.queryparser.classic.ParseException;
import org.apache.lucene.queryparser.classic.QueryParser;
import org.apache.lucene.search.Query;
import org.echocat.adam.report.Column;
import org.echocat.adam.report.ColumnElementModel; | /*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.profile;
public class UserProfileDataQueryMapper implements LuceneQueryMapper<UserProfileDataQuery> {
@Nonnull
private final LuceneAnalyzerFactory _luceneAnalyzerFactory;
public UserProfileDataQueryMapper(@Nonnull LuceneAnalyzerFactory luceneAnalyzerFactory) {
_luceneAnalyzerFactory = luceneAnalyzerFactory;
}
@Override
public Query convertToLuceneQuery(@Nonnull UserProfileDataQuery query) {
final QueryParser parser = new MultiFieldQueryParser(LUCENE_VERSION, toFieldsArray(query), _luceneAnalyzerFactory.createAnalyzer());
parser.setDefaultOperator(AND);
final String searchTerm = query.getSearchTerm();
try {
return parser.parse(searchTerm != null ? searchTerm : "");
} catch (final ParseException e) {
throw new RuntimeException("Unable to parse query: " + searchTerm, e);
}
}
@Nonnull
protected Set<String> toFields(@Nonnull UserProfileDataQuery query) {
final Set<String> fields = new HashSet<>();
final Iterable<Column> columns = query.getColumns();
if (columns != null) {
for (final Column column : columns) { | // Path: src/main/java/org/echocat/adam/report/Column.java
// public interface Column extends Localized, Iterable<ColumnElementModel> {
//
// @Nullable
// public Template getTemplate();
//
// @Nonnull
// public ViewAccess getAccess();
//
// @Nonnull
// public Link getLink();
//
// public static enum Link {
// none,
// profile
// }
//
// }
//
// Path: src/main/java/org/echocat/adam/report/ColumnElementModel.java
// public interface ColumnElementModel extends ElementModel {
//
// @Nonnull
// public Format getFormat();
//
// public static enum Format {
// plain,
// formatted
// }
//
// }
// Path: src/main/java/org/echocat/adam/profile/UserProfileDataQueryMapper.java
import javax.annotation.Nonnull;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import static com.atlassian.bonnie.BonnieConstants.LUCENE_VERSION;
import static org.apache.lucene.queryparser.classic.QueryParser.Operator.AND;
import com.atlassian.bonnie.analyzer.LuceneAnalyzerFactory;
import com.atlassian.confluence.search.v2.lucene.LuceneQueryMapper;
import org.apache.lucene.queryparser.classic.MultiFieldQueryParser;
import org.apache.lucene.queryparser.classic.ParseException;
import org.apache.lucene.queryparser.classic.QueryParser;
import org.apache.lucene.search.Query;
import org.echocat.adam.report.Column;
import org.echocat.adam.report.ColumnElementModel;
/*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.profile;
public class UserProfileDataQueryMapper implements LuceneQueryMapper<UserProfileDataQuery> {
@Nonnull
private final LuceneAnalyzerFactory _luceneAnalyzerFactory;
public UserProfileDataQueryMapper(@Nonnull LuceneAnalyzerFactory luceneAnalyzerFactory) {
_luceneAnalyzerFactory = luceneAnalyzerFactory;
}
@Override
public Query convertToLuceneQuery(@Nonnull UserProfileDataQuery query) {
final QueryParser parser = new MultiFieldQueryParser(LUCENE_VERSION, toFieldsArray(query), _luceneAnalyzerFactory.createAnalyzer());
parser.setDefaultOperator(AND);
final String searchTerm = query.getSearchTerm();
try {
return parser.parse(searchTerm != null ? searchTerm : "");
} catch (final ParseException e) {
throw new RuntimeException("Unable to parse query: " + searchTerm, e);
}
}
@Nonnull
protected Set<String> toFields(@Nonnull UserProfileDataQuery query) {
final Set<String> fields = new HashSet<>();
final Iterable<Column> columns = query.getColumns();
if (columns != null) {
for (final Column column : columns) { | for (final ColumnElementModel elementModel : column) { |
echocat/adam | src/main/java/org/echocat/adam/configuration/report/Report.java | // Path: src/main/java/org/echocat/adam/configuration/access/view/ViewAccess.java
// @XmlType(name = "viewAccess", namespace = SCHEMA_NAMESPACE)
// public class ViewAccess extends ViewAccessSupport<Default, Anonymous, Owner, Administrator, Group> {
//
// @Override
// @XmlElement(name = "default", namespace = SCHEMA_NAMESPACE, type = Default.class)
// public void setDefault(@Nullable Default all) {
// super.setDefault(all);
// }
//
// @Override
// @XmlElement(name = "anonymous", namespace = SCHEMA_NAMESPACE, type = Anonymous.class)
// public void setAnonymous(@Nullable Anonymous anonymous) {
// super.setAnonymous(anonymous);
// }
//
// @Override
// @XmlElement(name = "owner", namespace = SCHEMA_NAMESPACE, type = Owner.class)
// public void setOwner(@Nullable Owner owner) {
// super.setOwner(owner);
// }
//
// @Override
// @XmlElement(name = "administrator", namespace = SCHEMA_NAMESPACE, type = Administrator.class)
// public void setAdministrator(@Nullable Administrator administrator) {
// super.setAdministrator(administrator);
// }
//
// @Override
// @XmlElement(name = "group", namespace = SCHEMA_NAMESPACE, type = Group.class)
// public void setGroups(@Nullable List<Group> groups) {
// super.setGroups(groups);
// }
//
// }
//
// Path: src/main/java/org/echocat/adam/configuration/localization/Localized.java
// @XmlType(name = "localized", namespace = SCHEMA_NAMESPACE)
// public abstract class Localized extends IdEnabled {
//
// @Nullable
// private List<Localization> _localizations;
//
// @Nullable
// @XmlElement(name = "localization", namespace = SCHEMA_NAMESPACE)
// public List<Localization> getLocalizations() {
// return _localizations;
// }
//
// public void setLocalizations(@Nullable List<Localization> localizations) {
// _localizations = localizations;
// }
//
//
// }
//
// Path: src/main/java/org/echocat/adam/report/View.java
// public enum View {
// cards,
// table
// }
//
// Path: src/main/java/org/echocat/adam/configuration/ConfigurationContants.java
// public static final String SCHEMA_NAMESPACE = "https://adam.echocat.org/schemas/configuration.xsd";
| import javax.xml.bind.annotation.XmlType;
import java.util.List;
import static org.echocat.adam.configuration.ConfigurationContants.SCHEMA_NAMESPACE;
import static org.echocat.adam.report.Report.DEFAULT_ID;
import org.echocat.adam.configuration.access.view.ViewAccess;
import org.echocat.adam.configuration.localization.Localized;
import org.echocat.adam.report.View;
import javax.annotation.Nonnegative;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement; | /*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.configuration.report;
@XmlType(name = "report", namespace = SCHEMA_NAMESPACE)
public class Report extends Localized {
public Report() {
setId(DEFAULT_ID);
}
@Nullable
private List<Column> _columns;
@Nullable
private Filter _filter;
@Nullable | // Path: src/main/java/org/echocat/adam/configuration/access/view/ViewAccess.java
// @XmlType(name = "viewAccess", namespace = SCHEMA_NAMESPACE)
// public class ViewAccess extends ViewAccessSupport<Default, Anonymous, Owner, Administrator, Group> {
//
// @Override
// @XmlElement(name = "default", namespace = SCHEMA_NAMESPACE, type = Default.class)
// public void setDefault(@Nullable Default all) {
// super.setDefault(all);
// }
//
// @Override
// @XmlElement(name = "anonymous", namespace = SCHEMA_NAMESPACE, type = Anonymous.class)
// public void setAnonymous(@Nullable Anonymous anonymous) {
// super.setAnonymous(anonymous);
// }
//
// @Override
// @XmlElement(name = "owner", namespace = SCHEMA_NAMESPACE, type = Owner.class)
// public void setOwner(@Nullable Owner owner) {
// super.setOwner(owner);
// }
//
// @Override
// @XmlElement(name = "administrator", namespace = SCHEMA_NAMESPACE, type = Administrator.class)
// public void setAdministrator(@Nullable Administrator administrator) {
// super.setAdministrator(administrator);
// }
//
// @Override
// @XmlElement(name = "group", namespace = SCHEMA_NAMESPACE, type = Group.class)
// public void setGroups(@Nullable List<Group> groups) {
// super.setGroups(groups);
// }
//
// }
//
// Path: src/main/java/org/echocat/adam/configuration/localization/Localized.java
// @XmlType(name = "localized", namespace = SCHEMA_NAMESPACE)
// public abstract class Localized extends IdEnabled {
//
// @Nullable
// private List<Localization> _localizations;
//
// @Nullable
// @XmlElement(name = "localization", namespace = SCHEMA_NAMESPACE)
// public List<Localization> getLocalizations() {
// return _localizations;
// }
//
// public void setLocalizations(@Nullable List<Localization> localizations) {
// _localizations = localizations;
// }
//
//
// }
//
// Path: src/main/java/org/echocat/adam/report/View.java
// public enum View {
// cards,
// table
// }
//
// Path: src/main/java/org/echocat/adam/configuration/ConfigurationContants.java
// public static final String SCHEMA_NAMESPACE = "https://adam.echocat.org/schemas/configuration.xsd";
// Path: src/main/java/org/echocat/adam/configuration/report/Report.java
import javax.xml.bind.annotation.XmlType;
import java.util.List;
import static org.echocat.adam.configuration.ConfigurationContants.SCHEMA_NAMESPACE;
import static org.echocat.adam.report.Report.DEFAULT_ID;
import org.echocat.adam.configuration.access.view.ViewAccess;
import org.echocat.adam.configuration.localization.Localized;
import org.echocat.adam.report.View;
import javax.annotation.Nonnegative;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
/*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.configuration.report;
@XmlType(name = "report", namespace = SCHEMA_NAMESPACE)
public class Report extends Localized {
public Report() {
setId(DEFAULT_ID);
}
@Nullable
private List<Column> _columns;
@Nullable
private Filter _filter;
@Nullable | private ViewAccess _access; |
echocat/adam | src/main/java/org/echocat/adam/configuration/report/Report.java | // Path: src/main/java/org/echocat/adam/configuration/access/view/ViewAccess.java
// @XmlType(name = "viewAccess", namespace = SCHEMA_NAMESPACE)
// public class ViewAccess extends ViewAccessSupport<Default, Anonymous, Owner, Administrator, Group> {
//
// @Override
// @XmlElement(name = "default", namespace = SCHEMA_NAMESPACE, type = Default.class)
// public void setDefault(@Nullable Default all) {
// super.setDefault(all);
// }
//
// @Override
// @XmlElement(name = "anonymous", namespace = SCHEMA_NAMESPACE, type = Anonymous.class)
// public void setAnonymous(@Nullable Anonymous anonymous) {
// super.setAnonymous(anonymous);
// }
//
// @Override
// @XmlElement(name = "owner", namespace = SCHEMA_NAMESPACE, type = Owner.class)
// public void setOwner(@Nullable Owner owner) {
// super.setOwner(owner);
// }
//
// @Override
// @XmlElement(name = "administrator", namespace = SCHEMA_NAMESPACE, type = Administrator.class)
// public void setAdministrator(@Nullable Administrator administrator) {
// super.setAdministrator(administrator);
// }
//
// @Override
// @XmlElement(name = "group", namespace = SCHEMA_NAMESPACE, type = Group.class)
// public void setGroups(@Nullable List<Group> groups) {
// super.setGroups(groups);
// }
//
// }
//
// Path: src/main/java/org/echocat/adam/configuration/localization/Localized.java
// @XmlType(name = "localized", namespace = SCHEMA_NAMESPACE)
// public abstract class Localized extends IdEnabled {
//
// @Nullable
// private List<Localization> _localizations;
//
// @Nullable
// @XmlElement(name = "localization", namespace = SCHEMA_NAMESPACE)
// public List<Localization> getLocalizations() {
// return _localizations;
// }
//
// public void setLocalizations(@Nullable List<Localization> localizations) {
// _localizations = localizations;
// }
//
//
// }
//
// Path: src/main/java/org/echocat/adam/report/View.java
// public enum View {
// cards,
// table
// }
//
// Path: src/main/java/org/echocat/adam/configuration/ConfigurationContants.java
// public static final String SCHEMA_NAMESPACE = "https://adam.echocat.org/schemas/configuration.xsd";
| import javax.xml.bind.annotation.XmlType;
import java.util.List;
import static org.echocat.adam.configuration.ConfigurationContants.SCHEMA_NAMESPACE;
import static org.echocat.adam.report.Report.DEFAULT_ID;
import org.echocat.adam.configuration.access.view.ViewAccess;
import org.echocat.adam.configuration.localization.Localized;
import org.echocat.adam.report.View;
import javax.annotation.Nonnegative;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement; | /*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.configuration.report;
@XmlType(name = "report", namespace = SCHEMA_NAMESPACE)
public class Report extends Localized {
public Report() {
setId(DEFAULT_ID);
}
@Nullable
private List<Column> _columns;
@Nullable
private Filter _filter;
@Nullable
private ViewAccess _access;
@Nonnull | // Path: src/main/java/org/echocat/adam/configuration/access/view/ViewAccess.java
// @XmlType(name = "viewAccess", namespace = SCHEMA_NAMESPACE)
// public class ViewAccess extends ViewAccessSupport<Default, Anonymous, Owner, Administrator, Group> {
//
// @Override
// @XmlElement(name = "default", namespace = SCHEMA_NAMESPACE, type = Default.class)
// public void setDefault(@Nullable Default all) {
// super.setDefault(all);
// }
//
// @Override
// @XmlElement(name = "anonymous", namespace = SCHEMA_NAMESPACE, type = Anonymous.class)
// public void setAnonymous(@Nullable Anonymous anonymous) {
// super.setAnonymous(anonymous);
// }
//
// @Override
// @XmlElement(name = "owner", namespace = SCHEMA_NAMESPACE, type = Owner.class)
// public void setOwner(@Nullable Owner owner) {
// super.setOwner(owner);
// }
//
// @Override
// @XmlElement(name = "administrator", namespace = SCHEMA_NAMESPACE, type = Administrator.class)
// public void setAdministrator(@Nullable Administrator administrator) {
// super.setAdministrator(administrator);
// }
//
// @Override
// @XmlElement(name = "group", namespace = SCHEMA_NAMESPACE, type = Group.class)
// public void setGroups(@Nullable List<Group> groups) {
// super.setGroups(groups);
// }
//
// }
//
// Path: src/main/java/org/echocat/adam/configuration/localization/Localized.java
// @XmlType(name = "localized", namespace = SCHEMA_NAMESPACE)
// public abstract class Localized extends IdEnabled {
//
// @Nullable
// private List<Localization> _localizations;
//
// @Nullable
// @XmlElement(name = "localization", namespace = SCHEMA_NAMESPACE)
// public List<Localization> getLocalizations() {
// return _localizations;
// }
//
// public void setLocalizations(@Nullable List<Localization> localizations) {
// _localizations = localizations;
// }
//
//
// }
//
// Path: src/main/java/org/echocat/adam/report/View.java
// public enum View {
// cards,
// table
// }
//
// Path: src/main/java/org/echocat/adam/configuration/ConfigurationContants.java
// public static final String SCHEMA_NAMESPACE = "https://adam.echocat.org/schemas/configuration.xsd";
// Path: src/main/java/org/echocat/adam/configuration/report/Report.java
import javax.xml.bind.annotation.XmlType;
import java.util.List;
import static org.echocat.adam.configuration.ConfigurationContants.SCHEMA_NAMESPACE;
import static org.echocat.adam.report.Report.DEFAULT_ID;
import org.echocat.adam.configuration.access.view.ViewAccess;
import org.echocat.adam.configuration.localization.Localized;
import org.echocat.adam.report.View;
import javax.annotation.Nonnegative;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
/*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.configuration.report;
@XmlType(name = "report", namespace = SCHEMA_NAMESPACE)
public class Report extends Localized {
public Report() {
setId(DEFAULT_ID);
}
@Nullable
private List<Column> _columns;
@Nullable
private Filter _filter;
@Nullable
private ViewAccess _access;
@Nonnull | private View _defaultView = View.cards; |
echocat/adam | src/main/java/org/echocat/adam/configuration/report/Column.java | // Path: src/main/java/org/echocat/adam/configuration/localization/Localized.java
// @XmlType(name = "localized", namespace = SCHEMA_NAMESPACE)
// public abstract class Localized extends IdEnabled {
//
// @Nullable
// private List<Localization> _localizations;
//
// @Nullable
// @XmlElement(name = "localization", namespace = SCHEMA_NAMESPACE)
// public List<Localization> getLocalizations() {
// return _localizations;
// }
//
// public void setLocalizations(@Nullable List<Localization> localizations) {
// _localizations = localizations;
// }
//
//
// }
//
// Path: src/main/java/org/echocat/adam/configuration/template/Template.java
// @XmlType(name = "template", namespace = SCHEMA_NAMESPACE)
// public class Template extends TemplateSupport {
//
// @Nonnull
// private String _source = "";
// @Nonnull
// private TemplateFormat _format = velocity;
//
// @Override
// @Nonnull
// public String getSource() {
// return _source;
// }
//
// @XmlValue
// @XmlValueExtension
// public void setSource(@Nonnull String source) {
// _source = source;
// }
//
// @Override
// @Nonnull
// public TemplateFormat getFormat() {
// return _format;
// }
//
// @XmlAttribute(name = "format")
// public void setFormat(@Nonnull TemplateFormat format) {
// _format = format;
// }
//
// }
//
// Path: src/main/java/org/echocat/adam/report/Column.java
// public static enum Link {
// none,
// profile
// }
//
// Path: src/main/java/org/echocat/adam/configuration/ConfigurationContants.java
// public static final String SCHEMA_NAMESPACE = "https://adam.echocat.org/schemas/configuration.xsd";
| import java.util.List;
import static org.echocat.adam.configuration.ConfigurationContants.SCHEMA_NAMESPACE;
import org.echocat.adam.configuration.localization.Localized;
import org.echocat.adam.configuration.template.Template;
import org.echocat.adam.report.Column.Link;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType; | /*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.configuration.report;
@XmlType(name = "reportColumn", namespace = SCHEMA_NAMESPACE)
public class Column extends Localized {
@Nullable | // Path: src/main/java/org/echocat/adam/configuration/localization/Localized.java
// @XmlType(name = "localized", namespace = SCHEMA_NAMESPACE)
// public abstract class Localized extends IdEnabled {
//
// @Nullable
// private List<Localization> _localizations;
//
// @Nullable
// @XmlElement(name = "localization", namespace = SCHEMA_NAMESPACE)
// public List<Localization> getLocalizations() {
// return _localizations;
// }
//
// public void setLocalizations(@Nullable List<Localization> localizations) {
// _localizations = localizations;
// }
//
//
// }
//
// Path: src/main/java/org/echocat/adam/configuration/template/Template.java
// @XmlType(name = "template", namespace = SCHEMA_NAMESPACE)
// public class Template extends TemplateSupport {
//
// @Nonnull
// private String _source = "";
// @Nonnull
// private TemplateFormat _format = velocity;
//
// @Override
// @Nonnull
// public String getSource() {
// return _source;
// }
//
// @XmlValue
// @XmlValueExtension
// public void setSource(@Nonnull String source) {
// _source = source;
// }
//
// @Override
// @Nonnull
// public TemplateFormat getFormat() {
// return _format;
// }
//
// @XmlAttribute(name = "format")
// public void setFormat(@Nonnull TemplateFormat format) {
// _format = format;
// }
//
// }
//
// Path: src/main/java/org/echocat/adam/report/Column.java
// public static enum Link {
// none,
// profile
// }
//
// Path: src/main/java/org/echocat/adam/configuration/ConfigurationContants.java
// public static final String SCHEMA_NAMESPACE = "https://adam.echocat.org/schemas/configuration.xsd";
// Path: src/main/java/org/echocat/adam/configuration/report/Column.java
import java.util.List;
import static org.echocat.adam.configuration.ConfigurationContants.SCHEMA_NAMESPACE;
import org.echocat.adam.configuration.localization.Localized;
import org.echocat.adam.configuration.template.Template;
import org.echocat.adam.report.Column.Link;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
/*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.configuration.report;
@XmlType(name = "reportColumn", namespace = SCHEMA_NAMESPACE)
public class Column extends Localized {
@Nullable | private Template _template; |
echocat/adam | src/main/java/org/echocat/adam/configuration/report/Column.java | // Path: src/main/java/org/echocat/adam/configuration/localization/Localized.java
// @XmlType(name = "localized", namespace = SCHEMA_NAMESPACE)
// public abstract class Localized extends IdEnabled {
//
// @Nullable
// private List<Localization> _localizations;
//
// @Nullable
// @XmlElement(name = "localization", namespace = SCHEMA_NAMESPACE)
// public List<Localization> getLocalizations() {
// return _localizations;
// }
//
// public void setLocalizations(@Nullable List<Localization> localizations) {
// _localizations = localizations;
// }
//
//
// }
//
// Path: src/main/java/org/echocat/adam/configuration/template/Template.java
// @XmlType(name = "template", namespace = SCHEMA_NAMESPACE)
// public class Template extends TemplateSupport {
//
// @Nonnull
// private String _source = "";
// @Nonnull
// private TemplateFormat _format = velocity;
//
// @Override
// @Nonnull
// public String getSource() {
// return _source;
// }
//
// @XmlValue
// @XmlValueExtension
// public void setSource(@Nonnull String source) {
// _source = source;
// }
//
// @Override
// @Nonnull
// public TemplateFormat getFormat() {
// return _format;
// }
//
// @XmlAttribute(name = "format")
// public void setFormat(@Nonnull TemplateFormat format) {
// _format = format;
// }
//
// }
//
// Path: src/main/java/org/echocat/adam/report/Column.java
// public static enum Link {
// none,
// profile
// }
//
// Path: src/main/java/org/echocat/adam/configuration/ConfigurationContants.java
// public static final String SCHEMA_NAMESPACE = "https://adam.echocat.org/schemas/configuration.xsd";
| import java.util.List;
import static org.echocat.adam.configuration.ConfigurationContants.SCHEMA_NAMESPACE;
import org.echocat.adam.configuration.localization.Localized;
import org.echocat.adam.configuration.template.Template;
import org.echocat.adam.report.Column.Link;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType; | /*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.configuration.report;
@XmlType(name = "reportColumn", namespace = SCHEMA_NAMESPACE)
public class Column extends Localized {
@Nullable
private Template _template;
@Nullable
private List<Element> _elements;
@Nonnull | // Path: src/main/java/org/echocat/adam/configuration/localization/Localized.java
// @XmlType(name = "localized", namespace = SCHEMA_NAMESPACE)
// public abstract class Localized extends IdEnabled {
//
// @Nullable
// private List<Localization> _localizations;
//
// @Nullable
// @XmlElement(name = "localization", namespace = SCHEMA_NAMESPACE)
// public List<Localization> getLocalizations() {
// return _localizations;
// }
//
// public void setLocalizations(@Nullable List<Localization> localizations) {
// _localizations = localizations;
// }
//
//
// }
//
// Path: src/main/java/org/echocat/adam/configuration/template/Template.java
// @XmlType(name = "template", namespace = SCHEMA_NAMESPACE)
// public class Template extends TemplateSupport {
//
// @Nonnull
// private String _source = "";
// @Nonnull
// private TemplateFormat _format = velocity;
//
// @Override
// @Nonnull
// public String getSource() {
// return _source;
// }
//
// @XmlValue
// @XmlValueExtension
// public void setSource(@Nonnull String source) {
// _source = source;
// }
//
// @Override
// @Nonnull
// public TemplateFormat getFormat() {
// return _format;
// }
//
// @XmlAttribute(name = "format")
// public void setFormat(@Nonnull TemplateFormat format) {
// _format = format;
// }
//
// }
//
// Path: src/main/java/org/echocat/adam/report/Column.java
// public static enum Link {
// none,
// profile
// }
//
// Path: src/main/java/org/echocat/adam/configuration/ConfigurationContants.java
// public static final String SCHEMA_NAMESPACE = "https://adam.echocat.org/schemas/configuration.xsd";
// Path: src/main/java/org/echocat/adam/configuration/report/Column.java
import java.util.List;
import static org.echocat.adam.configuration.ConfigurationContants.SCHEMA_NAMESPACE;
import org.echocat.adam.configuration.localization.Localized;
import org.echocat.adam.configuration.template.Template;
import org.echocat.adam.report.Column.Link;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
/*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.configuration.report;
@XmlType(name = "reportColumn", namespace = SCHEMA_NAMESPACE)
public class Column extends Localized {
@Nullable
private Template _template;
@Nullable
private List<Element> _elements;
@Nonnull | private Link _link = Link.none; |
echocat/adam | src/main/java/org/echocat/adam/configuration/access/view/Rule.java | // Path: src/main/java/org/echocat/adam/access/ViewAccess.java
// public static enum Visibility {
// allowed,
// masked,
// forbidden;
//
// public boolean isViewAllowed() {
// return this == allowed || this == masked;
// }
//
// public boolean isMasked() {
// return this == masked;
// }
//
// public boolean isBetterThen(@Nonnull Visibility other) {
// return other == null || ordinal() < other.ordinal();
// }
//
// public boolean isBest() {
// return ordinal() == 0;
// }
//
// public static boolean isBestVisibility(@Nullable Visibility what) {
// return what != null && what.isBest();
// }
//
// public static boolean isBetterVisibility(@Nullable Visibility what, @Nullable Visibility then) {
// return what != null && what.isBetterThen(then);
// }
// }
| import javax.annotation.Nonnull;
import javax.xml.bind.annotation.XmlAttribute;
import org.echocat.adam.access.ViewAccess.Visibility; | /*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.configuration.access.view;
public interface Rule {
@Nonnull
@XmlAttribute(name = "view", required = true) | // Path: src/main/java/org/echocat/adam/access/ViewAccess.java
// public static enum Visibility {
// allowed,
// masked,
// forbidden;
//
// public boolean isViewAllowed() {
// return this == allowed || this == masked;
// }
//
// public boolean isMasked() {
// return this == masked;
// }
//
// public boolean isBetterThen(@Nonnull Visibility other) {
// return other == null || ordinal() < other.ordinal();
// }
//
// public boolean isBest() {
// return ordinal() == 0;
// }
//
// public static boolean isBestVisibility(@Nullable Visibility what) {
// return what != null && what.isBest();
// }
//
// public static boolean isBetterVisibility(@Nullable Visibility what, @Nullable Visibility then) {
// return what != null && what.isBetterThen(then);
// }
// }
// Path: src/main/java/org/echocat/adam/configuration/access/view/Rule.java
import javax.annotation.Nonnull;
import javax.xml.bind.annotation.XmlAttribute;
import org.echocat.adam.access.ViewAccess.Visibility;
/*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.configuration.access.view;
public interface Rule {
@Nonnull
@XmlAttribute(name = "view", required = true) | Visibility getView(); |
echocat/adam | src/main/java/org/echocat/adam/report/Report.java | // Path: src/main/java/org/echocat/adam/access/ViewAccess.java
// public interface ViewAccess {
//
// @Nonnull
// public Visibility checkView(@Nullable User forUser, @Nullable User target);
//
// public static enum Visibility {
// allowed,
// masked,
// forbidden;
//
// public boolean isViewAllowed() {
// return this == allowed || this == masked;
// }
//
// public boolean isMasked() {
// return this == masked;
// }
//
// public boolean isBetterThen(@Nonnull Visibility other) {
// return other == null || ordinal() < other.ordinal();
// }
//
// public boolean isBest() {
// return ordinal() == 0;
// }
//
// public static boolean isBestVisibility(@Nullable Visibility what) {
// return what != null && what.isBest();
// }
//
// public static boolean isBetterVisibility(@Nullable Visibility what, @Nullable Visibility then) {
// return what != null && what.isBetterThen(then);
// }
// }
//
// }
//
// Path: src/main/java/org/echocat/adam/localization/Localized.java
// public interface Localized extends IdEnabled<String> {
//
// @Nullable
// public Map<Locale, Localization> getLocalizations();
//
// }
| import org.echocat.adam.access.ViewAccess;
import org.echocat.adam.localization.Localized;
import javax.annotation.Nonnegative;
import javax.annotation.Nonnull;
import javax.annotation.Nullable; | /*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.report;
public interface Report extends Iterable<Column>, Localized {
@Nonnull
public static final String DEFAULT_ID = "all";
@Nonnull | // Path: src/main/java/org/echocat/adam/access/ViewAccess.java
// public interface ViewAccess {
//
// @Nonnull
// public Visibility checkView(@Nullable User forUser, @Nullable User target);
//
// public static enum Visibility {
// allowed,
// masked,
// forbidden;
//
// public boolean isViewAllowed() {
// return this == allowed || this == masked;
// }
//
// public boolean isMasked() {
// return this == masked;
// }
//
// public boolean isBetterThen(@Nonnull Visibility other) {
// return other == null || ordinal() < other.ordinal();
// }
//
// public boolean isBest() {
// return ordinal() == 0;
// }
//
// public static boolean isBestVisibility(@Nullable Visibility what) {
// return what != null && what.isBest();
// }
//
// public static boolean isBetterVisibility(@Nullable Visibility what, @Nullable Visibility then) {
// return what != null && what.isBetterThen(then);
// }
// }
//
// }
//
// Path: src/main/java/org/echocat/adam/localization/Localized.java
// public interface Localized extends IdEnabled<String> {
//
// @Nullable
// public Map<Locale, Localization> getLocalizations();
//
// }
// Path: src/main/java/org/echocat/adam/report/Report.java
import org.echocat.adam.access.ViewAccess;
import org.echocat.adam.localization.Localized;
import javax.annotation.Nonnegative;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.report;
public interface Report extends Iterable<Column>, Localized {
@Nonnull
public static final String DEFAULT_ID = "all";
@Nonnull | public ViewAccess getAccess(); |
echocat/adam | src/main/java/org/echocat/adam/configuration/Configuration.java | // Path: src/main/java/org/echocat/adam/configuration/report/Report.java
// @XmlType(name = "report", namespace = SCHEMA_NAMESPACE)
// public class Report extends Localized {
//
// public Report() {
// setId(DEFAULT_ID);
// }
//
// @Nullable
// private List<Column> _columns;
// @Nullable
// private Filter _filter;
// @Nullable
// private ViewAccess _access;
// @Nonnull
// private View _defaultView = View.cards;
// @Nonnegative
// private int _resultsPerPage = 50;
//
// @Nullable
// @XmlElement(name = "column", namespace = SCHEMA_NAMESPACE)
// public List<Column> getColumns() {
// return _columns;
// }
//
// public void setColumns(@Nullable List<Column> columns) {
// _columns = columns;
// }
//
// @Nullable
// @XmlElement(name = "filter", namespace = SCHEMA_NAMESPACE)
// public Filter getFilter() {
// return _filter;
// }
//
// public void setFilter(@Nullable Filter filter) {
// _filter = filter;
// }
//
// @Nullable
// @XmlElement(name = "access", namespace = SCHEMA_NAMESPACE)
// public ViewAccess getAccess() {
// return _access;
// }
//
// public void setAccess(@Nullable ViewAccess access) {
// _access = access;
// }
//
// @Nonnull
// @XmlAttribute(name = "defaultView")
// public View getDefaultView() {
// return _defaultView;
// }
//
// public void setDefaultView(@Nonnull View defaultView) {
// _defaultView = defaultView;
// }
//
// @XmlAttribute(name = "resultsPerPage")
// public int getResultsPerPage() {
// return _resultsPerPage;
// }
//
// public void setResultsPerPage(int resultsPerPage) {
// _resultsPerPage = resultsPerPage;
// }
// }
//
// Path: src/main/java/org/echocat/adam/configuration/view/View.java
// @XmlType(name = "view", namespace = SCHEMA_NAMESPACE)
// public class View extends Localized {
//
// public View() {
// setId(DEFAULT_ID);
// }
//
// @Nullable
// private List<Element> _elements;
// @Nullable
// private ViewAccess _access;
//
// @Nullable
// @XmlElement(name = "element", namespace = SCHEMA_NAMESPACE)
// public List<Element> getElements() {
// return _elements;
// }
//
// public void setElements(@Nullable List<Element> elements) {
// _elements = elements;
// }
//
// @Nullable
// @XmlElement(name = "access", namespace = SCHEMA_NAMESPACE)
// public ViewAccess getAccess() {
// return _access;
// }
//
// public void setAccess(@Nullable ViewAccess access) {
// _access = access;
// }
//
// @XmlType(name = "viewElement", namespace = SCHEMA_NAMESPACE)
// public static class Element extends IdEnabled {}
//
// }
//
// Path: src/main/java/org/echocat/adam/configuration/ConfigurationContants.java
// public static final String SCHEMA_NAMESPACE = "https://adam.echocat.org/schemas/configuration.xsd";
| import javax.xml.bind.annotation.XmlType;
import java.util.List;
import static org.echocat.adam.configuration.ConfigurationContants.SCHEMA_NAMESPACE;
import org.echocat.adam.configuration.profile.Profile;
import org.echocat.adam.configuration.report.Report;
import org.echocat.adam.configuration.view.View;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement; | /*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.configuration;
@XmlRootElement(name = "configuration", namespace = SCHEMA_NAMESPACE)
@XmlType(name = "configuration", namespace = SCHEMA_NAMESPACE)
public class Configuration {
@Nullable
private Profile _profile;
@Nullable | // Path: src/main/java/org/echocat/adam/configuration/report/Report.java
// @XmlType(name = "report", namespace = SCHEMA_NAMESPACE)
// public class Report extends Localized {
//
// public Report() {
// setId(DEFAULT_ID);
// }
//
// @Nullable
// private List<Column> _columns;
// @Nullable
// private Filter _filter;
// @Nullable
// private ViewAccess _access;
// @Nonnull
// private View _defaultView = View.cards;
// @Nonnegative
// private int _resultsPerPage = 50;
//
// @Nullable
// @XmlElement(name = "column", namespace = SCHEMA_NAMESPACE)
// public List<Column> getColumns() {
// return _columns;
// }
//
// public void setColumns(@Nullable List<Column> columns) {
// _columns = columns;
// }
//
// @Nullable
// @XmlElement(name = "filter", namespace = SCHEMA_NAMESPACE)
// public Filter getFilter() {
// return _filter;
// }
//
// public void setFilter(@Nullable Filter filter) {
// _filter = filter;
// }
//
// @Nullable
// @XmlElement(name = "access", namespace = SCHEMA_NAMESPACE)
// public ViewAccess getAccess() {
// return _access;
// }
//
// public void setAccess(@Nullable ViewAccess access) {
// _access = access;
// }
//
// @Nonnull
// @XmlAttribute(name = "defaultView")
// public View getDefaultView() {
// return _defaultView;
// }
//
// public void setDefaultView(@Nonnull View defaultView) {
// _defaultView = defaultView;
// }
//
// @XmlAttribute(name = "resultsPerPage")
// public int getResultsPerPage() {
// return _resultsPerPage;
// }
//
// public void setResultsPerPage(int resultsPerPage) {
// _resultsPerPage = resultsPerPage;
// }
// }
//
// Path: src/main/java/org/echocat/adam/configuration/view/View.java
// @XmlType(name = "view", namespace = SCHEMA_NAMESPACE)
// public class View extends Localized {
//
// public View() {
// setId(DEFAULT_ID);
// }
//
// @Nullable
// private List<Element> _elements;
// @Nullable
// private ViewAccess _access;
//
// @Nullable
// @XmlElement(name = "element", namespace = SCHEMA_NAMESPACE)
// public List<Element> getElements() {
// return _elements;
// }
//
// public void setElements(@Nullable List<Element> elements) {
// _elements = elements;
// }
//
// @Nullable
// @XmlElement(name = "access", namespace = SCHEMA_NAMESPACE)
// public ViewAccess getAccess() {
// return _access;
// }
//
// public void setAccess(@Nullable ViewAccess access) {
// _access = access;
// }
//
// @XmlType(name = "viewElement", namespace = SCHEMA_NAMESPACE)
// public static class Element extends IdEnabled {}
//
// }
//
// Path: src/main/java/org/echocat/adam/configuration/ConfigurationContants.java
// public static final String SCHEMA_NAMESPACE = "https://adam.echocat.org/schemas/configuration.xsd";
// Path: src/main/java/org/echocat/adam/configuration/Configuration.java
import javax.xml.bind.annotation.XmlType;
import java.util.List;
import static org.echocat.adam.configuration.ConfigurationContants.SCHEMA_NAMESPACE;
import org.echocat.adam.configuration.profile.Profile;
import org.echocat.adam.configuration.report.Report;
import org.echocat.adam.configuration.view.View;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
/*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.configuration;
@XmlRootElement(name = "configuration", namespace = SCHEMA_NAMESPACE)
@XmlType(name = "configuration", namespace = SCHEMA_NAMESPACE)
public class Configuration {
@Nullable
private Profile _profile;
@Nullable | private List<Report> _reports; |
echocat/adam | src/main/java/org/echocat/adam/configuration/Configuration.java | // Path: src/main/java/org/echocat/adam/configuration/report/Report.java
// @XmlType(name = "report", namespace = SCHEMA_NAMESPACE)
// public class Report extends Localized {
//
// public Report() {
// setId(DEFAULT_ID);
// }
//
// @Nullable
// private List<Column> _columns;
// @Nullable
// private Filter _filter;
// @Nullable
// private ViewAccess _access;
// @Nonnull
// private View _defaultView = View.cards;
// @Nonnegative
// private int _resultsPerPage = 50;
//
// @Nullable
// @XmlElement(name = "column", namespace = SCHEMA_NAMESPACE)
// public List<Column> getColumns() {
// return _columns;
// }
//
// public void setColumns(@Nullable List<Column> columns) {
// _columns = columns;
// }
//
// @Nullable
// @XmlElement(name = "filter", namespace = SCHEMA_NAMESPACE)
// public Filter getFilter() {
// return _filter;
// }
//
// public void setFilter(@Nullable Filter filter) {
// _filter = filter;
// }
//
// @Nullable
// @XmlElement(name = "access", namespace = SCHEMA_NAMESPACE)
// public ViewAccess getAccess() {
// return _access;
// }
//
// public void setAccess(@Nullable ViewAccess access) {
// _access = access;
// }
//
// @Nonnull
// @XmlAttribute(name = "defaultView")
// public View getDefaultView() {
// return _defaultView;
// }
//
// public void setDefaultView(@Nonnull View defaultView) {
// _defaultView = defaultView;
// }
//
// @XmlAttribute(name = "resultsPerPage")
// public int getResultsPerPage() {
// return _resultsPerPage;
// }
//
// public void setResultsPerPage(int resultsPerPage) {
// _resultsPerPage = resultsPerPage;
// }
// }
//
// Path: src/main/java/org/echocat/adam/configuration/view/View.java
// @XmlType(name = "view", namespace = SCHEMA_NAMESPACE)
// public class View extends Localized {
//
// public View() {
// setId(DEFAULT_ID);
// }
//
// @Nullable
// private List<Element> _elements;
// @Nullable
// private ViewAccess _access;
//
// @Nullable
// @XmlElement(name = "element", namespace = SCHEMA_NAMESPACE)
// public List<Element> getElements() {
// return _elements;
// }
//
// public void setElements(@Nullable List<Element> elements) {
// _elements = elements;
// }
//
// @Nullable
// @XmlElement(name = "access", namespace = SCHEMA_NAMESPACE)
// public ViewAccess getAccess() {
// return _access;
// }
//
// public void setAccess(@Nullable ViewAccess access) {
// _access = access;
// }
//
// @XmlType(name = "viewElement", namespace = SCHEMA_NAMESPACE)
// public static class Element extends IdEnabled {}
//
// }
//
// Path: src/main/java/org/echocat/adam/configuration/ConfigurationContants.java
// public static final String SCHEMA_NAMESPACE = "https://adam.echocat.org/schemas/configuration.xsd";
| import javax.xml.bind.annotation.XmlType;
import java.util.List;
import static org.echocat.adam.configuration.ConfigurationContants.SCHEMA_NAMESPACE;
import org.echocat.adam.configuration.profile.Profile;
import org.echocat.adam.configuration.report.Report;
import org.echocat.adam.configuration.view.View;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement; | /*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.configuration;
@XmlRootElement(name = "configuration", namespace = SCHEMA_NAMESPACE)
@XmlType(name = "configuration", namespace = SCHEMA_NAMESPACE)
public class Configuration {
@Nullable
private Profile _profile;
@Nullable
private List<Report> _reports;
@Nullable | // Path: src/main/java/org/echocat/adam/configuration/report/Report.java
// @XmlType(name = "report", namespace = SCHEMA_NAMESPACE)
// public class Report extends Localized {
//
// public Report() {
// setId(DEFAULT_ID);
// }
//
// @Nullable
// private List<Column> _columns;
// @Nullable
// private Filter _filter;
// @Nullable
// private ViewAccess _access;
// @Nonnull
// private View _defaultView = View.cards;
// @Nonnegative
// private int _resultsPerPage = 50;
//
// @Nullable
// @XmlElement(name = "column", namespace = SCHEMA_NAMESPACE)
// public List<Column> getColumns() {
// return _columns;
// }
//
// public void setColumns(@Nullable List<Column> columns) {
// _columns = columns;
// }
//
// @Nullable
// @XmlElement(name = "filter", namespace = SCHEMA_NAMESPACE)
// public Filter getFilter() {
// return _filter;
// }
//
// public void setFilter(@Nullable Filter filter) {
// _filter = filter;
// }
//
// @Nullable
// @XmlElement(name = "access", namespace = SCHEMA_NAMESPACE)
// public ViewAccess getAccess() {
// return _access;
// }
//
// public void setAccess(@Nullable ViewAccess access) {
// _access = access;
// }
//
// @Nonnull
// @XmlAttribute(name = "defaultView")
// public View getDefaultView() {
// return _defaultView;
// }
//
// public void setDefaultView(@Nonnull View defaultView) {
// _defaultView = defaultView;
// }
//
// @XmlAttribute(name = "resultsPerPage")
// public int getResultsPerPage() {
// return _resultsPerPage;
// }
//
// public void setResultsPerPage(int resultsPerPage) {
// _resultsPerPage = resultsPerPage;
// }
// }
//
// Path: src/main/java/org/echocat/adam/configuration/view/View.java
// @XmlType(name = "view", namespace = SCHEMA_NAMESPACE)
// public class View extends Localized {
//
// public View() {
// setId(DEFAULT_ID);
// }
//
// @Nullable
// private List<Element> _elements;
// @Nullable
// private ViewAccess _access;
//
// @Nullable
// @XmlElement(name = "element", namespace = SCHEMA_NAMESPACE)
// public List<Element> getElements() {
// return _elements;
// }
//
// public void setElements(@Nullable List<Element> elements) {
// _elements = elements;
// }
//
// @Nullable
// @XmlElement(name = "access", namespace = SCHEMA_NAMESPACE)
// public ViewAccess getAccess() {
// return _access;
// }
//
// public void setAccess(@Nullable ViewAccess access) {
// _access = access;
// }
//
// @XmlType(name = "viewElement", namespace = SCHEMA_NAMESPACE)
// public static class Element extends IdEnabled {}
//
// }
//
// Path: src/main/java/org/echocat/adam/configuration/ConfigurationContants.java
// public static final String SCHEMA_NAMESPACE = "https://adam.echocat.org/schemas/configuration.xsd";
// Path: src/main/java/org/echocat/adam/configuration/Configuration.java
import javax.xml.bind.annotation.XmlType;
import java.util.List;
import static org.echocat.adam.configuration.ConfigurationContants.SCHEMA_NAMESPACE;
import org.echocat.adam.configuration.profile.Profile;
import org.echocat.adam.configuration.report.Report;
import org.echocat.adam.configuration.view.View;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
/*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.configuration;
@XmlRootElement(name = "configuration", namespace = SCHEMA_NAMESPACE)
@XmlType(name = "configuration", namespace = SCHEMA_NAMESPACE)
public class Configuration {
@Nullable
private Profile _profile;
@Nullable
private List<Report> _reports;
@Nullable | private List<View> _views; |
echocat/adam | src/main/java/org/echocat/adam/profile/ExtendedViewUserProfileAction.java | // Path: src/main/java/org/echocat/adam/extensions/ExtendedWebInterfaceManager.java
// @Nonnull
// public static ExtendedWebInterfaceManager extendedWebInterfaceManager() {
// final ExtendedWebInterfaceManager result = c_instance;
// if (result == null) {
// throw new IllegalStateException("There is no instance initialized.");
// }
// return result;
// }
| import com.atlassian.plugin.web.WebInterfaceManager;
import static org.echocat.adam.extensions.ExtendedWebInterfaceManager.extendedWebInterfaceManager;
import com.atlassian.confluence.user.actions.ViewUserProfileAction; | /*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.profile;
@SuppressWarnings("deprecation")
public class ExtendedViewUserProfileAction extends ViewUserProfileAction {
@Override
public String execute() throws Exception {
final String result = super.execute();
return result;
}
@Override
public WebInterfaceManager getWebInterfaceManager() { | // Path: src/main/java/org/echocat/adam/extensions/ExtendedWebInterfaceManager.java
// @Nonnull
// public static ExtendedWebInterfaceManager extendedWebInterfaceManager() {
// final ExtendedWebInterfaceManager result = c_instance;
// if (result == null) {
// throw new IllegalStateException("There is no instance initialized.");
// }
// return result;
// }
// Path: src/main/java/org/echocat/adam/profile/ExtendedViewUserProfileAction.java
import com.atlassian.plugin.web.WebInterfaceManager;
import static org.echocat.adam.extensions.ExtendedWebInterfaceManager.extendedWebInterfaceManager;
import com.atlassian.confluence.user.actions.ViewUserProfileAction;
/*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.profile;
@SuppressWarnings("deprecation")
public class ExtendedViewUserProfileAction extends ViewUserProfileAction {
@Override
public String execute() throws Exception {
final String result = super.execute();
return result;
}
@Override
public WebInterfaceManager getWebInterfaceManager() { | return extendedWebInterfaceManager(); |
echocat/adam | src/main/java/org/echocat/adam/profile/UserProfileDataFilter.java | // Path: src/main/java/org/echocat/adam/report/Filter.java
// public interface Filter {
//
// @Nullable
// public Iterable<String> getIncludingGroups();
//
// @Nullable
// public Iterable<String> getExcludingGroups();
//
// public boolean hasTerms();
//
// }
//
// Path: src/main/java/org/echocat/adam/report/Report.java
// public interface Report extends Iterable<Column>, Localized {
//
// @Nonnull
// public static final String DEFAULT_ID = "all";
//
// @Nonnull
// public ViewAccess getAccess();
//
// @Nullable
// public Filter getFilter();
//
// @Nonnull
// public View getDefaultView();
//
// @Nonnegative
// public int getResultsPerPage();
//
// }
| import com.atlassian.confluence.search.v2.AbstractChainableSearchFilter;
import com.atlassian.confluence.search.v2.SearchFilter;
import org.echocat.adam.report.Filter;
import org.echocat.adam.report.Report;
import javax.annotation.Nonnull;
import javax.annotation.Nullable; | /*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014-2016 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.profile;
public class UserProfileDataFilter extends AbstractChainableSearchFilter {
@Nullable | // Path: src/main/java/org/echocat/adam/report/Filter.java
// public interface Filter {
//
// @Nullable
// public Iterable<String> getIncludingGroups();
//
// @Nullable
// public Iterable<String> getExcludingGroups();
//
// public boolean hasTerms();
//
// }
//
// Path: src/main/java/org/echocat/adam/report/Report.java
// public interface Report extends Iterable<Column>, Localized {
//
// @Nonnull
// public static final String DEFAULT_ID = "all";
//
// @Nonnull
// public ViewAccess getAccess();
//
// @Nullable
// public Filter getFilter();
//
// @Nonnull
// public View getDefaultView();
//
// @Nonnegative
// public int getResultsPerPage();
//
// }
// Path: src/main/java/org/echocat/adam/profile/UserProfileDataFilter.java
import com.atlassian.confluence.search.v2.AbstractChainableSearchFilter;
import com.atlassian.confluence.search.v2.SearchFilter;
import org.echocat.adam.report.Filter;
import org.echocat.adam.report.Report;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014-2016 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.profile;
public class UserProfileDataFilter extends AbstractChainableSearchFilter {
@Nullable | public static UserProfileDataFilter userProfileDataFilterFor(@Nonnull Report report) { |
echocat/adam | src/main/java/org/echocat/adam/profile/UserProfileDataFilter.java | // Path: src/main/java/org/echocat/adam/report/Filter.java
// public interface Filter {
//
// @Nullable
// public Iterable<String> getIncludingGroups();
//
// @Nullable
// public Iterable<String> getExcludingGroups();
//
// public boolean hasTerms();
//
// }
//
// Path: src/main/java/org/echocat/adam/report/Report.java
// public interface Report extends Iterable<Column>, Localized {
//
// @Nonnull
// public static final String DEFAULT_ID = "all";
//
// @Nonnull
// public ViewAccess getAccess();
//
// @Nullable
// public Filter getFilter();
//
// @Nonnull
// public View getDefaultView();
//
// @Nonnegative
// public int getResultsPerPage();
//
// }
| import com.atlassian.confluence.search.v2.AbstractChainableSearchFilter;
import com.atlassian.confluence.search.v2.SearchFilter;
import org.echocat.adam.report.Filter;
import org.echocat.adam.report.Report;
import javax.annotation.Nonnull;
import javax.annotation.Nullable; | /*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014-2016 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.profile;
public class UserProfileDataFilter extends AbstractChainableSearchFilter {
@Nullable
public static UserProfileDataFilter userProfileDataFilterFor(@Nonnull Report report) {
return userProfileDataFilterFor(report != null ? report.getFilter() : null);
}
@Nullable | // Path: src/main/java/org/echocat/adam/report/Filter.java
// public interface Filter {
//
// @Nullable
// public Iterable<String> getIncludingGroups();
//
// @Nullable
// public Iterable<String> getExcludingGroups();
//
// public boolean hasTerms();
//
// }
//
// Path: src/main/java/org/echocat/adam/report/Report.java
// public interface Report extends Iterable<Column>, Localized {
//
// @Nonnull
// public static final String DEFAULT_ID = "all";
//
// @Nonnull
// public ViewAccess getAccess();
//
// @Nullable
// public Filter getFilter();
//
// @Nonnull
// public View getDefaultView();
//
// @Nonnegative
// public int getResultsPerPage();
//
// }
// Path: src/main/java/org/echocat/adam/profile/UserProfileDataFilter.java
import com.atlassian.confluence.search.v2.AbstractChainableSearchFilter;
import com.atlassian.confluence.search.v2.SearchFilter;
import org.echocat.adam.report.Filter;
import org.echocat.adam.report.Report;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014-2016 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.profile;
public class UserProfileDataFilter extends AbstractChainableSearchFilter {
@Nullable
public static UserProfileDataFilter userProfileDataFilterFor(@Nonnull Report report) {
return userProfileDataFilterFor(report != null ? report.getFilter() : null);
}
@Nullable | public static UserProfileDataFilter userProfileDataFilterFor(@Nullable Filter filter) { |
echocat/adam | src/main/java/org/echocat/adam/profile/ExtendedViewMyProfileAction.java | // Path: src/main/java/org/echocat/adam/extensions/ExtendedWebInterfaceManager.java
// @Nonnull
// public static ExtendedWebInterfaceManager extendedWebInterfaceManager() {
// final ExtendedWebInterfaceManager result = c_instance;
// if (result == null) {
// throw new IllegalStateException("There is no instance initialized.");
// }
// return result;
// }
| import com.atlassian.plugin.web.WebInterfaceManager;
import static org.echocat.adam.extensions.ExtendedWebInterfaceManager.extendedWebInterfaceManager;
import com.atlassian.confluence.user.actions.ViewMyProfileAction; | /*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.profile;
@SuppressWarnings("deprecation")
public class ExtendedViewMyProfileAction extends ViewMyProfileAction {
@Override
public String execute() throws Exception {
final String result = super.execute();
return result;
}
@Override
public WebInterfaceManager getWebInterfaceManager() { | // Path: src/main/java/org/echocat/adam/extensions/ExtendedWebInterfaceManager.java
// @Nonnull
// public static ExtendedWebInterfaceManager extendedWebInterfaceManager() {
// final ExtendedWebInterfaceManager result = c_instance;
// if (result == null) {
// throw new IllegalStateException("There is no instance initialized.");
// }
// return result;
// }
// Path: src/main/java/org/echocat/adam/profile/ExtendedViewMyProfileAction.java
import com.atlassian.plugin.web.WebInterfaceManager;
import static org.echocat.adam.extensions.ExtendedWebInterfaceManager.extendedWebInterfaceManager;
import com.atlassian.confluence.user.actions.ViewMyProfileAction;
/*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.profile;
@SuppressWarnings("deprecation")
public class ExtendedViewMyProfileAction extends ViewMyProfileAction {
@Override
public String execute() throws Exception {
final String result = super.execute();
return result;
}
@Override
public WebInterfaceManager getWebInterfaceManager() { | return extendedWebInterfaceManager(); |
echocat/adam | src/main/java/org/echocat/adam/configuration/view/View.java | // Path: src/main/java/org/echocat/adam/configuration/IdEnabled.java
// public abstract class IdEnabled implements org.echocat.jomon.runtime.util.IdEnabled<String> {
//
// @Nonnull
// private String _id = randomUUID().toString();
//
// @Override
// @Nonnull
// @XmlAttribute(name = "id", required = true)
// public String getId() {
// return _id;
// }
//
// public void setId(@Nonnull String id) {
// _id = id;
// }
//
// }
//
// Path: src/main/java/org/echocat/adam/configuration/access/view/ViewAccess.java
// @XmlType(name = "viewAccess", namespace = SCHEMA_NAMESPACE)
// public class ViewAccess extends ViewAccessSupport<Default, Anonymous, Owner, Administrator, Group> {
//
// @Override
// @XmlElement(name = "default", namespace = SCHEMA_NAMESPACE, type = Default.class)
// public void setDefault(@Nullable Default all) {
// super.setDefault(all);
// }
//
// @Override
// @XmlElement(name = "anonymous", namespace = SCHEMA_NAMESPACE, type = Anonymous.class)
// public void setAnonymous(@Nullable Anonymous anonymous) {
// super.setAnonymous(anonymous);
// }
//
// @Override
// @XmlElement(name = "owner", namespace = SCHEMA_NAMESPACE, type = Owner.class)
// public void setOwner(@Nullable Owner owner) {
// super.setOwner(owner);
// }
//
// @Override
// @XmlElement(name = "administrator", namespace = SCHEMA_NAMESPACE, type = Administrator.class)
// public void setAdministrator(@Nullable Administrator administrator) {
// super.setAdministrator(administrator);
// }
//
// @Override
// @XmlElement(name = "group", namespace = SCHEMA_NAMESPACE, type = Group.class)
// public void setGroups(@Nullable List<Group> groups) {
// super.setGroups(groups);
// }
//
// }
//
// Path: src/main/java/org/echocat/adam/configuration/localization/Localized.java
// @XmlType(name = "localized", namespace = SCHEMA_NAMESPACE)
// public abstract class Localized extends IdEnabled {
//
// @Nullable
// private List<Localization> _localizations;
//
// @Nullable
// @XmlElement(name = "localization", namespace = SCHEMA_NAMESPACE)
// public List<Localization> getLocalizations() {
// return _localizations;
// }
//
// public void setLocalizations(@Nullable List<Localization> localizations) {
// _localizations = localizations;
// }
//
//
// }
//
// Path: src/main/java/org/echocat/adam/configuration/ConfigurationContants.java
// public static final String SCHEMA_NAMESPACE = "https://adam.echocat.org/schemas/configuration.xsd";
| import static org.echocat.adam.configuration.ConfigurationContants.SCHEMA_NAMESPACE;
import static org.echocat.adam.view.View.DEFAULT_ID;
import org.echocat.adam.configuration.IdEnabled;
import org.echocat.adam.configuration.access.view.ViewAccess;
import org.echocat.adam.configuration.localization.Localized;
import javax.annotation.Nullable;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
import java.util.List; | /*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.configuration.view;
@XmlType(name = "view", namespace = SCHEMA_NAMESPACE)
public class View extends Localized {
public View() {
setId(DEFAULT_ID);
}
@Nullable
private List<Element> _elements;
@Nullable | // Path: src/main/java/org/echocat/adam/configuration/IdEnabled.java
// public abstract class IdEnabled implements org.echocat.jomon.runtime.util.IdEnabled<String> {
//
// @Nonnull
// private String _id = randomUUID().toString();
//
// @Override
// @Nonnull
// @XmlAttribute(name = "id", required = true)
// public String getId() {
// return _id;
// }
//
// public void setId(@Nonnull String id) {
// _id = id;
// }
//
// }
//
// Path: src/main/java/org/echocat/adam/configuration/access/view/ViewAccess.java
// @XmlType(name = "viewAccess", namespace = SCHEMA_NAMESPACE)
// public class ViewAccess extends ViewAccessSupport<Default, Anonymous, Owner, Administrator, Group> {
//
// @Override
// @XmlElement(name = "default", namespace = SCHEMA_NAMESPACE, type = Default.class)
// public void setDefault(@Nullable Default all) {
// super.setDefault(all);
// }
//
// @Override
// @XmlElement(name = "anonymous", namespace = SCHEMA_NAMESPACE, type = Anonymous.class)
// public void setAnonymous(@Nullable Anonymous anonymous) {
// super.setAnonymous(anonymous);
// }
//
// @Override
// @XmlElement(name = "owner", namespace = SCHEMA_NAMESPACE, type = Owner.class)
// public void setOwner(@Nullable Owner owner) {
// super.setOwner(owner);
// }
//
// @Override
// @XmlElement(name = "administrator", namespace = SCHEMA_NAMESPACE, type = Administrator.class)
// public void setAdministrator(@Nullable Administrator administrator) {
// super.setAdministrator(administrator);
// }
//
// @Override
// @XmlElement(name = "group", namespace = SCHEMA_NAMESPACE, type = Group.class)
// public void setGroups(@Nullable List<Group> groups) {
// super.setGroups(groups);
// }
//
// }
//
// Path: src/main/java/org/echocat/adam/configuration/localization/Localized.java
// @XmlType(name = "localized", namespace = SCHEMA_NAMESPACE)
// public abstract class Localized extends IdEnabled {
//
// @Nullable
// private List<Localization> _localizations;
//
// @Nullable
// @XmlElement(name = "localization", namespace = SCHEMA_NAMESPACE)
// public List<Localization> getLocalizations() {
// return _localizations;
// }
//
// public void setLocalizations(@Nullable List<Localization> localizations) {
// _localizations = localizations;
// }
//
//
// }
//
// Path: src/main/java/org/echocat/adam/configuration/ConfigurationContants.java
// public static final String SCHEMA_NAMESPACE = "https://adam.echocat.org/schemas/configuration.xsd";
// Path: src/main/java/org/echocat/adam/configuration/view/View.java
import static org.echocat.adam.configuration.ConfigurationContants.SCHEMA_NAMESPACE;
import static org.echocat.adam.view.View.DEFAULT_ID;
import org.echocat.adam.configuration.IdEnabled;
import org.echocat.adam.configuration.access.view.ViewAccess;
import org.echocat.adam.configuration.localization.Localized;
import javax.annotation.Nullable;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
import java.util.List;
/*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.configuration.view;
@XmlType(name = "view", namespace = SCHEMA_NAMESPACE)
public class View extends Localized {
public View() {
setId(DEFAULT_ID);
}
@Nullable
private List<Element> _elements;
@Nullable | private ViewAccess _access; |
echocat/adam | src/main/java/org/echocat/adam/configuration/view/View.java | // Path: src/main/java/org/echocat/adam/configuration/IdEnabled.java
// public abstract class IdEnabled implements org.echocat.jomon.runtime.util.IdEnabled<String> {
//
// @Nonnull
// private String _id = randomUUID().toString();
//
// @Override
// @Nonnull
// @XmlAttribute(name = "id", required = true)
// public String getId() {
// return _id;
// }
//
// public void setId(@Nonnull String id) {
// _id = id;
// }
//
// }
//
// Path: src/main/java/org/echocat/adam/configuration/access/view/ViewAccess.java
// @XmlType(name = "viewAccess", namespace = SCHEMA_NAMESPACE)
// public class ViewAccess extends ViewAccessSupport<Default, Anonymous, Owner, Administrator, Group> {
//
// @Override
// @XmlElement(name = "default", namespace = SCHEMA_NAMESPACE, type = Default.class)
// public void setDefault(@Nullable Default all) {
// super.setDefault(all);
// }
//
// @Override
// @XmlElement(name = "anonymous", namespace = SCHEMA_NAMESPACE, type = Anonymous.class)
// public void setAnonymous(@Nullable Anonymous anonymous) {
// super.setAnonymous(anonymous);
// }
//
// @Override
// @XmlElement(name = "owner", namespace = SCHEMA_NAMESPACE, type = Owner.class)
// public void setOwner(@Nullable Owner owner) {
// super.setOwner(owner);
// }
//
// @Override
// @XmlElement(name = "administrator", namespace = SCHEMA_NAMESPACE, type = Administrator.class)
// public void setAdministrator(@Nullable Administrator administrator) {
// super.setAdministrator(administrator);
// }
//
// @Override
// @XmlElement(name = "group", namespace = SCHEMA_NAMESPACE, type = Group.class)
// public void setGroups(@Nullable List<Group> groups) {
// super.setGroups(groups);
// }
//
// }
//
// Path: src/main/java/org/echocat/adam/configuration/localization/Localized.java
// @XmlType(name = "localized", namespace = SCHEMA_NAMESPACE)
// public abstract class Localized extends IdEnabled {
//
// @Nullable
// private List<Localization> _localizations;
//
// @Nullable
// @XmlElement(name = "localization", namespace = SCHEMA_NAMESPACE)
// public List<Localization> getLocalizations() {
// return _localizations;
// }
//
// public void setLocalizations(@Nullable List<Localization> localizations) {
// _localizations = localizations;
// }
//
//
// }
//
// Path: src/main/java/org/echocat/adam/configuration/ConfigurationContants.java
// public static final String SCHEMA_NAMESPACE = "https://adam.echocat.org/schemas/configuration.xsd";
| import static org.echocat.adam.configuration.ConfigurationContants.SCHEMA_NAMESPACE;
import static org.echocat.adam.view.View.DEFAULT_ID;
import org.echocat.adam.configuration.IdEnabled;
import org.echocat.adam.configuration.access.view.ViewAccess;
import org.echocat.adam.configuration.localization.Localized;
import javax.annotation.Nullable;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
import java.util.List; | /*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.configuration.view;
@XmlType(name = "view", namespace = SCHEMA_NAMESPACE)
public class View extends Localized {
public View() {
setId(DEFAULT_ID);
}
@Nullable
private List<Element> _elements;
@Nullable
private ViewAccess _access;
@Nullable
@XmlElement(name = "element", namespace = SCHEMA_NAMESPACE)
public List<Element> getElements() {
return _elements;
}
public void setElements(@Nullable List<Element> elements) {
_elements = elements;
}
@Nullable
@XmlElement(name = "access", namespace = SCHEMA_NAMESPACE)
public ViewAccess getAccess() {
return _access;
}
public void setAccess(@Nullable ViewAccess access) {
_access = access;
}
@XmlType(name = "viewElement", namespace = SCHEMA_NAMESPACE) | // Path: src/main/java/org/echocat/adam/configuration/IdEnabled.java
// public abstract class IdEnabled implements org.echocat.jomon.runtime.util.IdEnabled<String> {
//
// @Nonnull
// private String _id = randomUUID().toString();
//
// @Override
// @Nonnull
// @XmlAttribute(name = "id", required = true)
// public String getId() {
// return _id;
// }
//
// public void setId(@Nonnull String id) {
// _id = id;
// }
//
// }
//
// Path: src/main/java/org/echocat/adam/configuration/access/view/ViewAccess.java
// @XmlType(name = "viewAccess", namespace = SCHEMA_NAMESPACE)
// public class ViewAccess extends ViewAccessSupport<Default, Anonymous, Owner, Administrator, Group> {
//
// @Override
// @XmlElement(name = "default", namespace = SCHEMA_NAMESPACE, type = Default.class)
// public void setDefault(@Nullable Default all) {
// super.setDefault(all);
// }
//
// @Override
// @XmlElement(name = "anonymous", namespace = SCHEMA_NAMESPACE, type = Anonymous.class)
// public void setAnonymous(@Nullable Anonymous anonymous) {
// super.setAnonymous(anonymous);
// }
//
// @Override
// @XmlElement(name = "owner", namespace = SCHEMA_NAMESPACE, type = Owner.class)
// public void setOwner(@Nullable Owner owner) {
// super.setOwner(owner);
// }
//
// @Override
// @XmlElement(name = "administrator", namespace = SCHEMA_NAMESPACE, type = Administrator.class)
// public void setAdministrator(@Nullable Administrator administrator) {
// super.setAdministrator(administrator);
// }
//
// @Override
// @XmlElement(name = "group", namespace = SCHEMA_NAMESPACE, type = Group.class)
// public void setGroups(@Nullable List<Group> groups) {
// super.setGroups(groups);
// }
//
// }
//
// Path: src/main/java/org/echocat/adam/configuration/localization/Localized.java
// @XmlType(name = "localized", namespace = SCHEMA_NAMESPACE)
// public abstract class Localized extends IdEnabled {
//
// @Nullable
// private List<Localization> _localizations;
//
// @Nullable
// @XmlElement(name = "localization", namespace = SCHEMA_NAMESPACE)
// public List<Localization> getLocalizations() {
// return _localizations;
// }
//
// public void setLocalizations(@Nullable List<Localization> localizations) {
// _localizations = localizations;
// }
//
//
// }
//
// Path: src/main/java/org/echocat/adam/configuration/ConfigurationContants.java
// public static final String SCHEMA_NAMESPACE = "https://adam.echocat.org/schemas/configuration.xsd";
// Path: src/main/java/org/echocat/adam/configuration/view/View.java
import static org.echocat.adam.configuration.ConfigurationContants.SCHEMA_NAMESPACE;
import static org.echocat.adam.view.View.DEFAULT_ID;
import org.echocat.adam.configuration.IdEnabled;
import org.echocat.adam.configuration.access.view.ViewAccess;
import org.echocat.adam.configuration.localization.Localized;
import javax.annotation.Nullable;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
import java.util.List;
/*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.configuration.view;
@XmlType(name = "view", namespace = SCHEMA_NAMESPACE)
public class View extends Localized {
public View() {
setId(DEFAULT_ID);
}
@Nullable
private List<Element> _elements;
@Nullable
private ViewAccess _access;
@Nullable
@XmlElement(name = "element", namespace = SCHEMA_NAMESPACE)
public List<Element> getElements() {
return _elements;
}
public void setElements(@Nullable List<Element> elements) {
_elements = elements;
}
@Nullable
@XmlElement(name = "access", namespace = SCHEMA_NAMESPACE)
public ViewAccess getAccess() {
return _access;
}
public void setAccess(@Nullable ViewAccess access) {
_access = access;
}
@XmlType(name = "viewElement", namespace = SCHEMA_NAMESPACE) | public static class Element extends IdEnabled {} |
echocat/adam | src/main/java/org/echocat/adam/configuration/report/Element.java | // Path: src/main/java/org/echocat/adam/configuration/IdEnabled.java
// public abstract class IdEnabled implements org.echocat.jomon.runtime.util.IdEnabled<String> {
//
// @Nonnull
// private String _id = randomUUID().toString();
//
// @Override
// @Nonnull
// @XmlAttribute(name = "id", required = true)
// public String getId() {
// return _id;
// }
//
// public void setId(@Nonnull String id) {
// _id = id;
// }
//
// }
//
// Path: src/main/java/org/echocat/adam/report/ColumnElementModel.java
// public static enum Format {
// plain,
// formatted
// }
//
// Path: src/main/java/org/echocat/adam/configuration/ConfigurationContants.java
// public static final String SCHEMA_NAMESPACE = "https://adam.echocat.org/schemas/configuration.xsd";
| import org.echocat.adam.configuration.IdEnabled;
import org.echocat.adam.report.ColumnElementModel.Format;
import javax.annotation.Nonnull;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlType;
import static org.echocat.adam.configuration.ConfigurationContants.SCHEMA_NAMESPACE;
import static org.echocat.adam.report.ColumnElementModel.Format.formatted; | /*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.configuration.report;
@XmlType(name = "reportColumnElement", namespace = SCHEMA_NAMESPACE)
public class Element extends IdEnabled {
@Nonnull | // Path: src/main/java/org/echocat/adam/configuration/IdEnabled.java
// public abstract class IdEnabled implements org.echocat.jomon.runtime.util.IdEnabled<String> {
//
// @Nonnull
// private String _id = randomUUID().toString();
//
// @Override
// @Nonnull
// @XmlAttribute(name = "id", required = true)
// public String getId() {
// return _id;
// }
//
// public void setId(@Nonnull String id) {
// _id = id;
// }
//
// }
//
// Path: src/main/java/org/echocat/adam/report/ColumnElementModel.java
// public static enum Format {
// plain,
// formatted
// }
//
// Path: src/main/java/org/echocat/adam/configuration/ConfigurationContants.java
// public static final String SCHEMA_NAMESPACE = "https://adam.echocat.org/schemas/configuration.xsd";
// Path: src/main/java/org/echocat/adam/configuration/report/Element.java
import org.echocat.adam.configuration.IdEnabled;
import org.echocat.adam.report.ColumnElementModel.Format;
import javax.annotation.Nonnull;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlType;
import static org.echocat.adam.configuration.ConfigurationContants.SCHEMA_NAMESPACE;
import static org.echocat.adam.report.ColumnElementModel.Format.formatted;
/*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.configuration.report;
@XmlType(name = "reportColumnElement", namespace = SCHEMA_NAMESPACE)
public class Element extends IdEnabled {
@Nonnull | private Format _format = formatted; |
echocat/adam | src/main/java/org/echocat/adam/configuration/profile/Element.java | // Path: src/main/java/org/echocat/adam/configuration/IdEnabled.java
// public abstract class IdEnabled implements org.echocat.jomon.runtime.util.IdEnabled<String> {
//
// @Nonnull
// private String _id = randomUUID().toString();
//
// @Override
// @Nonnull
// @XmlAttribute(name = "id", required = true)
// public String getId() {
// return _id;
// }
//
// public void setId(@Nonnull String id) {
// _id = id;
// }
//
// }
//
// Path: src/main/java/org/echocat/adam/configuration/access/viewedit/ViewEditAccess.java
// @XmlType(name = "viewEditAccess", namespace = SCHEMA_NAMESPACE)
// public class ViewEditAccess extends ViewAccessSupport<Default, Anonymous, Owner, Administrator, Group> {
//
// @Override
// @XmlElement(name = "default", namespace = SCHEMA_NAMESPACE, type = Default.class)
// public void setDefault(@Nullable Default all) {
// super.setDefault(all);
// }
//
// @Override
// @XmlElement(name = "anonymous", namespace = SCHEMA_NAMESPACE, type = Anonymous.class)
// public void setAnonymous(@Nullable Anonymous anonymous) {
// super.setAnonymous(anonymous);
// }
//
// @Override
// @XmlElement(name = "owner", namespace = SCHEMA_NAMESPACE, type = Owner.class)
// public void setOwner(@Nullable Owner owner) {
// super.setOwner(owner);
// }
//
// @Override
// @XmlElement(name = "administrator", namespace = SCHEMA_NAMESPACE, type = Administrator.class)
// public void setAdministrator(@Nullable Administrator administrator) {
// super.setAdministrator(administrator);
// }
//
// @Override
// @XmlElement(name = "group", namespace = SCHEMA_NAMESPACE, type = Group.class)
// public void setGroups(@Nullable List<Group> groups) {
// super.setGroups(groups);
// }
//
// }
//
// Path: src/main/java/org/echocat/adam/configuration/localization/Localized.java
// @XmlType(name = "localized", namespace = SCHEMA_NAMESPACE)
// public abstract class Localized extends IdEnabled {
//
// @Nullable
// private List<Localization> _localizations;
//
// @Nullable
// @XmlElement(name = "localization", namespace = SCHEMA_NAMESPACE)
// public List<Localization> getLocalizations() {
// return _localizations;
// }
//
// public void setLocalizations(@Nullable List<Localization> localizations) {
// _localizations = localizations;
// }
//
//
// }
//
// Path: src/main/java/org/echocat/adam/configuration/template/Template.java
// @XmlType(name = "template", namespace = SCHEMA_NAMESPACE)
// public class Template extends TemplateSupport {
//
// @Nonnull
// private String _source = "";
// @Nonnull
// private TemplateFormat _format = velocity;
//
// @Override
// @Nonnull
// public String getSource() {
// return _source;
// }
//
// @XmlValue
// @XmlValueExtension
// public void setSource(@Nonnull String source) {
// _source = source;
// }
//
// @Override
// @Nonnull
// public TemplateFormat getFormat() {
// return _format;
// }
//
// @XmlAttribute(name = "format")
// public void setFormat(@Nonnull TemplateFormat format) {
// _format = format;
// }
//
// }
//
// Path: src/main/java/org/echocat/adam/profile/element/ElementModel.java
// public static enum Type {
// singleLineText,
// multiLineText,
// emailAddress,
// url,
// phoneNumber,
// wikiMarkup,
// html
// }
//
// Path: src/main/java/org/echocat/adam/configuration/ConfigurationContants.java
// public static final String SCHEMA_NAMESPACE = "https://adam.echocat.org/schemas/configuration.xsd";
| import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
import java.util.List;
import static org.echocat.adam.configuration.ConfigurationContants.SCHEMA_NAMESPACE;
import static org.echocat.adam.profile.element.ElementModel.Type.singleLineText;
import org.echocat.adam.configuration.IdEnabled;
import org.echocat.adam.configuration.access.viewedit.ViewEditAccess;
import org.echocat.adam.configuration.localization.Localized;
import org.echocat.adam.configuration.template.Template;
import org.echocat.adam.profile.element.ElementModel.Type;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.xml.bind.annotation.XmlAttribute; | /*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.configuration.profile;
@XmlType(name = "profileGroupElement", namespace = SCHEMA_NAMESPACE)
public class Element extends Localized {
@Nullable
private List<ContextAttribute> _contextAttributes;
@Nullable | // Path: src/main/java/org/echocat/adam/configuration/IdEnabled.java
// public abstract class IdEnabled implements org.echocat.jomon.runtime.util.IdEnabled<String> {
//
// @Nonnull
// private String _id = randomUUID().toString();
//
// @Override
// @Nonnull
// @XmlAttribute(name = "id", required = true)
// public String getId() {
// return _id;
// }
//
// public void setId(@Nonnull String id) {
// _id = id;
// }
//
// }
//
// Path: src/main/java/org/echocat/adam/configuration/access/viewedit/ViewEditAccess.java
// @XmlType(name = "viewEditAccess", namespace = SCHEMA_NAMESPACE)
// public class ViewEditAccess extends ViewAccessSupport<Default, Anonymous, Owner, Administrator, Group> {
//
// @Override
// @XmlElement(name = "default", namespace = SCHEMA_NAMESPACE, type = Default.class)
// public void setDefault(@Nullable Default all) {
// super.setDefault(all);
// }
//
// @Override
// @XmlElement(name = "anonymous", namespace = SCHEMA_NAMESPACE, type = Anonymous.class)
// public void setAnonymous(@Nullable Anonymous anonymous) {
// super.setAnonymous(anonymous);
// }
//
// @Override
// @XmlElement(name = "owner", namespace = SCHEMA_NAMESPACE, type = Owner.class)
// public void setOwner(@Nullable Owner owner) {
// super.setOwner(owner);
// }
//
// @Override
// @XmlElement(name = "administrator", namespace = SCHEMA_NAMESPACE, type = Administrator.class)
// public void setAdministrator(@Nullable Administrator administrator) {
// super.setAdministrator(administrator);
// }
//
// @Override
// @XmlElement(name = "group", namespace = SCHEMA_NAMESPACE, type = Group.class)
// public void setGroups(@Nullable List<Group> groups) {
// super.setGroups(groups);
// }
//
// }
//
// Path: src/main/java/org/echocat/adam/configuration/localization/Localized.java
// @XmlType(name = "localized", namespace = SCHEMA_NAMESPACE)
// public abstract class Localized extends IdEnabled {
//
// @Nullable
// private List<Localization> _localizations;
//
// @Nullable
// @XmlElement(name = "localization", namespace = SCHEMA_NAMESPACE)
// public List<Localization> getLocalizations() {
// return _localizations;
// }
//
// public void setLocalizations(@Nullable List<Localization> localizations) {
// _localizations = localizations;
// }
//
//
// }
//
// Path: src/main/java/org/echocat/adam/configuration/template/Template.java
// @XmlType(name = "template", namespace = SCHEMA_NAMESPACE)
// public class Template extends TemplateSupport {
//
// @Nonnull
// private String _source = "";
// @Nonnull
// private TemplateFormat _format = velocity;
//
// @Override
// @Nonnull
// public String getSource() {
// return _source;
// }
//
// @XmlValue
// @XmlValueExtension
// public void setSource(@Nonnull String source) {
// _source = source;
// }
//
// @Override
// @Nonnull
// public TemplateFormat getFormat() {
// return _format;
// }
//
// @XmlAttribute(name = "format")
// public void setFormat(@Nonnull TemplateFormat format) {
// _format = format;
// }
//
// }
//
// Path: src/main/java/org/echocat/adam/profile/element/ElementModel.java
// public static enum Type {
// singleLineText,
// multiLineText,
// emailAddress,
// url,
// phoneNumber,
// wikiMarkup,
// html
// }
//
// Path: src/main/java/org/echocat/adam/configuration/ConfigurationContants.java
// public static final String SCHEMA_NAMESPACE = "https://adam.echocat.org/schemas/configuration.xsd";
// Path: src/main/java/org/echocat/adam/configuration/profile/Element.java
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
import java.util.List;
import static org.echocat.adam.configuration.ConfigurationContants.SCHEMA_NAMESPACE;
import static org.echocat.adam.profile.element.ElementModel.Type.singleLineText;
import org.echocat.adam.configuration.IdEnabled;
import org.echocat.adam.configuration.access.viewedit.ViewEditAccess;
import org.echocat.adam.configuration.localization.Localized;
import org.echocat.adam.configuration.template.Template;
import org.echocat.adam.profile.element.ElementModel.Type;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.xml.bind.annotation.XmlAttribute;
/*****************************************************************************************
* *** BEGIN LICENSE BLOCK *****
*
* echocat Adam, Copyright (c) 2014 echocat
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*
* *** END LICENSE BLOCK *****
****************************************************************************************/
package org.echocat.adam.configuration.profile;
@XmlType(name = "profileGroupElement", namespace = SCHEMA_NAMESPACE)
public class Element extends Localized {
@Nullable
private List<ContextAttribute> _contextAttributes;
@Nullable | private ViewEditAccess _access; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.