Skip to content

Commit

Permalink
codestyle
Browse files Browse the repository at this point in the history
  • Loading branch information
user1 authored and user1 committed Jun 9, 2016
1 parent 5409f97 commit cbd7fed
Show file tree
Hide file tree
Showing 17 changed files with 449 additions and 407 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ target/
.project
.settings/
bin/

.checkstyle
Binary file not shown.
20 changes: 7 additions & 13 deletions src/main/java/edu/kit/scc/CdmiRestController.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ public class CdmiRestController {
@Value("${oidc.clientsecret}")
private String clientSecret;

@PostConstruct
/**
* Init method to check and initialize the server.
*/
@PostConstruct
public void init() {
log.debug("INIT");
Container rootContainer = containerDaoImpl.findByPath("/");
Expand Down Expand Up @@ -414,19 +414,15 @@ public ResponseEntity<?> putCdmiObject(@RequestHeader("Authorization") String au
return new ResponseEntity<String>(container.toJson().toString(), responseHeaders,
HttpStatus.CREATED);
}
}
// create dataobject
else if (contentType.equals(MediaTypes.DATA_OBJECT)) {
} else if (contentType.equals(MediaTypes.DATA_OBJECT)) {
JSONObject json = new JSONObject(body);
DataObject dataObject = dataObjectDaoImpl.createByPath(requestPath, new DataObject(json));
if (dataObject != null) {
responseHeaders.setContentType(new MediaType("application", "cdmi-object"));
return new ResponseEntity<String>(dataObject.toJson().toString(), responseHeaders,
HttpStatus.CREATED);
}
}
// create domain
else if (contentType.equals(MediaTypes.ACCOUNT)) {
} else if (contentType.equals(MediaTypes.ACCOUNT)) {
JSONObject json = new JSONObject(body);
CdmiObject domain = null;
if (requestedFields == null) {
Expand Down Expand Up @@ -547,11 +543,9 @@ private JSONObject getRequestedJson(JSONObject object, String[] requestedFields)
} else if (field.startsWith("value:")) {
String range = field.split("value:")[1];
String[] rangeSplit = range.split("-");
requestedJson
.put("value",
new String(Arrays.copyOfRange(object.getString("value").getBytes(),
Integer.valueOf(rangeSplit[0].trim()),
Integer.valueOf(rangeSplit[1].trim()))));
requestedJson.put("value",
new String(Arrays.copyOfRange(object.getString("value").getBytes(),
Integer.valueOf(rangeSplit[0].trim()), Integer.valueOf(rangeSplit[1].trim()))));
} else {
throw new BadRequestException("Bad prefix");
}
Expand Down Expand Up @@ -606,7 +600,7 @@ public boolean verifyAuthorization(String authorizationHeader) {
}
} catch (Exception ex) {
log.error("ERROR {}", ex.toString());
//ex.printStackTrace();
// ex.printStackTrace();
}
return false;
}
Expand Down
15 changes: 4 additions & 11 deletions src/main/java/edu/kit/scc/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,10 @@
public final class Utils {

/*************************************************************************
* Compilation: javac CRC16.java Execution: java CRC16 s
*
* Reads in a string s as a command-line argument, and prints out its 16-bit Cyclic Redundancy
* Check (CRC16). Uses a lookup table.
*
* Reference: http://www.gelato.unsw.edu.au/lxr/source/lib/crc16.c
*
* % java CRC16 123456789 CRC16 = bb3d
*
* Uses irreducible polynomial: 1 + x^2 + x^15 + x^16
*
* Compilation: javac CRC16.java Execution: java CRC16 s Reads in a string s as a command-line
* argument, and prints out its 16-bit Cyclic Redundancy Check (CRC16). Uses a lookup table.
* Reference: http://www.gelato.unsw.edu.au/lxr/source/lib/crc16.c % java CRC16 123456789 CRC16 =
* bb3d Uses irreducible polynomial: 1 + x^2 + x^15 + x^16
*************************************************************************/
/*
* Copyright © 2000–2011, Robert Sedgewick and Kevin Wayne.
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/edu/kit/scc/http/CustomSslContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public void checkServerTrusted(X509Certificate[] chain, String authType)
@Override
public void checkClientTrusted(X509Certificate[] chain, String authType)
throws CertificateException {}
}}, null);
} }, null);
} catch (NoSuchAlgorithmException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Expand Down
66 changes: 32 additions & 34 deletions src/main/java/org/snia/cdmiserver/dao/AccountDao.java
Original file line number Diff line number Diff line change
@@ -1,33 +1,31 @@
/*
* Copyright (c) 2010, Sun Microsystems, Inc.
* Copyright (c) 2010, The Storage Networking Industry Association.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* Neither the name of The Storage Networking Industry Association (SNIA) nor
* the names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
* Copyright (c) 2010, Sun Microsystems, Inc. Copyright (c) 2010, The Storage Networking Industry
* Association.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted
* provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of conditions
* and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions
* and the following disclaimer in the documentation and/or other materials provided with the
* distribution.
*
* Neither the name of The Storage Networking Industry Association (SNIA) nor the names of its
* contributors may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
* WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

package org.snia.cdmiserver.dao;

import org.snia.cdmiserver.model.Account;
Expand All @@ -39,11 +37,11 @@
*/
public interface AccountDao {

/**
* <p>
* Find and return an {@link Account} by object id, if any; otherwise, return <code>null</code>.
* </p>
*/
public Account findByObjectId(String objectId);
/**
* <p>
* Find and return an {@link Account} by object id, if any; otherwise, return <code>null</code>.
* </p>
*/
public Account findByObjectId(String objectId);

}
84 changes: 40 additions & 44 deletions src/main/java/org/snia/cdmiserver/dao/CapabilityDao.java
Original file line number Diff line number Diff line change
@@ -1,33 +1,31 @@
/*
* Copyright (c) 2010, Sun Microsystems, Inc.
* Copyright (c) 2010, The Storage Networking Industry Association.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* Neither the name of The Storage Networking Industry Association (SNIA) nor
* the names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
* Copyright (c) 2010, Sun Microsystems, Inc. Copyright (c) 2010, The Storage Networking Industry
* Association.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted
* provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of conditions
* and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions
* and the following disclaimer in the documentation and/or other materials provided with the
* distribution.
*
* Neither the name of The Storage Networking Industry Association (SNIA) nor the names of its
* contributors may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
* WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

package org.snia.cdmiserver.dao;

import org.snia.cdmiserver.model.Capability;
Expand All @@ -39,21 +37,19 @@
*/
public interface CapabilityDao {

/**
* <p>
* Find and return a {@link Capability} by object id, if any; otherwise, return
* <code>null</code>.
* </p>
*/
public Capability findByObjectId(String objectId);
/**
* <p>
* Find and return a {@link Capability} by object id, if any; otherwise, return <code>null</code>.
* </p>
*/
public Capability findByObjectId(String objectId);

/**
* <p>
* Find and return a {@link Capability} by path, if any; otherwise, return <code>null</code>.
* </p>
*
* @param path
* Path to the requested {@link Capability}
*/
public Capability findByPath(String path);
/**
* <p>
* Find and return a {@link Capability} by path, if any; otherwise, return <code>null</code>.
* </p>
*
* @param path Path to the requested {@link Capability}
*/
public Capability findByPath(String path);
}
17 changes: 13 additions & 4 deletions src/main/java/org/snia/cdmiserver/dao/CdmiObjectDao.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
/*
* Copyright 2016 Karlsruhe Institute of Technology (KIT)
*
* 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
*/

package org.snia.cdmiserver.dao;

import org.snia.cdmiserver.model.CdmiObject;

public interface CdmiObjectDao {

public CdmiObject createCdmiObject(CdmiObject cdmiObject);
public CdmiObject createCdmiObject(CdmiObject cdmiObject);

public CdmiObject getCdmiObject(String objectId);
public CdmiObject getCdmiObject(String objectId);

public CdmiObject updateCdmiObject(CdmiObject cdmiObject);
public CdmiObject updateCdmiObject(CdmiObject cdmiObject);

public CdmiObject deleteCdmiObject(String objectId);
public CdmiObject deleteCdmiObject(String objectId);

}
Loading

0 comments on commit cbd7fed

Please sign in to comment.